Update vertex data for cube

This commit is contained in:
Hugo Mårdbrink 2025-09-06 01:37:45 +02:00
parent 2ba1022f79
commit fe42f2665c

View file

@ -24,12 +24,8 @@ import program_config "../config"
import shaders "../shaders/out" import shaders "../shaders/out"
CubeVertexData :: struct { VertexData :: struct {
pos: Vec3, x, y, z: f32,
}
OutlineVertexData :: struct {
pos: Vec3,
} }
Mesh :: struct { Mesh :: struct {
@ -110,54 +106,48 @@ init_cube_material :: proc(render_system: ^RenderSystem) {
@(private="file") @(private="file")
init_cube_mesh :: proc (render_system: ^RenderSystem) { init_cube_mesh :: proc (render_system: ^RenderSystem) {
cube_vertices := []CubeVertexData { cube_vertices := []VertexData {
{ pos = { -0.5, -0.5, 0.5 } }, { -0.5, -0.5, 0.5 },
{ pos = { 0.5, -0.5, 0.5 } }, { 0.5, -0.5, 0.5 },
{ pos = { 0.5, 0.5, 0.5 } }, { 0.5, 0.5, 0.5 },
{ pos = { -0.5, 0.5, 0.5 } }, { -0.5, 0.5, 0.5 },
{ pos = { -0.5, -0.5, -0.5 } }, { -0.5, -0.5, -0.5 },
{ pos = { 0.5, -0.5, -0.5 } }, { 0.5, -0.5, -0.5 },
{ pos = { 0.5, 0.5, -0.5 } }, { 0.5, 0.5, -0.5 },
{ pos = { -0.5, 0.5, -0.5 } }, { -0.5, 0.5, -0.5 },
{ pos = { -0.5, 0.5, 0.5 } }, { -0.5, 0.5, 0.5 },
{ pos = { 0.5, 0.5, 0.5 } }, { 0.5, 0.5, 0.5 },
{ pos = { 0.5, 0.5, -0.5 } }, { 0.5, 0.5, -0.5 },
{ pos = { -0.5, 0.5, -0.5 } }, { -0.5, 0.5, -0.5 },
{ pos = { -0.5, -0.5, 0.5 } }, { -0.5, -0.5, 0.5 },
{ pos = { 0.5, -0.5, 0.5 } }, { 0.5, -0.5, 0.5 },
{ pos = { 0.5, -0.5, -0.5 } }, { 0.5, -0.5, -0.5 },
{ pos = { -0.5, -0.5, -0.5 } }, { -0.5, -0.5, -0.5 },
{ pos = { 0.5, -0.5, 0.5 } }, { 0.5, -0.5, 0.5 },
{ pos = { 0.5, -0.5, -0.5 } }, { 0.5, -0.5, -0.5 },
{ pos = { 0.5, 0.5, -0.5 } }, { 0.5, 0.5, -0.5 },
{ pos = { 0.5, 0.5, 0.5 } }, { 0.5, 0.5, 0.5 },
{ pos = { -0.5, -0.5, 0.5 } }, { -0.5, -0.5, 0.5 },
{ pos = { -0.5, -0.5, -0.5 } }, { -0.5, -0.5, -0.5 },
{ pos = { -0.5, 0.5, -0.5 } }, { -0.5, 0.5, -0.5 },
{ pos = { -0.5, 0.5, 0.5 } }, { -0.5, 0.5, 0.5 },
} }
vertex_buffer := sg.make_buffer({ vertex_buffer := sg.make_buffer({
data = sg_range(cube_vertices) data = sg_range(cube_vertices)
}) })
cube_indices := []u16 { cube_indices := []u16 {
1, 0, 2, 0, 1, 2, 0, 2, 3,
3, 2, 0, 6, 5, 4, 7, 6, 4,
7, 4, 6, 8, 9, 10, 8, 10, 11,
5, 6, 4, 14, 13, 12, 15, 14, 12,
9, 8, 10, 16, 17, 18, 16, 18, 19,
11, 10, 8, 22, 21, 20, 23, 22, 20,
15, 12, 14,
13, 14, 12,
17, 16, 18,
19, 18, 16,
23, 20, 22,
21, 22, 20,
} }
index_buffer := sg.make_buffer({ index_buffer := sg.make_buffer({