View Full Version : Changing wrap mode on the fly

08-18-2010, 07:20 AM
I need to change the wrap mode from GL_CLAMP to GL_REPEAT depending on my shader texture modes:

glBindTexture(GL_TEXTURE_2D, shader.tex[i].glTex;
if (shader.tex[i].clamped) {
} else {

I have two questions:
1) will this work (can you modify the wrap mode after creation?
2) What is the performance hit expected?

I can (and will) try it, but any guidance would be helpful!

08-18-2010, 08:46 AM
Yes there is no reason why you can not change the wrap mode of any currently bound texture with

glTexParameteri (....)

I rebind quite a few texture parameters for every texture I bind so that my sandbox editor can change texture properties dynamically and I can see the effect immediately.

No real noticable performance hit, if at all.

08-18-2010, 11:26 AM
Thanks, that helps a lot!

Ketracel White
08-18-2010, 01:51 PM
No real noticable performance hit, if at all.

I can tell you that this is not true. Tested on a Geforce 8600 it's definitely faster if you have 2 textures with different clamping modes than changing the mode repeatedly.

Of course you'll only see the hit if your program really stresses the graphics hardware.

08-18-2010, 02:07 PM
Thanks! I was wondering. The quake3 source does just as you say (two separate textures with different clamp params). Was trying to figure out if I should do the same. Sound like I probably should.