Matrix In OpenGL
来源:互联网 发布:数据分析师主要做什么 编辑:程序博客网 时间:2024/05/17 09:14
Got some idea with my class of matrix operation facilitated by OpenGL original pipeline.
Notice that the matrix in OpenGL is column-major which represents the following matrix:
a column-major model-view matrix(fetched from OpenGL):
row 0: Xx Xy Xz Xw
row 1: Yx Yy Yz Yw
row 2: Zx Zy Zz Zw
row 3: Tx Ty Tz Tw
row 0: Xx Xy Xz Xw
row 1: Yx Yy Yz Yw
row 2: Zx Zy Zz Zw
row 3: Tx Ty Tz Tw
is the sequence in C/C++ if a model-view matrix is fetched from OpenGL because of the column-major
sequence in OpenGL. If in a row-major matrix, such as in DirectX or C++, this matrix should be
like this:
sequence in OpenGL. If in a row-major matrix, such as in DirectX or C++, this matrix should be
like this:
a row-major matrix we usually used in C/C++:
row 0: Xx Yx Zx Tx
row 1: Xy Yy Zy Ty
row 2: Xz Yz Zz Yz
row 3: Xw Yw Zw Tw
row 0: Xx Yx Zx Tx
row 1: Xy Yy Zy Ty
row 2: Xz Yz Zz Yz
row 3: Xw Yw Zw Tw
So, if you wish to apply a transformation with no errors or you don't want a transformation you
are not trying to have in OpenGL, use the 1st matrix form.
In C/C++, a 1 dimension array for being the matrix can be used in OpenGL with the right form
should be like:
are not trying to have in OpenGL, use the 1st matrix form.
In C/C++, a 1 dimension array for being the matrix can be used in OpenGL with the right form
should be like:
GLfloat modelViewMatrix = { Xx, Xy, Xz, Xw,
Yx, Yy, Yz, Yw,
Zx, Zy, Zz, Zw,
Tx, Ty, Tz, Tw};
Looks weird, huh? But that's it in GL, and we'd better get used to it and keep focused while applying custom transformation!
/****************************************************************************************/
But in GLSL use row-major ways to select certain element.
if a matrix is mat4 mat = {1.0, 2.0, 3.0, 1.0,
4.0, 5.0, 6.0, 7.0,
8.0, 9.0, 10.0, 11.0,
12.0, 13.0, 14.0, 15.0};
select 12.0 by using mat[3][0], Where 3 as column index and 0 as row index, like mat[col][row]. Column idx in front of row idx.
Yx, Yy, Yz, Yw,
Zx, Zy, Zz, Zw,
Tx, Ty, Tz, Tw};
Looks weird, huh? But that's it in GL, and we'd better get used to it and keep focused while applying custom transformation!
/****************************************************************************************/
But in GLSL use row-major ways to select certain element.
if a matrix is mat4 mat = {1.0, 2.0, 3.0, 1.0,
4.0, 5.0, 6.0, 7.0,
8.0, 9.0, 10.0, 11.0,
12.0, 13.0, 14.0, 15.0};
select 12.0 by using mat[3][0], Where 3 as column index and 0 as row index, like mat[col][row]. Column idx in front of row idx.
0 0
- view Matrix in opengl
- Matrix In OpenGL
- opengl matrix
- OpenGL: OpenGL Matrix Library
- OpenGL Matrix Library
- OpenGL Projection Matrix
- OpenGL Projection Matrix
- OpenGL Projection Matrix(转)
- OpenGL Matrix Column-Major
- OpenGL Perspective Projection Matrix
- OpenGL Perspective Projection Matrix
- OpenGL Perspective Projection Matrix
- OpenGL Perspective Projection Matrix
- OpenGL: Matrix Library
- OpenGL Projection Matrix
- OpenGL Perspective Projection Matrix
- OpenGL Projection Matrix
- openGL的project matrix 和 model matrix
- BUPT OJ183 Longest Subsequence
- day38 Hibernate关联关系配置(一对多、一对一和多对多)
- 安装python组件
- poj1562 Oil Deposits
- sqliite接口,很有用
- Matrix In OpenGL
- 【C++】PAT(advanced level)1028. List Sorting (25)
- 算法概论---思维导图
- Android里面所应用到的注册权限
- 百度地图API
- 版权控制SCM
- Codeforces Round #235 (Div. 2) / 410D Roman and Numbers (带有整除性质的数位DP)
- 迭代器product
- sort命令