Opengl 绘制矩形
来源:互联网 发布:淘宝客都使用什么软件 编辑:程序博客网 时间:2024/05/01 03:30
使用工具 :VC++ 6.0
#include "stdafx.h"
#include <windows.h> /* 有的书作glos.h,意思是根据编译所在的操作系统include操作系统的头文件根据编译所在的操作系统include操作系统的头文件 */
#include <gl\glut.h>
//Called to draw scene
void RenderSence(void)
{
//Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
//把绘制颜色设置为红色
glColor3f(1.0f,0.0f,0.0f);
//用当前颜色绘制一个矩形
glRectf(-25.0f,25.0f,25.0f,-25.0f);
//Flush drawing commands ---刷新绘制命令
glFlush();
}
//Set up the rendering state
void SetupRC(void)
{
glClearColor(0.0f,0.0f,1.0f,1.0f); //此时背景色为蓝色
}
void ChangeSize(GLsizei w,GLsizei h){
GLfloat aspectRatio;
//防止被0所除
if(h == 0) h=1;
//把视口设置为窗口大小
glViewport(0,0,w,h);
//重置坐标系统
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//建立剪裁区域(左、右、底、顶、近、远)
aspectRatio=(GLfloat)w/(GLfloat)h;
if(w<=h)
glOrtho(-100.0,100.0,-100/aspectRatio,100.0/aspectRatio,1.0,-1.0);
else
glOrtho(-100*aspectRatio,100.0*aspectRatio,-100.0,100.0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char* argv[])
{
printf("Hello World!\n");
glutInitDisplayMode(GLUT_SINGLE|GLUT_SINGLE|GLUT_RGB);
glutCreateWindow("Simple"); //窗口名为“Simple”
glutDisplayFunc(RenderSence);
glutReshapeFunc(ChangeSize);
SetupRC();
glutMainLoop();
return 0;
}
- Opengl 绘制矩形
- OpenGL-绘制简单矩形
- OpenGL入门之绘制矩形
- opengl之绘制一个矩形
- [OpenGL]用OpenGL图形的绘制--矩形
- opengl学习笔记2-2-矩形绘制
- OpenGL编程(二)绘制矩形
- 用openGL ES绘制圆角矩形的实现
- OpenGL ES 02 – 绘制图元 2 - 矩形
- opengl练习之绘制任意大小的矩形
- 《高效学习OpenGL》 之 读取和绘制像素矩形
- opengl学习笔记二之绘制一个矩形
- iOS开发OpenGL ES教程(2)绘制矩形
- android游戏开发(OpenGL ES绘制矩形平面)
- 西蒙iphone-OpenGL ES 教程-02 : 绘制矩形
- OpenGL ES零基础入门四矩形的绘制
- C++(11):OpenGL坐标系及绘制多个矩形
- 绘制矩形
- 精灵的淡入淡出(ccsprite)
- 如何编程的识别蓝牙是否已经连接了
- 精灵(CCSprite)自定义触摸事件
- 有环链表问题-确定有环链表的环起点,环长及柄长
- ring3读取MBR
- Opengl 绘制矩形
- ioctlsocket
- 粒子系统
- 如何学好3D游戏引擎编程
- 86标准sql与92标准SQL用法区别
- discuz中单个DIY片段 分开循环
- saxbuilder用法
- DPC,时钟中断,以及DPC定时器(3)
- JDBC各种数据库的连接驱动及url、dialect