OpenGl Test.
来源:互联网 发布:知言善行的意思 编辑:程序博客网 时间:2024/06/10 12:46
opengl Test.
所用opengl内容:
GLfloat 一种类型,可兼容32或者64位
glClear()清屏
glPushmatrix()压入当前矩阵堆栈
glPopMatrix()出stack
glRotatef()旋转
glColor3f()RGB颜色
glRectf()填充一个四方形
glutSwapBuffers()双缓存
#include <gl\glut.h>#include <stdlib.h>static GLfloat spin = 0.0;void init(void){glClearColor(0.0, 0.0, 0.0, 0.0);glShadeModel(GL_FLAT);}void display(void){glClear(GL_COLOR_BUFFER_BIT);glPushMatrix();glRotatef(spin, 0.0, 0.0, 1.0);glColor3f(1.0, 1.0, 1.0);glRectf(-25.0, -25.0, 25.0, 25.0);glPopMatrix();glutSwapBuffers();}void spinDisplay(void){spin = spin + 2.0;if (spin > 360.0)spin = spin - 360.0;glutPostRedisplay();}void reshape(int w, int h){glViewport(0, 0, (GLsizei)w, (GLsizei)h);glMatrixMode(GL_PROJECTION);glLoadIdentity();// 将当前的用户坐标系的原点移到了屏幕中心:类似于一个复位操作glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0);glMatrixMode(GL_MODELVIEW);//指定哪一个矩阵是当前矩阵glLoadIdentity();}void mouse(int button, int state, int x, int y){switch (button){case GLUT_LEFT_BUTTON:if (state == GLUT_DOWN)glutIdleFunc(spinDisplay);// 点击鼠标后,开始执行旋转逻辑。break;case GLUT_MIDDLE_BUTTON:if (state == GLUT_DOWN)glutIdleFunc(NULL);break;default:break;}}int main(int argc, char** argv){glutInit(&argc, argv);glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);glutInitWindowSize(250, 250);glutInitWindowPosition(100, 100);glutCreateWindow(argv[0]);init();glutDisplayFunc(display);// 绘制glutReshapeFunc(reshape);// 窗口大小发生变化时glutMouseFunc(mouse);// 鼠标事件glutMainLoop();// 开始return 0;}
0 0
- OpenGl Test.
- C# OpenGL Test Code
- OpenGL Depth and Stencil Test
- OpenGL vs2010 ActiveX Control Test Container
- centos安装openGL并且运行首个test
- OpenGL中viewport和 scissor test的问题
- OpenGL学习:Per-fragment operation(1)-模板测试(stencil test)
- OpenGL学习:Per-fragment operation(2)-深度测试(depth test)
- test
- test
- test
- test
- test
- test
- test
- Test
- test
- Test
- [HTML5]Application Cache,未缓存文件无法访问解决方法
- Derby数据库使用入门
- 十四周项目1-纯虚函数
- HDOJ-1728 逃离迷宫(BFS + 转弯)
- [chromium][browser][idea][closed] Part1 : 把AwContent和Chrome_shell编译成一个so
- OpenGl Test.
- XCode环境变量及路径设置
- jQuery操作select下拉框的方法
- Android 软件自动更新功能的实现
- 总体来说
- 第十四周项目2-玩基类
- 简单的Windows应用程序创建QRCode条形码控件QRCode Fontware
- MongoDB学习笔记(一) MongoDB介绍及安装
- 十四周项目2-2玩基类