opengl/glut的若干函数
来源:互联网 发布:淘宝买家秀兼职骗局 编辑:程序博客网 时间:2024/04/30 16:03
一直对opengl有兴趣,可是到现在还是略懂而已。
现在才算是明白如何把opengl那套原始的屏幕坐标转换为我所熟悉的坐标系统
先弄个小例子
呵呵 这都是gluOrtho2D的功劳啊
这里给出我所熟悉的一组函数
1.gluOrtho2D — define a 2D orthographic projection matrix
void gluOrtho2D(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top);
该函数就是把屏幕左下角坐标设计为left, bottom,右上角设置为 top,right
2. void glTranslatef(GLfloat x,GLfloat y,GLfloat z)
该函数用来平移图像
当然它还有向量版本
3. void glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z)
该函数用来翻转图像,第一个参数是角度
例如glRotatef(45,0,0,1.0);
把图像研z轴翻转45角度
4. void glScalef(GLfloat x, GLfloat y, GLfloat z);
是采用来缩放图像的函数
附注:
去年开始接触opengl现在还是这个水平 -_-!
现在才算是明白如何把opengl那套原始的屏幕坐标转换为我所熟悉的坐标系统
先弄个小例子
- #include <stdlib.h>
- #include <GL/glut.h>
- void init(void)
- {
- glClearColor (0.5, 0.5, 0.0, 0.0);
- glShadeModel (GL_SMOOTH);
- glLoadIdentity();
- gluOrtho2D(0,100,0,100);
- }
- void display(void)
- {
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- gluOrtho2D(0,100,0,100);
- glBegin(GL_TRIANGLES);
- glScalef(5.0,5.0,5.0);
- glColor3f(1.0,0.0,0.0);
- glVertex2f(50.0,75.0);
- glColor3f(0.0,1.0,0.0);
- glVertex2f(50.0,25.0);
- glColor3f(0.0,0.0,1.0);
- glVertex2f(25.0,0.0);
- glEnd();
- glFlush ();
- }
- void keyboard(unsigned char key, int x, int y)
- {
- switch (key)
- {
- case 27:
- exit(0);
- break;
- }
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowSize (400, 400);
- glutInitWindowPosition (0, 0);
- glutCreateWindow (argv[0]);
- init ();
- glutDisplayFunc(display);
- glutKeyboardFunc(keyboard);
- glutMainLoop();
- return 0;
- }
呵呵 这都是gluOrtho2D的功劳啊
这里给出我所熟悉的一组函数
1.gluOrtho2D — define a 2D orthographic projection matrix
void gluOrtho2D(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top);
该函数就是把屏幕左下角坐标设计为left, bottom,右上角设置为 top,right
2. void glTranslatef(GLfloat x,GLfloat y,GLfloat z)
该函数用来平移图像
当然它还有向量版本
3. void glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z)
该函数用来翻转图像,第一个参数是角度
例如glRotatef(45,0,0,1.0);
把图像研z轴翻转45角度
4. void glScalef(GLfloat x, GLfloat y, GLfloat z);
是采用来缩放图像的函数
附注:
去年开始接触opengl现在还是这个水平 -_-!
- opengl/glut的若干函数
- OpenGL的函数(GLU, GLUT)
- OpenGL中常用的 GLUT 函数
- opengl glut glutMainLoop()函数
- 【OpenGL】GLUT函数说明
- 初时OpenGL,OpenGL应用工具包GLUT的基本函数
- 基于glut学习OpenGL时的几个实用函数
- OpenGL 中常用的 GLUT 函数…
- [OpenGL] glut库的安装
- 【OpenGL】glut 消息事件处理函数 glutMainLoop();
- 【OpenGL】glut 消息事件处理函数 glutMainLoop();
- OpenGL(2)GLUT库菜单函数API
- OpenGL 中 GLUT 消息事件处理函数
- glut常用的函数
- 【OpenGL】glut
- openGL--GLUT
- OpenGL实用函数工具包GLUT在Visual Studio上的配置
- macOS系统OpenGL环境配置及某些弃用的glut函数使用
- C#多线程-不同线程之间通过事件委托封送调用方法
- timer类的用法
- 关于正交验证法
- XSLT格式化日期
- linux+apache2.2+php5.2+mysql5.0源码安装
- opengl/glut的若干函数
- C#开发的程序如何在运行的时候弹出选择调试器的代码
- 数据挖掘算法
- vb6托盘右键菜单
- cvirus.c病毒源代码(只是用与研究!请误乱用!)
- PRB: OnInitialUpdate() May Be Called More Than Once
- 如何用vb6建立带光栅的菜单
- fcntl函数
- 遥仰凰华重装系统后无法运行解决方法