PDA

View Full Version : Remove that flickering....



nix
05-16-2001, 04:26 AM
Hi,

2 questions:
--------------------------------------------
1. When I try to use the TextOut function to show some text in my OpenGL window it just flickers. How do I get rid of that?
--------------------------------------------
2. I use the font which is on the Nehe site. When I rotate it (after getting in to 2D mode) it will not rotate around the z axis on a circular course, it rotate around it in a egg shaped circle.

The code:
//**//
/// ENTER 2D MODE
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-100,100,-140,140,1,-1); /*******/

glPushMatrix();
glLoadIdentity();
glRotatef(m_GlobVar.m_zRotate[m_GlobVar.m_FlygplanNr],0,0,1);
glTranslatef(0.0f, -0.7 , 0.0f);
glScalef(0.14f,0.14f,0); // size of the glPrint("HELLO"); // TEXT OUT
glPopMatrix();
/// EXIT 2D MODE
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
//**//

I have tried to make changes to the /*******/ line but it will make no difference. My window size are 200*280.

PLEASE HELP ME !!!

If some of you have a better text function which can rotate around the z axis, please mail it to me.

/Nix

pATChes11
05-18-2001, 05:54 PM
uhh... it'd help if you drew the text to the back buffer for one thing.. and it'd help even mroe so if you also posted the code that actually draws the text :P

Sheepie
05-18-2001, 07:18 PM
Ok, for one thing, I don't know what you do within the /*****/ section but you have a glPushMatrix();
glLoadIdentity();

immediately following it. This would affect the Projection Matrix which was selected prior and not the Modelview matrix which is most likely what you want. Just a guess as I have no idea what is within the /******/

why not post the rest of the code so we can better help? http://www.opengl.org/discussion_boards/ubb/smile.gif

MButchers
05-19-2001, 12:53 AM
Hello there,

try switching the matrix mode back
to the model view matrix before outputing
your text

heres the code I use anyway :-

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, FWidth, FHeight, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);

glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);

glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_SCISSOR_TEST);
(* Render 2d controls here *)
(* End Controls Render *)

BindTexture(GL_TEXTURE_2D,0);

glPopAttrib();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

Hope it helps.