如何正确使用 glMultMatrix - iPhone - OpenGL ES

发布于 2025-01-06 15:29:35 字数 939 浏览 3 评论 0原文

我想知道是否有人可以帮助我学习如何正确使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅窗月明清似水 2025-01-13 15:29:35

解决了 - 我需要传递一个浮点数组:

例如

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文