Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

[GL] Nested rendering

Name: Anonymous 2010-10-30 16:24

So, suppose I have a list of things to render, and each thing could potentially have another list of things as a child, such that the thing's child is 'attached' (every transformation on it is relative to its parent).
How would I go about doing that properly? I've tried a combination of pushMatrix and popMatrix that doesn't quite work (children's coordinates and stuff stay global):
void draw_many (Thing *x) {
 while (x) {
  glPushMatrix();
  glTranslate (x->pos); /* and friends */
  glDraw (x->stuff);
  if (x->child)
   draw_many (x->child);
  glPopMatrix();
  x = x->next;
 }
}
void draw_everything() {
 setup_gl_shite();
 glLoadIdentity();
 draw_many (first_thing);
 finish_gl_shite();
}

I thought I understood the logic behind matrix stacks, but clearly not. Help me, /Xarn/, you're my only hope!

Name: Anonymous 2010-10-30 16:30

Oh. Predictably, I find the answer a minute after posting. glPushMatrix should be after all the transformations. Another potentially good thread wasted.

Name: Anonymous 2010-10-30 17:30

••

Name: Anonymous 2010-10-30 23:17

>>3
GTFO.

Name: Anonymous 2010-12-27 18:34


Don't change these.
Name: Email:
Entire Thread Thread List