Jump to content
  • Advertisement
Sign in to follow this  

Texture mapping problems.

This topic is 2980 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 am a beginner when it comes to OpenGL. I've been following NeHe's tutorials and I am currently on the texture mapping lesson. Whenever I run the program, my program window freezes up. However I can run other OpenGL programs that don't involve texture mapping just fine. Any suggestions? (I am using Dev C++)

Share this post

Link to post
Share on other sites
Here is a link to the tutorial page:


Would it possibly have something to do with out of date libraries?

Share this post

Link to post
Share on other sites
What happens when you click the pause button? Where does the program end up?

(Tip: If you end up with just a page of assembly find the call stack drop down list box and find the first function name which you recognize)

Share this post

Link to post
Share on other sites
Did you download the project? Or copy/paste from that page?

If the latter, are you sure you included the line
memset(TextureImage,0,sizeof(void *)*1);

Share this post

Link to post
Share on other sites
Unfortunately, it runs correctly on mine, including if I remove the bitmap. (It correctly exists with a message)

Therefore you could be right about the libs. I would suggest trying the following:

1. Do a clean build (build -> Clean solution)
2. Restart computer
3. Download a new version glaux libraries.

Share this post

Link to post
Share on other sites
I found another file on the website that involves replacing the glAux code with code that doesn't depend on the glAux libary.

This is not a full blown bitmap loader. It is a quick and easy
way to replace the glAux dependant code in my older tutorials
with code that does not depend on the glAux library!

This code only loads Truecolor Bitmap Images. It will not load
8-bit bitmaps. If you encounter a bitmap that will not load
use a program such as Irfanview to convert the bitmap to 24 bits.

bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) // Creates Texture From A Bitmap File
HBITMAP hBMP; // Handle Of The Bitmap
BITMAP BMP; // Bitmap Structure

glGenTextures(1, &texid); // Create The Texture

if (!hBMP) // Does The Bitmap Exist?
return FALSE; // If Not Return False

GetObject(hBMP, sizeof(BMP), &BMP); // Get The Object
// hBMP: Handle To Graphics Object
// sizeof(BMP): Size Of Buffer For Object Information
// &BMP: Buffer For Object Information

glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // Pixel Storage Mode (Word Alignment / 4 Bytes)

// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);

DeleteObject(hBMP); // Delete The Object

return TRUE; // Loading Was Successful

BOOL Initialize (GL_Window* window, Keys* keys) // Any GL Init Code & User Initialiazation Goes Here
g_window = window;
g_keys = keys;

// Start Of User Initialization
if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0])) // Load The Bitmap
return FALSE; // Return False If Loading Failed

How would I incorporate this into the original file?

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!