make quad spin
This commit is contained in:
parent
ec149216ff
commit
6779466792
10
source/app.d
10
source/app.d
@ -4,12 +4,15 @@ import derelict.opengl3.gl3;
|
||||
import glamour.vao;
|
||||
import glamour.shader;
|
||||
import glamour.vbo;
|
||||
import gl3n.linalg;
|
||||
|
||||
enum int WIDTH = 800;
|
||||
enum int HEIGHT = 600;
|
||||
|
||||
GLint position_idx;
|
||||
GLint color_idx;
|
||||
GLint view_idx;
|
||||
mat4 view_matrix;
|
||||
|
||||
void init()
|
||||
{
|
||||
@ -17,12 +20,13 @@ void init()
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
immutable string shader_src = `
|
||||
vertex:
|
||||
uniform mat4 view;
|
||||
in vec2 position;
|
||||
in vec3 color;
|
||||
out vec3 color_i;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
gl_Position = view * vec4(position, 0.0, 1.0);
|
||||
color_i = color;
|
||||
}
|
||||
fragment:
|
||||
@ -50,12 +54,16 @@ fragment:
|
||||
glVertexAttribPointer(color_idx, 3, GL_FLOAT, GL_FALSE, 0, null);
|
||||
ElementBuffer ibo = new ElementBuffer(indices);
|
||||
ibo.bind();
|
||||
view_idx = program.get_uniform_location("view");
|
||||
}
|
||||
|
||||
void display(SDL_Window * window)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
view_matrix.make_identity();
|
||||
view_matrix.rotate(SDL_GetTicks() / 500.0, vec3(0.0, 0.0, 1.0));
|
||||
glUniformMatrix4fv(view_idx, 1, GL_TRUE, view_matrix.value_ptr);
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, null);
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
Loading…
x
Reference in New Issue
Block a user