Text writing and ortho

I tried to display texture mapped fonts. I read at the NeHe site, that I shouldn’t use Ortho, because it is ugly. In my case, I have to use it. And it’s faster to set the screen coordinates.
I used the code below:

glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glDisable(GL_LIGHTING);
/***** gluOrtho2D(0,800, 600,0);*******/
/***** glRasterPos2i(50,50); **********/
glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(6, GL_UNSIGNED_BYTE, “Hello.”);
glPopAttrib();

glPopMatrix();
SwapBuffers(DCvalue);

This code works perfectly, but if I enable the glOrtho and the rasterpos lines, I don’t get anything written on the screen.
What is wrong here??? Pls help

You put it into the wrong matrix. Try this:

glMatrixMode(GL_MODELVIEW);
glPushMatrix(); // GL_MODELVIEW
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix(); // GL_PROJECTION
glLoadIdentity();
gluOrtho2D(0.0, 800.0, 600.0, 0.0);
glPushAttrib(GL_LIST_BIT | GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glListBase(base);
glColor3f(1.0, 1.0, 1.0); // Your font color when using bitmaps.
glRasterPos2i(50, 50);
glCallLists(6, GL_UNSIGNED_BYTE, "Hello.");
glPopAttrib(); // list base and lighting state restored
glPopMatrix(); // GL_PROJECTION
glMatrixMode(GL_MODELVIEW);
glPopMatrix(); // GL_MODELVIEW
SwapBuffers(DCvalue);

The code above should work nicely with wglUseFontBitmaps. With a do-it-yourself texture font, what did you compile into the display lists which works with glRasterPos? (Means, it’s not useful for a font texture.)
If you use textured quads per letter, switch the GL_MODELVIEW to be inside in my code, so that possible glTranslate calls you have per letter affect that right matrix.
If this doesn’t help, set your glClearColor to a weird color.
Check your font texture environment (e.g. GL_REPLACE instead of GL_MODULATE).

Strange. I don’t see anything…
Maybe the error is in the previous lines? I pasted your code directly into mine, overwriting everything.
Here’s what comes before your code:

HFONT fontol = CreateFont(40, 8, 0, 0,
FW_DONTCARE, 0, 0, 0,
ANSI_CHARSET,
OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FF_DONTCARE|DEFAULT_PITCH,
“Arial”);
SelectObject(DCvalue, fontol);

BOOL font = wglUseFontOutlines(DCvalue, 0, 255, base, 0.1f, 0.2f,
WGL_FONT_POLYGONS, agmf);

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

load_image(“d:\10_1.bmp”);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, backgr);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
Object
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

glListBase(base);

Still nothing… I don’t understand. Your code must be correct.

Does it work without the texture?
Wait, you said that code worked before, so what was your matrix setup then?
Maybe it’s so tiny that there is only a single point.
With wglUseFontOutlines you should probably move the modelview inside like this, as I don’t know how the display lists advance the position depending on the glyph widths:

 
glMatrixMode(GL_PROJECTION);
glPushMatrix(); // GL_PROJECTION
glLoadIdentity();
gluOrtho2D(0.0, 800.0, 0.0, 600.0); // Let's order it the OpenGL way for debugging.

glMatrixMode(GL_MODELVIEW);
glPushMatrix();// GL_MODELVIEW
glLoadIdentity();

glPushAttrib(GL_LIST_BIT | GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glListBase(base);
glColor3f(1.0, 1.0, 1.0); // Your font color when using bitmaps.
glRasterPos2i(50, 50);
glCallLists(6, GL_UNSIGNED_BYTE, "Hello.");
glPopAttrib(); // list base and lighting state restored

glMatrixMode(GL_PROJECTION);
glPopMatrix(); // GL_PROJECTION

glMatrixMode(GL_MODELVIEW);
glPopMatrix(); // GL_MODELVIEW

SwapBuffers(DCvalue);

If this gets you a tiny point in the bottom left corner, try gluOrtho2D(0.0, 8.0, 0.0, 6.0);
Bigger now?

The whole code works OK when I remove the glOrtho line. The letters appear at position 0,0. This is normal.
If I leave Ortho, I see a black screen.

The bitmap i use is a 512x512 bmp. It is loaded correctly, as the result is fine (without Ortho).

I think i will use another way to display the text: 0,0 is the center of the screen(400,300). -1,-1 will be 0,0, etc. Maybe. A bit lame thing when you can have ortho…

Thank you for the help. If you want, you can continue trying, but I don’t want to ask more of your time.
This thing remains a mistery to me. I used Ortho many times and it only failed once: with fonts…

Got it. I missed your last line. :smiley:
But now, I got the text in the botton left corner.

Thank you for the help.