Texture gets distorted when loading + SDL (solved)

Started by
-1 comments, last by Softnux 15 years, 9 months ago
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]

This topic is closed to new replies.

Advertisement