Results 1 to 2 of 2

Thread: glRotatef behaviour

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    5

    glRotatef behaviour

    Hello,

    I am rendering text in gl using an interface to freetype.

    When I attempt to rotate the text, the origin of the text moves. For example if I attempt to rotate text centered in the middle of my window by 45 degrees, the result is text rotated at the top left corner of my window.

    Is there something obvious that I could be doing wrong?

    Thanks.

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

    Re: glRotatef behaviour

    Where is the origin of you text, openGL rotates around 0,0,0. You must translate the origin point in which you rotate to this point.

    Let take a box, with the 0,0,0 origin at one corner. When we rotate the box it will be rotated around that corner. If we want the box to rotate round its center axis we must move it to 0,0,0.

    Let say our box it 0,0,0 top left and 1,1,0 bottom right. the center will be 0.5, 0.5, 0.0 .
    So we must translate the box's center to 0,0,0. which would be glTranslatef(-0.5, -0.5, 0.0);

    code looks something like this:

    glRotatef( 45, 0, 0, 1);
    glTranslatef(-0.5, -0.5, 0.0);
    Draw_box();


    Originally posted by MikeH77:
    Hello,

    I am rendering text in gl using an interface to freetype.

    When I attempt to rotate the text, the origin of the text moves. For example if I attempt to rotate text centered in the middle of my window by 45 degrees, the result is text rotated at the top left corner of my window.

    Is there something obvious that I could be doing wrong?

    Thanks.

Similar Threads

  1. glRotatef
    By kiwon0905 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-03-2012, 12:28 AM
  2. Why do i need glRotatef()?
    By openujs in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 11-14-2005, 06:33 AM
  3. Replace two glRotatef() with one glRotatef()?
    By tgtt in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-24-2004, 02:33 PM
  4. glRotatef()
    By simmosn in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-14-2002, 02:18 PM
  5. glRotatef
    By CyBBe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-06-2000, 11:09 AM

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