博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
opengl 矩阵变换
阅读量:6160 次
发布时间:2019-06-21

本文共 1440 字,大约阅读时间需要 4 分钟。

#include 
#include
#include
GLfloat step=0.0,s=0.1;void CALLBACK display();void CALLBACK display(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); s+=0.005; if(s>1.0)s=0.1; glPushMatrix(); glScalef(s,s,s); //glRotatef(step,0.0,1.0,0.0); //沿y轴旋转 glRotatef(step,0.0,0.0,-1.0);//沿z轴旋转(绕Z轴旋转时,大于0,表示逆时针旋转。小于0顺时针旋转) //glRotatef(step,1.0,0.0,0.0); //对物体进行数学描写叙述 glBegin(GL_POLYGON); glColor3f(0.0,1.0,1.0); glVertex2f(-0.4,-0.4); glColor3f(1.0,0.0,0.0); glVertex2f(0.0,0.0); glColor3f(1.0,0.0,1.0); glVertex2f(-0.4,0.4); glEnd(); glBegin(GL_LINES); glColor3f(0.0,1.0,1.0); glVertex2f(0.0,-0.2); glColor3f(1.0,0.0,1.0); glVertex2f(0.0,0.2); glEnd(); glBegin(GL_POLYGON); glColor3f(0.0,1.0,1.0); glVertex2f(0.4,-0.4); glColor3f(1.0,0.0,0.0); glVertex2f(0.0,0.0); glColor3f(1.0,0.0,1.0); glVertex2f(0.4,0.4); glEnd(); glPopMatrix(); glFlush(); auxSwapBuffers();}void CALLBACK stepDisplay (void){ step = step + 0.13; if (step >360.0) step = step -360.0; display();}void main(){ //初始化窗体(设置窗体的名称坐标尺寸和显示模式) auxInitDisplayMode(AUX_SINGLE|AUX_RGBA); auxInitPosition(0,0,600,600); auxInitWindow("openG"); glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); auxIdleFunc (stepDisplay); auxMainLoop(display);}

 

 

你可能感兴趣的文章
Android JSON数据解析
查看>>
DEV实现日期时间效果
查看>>
java注解【转】
查看>>
centos 下安装g++
查看>>
下一步工作分配
查看>>
Response. AppendHeader使用大全及文件下载.net函数使用注意点(转载)
查看>>
jQuery最佳实践
查看>>
centos64i386下apache 403没有权限访问。
查看>>
jquery用法大全
查看>>
PC-BSD 9.2 发布,基于 FreeBSD 9.2
查看>>
css斜线
查看>>
Windows phone 8 学习笔记(3) 通信
查看>>
Revit API找到风管穿过的墙(当前文档和链接文档)
查看>>
Scroll Depth – 衡量页面滚动的 Google 分析插件
查看>>
Windows 8.1 应用再出发 - 视图状态的更新
查看>>
自己制作交叉编译工具链
查看>>
Qt Style Sheet实践(四):行文本编辑框QLineEdit及自动补全
查看>>
[物理学与PDEs]第3章习题1 只有一个非零分量的磁场
查看>>
onInterceptTouchEvent和onTouchEvent调用时序
查看>>
android防止内存溢出浅析
查看>>