Start New Discussion within our Software Development Community

How can I get camera view and Triangle count of models in OpenGL? I know it's a vague question but I'm just starting opengl and none of the tutorials explain how to get the current camera view.

I hooked all OpenGL calls for a game and figured out how to turn on/off wireframe but the camera angle/view part is killing me.

Any ideas?

The camera in OpenGL (or any other 3D graphics code) is just the global transformation you do on the entire scene. It is not something that is attached to a model, nor anything that you can "get". Think of it this way, in the world, there is no difference between a moving/rotating camera and its opposite, that is, a fixed camera in a world which is moving/rotating in the opposite direction. In OpenGL, and other engines, the latter point of view prevails, because it is the one that makes sense mathematically. If you want to move the camera one meter to the right, instead, you make the entire world move 1 meter to the left, and the result is the same. So, the camera "position" is really just the inverse of the global transformation that you do on the entire world at the beginning of a rendering loop. Often, for convenience, you would create a class for cameras which store the "camera transformation", but in reality, in the rendering loop, you would take that transformation, reverse it, and apply it globally (before beginning to draw anything else).

As for getting the number of triangles, that's not something you would get from OpenGL, this is something that depends on your code and how you store/represent your models. OpenGL might have a global polygon count (for all models together), but I don't know how to get that.

For good tutorials on OpenGL, visit nehe.gamedev.net (Legacy tutorials, old but good for the basics).

This article has been dead for over six months. Start a new discussion instead.