如何正确使用 glMultMatrix - iPhone - OpenGL ES
我想知道是否有人可以帮助我学习如何正确使用 glMultMatrix。
我的应用程序中有以下渲染代码,但是看来我不能只将带有矩阵的 C 结构提供给 glMultMatrix :
-(void)render
{
matrixStruct matrices[] = {1, 0, -0, -9.37988, 0, -0.651537, 0.758617, 1133.64, 0, 0.758617, 0.651537, 129730, 0, 0, 0, 1};
// clear the matrix
glPushMatrix();
glLoadIdentity();
//scale
glScalef(0.00001, 0.00001, 0.00001);
glMultMatrixf(matrices);
[mesh render];
//restore the matrix
glPopMatrix();
}
我从 http://www.opengl.org/sdk/docs/man/xhtml/glMultMatrix.xml :
void glMultMatrixd( const GLdouble * m);
void glMultMatrixf( const GLfloat * m);
m
Points to 16 consecutive values that are used as the elements of a 4 × 4 column-major matrix.
我不确定应该如何格式化矩阵并将其传递给 glMultMatrix。另外,在调用 render 之前我是否需要启用 glMatrixMode ?
谢谢
I wonder if anyone can help me learn how to correctly use glMultMatrix.
I have the following render code in my app, however it appears I cannot just feed a C struct with the matrix to glMultMatrix :
-(void)render
{
matrixStruct matrices[] = {1, 0, -0, -9.37988, 0, -0.651537, 0.758617, 1133.64, 0, 0.758617, 0.651537, 129730, 0, 0, 0, 1};
// clear the matrix
glPushMatrix();
glLoadIdentity();
//scale
glScalef(0.00001, 0.00001, 0.00001);
glMultMatrixf(matrices);
[mesh render];
//restore the matrix
glPopMatrix();
}
I understand from the documentation at http://www.opengl.org/sdk/docs/man/xhtml/glMultMatrix.xml that I need to provide :
void glMultMatrixd( const GLdouble * m);
void glMultMatrixf( const GLfloat * m);
m
Points to 16 consecutive values that are used as the elements of a 4 × 4 column-major matrix.
I am not sure how I should format my matrix and pass it to glMultMatrix. Also do I need to enable glMatrixMode before I call render ?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了 - 我需要传递一个浮点数组:
例如
float matrices[] ={1,0,0,0,0,1,0,0,0,0,1,0,-578.556,7068.92,48.6953 ,1};
现在一切正常 - 谢谢。
Worked it out - I needed to pass an array of floats :
e.g
float matrices[] ={1,0,0,0,0,1,0,0,0,0,1,0,-578.556,7068.92,48.6953,1};
All working now - thanks.