#include <GL/glut.h>void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glFlush();
}int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("我的第一个OpenGL程序!");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}
什么问题也没有,调试总是有:
'textopengl02.exe': Loaded 'D:\Program Files\OpenGL\Visual Studio 2008\Projects\textopengl02\Release\textopengl02.exe', Symbols loaded.
'textopengl02.exe': Loaded 'C:\windows\system32\ntdll.dll'
'textopengl02.exe': Loaded 'C:\windows\system32\kernel32.dll'
'textopengl02.exe': Loaded 'C:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_d495ac4e\msvcr90.dll'
'textopengl02.exe': Loaded 'C:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_d495ac4e\msvcp90.dll'
The program '[3452] textopengl02.exe: Native' has exited with code 0 (0x0).
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glFlush();
}int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("我的第一个OpenGL程序!");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}
什么问题也没有,调试总是有:
'textopengl02.exe': Loaded 'D:\Program Files\OpenGL\Visual Studio 2008\Projects\textopengl02\Release\textopengl02.exe', Symbols loaded.
'textopengl02.exe': Loaded 'C:\windows\system32\ntdll.dll'
'textopengl02.exe': Loaded 'C:\windows\system32\kernel32.dll'
'textopengl02.exe': Loaded 'C:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_d495ac4e\msvcr90.dll'
'textopengl02.exe': Loaded 'C:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_d495ac4e\msvcp90.dll'
The program '[3452] textopengl02.exe: Native' has exited with code 0 (0x0).
还有你的 glRectf 的参数传大点呢
void reshape(GLsizei w,GLsizei h)
{
if(h==0)
{
h=1;
}
glViewport(0,0,w,h);
glMatrixMode(GL_PORJECTION);
glLoadIdentity();
gluPerspective(60.0,(GLdouble)w/(GLdouble)h,1.0,100.0);
gluLookAt(0.0,0.0,50.0,0.0,0.0,0.0,0.0,1.0,0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}在调用glutCreateWindow()之后加上
glutReshapeFunc(reshape);再试试看!