![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
(#1)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
glBindTexture ID cache/shadow -
2010.01.21, 01:15 AM
Hi all,
On another (locked) thread I read about caching of currently bound texture for less interfacing with the gpu. There was a snippet like this: Code:
void BindTexture(GLuint id){
static GLuint currentId=0;
if(currentId!=id) glBindTexture(GL_TEXTURE_2D,currentId=id);
}
Regards, Alex |
|
|
|
|
(#3)
|
|
|
Member
Posts: 392
Join Date: 2002.09
Location: Toronto
|
2010.01.25, 04:59 AM
It should work - the paranoid programmer in me wouldn't use an assignment in a function call though.
The blank texture could be something failing to load on the device for some reason (missing resource, wrong path, case sensitivity errors, etc.) or you might be loading non-power-of-2 textures, or not properly mipmaping, or some other GL state is getting messed up... Also, if you're using multitexture keep in mind that you need to track the current texture for each unit. Some of these situations should fail on the simulator too, but in general it's normal to run into differences between the simulator vs. the device, so debug on the device as often as possible. |
|
|
|
|
(#4)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2010.01.25, 07:08 AM
Hi Frank,
Thanks for the suggestion. I don't really know whether I use multitexturing or not.. what I definitely do is using the FBO extension and switching Framebuffers to generate textures.. As the problem (blank texture) occurs only on generated textures I think the problem is in the context.. Somewhere on the docs there was a note that glBindTexture affects only the current context.. so if you change the context you probably want to drop the current cache, right? So I'm going to try that now :-) Alex |
|
|
|
|
(#5)
|
|
|
Moderator
Posts: 417
Join Date: 2002.04
Location: Newcastle, UK
|
2010.01.25, 07:41 AM
Are you called glBindTexture anywhere else in your render path? If you are then it will end up out of sync with your currentId value which will not indicate it needs to be changed to the new texture the next time you call your BindTexture function.
Also check that you're not disabling TEXTURE2D anywhere in that render path. |
|
|
|
|
(#6)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2010.01.25, 07:48 AM
Hi,
Well, I checked like 10 times for the first suggestion.. i changed every line of glBindTexture to my custom shadowing version.. that's for sure. But now when I look through my code I see that I disable/re-enable GL_TEXTURE_2D in my transition code (fading between screens etc.). This definitely may be the problem! Will try to fix this now and let you know. Thanks! Alex |
|
|
|
|
(#7)
|
|
|
Member
Posts: 80
Join Date: 2008.11
Location: St.Petersburg, Russia
|
2010.01.25, 08:14 AM
Ok, so Zwilnik was right. Just added a BindTexture(0) to drop cache in the transition code and it works fine now.
However, in one and only one toggler in the game it still reproduces. Kinda stumped. Thanks Zwilnik! Alex |
|
|
|
|
(#8)
|
|
|
Member
Posts: 147
Join Date: 2009.04
Location: USA
|
2010.01.25, 07:42 AM
You shouldn't really need to change your current context when using FBOs ...
|
|
|
|
| Thread Tools | |
| Display Modes | |
|
|