opengl 坐标的基本变换
![]()
图一、相机模拟OpenGL中的各种坐标变换
|
![]()
图二、三维物体的显示过程
|
二、OpenGL中的几种变换
void gluLookAt(GLdouble eyex,GLdouble eyey,GLdouble eyez,GLdouble centerx,GLdouble centery,GLdouble upx,GLdouble upy,GLdouble upz); |
glTranslate{fd}(TYPE x,TYPE y,TYPE z); |
glRotate{fd}(TYPE angle,TYPE x,TYPE,y,TYPE z); |
glScale{fd}(TYPE x,TYPE y,TYPE z); |
void glFrustum(GLdouble left,GLdouble Right,GLdouble bottom,GLdouble top,GLdouble near,GLdouble far); |
![]()
图三、透视投影视景体
|
void gluPerspective(GLdouble fovy,GLdouble aspect,GLdouble zNear, GLdouble zFar); |
![]()
图四、透视投影视景体
|
![]()
图五、正射投影视景体
|
void glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top, GLdouble near,GLdouble far) |
void gluOrtho2D(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top) |
glViewport(GLint x,GLint y,GLsizei width, GLsizei height); |
![]()
图六、附加裁剪平面
|
#include "glos.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
void myinit(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
void CALLBACK display(void);
void CALLBACK display(void)
{
GLdouble eqn[4] = {1.0, 0.0, 0.0, 0.0};
glClear(GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 0.0, 1.0);
glPushMatrix();
glTranslatef (0.0, 0.0, -5.0);
/* clip the left part of wire_sphere : x<0 */
glClipPlane (GL_CLIP_PLANE0, eqn);
glEnable (GL_CLIP_PLANE0);
glRotatef (-90.0, 1.0, 0.0, 0.0);
auxWireSphere(1.0);
glPopMatrix();
glFlush();
}
void myinit (void)
{
glShadeModel (GL_FLAT);
}
void CALLBACK myReshape(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
}
void main(void)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 500, 500);
auxInitWindow ("Arbitrary Clipping Planes");
myinit ();
auxReshapeFunc (myReshape);
auxMainLoop(display);
}
|
(六)矩阵栈的操作
转载于:https://blog.51cto.com/general/562657
opengl 坐标的基本变换相关推荐
- OpenGL坐标的问题?
#include "stdafx.h" #include <gl/glut.h> static GLfloat xRot = 0.0f; static GLfloat ...
- opengl 坐标的理解
[目标]:学习OpenGL中的坐标系统. [参考]: 1.<计算机图形学(OpenGL版) (第三版)> Francis著 (本文主要涉及第三章~第七章) 2.<计算机图形学(Ope ...
- OpenGL坐标系及基本变换
转自:https://blog.csdn.net/dcrmg/article/details/53088463 左手坐标系.右手坐标系.笛卡尔坐标系 左手坐标系:伸开左手,大拇指指向X轴正方向,食指指 ...
- Win32 OpenGL编程(4) 2D图形基础(颜色及坐标体系进阶知识)
Win32 OpenGL 编程 (4) 2D 图形基础(颜色及坐标体系进阶知识) write by 九天雁翎 (JTianLing) -- blog.csdn.net/vagrxie 讨论新闻组及文件 ...
- 利用OpenGL渲染并用OpenCV输出显示二维图像
OpenGL所有渲染的结果都输出显示在窗口中,设置OpenCV的图像cv::Mat outimg,并使用OpenGL的glReadPixels从帧缓冲区中加载像素至内存: //use fast 4-b ...
- Learn OpenGL (一):打开窗口
原文 Hello Window 作者 JoeyDeVries 翻译 Geequlim, Krasjet 环境VS2015+OpenGL3.3 #include <glad/glad.h> ...
- OpenGL学习笔记3 —— 绘制3D物体、鼠标交互、反向变换
/* reference http://nehe.gamedev.net/article/using_gluunproject/16013/ */#include <windows.h> ...
- Android OpenGL ES 入门系列(一) --- 了解OpenGL ES的前世今生
转载请注明出处 本文出自Hansion的博客 OpenGL ES (OpenGL for Embedded Systems) 是 OpenGL 三维图形 API 的子集,针对手机.PDA和游戏主机等嵌 ...
- android 动画引擎,一个使用openGL渲染的炫丽Android动画库
这是一个 android 动画特效库 可以实现各种炫酷动画. github地址: ht t ps:// gith u b.co m/g pl ib s/an dro id- ma gic-s ur ...
最新文章
- 利用正则表达式去除所有html标签,只保留文字
- 解决打开WORD错误报告问题
- eclipse启动项目
- linux的运行级别如何更改成6,把Linux运行级别设置为6后如何解决的经验分享
- Java体系学习书籍推荐,BAT 面试官 如何面试
- STM32工作笔记0050---端口复用和重映射
- 腾讯AI加速器三期全球招募开启,打造AI+产业生力军
- tomcat容器启动
- 深入理解Nacos源码注册中心之服务发现(订阅拉取)
- DateUtils解析
- 三维空间内点到直线的距离计算公式
- 光电信息科学与工程学c语言吗,光电信息科学与工程是热门吗?本文讲给你讲个透彻...
- 范数、损失函数、标准差
- 分享一个在线去水印网站
- ERR wrong number of arguments for ‘srem‘ command
- 搞不定Excel没关系,这款神器让你秒变数据可视化高手
- 基于MQTT协议的Mosquitto的使用及libmosquitto客户端编程
- golang结构体指针
- 网站seo优化到底该怎么做呢
- Google天气接口