PDA

View Full Version : Bind two or more drawings



throwaway
11-30-2013, 07:42 AM
I am drawing 2D shapes to my OpenGL Window using glBegin() glEnd(). That is simple enough to do but what I'd like to do is bind them together somehow so that when I move one drawing it moves all drawings binded to it. Can any help me with this please.

Cornix
11-30-2013, 07:45 AM
Best solution (in my opinion) would be if you do this yourself by changing the vertex data in your application.
However, there is also the way to translate the modelview matrix.

Before you start rendering anything to the screen you can call:


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(x, y, z);

This would move all primitives together by x, y and z.

throwaway
11-30-2013, 07:54 AM
I not know if I should have mentioned in my original post but I'm drawing 2D shapes to the screen. Does that make a differences because I'm not using a z axis

Cornix
11-30-2013, 07:58 AM
z can still be used, even in 2D, as a way of depth-testing.
But even if you dont use it, it doesnt matter. Just put a 0 to the z coordinate.

throwaway
11-30-2013, 08:09 AM
Do you have any links to turorials showing how to do this because I'm new to OpenGL and I'm not quite sure what I have to do