Results 1 to 4 of 4

Thread: glRotate

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Duluth, MN, US
    Posts
    20

    glRotate

    Hi. I'm new to OpenGL and I have a problem.
    I'm trying to rotate an object about the axis using glRotatef(....). The code is something like this:

    if(x< 180)
    glRotatef(10, 1.f, 0.f, 0.f);

    For some reason, the object moves in the direction of positive x everytime the image is redrawn. I would prefer the object to stay stationary rather than move. Can someone give me why this is happening?

  2. #2
    Member Contributor
    Join Date
    Jan 2002
    Location
    Vancouver, Wa, USA
    Posts
    54

    Re: glRotate

    Do you want it to rotate constantly?

    if so, try:
    add an int called "rvar" for Rotation angle variable

    glRotatef(rvar, X,Y,Z); //Enable the XYZ sxis by giving them a value of 1. Or else leave as "0"
    then at the end of the function:
    rvar+=0.3f; //Add 0.3 to the angle for each loop.

    so:

    while(rvar < 120)
    {
    glRotatef(rvar,1.0,0.0,0.0);
    /* Do Junk */
    rvar+=0.03; //You can change of course ^_^
    }

    As for why it moves left, I dunno, is that ALL the code? show wha you have put prior, and define your ints.

    [This message has been edited by ThinIce (edited 01-31-2002).]
    ==============

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

    Re: glRotate

    Before or after glRotate are you using gltranslate of glscale?

    Also the object you are drawing, is the point (0,0,0) in the center of the object or at a edge? You must remember that rotate moves the object around its axis.
    If the axis is a corner of your object, then the object rotate from that point.

    Let us see how you have drawn your object?

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Duluth, MN, US
    Posts
    20

    Re: glRotate

    The base of the object is at (0,0,0). The top coordinate is roughly (0,0,70). I tried rotatating about the x-axis, and the object appeared to be moving in the direction of positive x while it rotated. I managed to fix it. The program reads in the coordinates from a file. The program which generates the coordinates was using a different coordinate system (which I didn't know). So (0,0,0) in the file's coorinates didn't map to (0,0,0) in my coordinates. So that's what was causing the problem.

    I appreciate everyones contributions.

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