diff options
author | iurii plugatarov <[email protected]> | 2024-08-18 20:54:42 +0200 |
---|---|---|
committer | iurii plugatarov <[email protected]> | 2024-08-18 20:54:42 +0200 |
commit | 30c8a4d7c2160c174392aa2dccf60178f9cd02c2 (patch) | |
tree | afea3e1e310dfac2afd51abc0f974b2c74a76ca4 /src/main.odin | |
parent | 05aa5178f7b0cf0962d4125a6a0af76a972150f2 (diff) | |
download | funhalla-30c8a4d7c2160c174392aa2dccf60178f9cd02c2.tar.gz |
diffuse
Diffstat (limited to '')
-rw-r--r-- | src/main.odin | 157 |
1 files changed, 46 insertions, 111 deletions
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( |