PDA

View Full Version : Text Rotation



spearlss
04-09-2002, 10:23 PM
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

Michael Steinberg
04-09-2002, 10:52 PM
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)

spearlss
04-10-2002, 03:51 AM
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 ();
}

Kuranes
04-10-2002, 10:06 PM
Bitmap aren't affected by geometric transformation.
(but only by rasterpos and glbitmap)
Use textured font if you want to rotate.

Michael Steinberg
04-10-2002, 10:23 PM
Hehe, now i got what he meant http://www.opengl.org/discussion_boards/ubb/smile.gif
sure, bitmap fonts are quite restrictive and at least used to be very slow.