Results 1 to 4 of 4

Thread: Moving an Object

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    2

    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............





  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    374

    Re: Moving an Object

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    2

    Re: Moving an Object

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

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    374

    Re: Moving an Object


Similar Threads

  1. moving object in circle across of other object
    By openGLWriter in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-19-2015, 09:18 AM
  2. moving around and going near an object...
    By Turbo555 in forum OpenGL: General
    Replies: 4
    Last Post: 03-27-2008, 11:46 AM
  3. Moving an Object
    By ToddAtWSU in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-14-2006, 02:53 PM
  4. Moving an Object in 2D
    By Sklar in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-23-2004, 02:08 PM
  5. "moving" around object
    By gemini in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-26-2003, 07:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean