PDA

View Full Version : default texture options



dvm
10-08-2004, 03:26 AM
Hi to everyone, today I stumbled upon a strange problem which I finally solved and I thought I'd get some opinions. I was trying to load a texture to an object. The texture was not showing up until I called:

g_EarthTexture = LoadTextureFile("textures/ev11612_land_ocean_ice_2048.bmp");
glBindTexture(GL_TEXTURE_2D, g_EarthTexture->texID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // line added
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // line added
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, g_EarthTexture->width,
g_EarthTexture->height, 0, GL_RGB, GL_UNSIGNED_BYTE,
g_EarthTexture->data);My question is, doesn't OpenGL provide default parameters for the textures? You have to define each one yourself? If yes, which ones are necessary? My programming environment is VC++ .NET 2003 + GLUT on Win2K. Thanks in advance ;)

MattS
10-08-2004, 04:45 AM
Yes it does have defaults:

For MAG_FILTER it is GL_LINEAR
For MIN_FILTER it is GL_NEAREST_MIPMAP_LINEAR

This does not appear to be documented in MSDN but then there is a large list of errors/omissions in MSDNs documentation of OpenGL.

The reason you had to add the line is because by default GL expects mipmaps to be available and you haven't supplied any. Therefore either provide mipmaps and remove the lines or don't provide mipmaps but you only _need_ to alter the MIN_FILTER to either GL_LINEAR or GL_NEAREST.

Matt

arekkusu
10-08-2004, 10:57 AM
The filtering defaults are documented in both the glTexParameter manpage and section 3.8.11 of the spec. Note that extensions (such as GL_TEXTURE_RECTANGLE_[NV|EXT|ARB]) may use different defaults.