commit e9877da533f6161b1d7f679fc70012ceb329431a
parent 0e92c3ed7f60299d1798a39b90a2108e18992a5a
Author: Brian Swetland <swetland@frotz.net>
Date: Sun, 1 Sep 2013 02:24:38 -0700
buffers: use texture unit 15 for load operations
Avoids stepping on active rendering textures and makes it obvious
when you forget to bind the right unit.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/common/buffers.cc b/common/buffers.cc
@@ -105,6 +105,12 @@ int Texture2D::load(const char *fn, int options) {
int Texture2D::load(void *data, unsigned w, unsigned h, int options) {
if (id == 0)
glGenTextures(1, &id);
+
+ /* GL 3.x guarantees at least 16 texture units. We'll use */
+ /* unit 15 for load operations to avoid stepping on other */
+ /* state that might be important. */
+ glActiveTexture(GL_TEXTURE0 + 15);
+
glBindTexture(GL_TEXTURE_2D, id);
if (options & OPT_TEX2D_GRAY)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,