create a second GLSL program for testing drawing the logo

This commit is contained in:
Josh Holtrop 2013-11-17 18:33:13 -05:00
parent f328282289
commit e84a0f17a4

View File

@ -11,9 +11,14 @@ enum int WIDTH = 1920;
enum int HEIGHT = 1080;
GLint position_idx;
GLint position2_idx;
GLint color_idx;
GLint view_idx;
GLint view2_idx;
mat4 view_matrix;
Shader program;
Shader program2;
VAO vao;
void init()
{
@ -38,10 +43,27 @@ fragment:
gl_FragColor = vec4(color_i, 1.0);
}
`;
VAO vao = new VAO();
Shader program = new Shader("program", shader_src);
immutable string shader2_src = `
vertex:
uniform mat4 view;
in vec2 position;
void main(void)
{
gl_Position = view * vec4(position, 0.0, 1.0);
}
fragment:
void main(void)
{
gl_FragColor = vec4(0, 0.3, 0.8, 1.0);
}
`;
vao = new VAO();
vao.bind();
program = new Shader("program", shader_src);
program2 = new Shader("program2", shader2_src);
program.bind();
position_idx = program.get_attrib_location("position");
position2_idx = program2.get_attrib_location("position");
color_idx = program.get_attrib_location("color");
float[] vertices = [0.4, 0.4, -0.4, 0.4, -0.4, -0.4, 0.4, -0.4];
float[] colors = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0];
@ -57,6 +79,7 @@ fragment:
ElementBuffer ibo = new ElementBuffer(indices);
ibo.bind();
view_idx = program.get_uniform_location("view");
view2_idx = program2.get_uniform_location("view");
}
void display(SDL_Window * window)
@ -66,6 +89,9 @@ void display(SDL_Window * window)
view_matrix.make_identity();
view_matrix.rotatez(SDL_GetTicks() / 500.0);
view_matrix.scale(HEIGHT / cast(float)WIDTH, 1.0, 1.0);
program.bind();
vao.bind();
glUniformMatrix4fv(view_idx, 1, GL_TRUE, view_matrix.value_ptr);
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, null);