summary refs log tree commit diff
path: root/src/main.odin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main.odin157
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(