Sanity Check - OpenGL texture question

Started by
5 comments, last by toddhd 19 years, 6 months ago
I'm building a small "engine" (and I use the term very loosely) to build games on. I started by making a class called CEngine that handles creating the OpenGL screens. Works great. Next I created a class called CEngineFont, which is basically Nehe's Lesson 17 (Textured Fonts) just put into a class. When the class is created, it calls the LoadTexture() and BuildFont() functions, and then you just call the glPrint() function from your main app to print.

CEngineFont font;
font.glPrint(10,10,"Hello World",0);
The problem is, nothing show up. I tracked the progress using the debugger - the textures seem to be loading ok, the fonts are being built - everything looks kosher. Just to test, I built a test function in CEngineFont that simply displays a textured quad. The quad shows up, but just as a white square. The texure is missing. *** The textures are known good *** - they are the same ones from NeHe's tutorial in fact. So no "power of 2" problems or any of that stuff. So here is the question - is there some reason that a texture loaded in a class won't show up properly? I'll be happy to post any code you need...
-Todd"Windows dectected that your mouse has moved. Please reboot for the changes to take effect"
Advertisement
it doesnt matter where its loaded.

have u called glEnable(GL_TEXTURE_2D); ?
PsYvIsIoN
Quote:Original post by PsyVision
have u called glEnable(GL_TEXTURE_2D); ?


Yes, I did
-Todd"Windows dectected that your mouse has moved. Please reboot for the changes to take effect"
Beware: Load textures only AFTER the window is created. I know this puzzled me some time ago when I didn't. The texture ID generated was 0 (as in ZERO) which is faulty.

Also be on the lookout for the set-up of the ortho mode and the 2D raster. Use the exact manner NeHe does it. Also note that it is possible you are rendering your fonts outside the 2D raster. Check the values you are giving to glOrtho.

I assume you managed to copy/paste NeHe's code correctly, so I don't think anything goes wrong in the actual generation (except for generating before the window is created).
STOP THE PLANET!! I WANT TO GET OFF!!
Have you been able to draw textures on that computer before? I remember that the computers at my high school, for some reason, only drew textures as white.
I am the master of ideas.....If only I could write them down...
Have you explicitly set the mag/min filters?The min filter is by default GL_NEAREST_MIPMAP_LINEAR, and if you don't use mipmaps, the texture will not show.
Original post by Structural
Beware: Load textures only AFTER the window is created.


Yup, that was it. Since I put the LoadTexture and BuildFont functions into the Class Constructor, they were being called when before the windows was even created.

Now I'm having some other kind of memory issue, some I'm still not seeing the images, but at least I know I'm on the right track. Thanks!
-Todd"Windows dectected that your mouse has moved. Please reboot for the changes to take effect"

This topic is closed to new replies.

Advertisement