glEnable(GL_TEXTURE_2D) and glDisable

Started by
5 comments, last by Hedos 19 years, 11 months ago
Are the functions glEnable(GL_TEXTURE_2D) and glDisable(GL_TEXTURE_2D) fast? I''m using them a lot when I have to switch from textured polygons to colored polygons and text and I''m wondering if it might have a signifiant impact on speed or not?
Advertisement
they do a state set so while they wont be mentaly fast unless you are being dumb about thinks (drawing a textured quand, turning it off, drawing a polygon, turning it back on, and repeat) I very much doubt it would be a bottle neck.

If you ARE doing it like that then you''ll want to batch things (infact, do so anyways), so you draw all your textured stuff, then your untextured stuff
In my engine, I turn texture on/off quite a few times (once for the particles, then a few times for menus, borders, etc. Thse speed penalty is neglectable.
In their bare form they should not pose a performance hit because all it''s doing is redirecting some pointers in memory to point to an alternative texture - which is also in memory (slightly oversimplified, but essentially it''s what''s going on). Now loading textures or performing other texture transformations each frame will be a significant hit. If you are seeing any hits, then as _the_phantom_ says, you might need to reorg your code or rethink your strategy. Hope that helps!
Ok, thanks

And I don''t think I''m really overusing it anyway,
I was told that glBindTexture(GL_TEXTURE_2D, 0); was faster than disabling and re-enabling texturing if you are doing it often.. is the not the case?
Hmm, glBindTexture(GL_TEXTURE_2D, 0) is probably faster than disabling the texture, however it''s still doing the texture calculations which (depending on how many polys you''re drawing) would slow it down.

That''s just my guess.
Jeff Bland (Reverse_Gecko)reversegecko@gmail.com

This topic is closed to new replies.

Advertisement