Jump to content
  • Advertisement
Sign in to follow this  
toddhd

OpenGL Sanity Check - OpenGL texture question

This topic is 5407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!