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 5 of 5

Thread: Text Rotation

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2000
    Posts
    10

    Text Rotation

    I tried to modify the examples "xfont.c" and
    drawf.c (from the OpenGl red book)

    I want to rotate by any angle the text in the x-y plane but while the translations
    are done the rotation are not!

    follows the routines modified:

    from xfont.c

    void display(void)
    {
    GLfloat white[3] = { 1.0, 1.0, 1.0 };
    int i, j;
    char teststring[33];
    wchar_t wc;
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3fv(white);
    for (i = 32; i < 127; i += 32) {
    glRasterPos2i(20, 200 - 18*(GLint) i/32);
    for (j = 0; j < 32; j++)
    teststring[j] = (char) (i+j);
    teststring[32] = 0;
    printString1(teststring);
    }
    glRasterPos2i(20, 100);
    printString1("The quick brown fox jumps");
    glRasterPos2i(20, 82);
    printString1("over a lazy dog.");

    glRasterPos2i(20, 300);
    sscanf("0x0021","%x",&wc);
    printString2(&wc);

    => glRotatef(30.,0.,0.,1.);
    glRasterPos2i(200, 300);
    printString1("TEST");

    glFlush ();
    }
    ===========
    from drawf.c
    void myinit(void)
    {
    glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glNewList(100, GL_COMPILE);
    ==> glRotatef (10., 1., 1., 1.);
    glTranslatef (200, 0, 0);
    glRasterPos2i (120.5, 120.5);
    glBitmap (10, 12, 0.0, 0.0, 12.0, 10.0, rasters);
    ==> glRotatef(30.,0.,0.,1.);
    glBitmap (10, 12, 0.0, 0.0, 12.0, 10.0, rasters);
    ==> glRotatef(30.,1.,1.,1.);
    glBitmap (10, 12, 0.0, 0.0, 12.0, 10.0, rasters);
    glEndList();
    }

    Thanks for a reply

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: Text Rotation

    I dont really get what you mean. Do you want to change the order of rotation and translation? (ie. first translate then rotate or the other way round)
    - Michael Steinberg

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2000
    Posts
    10

    Re: Text Rotation

    I simplify more:

    Rotation does not take into effect.

    from drawf.c:

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
    glRotatef(30.,0.,0.,1.);
    glRasterPos2i (20.5, 20.5);
    glBitmap (10, 12, 0.0, 0.0, 12.0, 0.0, rasters);
    glBitmap (10, 12, 0.0, 0.0, 12.0, 0.0, rasters);
    glBitmap (10, 12, 0.0, 0.0, 12.0, 0.0, rasters);
    glFlush();
    }
    ------------------------------------------
    from xfont.c:

    void display(void)
    {
    GLfloat white[3] = { 1.0, 1.0, 1.0 };
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3fv(white);
    glRotatef(30.,0.,0.,1.);
    glRasterPos2i(20, 100);
    printString("TEST");
    glFlush ();
    }

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    France
    Posts
    13

    Re: Text Rotation

    Bitmap aren't affected by geometric transformation.
    (but only by rasterpos and glbitmap)
    Use textured font if you want to rotate.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: Text Rotation

    Hehe, now i got what he meant
    sure, bitmap fonts are quite restrictive and at least used to be very slow.
    - Michael Steinberg

Posting Permissions

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