forked from enlightenment/efl
Evas GL:Bind texture to correct one.
Summary: If user bind textureA and want to use it continuously, do not call glBindTexture(textureA) again. But expect that textureA will be binding. So EvasGL sould not change binded texture silently. Restore texture to previous bound one after allocating new texture. And when destroy texture, reset texture to 0 if it is current bound texture. Test Plan: Tizen 3.0 Reviewers: wonsik, dkdk, cedric, jpeg Reviewed By: jpeg Differential Revision: https://phab.enlightenment.org/D4524
This commit is contained in:
parent
4a0a9d8ae1
commit
40e9da0101
|
@ -234,19 +234,26 @@ _texture_allocate_2d(GLuint tex, GLint ifmt, GLenum fmt, GLenum type, int w, int
|
||||||
{
|
{
|
||||||
//if (!(*tex))
|
//if (!(*tex))
|
||||||
// glGenTextures(1, tex);
|
// glGenTextures(1, tex);
|
||||||
|
GLint curr_tex = 0;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, tex);
|
glBindTexture(GL_TEXTURE_2D, tex);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, ifmt, w, h, 0, fmt, type, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, ifmt, w, h, 0, fmt, type, NULL);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)curr_tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy Texture
|
// Destroy Texture
|
||||||
static void
|
static void
|
||||||
_texture_destroy(GLuint *tex)
|
_texture_destroy(GLuint *tex)
|
||||||
{
|
{
|
||||||
|
GLint curr_tex = 0;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex);
|
||||||
|
|
||||||
|
if ((GLuint)curr_tex == *tex) glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
if (*tex)
|
if (*tex)
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, tex);
|
glDeleteTextures(1, tex);
|
||||||
|
|
Loading…
Reference in New Issue