File: ref_counted_texture.cpp

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 (25 lines) | stat: -rw-r--r-- 839 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
24
25
#include "ref_counted_texture.h"

#include <epoxy/gl.h>
#include <movit/util.h>

RefCountedTexture create_texture_2d(GLuint width, GLuint height, GLenum internal_format, GLenum format, GLenum type, const GLvoid *pixels)
{
	GLuint tex;
	glCreateTextures(GL_TEXTURE_2D, 1, &tex);
	check_error();
	glTextureStorage2D(tex, 1, internal_format, width, height);
	check_error();
	glTextureSubImage2D(tex, 0, 0, 0, width, height, format, type, pixels);
	check_error();
	glTextureParameteri(tex, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	check_error();
	glTextureParameteri(tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	check_error();
	glTextureParameteri(tex, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	check_error();
	glTextureParameteri(tex, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	check_error();

	return RefCountedTexture(new GLuint(tex), TextureDeleter());
}