Problem with text

Hi, I try to use Nehe’s code (lesson 13 of his tut.). But the text follow my object when he move. Here is my code:

glLoadIdentity();
glTranslatef(0.0f,0.0f,profondeur);
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);
drawMyObject();

glColor3f(1.0f,1.0f,1.0f);
glRasterPos2f(-0.2,-0.2);
glPrint(“Fps=%f3.2”,fps);

Where does the probleme come from ??

I’ve try to use glPushMatrix and glPopMatrix without succes but I still don’t understand what they exactly did.

Thanks for your answers…

glRasterPos is transformed like a standard vertex. You must set a different transformation than the object’s one before the glRasterPos call to keep its position static.

Here is a quick fix:

glLoadIdentity();
glTranslatef(0.0f,0.0f,profondeur);
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);
drawMyObject();

glColor3f(1.0f,1.0f,1.0f);
glLoadIdentity(); // added this
glRasterPos2f(-0.2,-0.2);
glPrint(“Fps=%f3.2”,fps);

This is a quick fix and you are right, you should look into pushing and poping as these will achieve a similar effect and will come in useful later. Imagine a pile of trays in a cabinet or what ever, each tray stores all information about rotations and movement etc., when you load an identity matrix you add to the top of this pile a blank tray, when you push the matrix you push the matrix that is on top you push the top tray down one level in the cabinet and make a blank new identity on top which you might further rotate or whatever, to get back to the origional state you pop the top tray off the top of the pile this leaves the tray that was below with the origional rotations and movement on top. Get it, this sounds like a good topic for me to make a tutorial on for my website. Tell me if this doesn’t make any sense or my code doesn’t work.

it doesn’t seem to work !

Where is your web site, cause I look for each useful tut. ?