关于opengl的问题,编译后什么也没有,就一个控制台,小弟积分少,跪求大牛解答一下

baoshuai631 2011-04-05 09:39:12
具体问题:GLUT: Fatal Error in (unamed): pixel format with necessary capabilities not found

#include<Windows.h>
#include<gl/glut.h>

GLfloat x1=100.0f;
GLfloat y1=150.0f;
GLsizei rsize=50;

GLfloat xstep=1.0f;
GLfloat ystep=1.0f;

GLfloat windowWidth;
GLfloat windowHeight;

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,0.0f,0.0f);
glRectf(x1,y1,x1+rsize,y1+rsize);
glutSwapBuffers();
}
void TimerFunction(int value)
{
if(x1>windowWidth-rsize||x1<0)
xstep=-xstep;
if(y1>windowHeight-rsize||y1<0)
ystep=-ystep;
if(x1>windowWidth-rsize)
x1=windowWidth-rsize-1;
if(y1>windowWidth-rsize)
y1=windowWidth-rsize-1;
x1+=xstep;
y1+=ystep;
glutPostRedisplay();
glutTimerFunc(33,TimerFunction,1);

}
void init()
{
glClearColor(0.0f,0.0f,1.0f,1.0f);
}
void reshape(GLsizei w,GLsizei h)
{
if(h==0)
h=1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
{
windowHeight=250.0f*h/w;
windowWidth=250.0f;
}
else
{
windowWidth=250.0f*w/h;
windowHeight=250.0f;
}
glOrtho(0.0f,windowWidth,0.0f,windowHeight,1.0f,-1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main()
{
glutInitDisplayMode(GL_DOUBLE|GL_RGB);
glutCreateWindow("bounce");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutTimerFunc(33,TimerFunction,1);
init();
glutMainLoop();
}
...全文
40 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
baoshuai633 2011-04-05
  • 打赏
  • 举报
回复
GL_DOUBLE|GL_RGB

将GL改成GLUT

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧