|
|
@ -804,81 +804,81 @@ static const char fragment_shader[] = |
|
|
|
static int |
|
|
|
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; |
|
|
|
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); |
|
|
|
glGetShaderiv(v, GL_COMPILE_STATUS, &status); |
|
|
|
glGetShaderiv(v, GL_COMPILE_STATUS, &status); |
|
|
|
if (!status) { |
|
|
|
if (!status) { |
|
|
|
glGetShaderInfoLog(v, sizeof msg, NULL, msg); |
|
|
|
glGetShaderInfoLog(v, sizeof msg, NULL, msg); |
|
|
|
fprintf(stderr, "vertex shader info: %s\n", msg); |
|
|
|
fprintf(stderr, "vertex shader info: %s\n", msg); |
|
|
|
return -1; |
|
|
|
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); |
|
|
|
glGetShaderiv(f, GL_COMPILE_STATUS, &status); |
|
|
|
glGetShaderiv(f, GL_COMPILE_STATUS, &status); |
|
|
|
if (!status) { |
|
|
|
if (!status) { |
|
|
|
glGetShaderInfoLog(f, sizeof msg, NULL, msg); |
|
|
|
glGetShaderInfoLog(f, sizeof msg, NULL, msg); |
|
|
|
fprintf(stderr, "fragment shader info: %s\n", msg); |
|
|
|
fprintf(stderr, "fragment shader info: %s\n", msg); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
program = glCreateProgram(); |
|
|
|
program = glCreateProgram(); |
|
|
|
glAttachShader(program, v); |
|
|
|
glAttachShader(program, v); |
|
|
|
glAttachShader(program, f); |
|
|
|
glAttachShader(program, f); |
|
|
|
glBindAttribLocation(program, 0, "position"); |
|
|
|
glBindAttribLocation(program, 0, "position"); |
|
|
|
glBindAttribLocation(program, 1, "texcoord"); |
|
|
|
glBindAttribLocation(program, 1, "texcoord"); |
|
|
|
|
|
|
|
|
|
|
|
glLinkProgram(program); |
|
|
|
glLinkProgram(program); |
|
|
|
glGetProgramiv(program, GL_LINK_STATUS, &status); |
|
|
|
glGetProgramiv(program, GL_LINK_STATUS, &status); |
|
|
|
if (!status) { |
|
|
|
if (!status) { |
|
|
|
glGetProgramInfoLog(program, sizeof msg, NULL, msg); |
|
|
|
glGetProgramInfoLog(program, sizeof msg, NULL, msg); |
|
|
|
fprintf(stderr, "link info: %s\n", msg); |
|
|
|
fprintf(stderr, "link info: %s\n", msg); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
glUseProgram(program); |
|
|
|
glUseProgram(program); |
|
|
|
ec->proj_uniform = glGetUniformLocation(program, "proj"); |
|
|
|
ec->proj_uniform = glGetUniformLocation(program, "proj"); |
|
|
|
ec->tex_uniform = glGetUniformLocation(program, "tex"); |
|
|
|
ec->tex_uniform = glGetUniformLocation(program, "tex"); |
|
|
|
|
|
|
|
|
|
|
|
vertices[ 0] = 0.0; |
|
|
|
vertices[ 0] = 0.0; |
|
|
|
vertices[ 1] = 0.0; |
|
|
|
vertices[ 1] = 0.0; |
|
|
|
vertices[ 2] = 0.0; |
|
|
|
vertices[ 2] = 0.0; |
|
|
|
vertices[ 3] = 0.0; |
|
|
|
vertices[ 3] = 0.0; |
|
|
|
vertices[ 4] = 0.0; |
|
|
|
vertices[ 4] = 0.0; |
|
|
|
|
|
|
|
|
|
|
|
vertices[ 5] = 0.0; |
|
|
|
vertices[ 5] = 0.0; |
|
|
|
vertices[ 6] = 1.0; |
|
|
|
vertices[ 6] = 1.0; |
|
|
|
vertices[ 7] = 0.0; |
|
|
|
vertices[ 7] = 0.0; |
|
|
|
vertices[ 8] = 0.0; |
|
|
|
vertices[ 8] = 0.0; |
|
|
|
vertices[ 9] = 1.0; |
|
|
|
vertices[ 9] = 1.0; |
|
|
|
|
|
|
|
|
|
|
|
vertices[10] = 1.0; |
|
|
|
vertices[10] = 1.0; |
|
|
|
vertices[11] = 0.0; |
|
|
|
vertices[11] = 0.0; |
|
|
|
vertices[12] = 0.0; |
|
|
|
vertices[12] = 0.0; |
|
|
|
vertices[13] = 1.0; |
|
|
|
vertices[13] = 1.0; |
|
|
|
vertices[14] = 0.0; |
|
|
|
vertices[14] = 0.0; |
|
|
|
|
|
|
|
|
|
|
|
vertices[15] = 1.0; |
|
|
|
vertices[15] = 1.0; |
|
|
|
vertices[16] = 1.0; |
|
|
|
vertices[16] = 1.0; |
|
|
|
vertices[17] = 0.0; |
|
|
|
vertices[17] = 0.0; |
|
|
|
vertices[18] = 1.0; |
|
|
|
vertices[18] = 1.0; |
|
|
|
vertices[19] = 1.0; |
|
|
|
vertices[19] = 1.0; |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_interface visual_interface = { |
|
|
|
static const struct wl_interface visual_interface = { |
|
|
|