commit 43369cceed992f722cccbf4a47eed54f65ec6151
parent a7d20d40f0862f7b2440904683864b40e2607c1e
Author: Brian Swetland <swetland@frotz.net>
Date: Thu, 12 Sep 2013 21:22:33 -0700
texture2d: provide createRGBA() to create an empty texture
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/common/buffers.cc b/common/buffers.cc
@@ -136,3 +136,16 @@ int Texture2D::load(void *data, unsigned w, unsigned h, int options) {
return 0;
}
+int Texture2D::createRGBA(unsigned w, unsigned h) {
+ if (id)
+ glDeleteTextures(1, &id);
+ glGenTextures(1, &id);
+ glActiveTexture(GL_TEXTURE0 + 15);
+ glBindTexture(GL_TEXTURE_2D, id);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ width = w;
+ height = h;
+ return 0;
+}
diff --git a/common/core.h b/common/core.h
@@ -97,6 +97,7 @@ struct Texture2D {
~Texture2D() { if (id) { glDeleteTextures(1, &id); } };
int load(const char *fn, int options);
int load(void *data, unsigned w, unsigned h, int options);
+ int createRGBA(unsigned w, unsigned h);
void use(unsigned index) {
glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(GL_TEXTURE_2D, id);