Skip to main content
gamedev.net
🔒 Locked

Texturing problem

Started by Luke Philpot Jan 4, 2007 at 9:28 AM 8 replies 2.5k views
Original Post
Luke Philpot
Luke Philpot
I have always used gluBuild2DMipmaps in my texture manager, but I needed to use glTexImage2D to test something out. Anyway, no matter what I do, glTexImage2D will not work. Mipmaps:
		gluBuild2DMipmaps( GL_TEXTURE_2D, 3, texture->image.GetWidth( ),
				texture->image.GetHeight( ), GL_RGB, 
				GL_UNSIGNED_BYTE, texture->image.GetPixels( ) );

glTexImage2D


			glTexImage2D( GL_TEXTURE_2D, 0, 3, texture->image.GetWidth( ), 
				texture->image.GetHeight( ), 0, GL_RGB, 
				GL_UNSIGNED_BYTE, texture->image.GetPixels() );


all I get with glTexImage2D is a blank white texture. I have tried all sorts of things but it just will not work! Any ideas?
Kalidor
Kalidor
Quote:
Original post by Luke Philpot
all I get with glTexImage2D is a blank white texture
Make sure you are using a non-mipmapping minification filter.
miminawewe
miminawewe
Luke: Are you using glTexParameter2D calls before the gluBuild2DMipmaps(...) and if you are then if you are setting glTexParameter2D(..., GL_MAG_FILTER, GL_MIPMAP_LINEAR) then remove this call. Let it be glTexParameter2D(GL_TEXTURE_2D, GL_MAG_FILTER, GL_LINEAR) and glTexParameter2D(GL_TEXTURE_2D, GL_MIN_FILTER, GL_LINEAR).
I also think you should avoid setting the '3' argument I'm seeing in the function calls and use the appropriate constants. If you don't know these constants then refer to the OpenGL redbook, or google.
Textures don't have to be square just make sure that the length is a power of 2 and so is the width. 64X32 is OK.
I think the maximum number of display lists is limited by memory available not OpenGL.
Anonymous: First of all any texture coordinate above 1 is assumed as 1 and below 0 is assumed as 0. Whether the texture stretches or not depends on how how you set
glTexParameter2D(GL_TEXTURE_2D, GL_CLAMP_S,...) and glTexParameter2D(GL_TEXTURE_2D, GL_CLAMP_T,...). If '...' is GL_REPEAT then in a coordinate above 1 causes the texture to repeat i.e. if you pass a texture coordinate of 2 for either coordinate then the texture is repeated twice. If the triangle is mapped by that texture is scaled down then so is the texture but it will still be repeated. This whole thing is not easy to explain without pictures. Google around you should find a good tutorial on your problem.
MARS_999
MARS_999
I am with Kalidor on this, check your min filter settings. GL_LINEAR or GL_NEAREST are only allowed with glTexImage2D
Luke Philpot
Luke Philpot
Oh god I feel so embarassed now...

My problem was that somewhere along the line my glTexParameteri call got changed to glTexEnvi! I don't know how that happened, and I don't know why the glu function worked with it and not the GL one.

Thanks, miminawewe, I think it was your post that triggered something in the back of my mind.

AP: Any combination of powers of two (up to your video cards limit, usually 2048 or 4096) will be fine, ie 128x256, 1024x512.

The maximum number of display lists varies from implementations, but I think it's normally something around 64 or 128? Don't quote me.

Once again, thanks for all the help guys! I'm going to go and hide in the corner and try and remove the redness from my cheeks ;)
Kalidor
Kalidor
Quote:
Original post by Luke Philpot
My problem was that somewhere along the line my glTexParameteri call got changed to glTexEnvi! I don't know how that happened, and I don't know why the glu function worked with it and not the GL one.
This is because the default minification filter is GL_NEAREST_MIPMAP_LINEAR and you weren't changing it so there was a mipmapping filter set. Also, calling any GL function with invalid parameters will produce an error and the function will be ignored, so you calling glTexEnvi trying to change the minification filter (I think that's what you meant) will simply produce an error and do nothing else. This is why you should be checking for OpenGL errors every frame and when one pops up you should fix it right away.
Quote:
Original post by Luke Philpot
The maximum number of display lists varies from implementations, but I think it's normally something around 64 or 128? Don't quote me.
Actually OpenGL doesn't specify a maximum number of display lists, not even that there is an implementation dependent maximum. So the maximum is theoretically limited only by what a GLuint can store, which is at least 232 (> 4 billion). The maximum for "useful" display lists (display lists that are stored in video ram),however, is dependent on the amount of video ram your card has and your video drivers.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.