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

2024-01-08 21:48
文章标签 es 转换 矩阵 资料 opengl glu

本文主要是介绍OpenGL ES 中 GLU 做矩阵转换的资料,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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.


这篇关于OpenGL ES 中 GLU 做矩阵转换的资料的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/584929

相关文章

C#实现将Excel表格转换为图片(JPG/ PNG)

《C#实现将Excel表格转换为图片(JPG/PNG)》Excel表格可能会因为不同设备或字体缺失等问题,导致格式错乱或数据显示异常,转换为图片后,能确保数据的排版等保持一致,下面我们看看如何使用C... 目录通过C# 转换Excel工作表到图片通过C# 转换指定单元格区域到图片知识扩展C# 将 Excel

C++使用printf语句实现进制转换的示例代码

《C++使用printf语句实现进制转换的示例代码》在C语言中,printf函数可以直接实现部分进制转换功能,通过格式说明符(formatspecifier)快速输出不同进制的数值,下面给大家分享C+... 目录一、printf 原生支持的进制转换1. 十进制、八进制、十六进制转换2. 显示进制前缀3. 指

使用Python开发一个带EPUB转换功能的Markdown编辑器

《使用Python开发一个带EPUB转换功能的Markdown编辑器》Markdown因其简单易用和强大的格式支持,成为了写作者、开发者及内容创作者的首选格式,本文将通过Python开发一个Markd... 目录应用概览代码结构与核心组件1. 初始化与布局 (__init__)2. 工具栏 (setup_t

Java中Date、LocalDate、LocalDateTime、LocalTime、时间戳之间的相互转换代码

《Java中Date、LocalDate、LocalDateTime、LocalTime、时间戳之间的相互转换代码》:本文主要介绍Java中日期时间转换的多种方法,包括将Date转换为LocalD... 目录一、Date转LocalDateTime二、Date转LocalDate三、LocalDateTim

Python实现AVIF图片与其他图片格式间的批量转换

《Python实现AVIF图片与其他图片格式间的批量转换》这篇文章主要为大家详细介绍了如何使用Pillow库实现AVIF与其他格式的相互转换,即将AVIF转换为常见的格式,比如JPG或PNG,需要的小... 目录环境配置1.将单个 AVIF 图片转换为 JPG 和 PNG2.批量转换目录下所有 AVIF 图

详解如何通过Python批量转换图片为PDF

《详解如何通过Python批量转换图片为PDF》:本文主要介绍如何基于Python+Tkinter开发的图片批量转PDF工具,可以支持批量添加图片,拖拽等操作,感兴趣的小伙伴可以参考一下... 目录1. 概述2. 功能亮点2.1 主要功能2.2 界面设计3. 使用指南3.1 运行环境3.2 使用步骤4. 核

Java实现时间与字符串互相转换详解

《Java实现时间与字符串互相转换详解》这篇文章主要为大家详细介绍了Java中实现时间与字符串互相转换的相关方法,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、日期格式化为字符串(一)使用预定义格式(二)自定义格式二、字符串解析为日期(一)解析ISO格式字符串(二)解析自定义

在java中如何将inputStream对象转换为File对象(不生成本地文件)

《在java中如何将inputStream对象转换为File对象(不生成本地文件)》:本文主要介绍在java中如何将inputStream对象转换为File对象(不生成本地文件),具有很好的参考价... 目录需求说明问题解决总结需求说明在后端中通过POI生成Excel文件流,将输出流(outputStre

python+opencv处理颜色之将目标颜色转换实例代码

《python+opencv处理颜色之将目标颜色转换实例代码》OpenCV是一个的跨平台计算机视觉库,可以运行在Linux、Windows和MacOS操作系统上,:本文主要介绍python+ope... 目录下面是代码+ 效果 + 解释转HSV: 关于颜色总是要转HSV的掩膜再标注总结 目标:将红色的部分滤

利用Python开发Markdown表格结构转换为Excel工具

《利用Python开发Markdown表格结构转换为Excel工具》在数据管理和文档编写过程中,我们经常使用Markdown来记录表格数据,但它没有Excel使用方便,所以本文将使用Python编写一... 目录1.完整代码2. 项目概述3. 代码解析3.1 依赖库3.2 GUI 设计3.3 解析 Mark