Skip to main content
GameDev.net gamedev.net
🔒 Locked

texture filtering problems

Started by Raloth Aug 30, 2003 at 11:12 PM 5 replies 350+ views
Original Post
Raloth
Raloth
My texture filter parameters don't seem to be having an effect. I copied and pasted my code from another demo program I made into this one so I could expand on it and now it seems to be broken... I have an alphamap (nevermind it's purpose) and I want the values to be interpolated as it is stretched. Each alpha value is either 255 or 0 and the rgb values are all 0. Unfortunately they are sort of blended, but then it just cuts off and goes to 0 for no reason I can find. Here's how I generate the texture:
glActiveTextureARB(GL_TEXTURE1_ARB);
glGenTextures(1,&texture);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glBindTexture(GL_TEXTURE_2D,texture);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D,4,LANDSCAPE_SIZE,LANDSCAPE_SIZE,GL_ALPHA,GL_UNSIGNED_BYTE,alphamap);  
It is stored in the second texture unit for multitexturing purposes. LANDSCAPE_SIZE is a constant set to 128 and alphamap is a pointer to GLubytes that contain the alpha values I want. I can't find anything wrong with this, and it's even more confusing since it works in the demo program just fine. [edited by - Raloth on August 30, 2003 12:13:37 AM]
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Anthony Serrano
Anthony Serrano
Well, I''m not exactly sure what the problem is without seeing screenshots, but I did notice a few errors.

1. GL_LINEAR_MIPMAP_LINEAR is an invalid value for GL_TEXTURE_MAG_FILTER; the only acceptable values are GL_LINEAR and GL_NEAREST.

2. gluBuild2DMipmaps needs to be called BEFORE you set a mipmapped filter; otherwise OpenGL will disable this texture unit.
Brother Bob
Brother Bob
quote:
Original post by Anthony Serrano
2. gluBuild2DMipmaps needs to be called BEFORE you set a mipmapped filter; otherwise OpenGL will disable this texture unit.

This is not correct. When the texture name is bound for the first time the texture is created and you can set it''s filter parameters. The order of operations in OpenGL usually don''t matter, so you can set filter parameters before loading the texture data.
Raloth
Raloth
Sorry for the question . I messed something up in my alphamap generation during the transfer...the filters were working fine...

Is there a way to do trilinear filtering though, like an extension or something?
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
EasyRaider
EasyRaider
quote:
Original post by Raloth
Is there a way to do trilinear filtering though, like an extension or something?


What do you mean? GL_LINEAR_MIPMAP_LINEAR specifies trilinear filtering. However, there is no need for this when the texture is magnified.
-------------------Our only true limitis our imaginationAim for the horizonbut watch your step
Raloth
Raloth
Oh...I never knew that . I thought it meant linearly blend between the two mipmaps...and then linear blend between the pixels you get...but I guess that is trilinear.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Anthony Serrano
Anthony Serrano
quote:
Original post by Brother Bob
This is not correct. When the texture name is bound for the first time the texture is created and you can set it''s filter parameters. The order of operations in OpenGL usually don''t matter, so you can set filter parameters before loading the texture data.



My bad. I forgot that OpenGL checks for texture completeness at rasteriation, and not at the time the filter is set.

Topic Locked

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

Sign in to reply to this topic.