如何用我自己的 4x4 矩阵更新 opengl 模型视图矩阵? [英] How to update opengl modelview matrix with my own 4x4 matrix?

查看:38
本文介绍了如何用我自己的 4x4 矩阵更新 opengl 模型视图矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于对象变换的 4x4 矩阵.

I have 4x4 matrix for object's transformations.

float mat44[16];

但我不知道如何使用我的矩阵更新 OpenGL ModelView 矩阵.我应该使用带有矩阵中相关值的 glTranslatef()/glRotatef() 还是应该使用 glLoadMatrix(),glMultMatrix() ?请帮忙.谢谢.

But i don't know how to update OpenGL ModelView matrix using my matrix. should i use glTranslatef()/glRotatef() with relavant values from my matrix or should i use glLoadMatrix(),glMultMatrix() ? Pls help. Thanks.

推荐答案

如果你想将你的变换应用到 OpenGL 矩阵堆栈中已经存在的当前变换,那么你应该写:

If you want to apply your transformation to current transformation already in OpenGL matrix stack, then you should write:

glMultMatrixf(mat44);

但是如果您想丢弃当前位于 OpenGL 矩阵堆栈顶部的内容并使用您自己的转换,那么您应该编写:

But if you want to discard what's currently on top of OpenGL matrix stack and use your own transformation, then you should write:

glLoadMatrixf(mat44);

这篇关于如何用我自己的 4x4 矩阵更新 opengl 模型视图矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆