Sign in to follow this  

Problem loading bitmaps (Lesson #7)

Recommended Posts

Hello! Having shamelessly stolen the code for mipmapping from Lesson #7, i seem to have a problem loading certain bitmaps. Most of the bitmaps i can load, but some seem to give me "acces violation". Here is the code i am using:
[source langg = "cpp"]
AUX_RGBImageRec *LoadBMP(char *Filename)					// Loads A Bitmap Image
	if (!Filename)								// Make Sure A Filename Was Given
		return NULL;							// If Not Return NULL
	if (File)								// Does The File Exist?
		fclose(File);							// Close The Handle
		return auxDIBImageLoad(Filename);				// Load The Bitmap And Return A Pointer
		return NULL;								// If Load Failed Return NULL
int LoadGLTextures()
 int status = FALSE;
 AUX_RGBImageRec* TextureImage[1];
 memset(TextureImage,0,sizeof(void *)*1);
 if(TextureImage[0] = LoadBMP("Images/OneBit5.bmp"))
  status = TRUE;
  glBindTexture(GL_TEXTURE_2D, texture[0]);

		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
 	if (TextureImage[0])									// If Texture Exists
		if (TextureImage[0]->data)							// If Texture Image Exists
			free(TextureImage[0]->data);					// Free The Texture Image Memory

		free(TextureImage[0]);								// Free The Image Structure
	return status;

Not sure it is important, but this is how i draw:
[source langg = "cpp"]
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
	glBindTexture(GL_TEXTURE_2D, texture[0]);
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.5f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.5f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.5f,  1.5f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.5f,  1.5f,  1.0f);	
	return TRUE;										

Thanks in advance!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this