Implementing a scene graph on OpenGL ES 2.0
I am looking for a way to implement some basic scene management in OpenGL ES 2.0 where there's no fixed function pipeline.
Normally I would implement a Node base class that would apply its transformations with glTransl开发者_StackOverflowate
and glRotate
, draw itself(if there's anything to draw) and then call the draw method of its child nodes.
Does anybody have an example of this implemented with OpenGL ES 2.0(or OpenGL 3.0)?
The key difference is, that instead of calling glRotate, glTranslate, glScale, etc. you build a transformation matrix yourself, probably also some transformation hierachy. And then, before rendering the object in question, you supply its transformation matrix through a Uniform.
The code required for this is really simple, just a bunch of linear algebra on 4 vectors and 4×4 matrices – and quaternions if you want to use them.
精彩评论