]> git.sesse.net Git - nageru/blob - shared/ref_counted_texture.h
Change Futatabi frames to be cached as textures instead of in system memory.
[nageru] / shared / ref_counted_texture.h
1 #ifndef _REF_COUNTED_TEXTURE_H
2 #define _REF_COUNTED_TEXTURE_H 1
3
4 // A wrapper around an OpenGL texture that is automatically deleted.
5
6 #include <epoxy/gl.h>
7 #include <memory>
8
9 struct TextureDeleter {
10         void operator() (GLuint *tex)
11         {
12                 glDeleteTextures(1, tex);
13                 delete tex;
14         }
15 };
16
17 typedef std::unique_ptr<GLuint, TextureDeleter> UniqueTexture;
18 typedef std::shared_ptr<GLuint> RefCountedTexture;
19
20 // TODO: consider mipmaps.
21 RefCountedTexture create_texture_2d(GLuint width, GLuint height, GLenum internal_format, GLenum format, GLenum type, const GLvoid *pixels);
22
23 #endif  // !defined(_REF_COUNTED_TEXTURE)