Sign in to follow this  
Softnux

Texture gets distorted when loading + SDL (solved)

Recommended Posts

My textures end up like this: when trying to make them from a SDL surface using the following code:

	GLuint ttexture;

	
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
	glGenTextures(1, &ttexture);
	glBindTexture(GL_TEXTURE_2D, ttexture);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	SDL_PixelFormat *fmt = Surface->format;

	// If there is alpha
	if(fmt->Amask)
	{
		gluBuild2DMipmaps(GL_TEXTURE_2D, 4, Surface->w, Surface->h, GL_BGRA, GL_UNSIGNED_BYTE, Surface->pixels);
	}
	else
	{
		gluBuild2DMipmaps(GL_TEXTURE_2D, 4, Surface->w, Surface->h, GL_BGR, GL_UNSIGNED_BYTE, Surface->pixels);
	}



Tried a bunch of code from all over the forum already, everyone gives a different distortion. Any suggestions? Edit: Solved. The problem wasn't there. Had my drawingcode drawing it tiled 50x50 :P [Edited by - Softnux on July 5, 2008 12:41:05 PM]

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