File: ref_counted_texture.h

package info (click to toggle)
nageru 2.3.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,120 kB
  • sloc: cpp: 39,131; perl: 94; sh: 18; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 608 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef _REF_COUNTED_TEXTURE_H
#define _REF_COUNTED_TEXTURE_H 1

// A wrapper around an OpenGL texture that is automatically deleted.

#include <epoxy/gl.h>
#include <memory>

struct TextureDeleter {
	void operator() (GLuint *tex)
	{
		glDeleteTextures(1, tex);
		delete tex;
	}
};

typedef std::unique_ptr<GLuint, TextureDeleter> UniqueTexture;
typedef std::shared_ptr<GLuint> RefCountedTexture;

// TODO: consider mipmaps.
RefCountedTexture create_texture_2d(GLuint width, GLuint height, GLenum internal_format, GLenum format, GLenum type, const GLvoid *pixels);

#endif  // !defined(_REF_COUNTED_TEXTURE)