没有合适的资源?快使用搜索试试~ 我知道了~
一个openGL旋转立方体的程序
需积分: 9 7 下载量 89 浏览量
2016-01-01
16:28:25
上传
评论
收藏 4KB TXT 举报
温馨提示
试读
6页
一个图形学关于openGL的小程序,是一个旋转的立方体
资源推荐
资源详情
资源评论
#include <stdio.h>
#include<GL\glut.h>
static float xrot = 0.0;
static float yrot = 0.0;
static float zrot = 0.0;
GLfloat LightAmbient[] = { 1.5f, 1.5f, 1.5f, 1.0f }; //环境光参数,半亮白色
GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; //漫射光参数,
GLfloat LightPosition[] = { 0.0f, 0.0f, 0.0f, 1.0f }; //光源位置
void cube()
{
GLint texture[6];
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 0.0);
glVertex3f(1.0, 1.0, -1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, -1.0);
glColor3f(0.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[1]);
glBegin(GL_QUADS);
#include<GL\glut.h>
static float xrot = 0.0;
static float yrot = 0.0;
static float zrot = 0.0;
GLfloat LightAmbient[] = { 1.5f, 1.5f, 1.5f, 1.0f }; //环境光参数,半亮白色
GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; //漫射光参数,
GLfloat LightPosition[] = { 0.0f, 0.0f, 0.0f, 1.0f }; //光源位置
void cube()
{
GLint texture[6];
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 0.0);
glVertex3f(1.0, 1.0, -1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, -1.0);
glColor3f(0.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[1]);
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glColor3f(0.0, 0.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[2]);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glColor3f(0.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glColor3f(1.0, 0.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[3]);
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glColor3f(0.0, 0.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(1.0, -1.0, 1.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glColor3f(0.0, 0.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[2]);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glColor3f(0.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glColor3f(1.0, 0.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[3]);
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glColor3f(0.0, 0.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, -1.0);
剩余5页未读,继续阅读
资源评论
qq_29606683
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功