OpenGL Matrix Column-Major

 



如下是 msdn的相关函数的说明,又进一步说明和验证 color-major 概念


glLoadMatrixd function

Applies to: desktop apps only

The glLoadMatrixd and glLoadMatrixf functions replace the current matrix with an arbitrary matrix.

Syntax

void WINAPI glLoadMatrixd(
  const GLdouble *m
);

Parameters

m

A pointer to a 4x4 matrix stored in column-major order as 16 consecutive values.

Return value

This function does not return a value.

Error codes

The following error code can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_OPERATION

                                The function was called between a call to glBegin and the corresponding call to glEnd.

Remarks

The glLoadMatrix function replaces the current matrix with the one specified in m. The current matrix is the projection matrix, modelview matrix, or texture matrix, determined by the current matrix mode (see glMatrixMode).

The m parameter points to a 4x4 matrix of single-precision or double-precision floating-point values stored in column-major order. That is, the matrix is stored as shown in the following image.

// 4 x 4 array will be organized into a0, a4, a8, a12 (from first colum of 16 consecutive values),

// then a1, a5, a9, a13 (from second column), etc

// Therefore it is regarded as column-major order.

Ee872048.load02(en-us,VS.85).png

The following functions retrieve information related to glLoadMatrix:

glGet with argument GL_MATRIX_MODE

glGet with argument GL_MODELVIEW_MATRIX

glGet with argument GL_PROJECTION_MATRIX

glGet with argument GL_TEXTURE_MATRIX

 

// for example

 const GLdouble bias[16] = { 
  0.5, 0.0, 0.0, 0.0,
  0.0, 0.5, 0.0, 0.0,
  0.0, 0.0, 0.5, 0.0,
 0.5, 0.5, 0.5, 1.0};

 glLoadIdentity(); 
 glLoadMatrixd(bias);

This will cause current matrix is like thus.

  0.5, 0.0, 0.0, 0.5,  (a0, a4, a8,  a12)
  0.0, 0.5, 0.0, 0.5,  (a1, a5, a9,  a13)
  0.0, 0.0, 0.5, 0.5,  (a2, a6, a10, a14)
 0.0, 0.0, 0.0, 1.0    (a3, a7, a11, a15)


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值