Propagate shader compile/link errors
And silence the no-error case.
This commit is contained in:
parent
bf6ceda545
commit
a946821b4f
@ -662,7 +662,8 @@ drm_compositor_create(struct wl_display *display)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Can't init base class until we have a current egl context */
|
/* Can't init base class until we have a current egl context */
|
||||||
wlsc_compositor_init(&ec->base, display);
|
if (wlsc_compositor_init(&ec->base, display) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (create_outputs(ec) < 0) {
|
if (create_outputs(ec) < 0) {
|
||||||
fprintf(stderr, "failed to create output for %s\n", path);
|
fprintf(stderr, "failed to create output for %s\n", path);
|
||||||
|
@ -644,7 +644,8 @@ x11_compositor_create(struct wl_display *display)
|
|||||||
x11_compositor_init_egl(c);
|
x11_compositor_init_egl(c);
|
||||||
|
|
||||||
/* Can't init base class until we have a current egl context */
|
/* Can't init base class until we have a current egl context */
|
||||||
wlsc_compositor_init(&c->base, display);
|
if (wlsc_compositor_init(&c->base, display) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
x11_compositor_create_output(c, 1024, 640);
|
x11_compositor_create_output(c, 1024, 640);
|
||||||
|
|
||||||
|
32
compositor.c
32
compositor.c
@ -801,27 +801,36 @@ static const char fragment_shader[] =
|
|||||||
" gl_FragColor = texture2D(tex, v_texcoord)\n;"
|
" gl_FragColor = texture2D(tex, v_texcoord)\n;"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
static void
|
static int
|
||||||
init_shaders(struct wlsc_compositor *ec)
|
init_shaders(struct wlsc_compositor *ec)
|
||||||
{
|
{
|
||||||
GLuint v, f, program;
|
GLuint v, f, program;
|
||||||
const char *p;
|
const char *p;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
GLfloat vertices[4 * 5];
|
GLfloat vertices[4 * 5];
|
||||||
|
GLint status;
|
||||||
|
|
||||||
p = vertex_shader;
|
p = vertex_shader;
|
||||||
v = glCreateShader(GL_VERTEX_SHADER);
|
v = glCreateShader(GL_VERTEX_SHADER);
|
||||||
glShaderSource(v, 1, &p, NULL);
|
glShaderSource(v, 1, &p, NULL);
|
||||||
glCompileShader(v);
|
glCompileShader(v);
|
||||||
glGetShaderInfoLog(v, sizeof msg, NULL, msg);
|
glGetShaderiv(v, GL_COMPILE_STATUS, &status);
|
||||||
printf("vertex shader info: %s\n", msg);
|
if (!status) {
|
||||||
|
glGetShaderInfoLog(v, sizeof msg, NULL, msg);
|
||||||
|
fprintf(stderr, "vertex shader info: %s\n", msg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
p = fragment_shader;
|
p = fragment_shader;
|
||||||
f = glCreateShader(GL_FRAGMENT_SHADER);
|
f = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
glShaderSource(f, 1, &p, NULL);
|
glShaderSource(f, 1, &p, NULL);
|
||||||
glCompileShader(f);
|
glCompileShader(f);
|
||||||
glGetShaderInfoLog(f, sizeof msg, NULL, msg);
|
glGetShaderiv(f, GL_COMPILE_STATUS, &status);
|
||||||
printf("fragment shader info: %s\n", msg);
|
if (!status) {
|
||||||
|
glGetShaderInfoLog(f, sizeof msg, NULL, msg);
|
||||||
|
fprintf(stderr, "fragment shader info: %s\n", msg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
program = glCreateProgram();
|
program = glCreateProgram();
|
||||||
glAttachShader(program, v);
|
glAttachShader(program, v);
|
||||||
@ -830,8 +839,12 @@ init_shaders(struct wlsc_compositor *ec)
|
|||||||
glBindAttribLocation(program, 1, "texcoord");
|
glBindAttribLocation(program, 1, "texcoord");
|
||||||
|
|
||||||
glLinkProgram(program);
|
glLinkProgram(program);
|
||||||
glGetProgramInfoLog(program, sizeof msg, NULL, msg);
|
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
||||||
printf("info: %s\n", msg);
|
if (!status) {
|
||||||
|
glGetProgramInfoLog(program, sizeof msg, NULL, msg);
|
||||||
|
fprintf(stderr, "link info: %s\n", msg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
ec->proj_uniform = glGetUniformLocation(program, "proj");
|
ec->proj_uniform = glGetUniformLocation(program, "proj");
|
||||||
@ -864,6 +877,8 @@ init_shaders(struct wlsc_compositor *ec)
|
|||||||
glGenBuffers(1, &ec->vbo);
|
glGenBuffers(1, &ec->vbo);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, ec->vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, ec->vbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof vertices, vertices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_interface visual_interface = {
|
static const struct wl_interface visual_interface = {
|
||||||
@ -938,7 +953,8 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
|
|||||||
glGenFramebuffers(1, &ec->fbo);
|
glGenFramebuffers(1, &ec->fbo);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, ec->fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, ec->fbo);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
init_shaders(ec);
|
if (init_shaders(ec) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
loop = wl_display_get_event_loop(ec->wl_display);
|
loop = wl_display_get_event_loop(ec->wl_display);
|
||||||
ec->timer_source = wl_event_loop_add_timer(loop, repaint, ec);
|
ec->timer_source = wl_event_loop_add_timer(loop, repaint, ec);
|
||||||
|
Loading…
Reference in New Issue
Block a user