OpenGL ES 中 GLU 做矩阵转换的资料

简介: OpenGL ES 中 GLU 做矩阵转换的资料 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循“署名-非商业用途-保持一致”创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。

OpenGL ES 中 GLU 做矩阵转换的资料

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino否则,出自本博客的文章拒绝转载或再转载,谢谢合作。



还是有空再翻译,这些只是用过的知识备忘,其实我只是明白了之后,才找到了这些资料,没弄明白的时侯,并不知道这些资料这么有用。

也许用不了多久,记忆就会消退,当再次需要的时侯,耤由这些点滴的资料,便可唤起曾经的回忆,苦难总是在过去之后,便成为最美好的记忆。


摘自:开放图形库图形系统工具库(1.3版)The OpenGL Graphics System Utility Library (Version 1.3)

第 4 章 矩阵转换
Chapter 4 Matrix Manipulation


        GLU 库包含对矩阵创建和坐标投影(转换)的支持。矩阵函数创建矩阵并给当前的 OpenGL 矩阵乘以这个结果。他们用于设置投影和视图参数。

坐标投影函数用于将对象空间坐标转换到屏幕坐标或者反之亦然。这使得确定一个对象在窗口的哪里进行绘制成为可能。

The GLU library includes support for matrix creation and coordinate pro-jection (transformation). The matrix routines create matrices and multiply

the current OpenGL matrix by the result. They are used for setting projec-tion and viewing parameters. The coordinate projection routines are used

to transform object space coordinates into screen coordinates or vice-versa.This makes it possible to determine where in the window an object is being

drawn.


4.1 矩阵设置
4.1 Matrix Setup

以下函数创建投影和视图矩阵,并使用 glMultMatrix 把它们应用到当前的矩阵。使用这些函数,用户可以构建一个裁剪体积并设置一个视图参数秋渲染屏幕。

gluOrtho2D 和 gluPerspective 构建常规需要的投影矩阵。

void gluOrtho2D( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top );

设置一个二维的正交视图区域。参数确定了可视区域的边界框。

调用 gluOrtho2D(left, right, bottom, top) 等于调用 glOrtho(left, right, bottom, top, 1, 1) 。

The following routines create projection and viewing matrices and apply

them to the current matrix using glMultMatrix. With these routines, a

user can construct a clipping volume and set viewing parameters to render

a scene.

gluOrtho2D and gluPerspective build commonly-needed projection

matrices.

void gluOrtho2D( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top );

sets up a two dimensional orthographic viewing region. The pa-

rameters dene the bounding box of the region to be viewed. Call-

ing gluOrtho2D(left, right, bottom, top) is equivalent to calling

glOrtho(left, right, bottom, top, 1, 1).

void gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far );


sets up a perspective viewing volume. fovy denes the eld-of-view angle

(in degrees) in the y direction. aspect is the aspect ratio used to determine

the eld-of-view in the x direction. It is the ratio of x (width) to y (height).

near and far dene the near and far clipping planes (as positive distances

from the eye point).

gluLookAt creates a commonly-used viewing matrix:

void gluLookAt( GLdouble eyex, GLdouble eyey,

GLdouble eyez, GLdouble centerx, GLdouble centery,

GLdouble centerz, GLdouble upx, GLdouble upy,

GLdouble upz );

The viewing matrix created is based on an eye point (eyex,eyey,eyez),

a reference point that represents the center of the scene (cen-

terx,centery,centerz), and an up vector (upx,upy,upz). The matrix is de-

signed to map the center of the scene to the negative Z axis, so that when

a typical projection matrix is used, the center of the scene will map to the

center of the viewport. Similarly, the projection of the up vector on the

viewing plane is mapped to the positive Y axis so that it will point upward

in the viewport. The up vector must not be parallel to the line-of-sight from

the eye to the center of the scene.

gluPickMatrix is designed to simplify selection by creating a matrix

that restricts drawing to a small region of the viewport. This is typically used

to determine which objects are being drawn near the cursor. First restrict

drawing to a small region around the cursor, then rerender the scene with

selection mode turned on. All objects that were being drawn near the cursor

will be selected and stored in the selection buer.

void gluPickMatrix( GLdouble x, GLdouble y,

GLdouble deltax, GLdouble deltay,

const GLint viewport[4] );

gluPickMatrix should be called just before applying a projection ma-

trix to the stack (eectively pre-multiplying the projection matrix by the

selection matrix). x and y specify the center of the selection bounding

box in pixel coordinates; deltax and deltay specify its width and height

in pixels. viewport should specify the current viewport's x, y, width, and

height. A convenient way to obtain this information is to call glGetInte-

gerv(GL VIEWPORT, viewport).


4.2 Coordinate Projection

Two routines are provided to project coordinates back and forth from ob-

ject space to screen space. gluProject projects from object space to screen

space, and gluUnProject does the reverse. gluUnProject4 should be

used instead of gluUnProject when a nonstandard glDepthRange is in

eect, or when a clip-space w coordinate other than 1 needs to be spec-

ied, as for vertices in the OpenGL glFeedbackBuer when data type

GL 4D COLOR TEXTURE is returned.

int gluProject( GLdouble objx, GLdouble objy,

GLdouble objz, const GLdouble modelMatrix[16],

const GLdouble projMatrix[16], const GLint viewport[4],

GLdouble *winx, GLdouble *winy, GLdouble *winz );

gluProject performs the projection with the given modelMatrix, pro-

jectionMatrix, and viewport. The format of these arguments is the same as

if they were obtained from glGetDoublev and glGetIntegerv. A return

value of GL TRUE indicates success, and GL FALSE indicates failure.

int gluUnProject( GLdouble winx, GLdouble winy,

GLdouble winz, const GLdouble modelMatrix[16],

const GLdouble projMatrix[16], const GLint viewport[4],

GLdouble *objx, GLdouble *objy, GLdouble *objz );

gluUnProject uses the given modelMatrix, projectionMatrix, and view-

port to perform the projection. A return value of GL TRUE indicates success,

and GL FALSE indicates failure.

int gluUnProject4( GLdouble winx, GLdouble winy,

GLdouble winz, GLdouble clipw,

const GLdouble modelMatrix[16],

const GLdouble projMatrix[16], const GLint viewport[4],

GLclampd near, GLclampd far, GLdouble *objx,

GLdouble *objy, GLdouble *objz, GLdouble *objw );

gluUnProject4 takes three additional parameters and returns one ad-

ditional parameter clipw is the clip-space w coordinate of the screen-space

vertex (e.g. the wc value computed by OpenGL); normally, clipw = 1. near

and far correspond to the current glDepthRange; normally, near = 0 and

far = 1. The object-space w value of the unprojected vertex is returned in

objw. Other parameters are the same as for gluUnProject.


目录
相关文章
|
4月前
|
XML 小程序 Java
【Android App】三维投影OpenGL ES的讲解及着色器实现(附源码和演示 超详细)
【Android App】三维投影OpenGL ES的讲解及着色器实现(附源码和演示 超详细)
49 0
|
12月前
|
存储 编解码 算法
Opengl ES之LUT滤镜(上)
Opengl ES之连载系列
336 0
|
12月前
|
数据安全/隐私保护 开发者
OpenGL ES 多目标渲染(MRT)
Opengl ES连载系列
213 0
|
12月前
|
数据安全/隐私保护 索引
Opengl ES之纹理数组
Opengl ES连载系列
172 0
|
12月前
|
数据安全/隐私保护
Opengl ES之水印贴图
Opengl ES之连载系列
81 0
|
12月前
|
Java 数据安全/隐私保护 Android开发
Opengl ES之矩阵变换(下)
Opengl ES连载系列
82 0
|
12月前
|
Java API 数据安全/隐私保护
Opengl ES之矩阵变换(上)
Opengl ES连载系列
82 0
|
12月前
|
存储
Opengl ES之踩坑记
Opengl ES之连载系列
90 0
|
12月前
|
存储 编解码 算法
Opengl ES之RGB转NV21
Opengl ES连载系列
115 0
|
12月前
|
并行计算 C++
Opengl ES之YUV数据渲染
Opengl ES连载系列
128 0