2

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 glTranslate 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)?

genpfault
  • 51,148
  • 11
  • 85
  • 139
rgngl
  • 5,353
  • 3
  • 30
  • 34

1 Answers1

5

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.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Sorry for insisting being a noob :) Then my question is should every node perform its own drawing(and have it's own shader, which doesn't sound ok to me anyway) or should there be one class responsible for all drawing and nodes in the scene call the rendering method in that class? – rgngl Jul 05 '11 at 13:54
  • Funny you should ask. Someone else did ask exactly this just recently, see my answer here: http://stackoverflow.com/questions/6583024/oo-architecture-for-rendering-in-shader-based-games/6583203#6583203 – datenwolf Jul 05 '11 at 14:22
  • @datenwolf - this is a similar question to one i'm asking here: http://stackoverflow.com/questions/14720111/drawing-a-scene-graph-with-opengl-es2. would you be kind enough to have a look? i think i'm looking for this sort of explanation, maybe made a bit more explicit with some code help. thanks! – danh Feb 06 '13 at 06:13