1.å¦ä½å¨Linuxä¸ä½¿ç¨OpenGL+ C++å¼å
2.为什么我的OpenGL程序只输出一个白色背景的窗口而没有图形呢?
å¦ä½å¨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, 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è¿è¡ç»æ
为什么我的OpenGL程序只输出一个白色背景的窗口而没有图形呢?
错误有3个,(1)深度测试
(2)glLookAt中eyeZ参数
(3)双缓存模式却忘了加glutSwapBuffers()
修改后的lazarus源码代码,以及相关的qq头像源码大全注释,我都放在附件的select 模糊查询源码cpp文件里了。
p.s. VS上跑的vb net 桌面源码,能显示红、表格提交页面源码蓝、黄3个椭圆。
2024-12-23 01:19
2024-12-23 01:10
2024-12-23 01:04
2024-12-23 00:40
2024-12-23 00:11
2024-12-23 00:04
2024-12-22 23:43
2024-12-22 23:38