Results 1 to 5 of 5

Thread: glRotatef()

  1. #1

    glRotatef()

    when i use the following to rotate it works:
    glRotatef(45.0, 0.0, 0.0, 1.0);

    however, when i rotate in any of the other axies, nothing. ie the following doesn't do anything:
    glRotatef(0.0, 0.0, 45.0, 1.0),

  2. #2
    Member Contributor
    Join Date
    Aug 2002
    Location
    Brooklyn, NY, USA
    Posts
    53

    Re: glRotatef()

    Originally posted by simmosn:
    however, when i rotate in any of the other axies, nothing. ie the following doesn't do anything:
    glRotatef(0.0, 0.0, 45.0, 1.0),
    The first argument specifies how many degree you want to rotate around an axis. The following three argument specifiy the x, y, z axis to rotate, respectively. In that statement, you're rotating the y and z axis 0 degrees. Thats why you don't see any change. Also, the last three parameters are clamped to the range of [0, 1].

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    20

    Re: glRotatef()

    your error is this i think :

    glRotatef(angle,x,y,z);

    the first parameter is the angle, the others are the axis on wich you want to rotate.

    if u want to rotate set the axis to 1.0

    //rotate 45 on x axis
    glRotatef(45.0, 1.0, 0.0, 0.0);

    //rotate 45 on y axis
    glRotatef(45.0, 0.0, 1.0, 0.0);

    //rotate 45 on z axis
    glRotatef(45.0, 0.0, 0.0, 1.0);

  4. #4
    Member Contributor
    Join Date
    Aug 2002
    Location
    Brooklyn, NY, USA
    Posts
    53

    Re: glRotatef()

    Do something like this:
    void Render()
    {

    glClear(GL_COLOR_BUFFER_BIT);
    glLoadIdentity();
    static float angle; // initializes angle to 0.0f

    glRotatef(angle, 0.0f, 1.0f, 1.0f); // Rotate around the y and z axis.

    glTranslatef(0.0f, 0.0f, -100.0f);

    DrawSomeCube();

    angle++;

    if(angle >= 360.0f)
    angle = 0.0f;

    glFlush();
    }

  5. #5

    Re: glRotatef()

    thanks for your help. i was being a bit thick, but all part of the learning process

Similar Threads

  1. glRotatef
    By kiwon0905 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-03-2012, 12:28 AM
  2. Replace two glRotatef() with one glRotatef()?
    By tgtt in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-24-2004, 02:33 PM
  3. glRotatef()
    By Rajveer in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-05-2002, 10:28 AM
  4. glRotatef
    By beet6 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-18-2002, 01:31 PM
  5. glRotatef
    By Krime384 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-01-2000, 02:46 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