有opengl的么,问个glColor3f()
glColor3f()不能手动更改值,改了之后不能刷新出来,颜色还是原来的颜色//---------------------------核心函数---------------------------
GLfloat go_x=0.0f,go_y=0.0f,go_z=-10.0f;//物体运动值
GLfloat rtri=0.0f;//自身旋转
GLfloat rtri_x=0.0f;
int DrawGLScene(GLvoid)// 从这里开始进行所有的绘制
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// 清除屏幕和深度缓存
glLoadIdentity();// 重置当前的模型观察矩阵(置中)
glTranslatef(go_x,go_y,go_z);// 模型点后退10个位
glRotatef(rtri,rtri_x,1.0f,0.0f);// Y轴自旋转
glBegin(GL_TRIANGLES);// 立体三角
glColor3f(1.0f,0.0f,0.0f);//红色
glVertex3f(0.0f,1.0f,0.0f);
glColor3f(0.0f,1.0f,0.0f);//绿色
glVertex3f(-1.0,-1.0f,1.0f);
glColor3f(0.0f,0.0f,1.0f);//蓝色
glVertex3f(1.0f,-1.0f,1.0f);
glColor3f(1.0f,0.0f,0.0f);//红色
glVertex3f(0.0f,1.0f,0.0f);
glColor3f(0.0f,0.0f,1.0f);//蓝色
glVertex3f(1.0f,-1.0f,1.0f);
glColor3f(0.0f,1.0f,0.0f);//绿色
glVertex3f(1.0f,-1.0f,-1.0f);
glColor3f(1.0f,0.0f,0.0f);//红色
glVertex3f(0.0f,1.0f,0.0f);
glColor3f(0.0f,1.0f,0.0f);//绿色
glVertex3f(1.0f,-1.0f,-1.0f);
glColor3f(0.0f,0.0f,1.0f);//蓝色
glVertex3f(-1.0f,-1.0f,-1.0f);
glColor3f(1.0f,0.0f,0.0f);//红色
glVertex3f(0.0f,1.0f,0.0f);
glColor3f(0.0f,0.0f,1.0f);//蓝色
glVertex3f(-1.0f,-1.0f,-1.0f);
glColor3f(0.0f,1.0f,0.0f);//绿色
glVertex3f(-1.0f,-1.0f,1.0f);
glEnd();
if (keys[VK_UP])go_y+=0.2f;//上
if (keys[VK_DOWN])go_y-=0.2f;//下
if (keys[VK_LEFT])go_x-=0.2f;//左
if (keys[VK_RIGHT])go_x+=0.2f;//右
if (keys[VK_SUBTRACT])go_z-=0.2f;//减号(小键盘)
if (keys[VK_ADD])go_z+=0.2f;//加号(小键盘)
if (keys[VK_F2]){go_x=0.0f;go_y=0.0f;go_z=-10.0f;rtri_x=0.0f;}//还原图形位置
if (keys[VK_F3])rtri_x+=0.2f;//切换X轴增加
if (keys[VK_F4])rtri_x-=0.2f;//切换X轴减少
rtri+=1.0f;//自旋转
if (keys[VK_F1])
{
keys[VK_F1]=FALSE;//激活F1后撤销内部状态
MessageBox(hWnd ,"键盘上,下,左,右.(X,Y轴)\n"
"小键盘减号:缩小图形.(Z轴)\n小键盘加号:增大图形.(Z轴)\n"
"回车:切换窗口和全屏状态.\n"
"F2:还原图形位置和大小.\n"
"F3:X轴自旋转增加.\n"
"F4:X轴自旋转减少.\n"
"ESC:退出程序.\n"
"\n这是NEHE的框架,OpenGL为演示.(天使梦魔 [email]shakugan.shana@[/email])"
,"帮助",0);
}
return TRUE; // 一切 OK
}
opengl.zip
(11.02 KB)