From 30c8a4d7c2160c174392aa2dccf60178f9cd02c2 Mon Sep 17 00:00:00 2001 From: iurii plugatarov Date: Sun, 18 Aug 2024 21:54:42 +0300 Subject: diffuse --- src/main.odin | 157 +++++++++++++++++----------------------------------------- 1 file changed, 46 insertions(+), 111 deletions(-) (limited to 'src/main.odin') diff --git a/src/main.odin b/src/main.odin index c2c54ef..43cd5fb 100644 --- a/src/main.odin +++ b/src/main.odin @@ -139,114 +139,47 @@ main :: proc() { } vertices: []f32 = { - -0.5, - -0.5, - -0.5, - 0.5, - -0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5, - 0.5, - -0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - -0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - 0.5, - 0.5, - 0.5, - 0.5, - -0.5, - -0.5, - -0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - -0.5, - -0.5, - -0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - -0.5, + -0.5, -0.5, -0.5, 0.0, 0.0, -1.0, + 0.5, -0.5, -0.5, 0.0, 0.0, -1.0, + 0.5, 0.5, -0.5, 0.0, 0.0, -1.0, + 0.5, 0.5, -0.5, 0.0, 0.0, -1.0, + -0.5, 0.5, -0.5, 0.0, 0.0, -1.0, + -0.5, -0.5, -0.5, 0.0, 0.0, -1.0, + + -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, + 0.5, -0.5, 0.5, 0.0, 0.0, 1.0, + 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, + 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, + -0.5, 0.5, 0.5, 0.0, 0.0, 1.0, + -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, + + -0.5, 0.5, 0.5, -1.0, 0.0, 0.0, + -0.5, 0.5, -0.5, -1.0, 0.0, 0.0, + -0.5, -0.5, -0.5, -1.0, 0.0, 0.0, + -0.5, -0.5, -0.5, -1.0, 0.0, 0.0, + -0.5, -0.5, 0.5, -1.0, 0.0, 0.0, + -0.5, 0.5, 0.5, -1.0, 0.0, 0.0, + + 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, + 0.5, 0.5, -0.5, 1.0, 0.0, 0.0, + 0.5, -0.5, -0.5, 1.0, 0.0, 0.0, + 0.5, -0.5, -0.5, 1.0, 0.0, 0.0, + 0.5, -0.5, 0.5, 1.0, 0.0, 0.0, + 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, + + -0.5, -0.5, -0.5, 0.0, -1.0, 0.0, + 0.5, -0.5, -0.5, 0.0, -1.0, 0.0, + 0.5, -0.5, 0.5, 0.0, -1.0, 0.0, + 0.5, -0.5, 0.5, 0.0, -1.0, 0.0, + -0.5, -0.5, 0.5, 0.0, -1.0, 0.0, + -0.5, -0.5, -0.5, 0.0, -1.0, 0.0, + + -0.5, 0.5, -0.5, 0.0, 1.0, 0.0, + 0.5, 0.5, -0.5, 0.0, 1.0, 0.0, + 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, + 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, + -0.5, 0.5, 0.5, 0.0, 1.0, 0.0, + -0.5, 0.5, -0.5, 0.0, 1.0, 0.0 } @@ -263,14 +196,15 @@ main :: proc() { gl.GenVertexArrays(1, &cube_vao) gl.BindVertexArray(cube_vao) - gl.VertexAttribPointer(0, 3, gl.FLOAT, gl.FALSE, 3 * size_of(f32), 0) + gl.VertexAttribPointer(0, 3, gl.FLOAT, gl.FALSE, 6 * size_of(f32), 0) gl.EnableVertexAttribArray(0) - + gl.VertexAttribPointer(1, 3, gl.FLOAT, gl.FALSE, 6 * size_of(f32), 3 * size_of(f32)) + gl.EnableVertexAttribArray(1) gl.GenVertexArrays(1, &light_cube_vao) gl.BindVertexArray(light_cube_vao) gl.BindBuffer(gl.ARRAY_BUFFER, vbo) - gl.VertexAttribPointer(0, 3, gl.FLOAT, gl.FALSE, 3 * size_of(f32), 0) + gl.VertexAttribPointer(0, 3, gl.FLOAT, gl.FALSE, 6 * size_of(f32), 0) gl.EnableVertexAttribArray(0) //gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE) @@ -293,6 +227,7 @@ main :: proc() { light_color := Vec3{1.0, 1.0, 1.0} shader.set_vec3(lighting_shader, cstring("object_color"), &object_color[0]) shader.set_vec3(lighting_shader, cstring("light_color"), &light_color[0]) + shader.set_vec3(lighting_shader, cstring("light_position"), &light_pos[0]) aspect: f32 = 800.0 / 600.0 projection := linalg.matrix4_perspective_f32( -- cgit 1.4.1-2-gfad0