]> git.sesse.net Git - nageru/blobdiff - nageru/ref_counted_texture.h
Make the ImageInput cache store textures, not images.
[nageru] / nageru / ref_counted_texture.h
diff --git a/nageru/ref_counted_texture.h b/nageru/ref_counted_texture.h
new file mode 100644 (file)
index 0000000..1a94476
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _UNIQUE_TEXTURE_H
+#define _UNIQUE_TEXTURE_H 1
+
+// A wrapper around an OpenGL texture that is automatically deleted.
+// Used only by ImageInput.
+
+#include <epoxy/gl.h>
+#include <memory>
+
+struct TextureDeleter {
+       void operator() (GLuint *tex)
+       {
+               glDeleteTextures(1, tex);
+               delete tex;
+       }
+};
+
+typedef std::unique_ptr<GLuint, TextureDeleter> RefCountedTexture;
+
+#endif  // !defined(_REF_COUNTED_TEXTURE)