简体   繁体   中英

switching camera's view in opengl c++

I want to control 2 cameras, each with different modelview matrix.

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.

Custom math library is needed for core OpenGL (3.3 and above) and OpenGL ES 2.0

try not to stick with math library inside "old" OpenGL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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