]> git.sesse.net Git - nageru/blob - shared/ref_counted_texture.cpp
Change Futatabi frames to be cached as textures instead of in system memory.
[nageru] / shared / ref_counted_texture.cpp
1 #include "ref_counted_texture.h"
2
3 #include <epoxy/gl.h>
4 #include <movit/util.h>
5
6 RefCountedTexture create_texture_2d(GLuint width, GLuint height, GLenum internal_format, GLenum format, GLenum type, const GLvoid *pixels)
7 {
8         GLuint tex;
9         glCreateTextures(GL_TEXTURE_2D, 1, &tex);
10         check_error();
11         glTextureStorage2D(tex, 1, internal_format, width, height);
12         check_error();
13         glTextureSubImage2D(tex, 0, 0, 0, width, height, format, type, pixels);
14         check_error();
15         glTextureParameteri(tex, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
16         check_error();
17         glTextureParameteri(tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
18         check_error();
19         glTextureParameteri(tex, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
20         check_error();
21         glTextureParameteri(tex, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
22         check_error();
23
24         return RefCountedTexture(new GLuint(tex), TextureDeleter());
25 }