Blurry textures

Started by
2 comments, last by leggyguy 17 years, 8 months ago
Hi, I wonder if anyone can help. I have created a texture in photoshop which I am going to use as a background. For now, I have gone into Ortho mode and drawn the texture to cover the entire screen. The sizing is perfect, but when I compare the two images (the image in photoshop and the image within the program I created) I notice the image in the game is not as crisp. Here is the difference: http://imagesocket.com/view/compare7e6.png As you can see the rightmsot is blurry, and not like the image I had in photoshop. Here is the code I am using to load the image, is there anything wrong with it? Or do I need to do something else to make my texture as crisp as it is in photoshop? This is a 2d application, and I need the image within it to be as good in quality as it is in photoshop. Speed isn't too important.
	
AUX_RGBImageRec *pBitmap = NULL;
	
	//if(!strFileName)									// Return from the function if no file name was passed in
	//	return;

	pBitmap = auxDIBImageLoad(strFileName.c_str() );				// Load the bitmap and store the data
	
	if(pBitmap == NULL)									// If we can't load the file, quit!
		exit(0);

	// Generate a texture with the associative texture ID stored in the array
	glGenTextures(1, &textureArray[textureID]);

	// This sets the alignment requirements for the start of each pixel row in memory.
	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

	// Bind the texture to the texture arrays index and init the texture
	glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);

	// Build Mipmaps (builds different versions of the picture for distances - looks better)
	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);

	// Lastly, we need to tell OpenGL the quality of our texture map.  GL_LINEAR_MIPMAP_LINEAR
	// is the smoothest.  GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR, 
	// but looks blochy and pixilated.  Good for slower computers though.  
		
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
Advertisement
Use GL_LINEAR_MIPMAP_NEAREST or GL_NEAREST_MIPMAP_NEAREST filter for sharp textures. If you need extremely sharp textures don't use mipmaps, but this will be a HUGE perfromance drop, or bias texture LOD.
if (time() == $) { $ = 0; }
gluBuild2dMipmaps will resize your source image if it's not power-of-two in size (ie. 32x64, 256x512, 128x128, etc.). The resize is very simple (read: dumb) and is likely the cause of your blurryness.

Either make sure your source image is the correct size or use a non-POT extension (google it) so you can use any sized texture. The extension route is likely to be less widely supported though, and often somewhat slower.
Thanks, the texture size is the same size as the application window, 1024x768.

I shall have to recreate my textures, but this has fixed the problem save for a rearrange being in order.

This topic is closed to new replies.

Advertisement