I'm using the Slick2D library in order to render text to the screen but in order to render gl shapes like Rect, I need to first disable GL_TEXTURE_2D. I'm just curious as to why that is needed. Why does GL_TEXTURE_2D disable the rendering of shapes?
2 Answers
The way OpenGL works is basically one large, global state machine. When you bind a texture, every triangle you draw afterwards will use that texture.
The issue here is that the text drawing doesn't unbind it's texture afterwards, so the shapes you draw afterwards will be using that texture instead of no texture. The reason why you think it's "disabling" rendering is because the texture is made up of characters with everything else being transparent. What you're seeing is OpenGL drawing your shape with opacity at 0.
What happens when you disable GL_TEXTURE_2D
is that the texture gets unbound and you draw regularly without a texture.

- 14,512
- 6
- 44
- 59
-
2That made a lot of sense. So I'm guessing it's not uncommon to have a lot of glEnable and glDisable calls for rendering different things. Thanks a bunch – Adam Keenan Dec 17 '12 at 19:12
Because the string's texture is applied. As you probably don't set any texture coords it probably uses a section of the texture that is transparent and hence you see nothing.

- 61,365
- 24
- 124
- 204
-
So the string's texture covers the whole screen, covering the shape? – Adam Keenan Dec 17 '12 at 19:03
-
@adamk33n3r nope a transparent part of the strings texture covers your shape and hence nothing gets drawn ... – Goz Dec 17 '12 at 19:04
-
Ig that makes sense. It just seems that if it's transparent then the shape would show through. Thanks Goz – Adam Keenan Dec 17 '12 at 19:09
-
-
Ohhh. Im sorry. I interpreted your comment as the transparent part of the string that I drew was covering my shape. Not that my shape was transparent. I get it now. The other answer explained it better for me. – Adam Keenan Dec 17 '12 at 19:14