render: Fetch uniform locations in one place

pull/20/head
Andri Yngvason 2020-03-05 18:20:54 +00:00
parent 6b3b448405
commit 1bf618a098
2 changed files with 5 additions and 2 deletions

View File

@ -39,6 +39,7 @@ struct renderer {
struct {
GLuint program;
GLint u_tex;
} shader;
};

View File

@ -411,6 +411,8 @@ int renderer_init(struct renderer* self, uint32_t width, uint32_t height,
break;
}
self->shader.u_tex = glGetUniformLocation(self->shader.program, "u_tex");
self->width = width;
self->height = height;
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &self->read_format);
@ -485,7 +487,7 @@ int render_dmabuf_frame(struct renderer* self, struct dmabuf_frame* frame)
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image);
glUseProgram(self->shader.program);
glUniform1i(glGetUniformLocation(self->shader.program, "u_tex"), 0);
glUniform1i(self->shader.u_tex, 0);
gl_render();
glBindTexture(GL_TEXTURE_2D, 0);
@ -514,7 +516,7 @@ int render_framebuffer(struct renderer* self, const void* addr, uint32_t format,
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
glUseProgram(self->shader.program);
glUniform1i(glGetUniformLocation(self->shader.program, "u_tex"), 0);
glUniform1i(self->shader.u_tex, 0);
gl_render();
glBindTexture(GL_TEXTURE_2D, 0);