因为最近在移植 Qt5.7 + opengl , 遇到了难以越过的山峰,没有办法,试着在 ubuntu 16.04上将 opengl 配置以下,记录:
安装相关的库:
sudo apt-get install build-essential libgl1-mesa-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev
#include <GL/glut.h>
void init();
void display();
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutCreateWindow("OpenGL 3D View");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glOrtho(-5, 5, -5, 5, 5, 15);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0, 0);
glutWireTeapot(3);
glFlush();
}
all:
g++ -I/usr/include -L/usr/local/lib -L/usr/X11R6/lib test.cpp -o gltest -lglut -lGLU -lGL -lX11 -lXext -lXi -lm
clean:
rm gltest -rf
./gltest