Results 1 to 4 of 4

Thread: glRotate

  1. #1
    Guest

    glRotate

    When I use the Rotate function like this:
    glRotatef(x,0.0f,0.0f,0.0f)
    x increases with 45.0f / DrawGLScene

    Why does my cube move into the screen and comes out again with its back first.

    If someone would like to help my stupid brain I'd be glad. Thanks.

    Jonas

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: glRotate

    You need to post more of the code...
    But I see the following problems:

    maybe a error on your part in typing the message but glRotatef(x, 0.0, 0.0, 0.0) does nothing, no rotation will take place. one of the axis must be 1 in order to rotate that axis. zero causes no rotation to take place.

    your problem could be a couple of things.

    One you are not rotating your cube from the center.
    Two you could have your gltranslate at the wrong location.
    three you are not using glpush/pop.

    You cube shuold be drawn with 0,0,0 being the center of the cube, else if a corner starts at 0,0,0 you are rotating from the corner not the center.

    if you need to move and rotate a cube here is example code:

    glPushMatrix();
    glTranslatef(......); move somewhere on the screen.

    glRotatef(.......); Rotate cube around axis.

    draw_cube();

    glPopMatrix();


    Originally posted by Grower:
    When I use the Rotate function like this:
    glRotatef(x,0.0f,0.0f,0.0f)
    x increases with 45.0f / DrawGLScene

    Why does my cube move into the screen and comes out again with its back first.

    If someone would like to help my stupid brain I'd be glad. Thanks.

    Jonas


    [This message has been edited by nexusone (edited 08-09-2002).]

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: glRotate

    because the rotate function is about 0,0,0 and the centre of your cube is not at 0,0,0
    I think thats what you mean anyway.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    216

    Re: glRotate

    Maybe it's because the 2nd, 3rd, and 4th parameters are the axis of rotation. 0,0,0 is not valid.

    For example:

    a,1,0,0 rotates a degrees around the x axis
    a,0,1,0 rotates a degrees around the y axis
    a,0,0,1 rotates a degrees around the z axis

Similar Threads

  1. glRotate
    By Blacknight in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-21-2010, 11:40 PM
  2. glrotate
    By tpthyd in forum OpenGL: General
    Replies: 1
    Last Post: 02-11-2009, 04:12 AM
  3. glRotate help
    By malancha in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-05-2004, 07:27 PM
  4. glRotate
    By azariah in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 04-02-2002, 10:13 PM
  5. glRotate or not?
    By darkdreamer in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 02-07-2001, 11:35 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