| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1715 人关注过本帖
标题:有opengl的么,问个glColor3f()
只看楼主 加入收藏
天使梦魔
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:37
帖 子:564
专家分:2754
注 册:2007-8-29
结帖率:83.33%
收藏
 问题点数:0 回复次数:0 
有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)
搜索更多相关主题的帖子: opengl 
2008-01-16 09:55
快速回复:有opengl的么,问个glColor3f()
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016660 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved