как в астралинуксе подключить библиотеку opengl к проекту?
Не получается в астра линуксе поднять проект с openGL-ом .
Вот два примера: первый это 2dpainting из примера , окна Qt поднимаются а вот сама библиотека опенгл не "подтягивается"
второй: про файл
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
#-
INCLUDEPATH += $$PWD/glfw_bin/include/GLFW/ \ # добавляем для удобства чтоб напрямую писать
$$PWD/glew_bin/include/GL/ \ # только название заголовчного файла без полного пути
$$PWD/stb_image/
HEADERS += \
glfw_bin/include/GLFW/glfw3.h \
glfw_bin/include/GLFW/glfw3native.h \
glew_bin/include/GL/glew.h \
# --- linux ---
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/ -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
майн :
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <glew.h>
#include <freeglut.h>
#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();
glutSwapBuffers();
}
// 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);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("circle.cpp");
glutDisplayFunc(drawScene);
glutReshapeFunc(resize);
glutKeyboardFunc(keyInput);
glewExperimental = GL_TRUE;
glewInit();
setup();
glutMainLoop();
}
Сами библиотеки в операциоке присутствуют
а вот результат (этот код прекрасно работает в убунте)
Ответы (1 шт):
Автор решения: timob256
→ Ссылка
первую проблему решил :
надо было добавить строку :
QApplication::setAttribute(Qt::AA_ForceRasterWidgets, false);
вот в коде :
#include "window.h"
#include <QApplication>
#include <QSurfaceFormat>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setAttribute(Qt::AA_ForceRasterWidgets, false);
QSurfaceFormat fmt;
fmt.setSamples(4);
QSurfaceFormat::setDefaultFormat(fmt);
Window window;
window.show();
return app.exec();
}


