PDA

View Full Version : Group Objects



truetaurus
10-24-2009, 06:58 AM
Is it possible to group objects together so they act as one?

tidaldus
10-25-2009, 11:02 AM
There are no objects in OpenGL.
There are only triangle and quad faces, points and lines.
It's up to your program to manage these as objects, and there you can do what you want.

MaxH
10-26-2009, 10:17 AM
PushMatrix and PopMatrix are useful when it comes to 'grouping' objects for the purpose of applying transformations. For example, let's say you have 5 objects, each of which is drawn by a separate subroutine (another important step). The pseudo code below applies a Translate to all 5 objects, a Rotate to objects 1,2,3 (but NOT 4,5), and a Scale to objects 4 and 5, (but not 1,2,3).



glLoadIdentity
glTranslate

glPushMatrix
glRotate
Draw_Object1
Draw_Object2
Draw_Object3
glPopMatrix

glPushMatrix
glScale
Draw_Object4
Draw_Object5
glPopMatrix