🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Textures and Bitmap Fonts Conflicting?

Started by
1 comment, last by Voien21 17 years, 1 month ago
I am a C++ beginner using NeHe's code from Tutorial 6 for Textures and Tutorial 13 for bitmap fonts. I am using the "Glaux replacement" code that does not use glaux for texture mapping. Whenever I use them together, the text does not show up bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) { HBITMAP hBMP; BITMAP BMP; glGenTextures(1, &texid); hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ); if (!hBMP) return FALSE; GetObject(hBMP, sizeof(BMP), &BMP); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glBindTexture(GL_TEXTURE_2D, texid); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);//This line is trouble DeleteObject(hBMP); return TRUE; } By experimenting with commenting certain lines, I determined that whenever gluBuild2DMipmaps() or glTexImage2D() is called (needed for textures), my bitmap text would not show up at all. Is there something in the gluBuil2DMipmaps that conflicts with NeHe's code to use bitmap fonts? I would like to use bitmap fonts because they are simple, and I already know how. What can I do to save my project? Thanks for any help.
Advertisement
You are showing only half of the code; without seeing the other part, one can suspect embarrassing errors like reusing and overwriting the same OpenGL texture for the bitmap and the fonts.

Omae Wa Mou Shindeiru

Sorry! In looking back at my code and the Redbook, I realize that my glEnable(GL_TEXTURE_2D) was in my initialization function (I think that is how it appears in NeHe's tutorial). By enabling textures only when drawing textured objects and then disabling them, everything went smoothly. Thanks.

[Edited by - Voien21 on May 29, 2007 3:24:24 PM]

This topic is closed to new replies.

Advertisement