1.å¦ä½å¨Linuxä¸ä½¿ç¨OpenGL+ C++å¼å
å¦ä½å¨Linuxä¸ä½¿ç¨OpenGL+ C++å¼å
åææ¯ï¼1.é 置好äºUbuntuä¸çc++ç¯å¢ï¼gcc以åg++å¯ç¨ã
2.使ç¨eclipse for c+åOpenGLå¼å
ããæ¥éª¤ä¸ï¼
å¨ubuntuç»ç«¯ä¸è¿è¡ä»¥ä¸å½ä»¤ï¼å®è£ openglæéè¦çåºæ件
$ sudo apt-get install build-essential
$ sudo apt-get install freeglut3-dev
ããæ¥éª¤äºï¼
ããè¿è¡ä¸ä¸openglå®ä¾ï¼æµè¯é ç½®çç¯å¢æ¯å¦å®è£ æå
å¨eclipseä¸æ°å»ºä¸ä¸ªå·¥ç¨æ件ï¼å设æ们å½å为Testï¼å¨å·¥ç¨Testéé¢æ°å»ºä¸ä¸ªC++æºä»£ç æ件ï¼è¿éæ们æå®å½å为main.cppï¼å¨main.cppæ件ä¸æå ¥ä¸ä¸ä»£ç
#include <GL/glut.h>ããvoid init();
void display();
ããint main(int argc,lucksheet源码分析 char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB |GLUT_SINGLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(, );
ãã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, );
glMatrixMode(GL_MODELVIEW);
gluLookAt(0, 0, , 0, 0, 0, 0, 1, 0);
}
ããvoid display()
{
glClear(GL_COLOR_BUFFER_BIT);
ããglColor3f(1.0, 0, 0);
glutWireTeapot(3);
ããglFlush();
}
å³å»å·¥ç¨æ件å
Test->ç¹å»å±æ§ï¼Propertiesï¼->C/C++Bulid->Settings->GCC C++Linker->Libraries,
å¨è¿ä¸ªçªå£ä¸æ·»å å 个个åºï¼
åå«ä¸ºGLU,glut,GLï¼
ç¹å»OKã
å¦æè¿æ³ä½¿ç¨opencvï¼
å¨è¿éè¿å å ¥cv,cxcore,highguiçåºæ件ï¼
æ ¹æ®èªå·±çéè¦æ¥å®
åæ¶å¨GCC Cï¼ï¼ Compiler->Includesä¸çincudepathä¸æ·»å è·¯å¾/usr/include/GL
å¦æè¿æ³ä½¿ç¨opencvä¸çåºï¼é£ä¹å å ¥opencvçè·¯å¾ï¼ä¸è¬æ¯/usr/include/opencv
ããè¿è¡ä»¥ä¸ç¨åºï¼ä¼æ¾ç¤ºä¸ä¸ªè¶å£¶å½¢ç¶çopenglè¿è¡ç»æ