render: rename shader_program -> dmabuf_shader_program
parent
36e7bde860
commit
8cc00dd5eb
|
@ -25,7 +25,7 @@ struct renderer {
|
||||||
EGLDisplay display;
|
EGLDisplay display;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
EGLContext context;
|
EGLContext context;
|
||||||
GLuint shader_program;
|
GLuint dmabuf_shader_program;
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
GLint read_format;
|
GLint read_format;
|
||||||
|
|
46
src/render.c
46
src/render.c
|
@ -148,25 +148,27 @@ static int gl_load_shader(GLuint* dst, const char* source, GLenum type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gl_compile_shader_program(GLuint* dst)
|
static const char dmabuf_vertex_src[] =
|
||||||
{
|
"attribute vec2 pos;\n"
|
||||||
static const char vertex_src[] =
|
"attribute vec2 texture;\n"
|
||||||
"attribute vec2 pos;\n"
|
"varying vec2 v_texture;\n"
|
||||||
"attribute vec2 texture;\n"
|
"void main() {\n"
|
||||||
"varying vec2 v_texture;\n"
|
" v_texture = vec2(texture.s, 1.0 - texture.t);\n"
|
||||||
"void main() {\n"
|
" gl_Position = vec4(pos, 0, 1);\n"
|
||||||
" v_texture = vec2(texture.s, 1.0 - texture.t);\n"
|
"}\n";
|
||||||
" gl_Position = vec4(pos, 0, 1);\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char fragment_src[] =
|
static const char dmabuf_fragment_src[] =
|
||||||
"#extension GL_OES_EGL_image_external: require\n\n"
|
"#extension GL_OES_EGL_image_external: require\n\n"
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"uniform samplerExternalOES u_tex;\n"
|
"uniform samplerExternalOES u_tex;\n"
|
||||||
"varying vec2 v_texture;\n"
|
"varying vec2 v_texture;\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_FragColor = texture2D(u_tex, v_texture);\n"
|
" gl_FragColor = texture2D(u_tex, v_texture);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
static int gl_compile_shader_program(GLuint* dst, const char* vertex_src,
|
||||||
|
const char* fragment_src)
|
||||||
|
{
|
||||||
|
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
GLuint vertex, fragment;
|
GLuint vertex, fragment;
|
||||||
|
@ -244,7 +246,7 @@ void renderer_destroy(struct renderer* self)
|
||||||
{
|
{
|
||||||
eglDestroySurface(self->display, self->surface);
|
eglDestroySurface(self->display, self->surface);
|
||||||
eglDestroyContext(self->display, self->context);
|
eglDestroyContext(self->display, self->context);
|
||||||
glDeleteProgram(self->shader_program);
|
glDeleteProgram(self->dmabuf_shader_program);
|
||||||
}
|
}
|
||||||
|
|
||||||
int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
|
int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
|
||||||
|
@ -310,10 +312,12 @@ int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
|
||||||
if (gl_load_late_extensions() < 0)
|
if (gl_load_late_extensions() < 0)
|
||||||
goto late_extension_failure;
|
goto late_extension_failure;
|
||||||
|
|
||||||
if (gl_compile_shader_program(&self->shader_program) < 0)
|
if (gl_compile_shader_program(&self->dmabuf_shader_program,
|
||||||
|
dmabuf_vertex_src,
|
||||||
|
dmabuf_fragment_src) < 0)
|
||||||
goto shader_failure;
|
goto shader_failure;
|
||||||
|
|
||||||
glUseProgram(self->shader_program);
|
glUseProgram(self->dmabuf_shader_program);
|
||||||
|
|
||||||
self->width = width;
|
self->width = width;
|
||||||
self->height = height;
|
self->height = height;
|
||||||
|
|
Loading…
Reference in New Issue