Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Glrotatef()

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2016
    Posts
    7

    Glrotatef()

    hello i am still new to the gl programming so i'm asked to make a triangle rotate arround a cirlce so i used the center of the circle as a center of rotation using translated() then rotated() but the question is that when i do that it rotates fat from it... i need to adjust the distance between the translated origin and the triangle how do i do that ?

  2. #2
    Intern Contributor
    Join Date
    Feb 2016
    Posts
    64
    Could you post some code about the transformations you do? Maybe you are not translating back after rotating.

    Try to set up different orders when doing transformations. The old pipeline is a bit annoying about that, if I recall correctly.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2016
    Posts
    7

    translations

    Quote Originally Posted by Spoops View Post
    Could you post some code about the transformations you do? Maybe you are not translating back after rotating.

    Try to set up different orders when doing transformations. The old pipeline is a bit annoying about that, if I recall correctly.
    i don't quiet understand how to translate back ? this is what i only do (it's the idea of making triangles rotate around a circle"tires of a car " ) : every thing has his functions created and drawn
    void Draw()
    {
    glClear(GL_COLOR_BUFFER_BIT); //clears the previous drawings from the window
    glLoadIdentity();

    glColor3f(0.0, 0.0, 0.0);
    glBegin(GL_LINE_STRIP);
    glVertex2f(-25, 10);
    glVertex2f(-25, 30);
    glVertex2f(-15, 30);
    glVertex2f( -15, 10);
    glVertex2f(-15, 30);
    glVertex2f(10,30);
    glVertex2f(10,10 );
    glVertex2f(10, 30);
    glVertex2f(15, 30);
    glVertex2f(15, 10);
    glEnd();

    glBegin(GL_POLYGON);
    glVertex2f(-50, 10);
    glVertex2f(50, 10);
    glVertex2f(50, -10);
    glVertex2f(-50, -10);

    glEnd();

    // draw circle
    Draw_Circle(15,-32,-20);
    glColor3f(1.0, 1.0, 1.0);
    Draw_Circle(7.5, -32, -20);
    glColor3f(0.0, 0.6, 1.0);
    Draw_Circle(3, -32, -20);


    // draw circle 2
    glColor3f(0.0, 0.0, 0.0);
    Draw_Circle(15, 20, -20);
    glColor3f(1.0, 1.0, 1.0);
    Draw_Circle(7.5, 20, -20);
    glColor3f(0.0, 0.6, 1.0);
    Draw_Circle(3, 20, -20);

    //glPushMatrix();

    glColor3f(0.0, 1.0, 1.0);
    glTranslated(50, 50, 0);
    glRotated(angle, 0.0, 0.0, 1.0);
    //glScaled(200, 200, 1);
    glBegin(GL_TRIANGLES);
    glVertex2f(-32, -12);
    glVertex2f(-34,-16);
    glVertex2f(-30,-16);
    glEnd();
    //glPopMatrix();

    glutSwapBuffers();
    glFlush();//execute all commands from buffers
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •