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

相关文章

SpringBoot整合(ES)ElasticSearch7.8实践

《SpringBoot整合(ES)ElasticSearch7.8实践》本文详细介绍了SpringBoot整合ElasticSearch7.8的教程,涵盖依赖添加、客户端初始化、索引创建与获取、批量插... 目录SpringBoot整合ElasticSearch7.8添加依赖初始化创建SpringBoot项

Kotlin Map映射转换问题小结

《KotlinMap映射转换问题小结》文章介绍了Kotlin集合转换的多种方法,包括map(一对一转换)、mapIndexed(带索引)、mapNotNull(过滤null)、mapKeys/map... 目录Kotlin 集合转换:map、mapIndexed、mapNotNull、mapKeys、map

关于集合与数组转换实现方法

《关于集合与数组转换实现方法》:本文主要介绍关于集合与数组转换实现方法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、Arrays.asList()1.1、方法作用1.2、内部实现1.3、修改元素的影响1.4、注意事项2、list.toArray()2.1、方

利用Python脚本实现批量将图片转换为WebP格式

《利用Python脚本实现批量将图片转换为WebP格式》Python语言的简洁语法和库支持使其成为图像处理的理想选择,本文将介绍如何利用Python实现批量将图片转换为WebP格式的脚本,WebP作为... 目录简介1. python在图像处理中的应用2. WebP格式的原理和优势2.1 WebP格式与传统

java Long 与long之间的转换流程

《javaLong与long之间的转换流程》Long类提供了一些方法,用于在long和其他数据类型(如String)之间进行转换,本文将详细介绍如何在Java中实现Long和long之间的转换,感... 目录概述流程步骤1:将long转换为Long对象步骤2:将Longhttp://www.cppcns.c

在Java中将XLS转换为XLSX的实现方案

《在Java中将XLS转换为XLSX的实现方案》在本文中,我们将探讨传统ExcelXLS格式与现代XLSX格式的结构差异,并为Java开发者提供转换方案,通过了解底层原理、性能优势及实用工具,您将掌握... 目录为什么升级XLS到XLSX值得投入?实际转换过程解析推荐技术方案对比Apache POI实现编程

C/C++中OpenCV 矩阵运算的实现

《C/C++中OpenCV矩阵运算的实现》本文主要介绍了C/C++中OpenCV矩阵运算的实现,包括基本算术运算(标量与矩阵)、矩阵乘法、转置、逆矩阵、行列式、迹、范数等操作,感兴趣的可以了解一下... 目录矩阵的创建与初始化创建矩阵访问矩阵元素基本的算术运算 ➕➖✖️➗矩阵与标量运算矩阵与矩阵运算 (逐元

Python使用FFmpeg实现高效音频格式转换工具

《Python使用FFmpeg实现高效音频格式转换工具》在数字音频处理领域,音频格式转换是一项基础但至关重要的功能,本文主要为大家介绍了Python如何使用FFmpeg实现强大功能的图形化音频转换工具... 目录概述功能详解软件效果展示主界面布局转换过程截图完成提示开发步骤详解1. 环境准备2. 项目功能结

使用Python实现网页表格转换为markdown

《使用Python实现网页表格转换为markdown》在日常工作中,我们经常需要从网页上复制表格数据,并将其转换成Markdown格式,本文将使用Python编写一个网页表格转Markdown工具,需... 在日常工作中,我们经常需要从网页上复制表格数据,并将其转换成Markdown格式,以便在文档、邮件或

Python将字符串转换为小写字母的几种常用方法

《Python将字符串转换为小写字母的几种常用方法》:本文主要介绍Python中将字符串大写字母转小写的四种方法:lower()方法简洁高效,手动ASCII转换灵活可控,str.translate... 目录一、使用内置方法 lower()(最简单)二、手动遍历 + ASCII 码转换三、使用 str.tr