简体   繁体   English

在opengl c ++中切换相机的视图

[英]switching camera's view in opengl c++

I want to control 2 cameras, each with different modelview matrix. 我想控制2个摄像机,每个摄像机具有不同的modelview矩阵。

But I'm not able to save and recover the matrix. 但是我无法保存和恢复矩阵。 Any suggestions? 有什么建议么?

Why can't you save them? 你为什么不能保存它们? This should let you save and restore a matrix. 这样可以保存和还原矩阵。 Or just use push/pop. 或者只是使用推/弹出。

float matrix[16];
glGetFloatf(GL_MODELVIEW_MATRIX, &matrix); //save
glLoadMatrixf(&matrix); //restore

each camera class should have its own modelview matrix. 每个相机类应具有自己的模型视图矩阵。 You can either get the current model view matrix from OpenGL (as it was explained by Tim), or you can use some custom library for math. 您可以从OpenGL获取当前的模型视图矩阵(正如Tim解释的那样),也可以使用一些自定义库进行数学计算。

Custom math library is needed for core OpenGL (3.3 and above) and OpenGL ES 2.0 核心OpenGL(3.3及更高版本)和OpenGL ES 2.0需要自定义数学库

try not to stick with math library inside "old" OpenGL 尽量不要在“旧” OpenGL中使用数学库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM