The Viewport Transformation
英文帖子链接http://glasnost.itcarlow.ie/~powerk/GeneralGraphicsNotes/projection/viewport_transformation.html
抽空翻译一下,先记录下来备用
The Viewport Transformation
The final stage of the vertex transformation process is to map the points from the normalized view volume to their final position in the viewport on screen. We want to transform the view volume to the shape and position of the viewport.
The normalised view volume is a cube centred on the origin, bounded by points (−1,−1,−1) and (1,1,1). The u and v coordinates of each point will be transformed to x and y screen coordinates (pixel coordinates) and we will scale the n coordinates (pseudo-depth) to a range between 0 and 1 (scale the front plane to 0 and the back plane to 1), this depth value will be called z.
The x,y sceen coordinates wil be used to draw the pixel in the refresh buffer. The z value will be stored in the depth buffer for hidden surface removal.
The viewport transformation will be represented by a 4x4 matrix. It encapsulates 2 stages
- a scaling to the shape of the viewport
- a transformation to the position of the viewport
The viewport is defined as the rectangle between (vl,vb) and (vr,vt)
The view-volume needs to be scaled to the width and height of the viewport. At this stage we will also scale the pseudo-depth to a range of 0 to 1. The normalised view volume has a height, width and depth of 2.
The width of the viewport is vr−vl and the height of the view port is vt−vb
To scale a value from one range of values to another, we divide by the size of the original range and multiply by the size of the new range.
Therefore the scaling matrix required is;
Finally we need to translate the scaled normalised view volume to the position of the viewport. This is a combination of two translations; first translate to the origin (add vr−vl2 to u and add vt−vb2 to v. Second move from the origin to the position of the viewport (add vl and vb to u and v). The n-coordinate (now in the range {−12⋯12}) needs to be shifted by +12
Note; vr−vl2+vl=vr+vl2, similarly the translation for v is vt+vb2.
So the translation matrix is;
Combining the above two transfomations gives us the Viewport Transformation Matrix;
Aspect Ratio
The aspect ratio is the relationship of the width of the viewport to its height widthheight, this is sometimes written as width:height as in 4:3 or 16:9.
It is important that the aspect ratio of the viewport is the same as the aspect ratio of the viewvolume in order to avoid distortion.
Viewport Transformation in OpenGL
In OpenGL the viewport transformation is controlled by the functionglViewPort()which is used to set the size and position of the viewport.
The Viewport Transformation的更多相关文章
- OpenCASCADE Coordinate Transforms
OpenCASCADE Coordinate Transforms eryar@163.com Abstract. The purpose of the OpenGL graphics process ...
- OpenCASCADE Camera
OpenCASCADE Camera eryar@163.com Abstract. OpenCASCADE introduce a new class Graphic3d_Camera for th ...
- OpenGL管线(用经典管线代说着色器内部)
图形管线(graphics pipeline)向来以复杂为特点,这归结为图形任务的复杂性和挑战性.OpenGL作为图形硬件标准,是最通用的图形管线版本.本文用自顶向下的思路来简单总结OpenGL图形管 ...
- OpenGL基础图形编程
一.OpenGL与3D图形世界1.1.OpenGL使人们进入三维图形世界 我们生活在一个充满三维物体的三维世界中,为了使计算机能精确地再现这些物体,我们必须能在三维空间描绘这些物体.我们又生活在一个充 ...
- 【转】OpenGL基础图形编程(一)
原文:http://blog.chinaunix.net/uid-20638550-id-1909183.html 分类: 一.OpenGL与3D图形世界 1.1.OpenGL使人们进入三维图形世界 ...
- iOS 8 Metal Swift教程(一) :开始学习
在本篇教程中,你将应用到3D图形中的一系列矩阵变换,并会学习到如下内容: 如何使用模型(model),视图(view)以及投影变换(projection transformations). 如何使用矩 ...
- 【opengl】OpenGL中三维物体显示在二维屏幕上显示的变换过程
转自:http://blog.sina.com.cn/s/blog_957b9fdb0100zesv.html 为了说明在三维物体到二维图象之间,需要经过什么样的变换,我们引入了相机(Camera)模 ...
- Android OpenGL ES(十二):三维坐标系及坐标变换初步 .
OpenGL ES图形库最终的结果是在二维平面上显示3D物体(常称作模型Model)这是因为目前的打部分显示器还只能显示二维图形.但我们在构造3D模型时必须要有空间现象能力,所有对模型的描述还是使用三 ...
- SharpGL学习笔记(七) OpenGL的变换总结
笔者接触OpenGL最大的困难是: 经常调试一份代码时, 屏幕漆黑一片, 也不知道结果对不对,不知道如何是好! 这其实就是关于OpenGL"变换"的基础概念没有掌握好, 以至于对& ...
随机推荐
- strut2.xml中result param详细设置
1.Struts2.xml配置文件: 2.Jsp中:说明回调函数一个参数即可.把上面的俩个参数msg和page封装到一起了 3.msg是Action中全局变量 可参考:http://qiaolevip ...
- 转-SecureCRT设置
原帖地址:http://www.2cto.com/os/201410/341569.html 一.基本设置 1.修改设置 为了SecureCRT用起来更方便,需要做一些设置,需要修改的有如下几处: 1 ...
- cocos2dx解析lua table数据结构 简易版.
之前一直用xml填配置, cocos2dx自带了xml解析接口, 非常方便. 但是, 接口好用也改变不了xml的结构字符太多, 书写麻烦, 乱七八糟的事实. 很早就想换lua, 无奈引擎没有现成接口, ...
- 为什么我们不喜欢用富UI控件
我们对于理解一般意义的抽象关系并没有问题,但如第一部分使用Entity Framework 时说明的,事实恰好相反.我们还喜欢在交付应用程序时利用抽象关系,比如使用Azure等云服务.在这两种情况下, ...
- 行列的几种命名方式.line-.colume======.row-.col=========.tr-.td
第一种从line-height的语义来来讲,line表示hang再贴切不过了,colume纵列或者柱子也很形象,缺点太长了 第二种组合模拟rowspan,colspan而来,想必这个col也是colu ...
- PHP表单
二.PHP表单 1.PHP表单处理 welcome.html <html> <body> <form action="welcome.php" met ...
- HTML5中的Range对象的研究(转载)
一:Range对象的概念 Range对象代表页面上的一段连续区域,通过Range对象,可以获取或修改页面上的任何区域,可以通过如下创建一个空的Range对象,如下: var range = docu ...
- 入门3:PHP环境开发搭建(windows)
一.环境需要 硬件环境(最低配置): 双核CPU 8G内存 操作系统环境: Windows(64位)7+ Mac OS X 10.10+ Linux 64位(推荐Ubuntu 14 LTS) /**拓 ...
- Asp.net MVC分页实例
分页是网页基本功能,这里主要讨论在Asp.net MVC环境下分页的前端实现,不涉及后台分页.实现效果如下图显示: Step 1.建立分页信息类 public class PagingInfo { p ...
- MySQL查询优化:连接查询排序limit
MySQL查询优化:连接查询排序limit(join.order by.limit语句) 2013-02-27 个评论 收藏 我要投稿 MySQL查询优化:连接查询排序 ...