Moving an Object

Hi,

I am very new to OpenGL…
and am currently using JOGL.

Creating an object is OK…but i just cant get the object to move…
eg:- I create a simple 2D triangle
I want to rotate it around a vertice A…

                   |\
                   |  \
                   |_ _ \   pos 1

                    _ _ 
                   |    /
                   |  /
                   |/       pos 2

and so on…

could someone tell me what commands do i use to make this happen…

I tried creating four different triangles,around a vertice…
sequentially…but i dont know how to clear the previous drawn triangle…so that the next triangle appears alone…i mean the triangle appears to be moving…

I follow the approach below…

  1. I draw a triangle with a begin and end section…
  2. I issue the glClear command…
  3. I draw the triangle again in a new position…

Is the above approach incorrect???
Please suggest a solution…

First of all you need to draw just one triangle and issue glRotate/glTranslate calls to move it. It is not necessary to create other triangles.
For animation you should make sure that you use a double buffered context and call the corresponding ‘swapbuffers’ command after each frame (glxSwapBuffers in Linux, most likely wglSwapBuffers in Windows and something similar for jogl, I think).
Take a look here, lesson 4 should help.

Thanks a lot…

But now i have another problem…
The object rotates…thats fine…but how do i make it move
in 2D context…
for eg gl.glRotatef(angle/16, 0, 0, 1);(angle starts from 1…)
would rotate the object about the Z-axis…

i need to move the object in 2D view about a certain vertex of the object in the XY plane only…

what should i do???

glTranslate?