opengl新手求教,为啥运行后没有图像显示?
照着nehe的教程写的,不知道为什么。。代码如下:#include"stdAfx.h"#include<gl/glut.h>#include<gl/gl.h>voiddi...
照着nehe的教程写的,不知道为什么。。代码如下:
#include "stdAfx.h"
#include <gl/glut.h>
#include <gl/gl.h>
void display()
{
GLfloat rquad=0;
glLoadIdentity();
glClearColor(1.0,1.0,1.0,0.0); //background color
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(0.0f,0.0f,-7.0f);
glColor3f(0.0,0.0,0.0); //chair color
glRotatef(rquad,0.0f,1.0f,0.0f);
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f( 0.5,-0.5,0.0);
glVertex3f( 0.5, 0.5,0.0);
glVertex3f(-0.5, 0.5,0.0);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glVertex3f( 0.5,-0.5,-0.5);
glVertex3f( 0.5, 0.5,-0.5);
glVertex3f(-0.5, 0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5, 0.5,-0.5);
glVertex3f(-0.5, 0.5, 0.0);
glVertex3f(-0.5,-0.5, 0.0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5, 0.5,-0.5);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.5,-0.5, 0.0);
glVertex3f(0.5,-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,0.0,-0.5);
glVertex3f( 0.5,0.0,-0.5);
glVertex3f( 0.5,0.0, 0.0);
glVertex3f(-0.5,0.0, 0.0);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5,0.5,-0.5);
glVertex3f( 0.5,0.5,-0.5);
glVertex3f( 0.5,0.5, 0.0);
glVertex3f(-0.5,0.5, 0.0);
glEnd();
rquad-=0.15f;
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);
glutCreateWindow("demo");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
代码格式好乱我也不知道为啥。。。。 展开
#include "stdAfx.h"
#include <gl/glut.h>
#include <gl/gl.h>
void display()
{
GLfloat rquad=0;
glLoadIdentity();
glClearColor(1.0,1.0,1.0,0.0); //background color
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(0.0f,0.0f,-7.0f);
glColor3f(0.0,0.0,0.0); //chair color
glRotatef(rquad,0.0f,1.0f,0.0f);
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f( 0.5,-0.5,0.0);
glVertex3f( 0.5, 0.5,0.0);
glVertex3f(-0.5, 0.5,0.0);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glVertex3f( 0.5,-0.5,-0.5);
glVertex3f( 0.5, 0.5,-0.5);
glVertex3f(-0.5, 0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5, 0.5,-0.5);
glVertex3f(-0.5, 0.5, 0.0);
glVertex3f(-0.5,-0.5, 0.0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5, 0.5,-0.5);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.5,-0.5, 0.0);
glVertex3f(0.5,-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(-0.5,0.0,-0.5);
glVertex3f( 0.5,0.0,-0.5);
glVertex3f( 0.5,0.0, 0.0);
glVertex3f(-0.5,0.0, 0.0);
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5,0.5,-0.5);
glVertex3f( 0.5,0.5,-0.5);
glVertex3f( 0.5,0.5, 0.0);
glVertex3f(-0.5,0.5, 0.0);
glEnd();
rquad-=0.15f;
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);
glutCreateWindow("demo");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
代码格式好乱我也不知道为啥。。。。 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
你去下载Powervr的sdk自己看吧..
什么nehe啊 都是没人用边角料 ,还是看看手机端的opengles 吧,这是未来的方向
http://community.imgtec.com/developers/powervr/
这个sdk有你想要的全部....pc端模拟器都有
什么nehe啊 都是没人用边角料 ,还是看看手机端的opengles 吧,这是未来的方向
http://community.imgtec.com/developers/powervr/
这个sdk有你想要的全部....pc端模拟器都有
追问
都说nehe的是新手必备么不是,而且我的要求就是做电脑的三维动图啊。。跟手机端没关系啊都
追答
nehe 不好用,我同学以前用过.
我推荐的这个sdk,你在pc端装好后,可以直接在vc里面玩opengles, 他的GLES2.0接口比nehe里的GL1.0的语法好学好用.
你试试就知道啦.
而且你用这个GLES开发出来的程序..以后只要带着对应的几个DLL,在任何win上都能跑.用起来比标准的 vs上自带的GL 方便
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询