Не работает glut библиотека

84
17 января 2021, 01:30

Пытаюсь запустить glut, раньше пытался эту библиотеку в виндовс "положить" но не сработало.

Вот код:

.pro

TEMPLATE = app
CONFIG += console c++11
#CONFIG -= app_bundle
#CONFIG -= qt
QT += opengl

SOURCES += main.cpp

unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lOpenGL
INCLUDEPATH += $$PWD/../../../../usr/include/GL
DEPENDPATH += $$PWD/../../../../usr/include/GL

unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lGLEW
INCLUDEPATH += $$PWD/../../../../usr/include/GL
DEPENDPATH += $$PWD/../../../../usr/include/GL
unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lglfw
INCLUDEPATH += $$PWD/../../../../usr/include/GLFW
DEPENDPATH += $$PWD/../../../../usr/include/GLFW
unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lglut
INCLUDEPATH += $$PWD/../../../../usr/include/GL
DEPENDPATH += $$PWD/../../../../usr/include/GL
# добавил для полной комплектации
unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lGLU
INCLUDEPATH += $$PWD/../../../../usr/include/GL
DEPENDPATH += $$PWD/../../../../usr/include/GL

main.cpp

#include <cstdlib>
#include <cmath>
#include <iostream>
//#ifdef __APPLE__
//#  include <GL/glew.h>
//#  include <GL/freeglut.h>
//#  include <OpenGL/glext.h>
//#else
#  include <GL/glew.h>
#  include <GL/freeglut.h>
#  include <GL/glext.h>
//#pragma comment(lib, "glew32.lib")
//#endif
#define PI 3.14159265358979324
using namespace std;
// Globals.
static float R = 40.0; // Radius of circle.
static float X = 50.0; // X-coordinate of center of circle.
static float Y = 50.0; // Y-coordinate of center of circle.
static int numVertices = 5; // Number of vertices on circle.
// Drawing routine.
void drawScene(void)
{
   float t = 0; // Angle parameter.
   int i;
   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(0.0, 0.0, 0.0);
   // Draw a line loop with vertices at equal angles apart on a circle
   // with center at (X, Y) and radius R, The vertices are colored randomly.
   glBegin(GL_LINE_LOOP);
      for(i = 0; i < numVertices; ++i)
      {
         glColor3f((float)rand()/(float)RAND_MAX, (float)rand()/(float)RAND_MAX, (float)rand()/(float)RAND_MAX);
         glVertex3f(X + R * cos(t), Y + R * sin(t), 0.0);
         t += 2 * PI / numVertices;
      }
   glEnd();
   glFlush();
}
// Initialization routine.
void setup(void)
{
   glClearColor(1.0, 1.0, 1.0, 0.0);
}
// OpenGL window reshape routine.
void resize(int w, int h)
{
   glViewport(0, 0, w, h);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
}
// Keyboard input processing routine.
void keyInput(unsigned char key, int x, int y)
{
   switch(key)
   {
      case 27:
         exit(0);
         break;
      case '+':
         numVertices++;
         glutPostRedisplay();
         break;
      case '-':
         if (numVertices > 3) numVertices--;
         glutPostRedisplay();
         break;
      default:
         break;
   }
}
// Routine to output interaction instructions to the C++ window.
void printInteraction(void)
{
   cout << "Interaction:" << endl;
   cout << "Press +/- to increase/decrease the number of vertices on the circle." << endl;
}
// Main routine.
int main(int argc, char **argv)
{
   printInteraction();
   glutInit(&argc, argv);
   glutInitContextVersion(4, 3);
   glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
   glutInitWindowSize(500, 500);
   glutInitWindowPosition(100, 100);
   glutCreateWindow("circle.cpp");
   glutDisplayFunc(drawScene);
   glutReshapeFunc(resize);
   glutKeyboardFunc(keyInput);
   glewExperimental = GL_TRUE;
   glewInit();
   setup();
   glutMainLoop();
}
// также пытался этот код реализовать, а тот который на верху комментировать, увы тот же результат :( .
//// Drawing routine.
//void drawScene(void)
//{
//   glClear(GL_COLOR_BUFFER_BIT);
//   glColor3f(0.0, 0.0, 0.0);
//   // Draw a polygon with specified vertices.
//   glBegin(GL_POLYGON);
//      glVertex3f(20.0, 20.0, 0.0);
//      glVertex3f(80.0, 20.0, 0.0);
//      glVertex3f(80.0, 80.0, 0.0);
//      glVertex3f(20.0, 80.0, 0.0);
//   glEnd();
//   glFlush();
//}
//// Initialization routine.
//void setup(void)
//{
//   glClearColor(1.0, 1.0, 1.0, 0.0);
//}
//// OpenGL window reshape routine.
//void resize(int w, int h)
//{
//   glViewport(0, 0, w, h);
//   glMatrixMode(GL_PROJECTION);
//   glLoadIdentity();
//   glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
//   glMatrixMode(GL_MODELVIEW);
//   glLoadIdentity();
//}
//// Keyboard input processing routine.
//void keyInput(unsigned char key, int x, int y)
//{
//   switch(key)
//   {
//      case 27:
//         exit(0);
//         break;
//      default:
//         break;
//   }
//}
//// Main routine.
//int main(int argc, char **argv)
//{
//   glutInit(&argc, argv);
//   glutInitContextVersion(4, 3);
//   glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
//   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
//   glutInitWindowSize(500, 500);
//   glutInitWindowPosition(100, 100);
//   glutCreateWindow("experimentWindowSize.cpp");
//   glutDisplayFunc(drawScene);
//   glutReshapeFunc(resize);
//   glutKeyboardFunc(keyInput);
//   glewExperimental = GL_TRUE;
//   glewInit();
//   setup();
//   glutMainLoop();
//}

Не могу понять почему не работает и почему именно вокруг этой библиотеки нужны такие страшные танцы с бубном.

вот попытка "обновить" библиотеку

READ ALSO
Как грамотно построить класс-рендерер? [закрыт]

Как грамотно построить класс-рендерер? [закрыт]

Хотите улучшить этот вопрос? Переформулируйте вопрос так, чтобы он был сосредоточен только на одной проблеме

76
Как можно вернуть из JNI vector&lt;vector&lt;float&gt;&gt;?

Как можно вернуть из JNI vector<vector<float>>?

У меня есть вот такая C++ имплементация

71
Не работает jquery в Visual Studio 2017

Не работает jquery в Visual Studio 2017

Есть проект aspnet core 2

121
&lt;div&gt; или стандарт?

<div> или стандарт?

Недавно начал изучать HTML и уже 3 сайта написал (списывал проекты с ютуба и разбирал код)Везде видел <div> <div> вместо <header> <footer> и тд

130