diff --git a/ecs/render_system.odin b/ecs/render_system.odin index 0eb9fef..82f9843 100644 --- a/ecs/render_system.odin +++ b/ecs/render_system.odin @@ -17,6 +17,7 @@ import "core:os" import stbi "vendor:stb/image" import sa "../sokol/app" +import sl "../sokol/log" import sh "../sokol/helpers" import sg "../sokol/gfx" @@ -25,7 +26,7 @@ import program_config "../config" import shaders "../shaders/out" VertexData :: struct { - x, y, z: f32, + pos: Vec3, } Mesh :: struct { @@ -57,7 +58,7 @@ init_outline_material :: proc(render_system: ^RenderSystem) { }, }, index_type = .UINT16, - cull_mode = .FRONT, + cull_mode = .BACK, depth = { pixel_format = .DEFAULT, write_enabled = true, @@ -86,7 +87,7 @@ init_cube_material :: proc(render_system: ^RenderSystem) { }, }, index_type = .UINT16, - cull_mode = .BACK, + cull_mode = .FRONT, depth = { pixel_format = .DEFAULT, write_enabled = true, @@ -107,35 +108,35 @@ init_cube_material :: proc(render_system: ^RenderSystem) { @(private="file") init_cube_mesh :: proc (render_system: ^RenderSystem) { cube_vertices := []VertexData { - { -0.5, -0.5, 0.5 }, - { 0.5, -0.5, 0.5 }, - { 0.5, 0.5, 0.5 }, - { -0.5, 0.5, 0.5 }, + { pos = { -0.5, -0.5, 0.5 }, }, + { pos = { 0.5, -0.5, 0.5 }, }, + { pos = { 0.5, 0.5, 0.5 }, }, + { pos = { -0.5, 0.5, 0.5 }, }, - { -0.5, -0.5, -0.5 }, - { 0.5, -0.5, -0.5 }, - { 0.5, 0.5, -0.5 }, - { -0.5, 0.5, -0.5 }, + { pos = { -0.5, -0.5, -0.5 }, }, + { pos = { 0.5, -0.5, -0.5 }, }, + { pos = { 0.5, 0.5, -0.5 }, }, + { pos = { -0.5, 0.5, -0.5 }, }, - { -0.5, 0.5, 0.5 }, - { 0.5, 0.5, 0.5 }, - { 0.5, 0.5, -0.5 }, - { -0.5, 0.5, -0.5 }, + { pos = { -0.5, 0.5, 0.5 }, }, + { pos = { 0.5, 0.5, 0.5 }, }, + { pos = { 0.5, 0.5, -0.5 }, }, + { pos = { -0.5, 0.5, -0.5 }, }, - { -0.5, -0.5, 0.5 }, - { 0.5, -0.5, 0.5 }, - { 0.5, -0.5, -0.5 }, - { -0.5, -0.5, -0.5 }, + { pos = { -0.5, -0.5, 0.5 }, }, + { pos = { 0.5, -0.5, 0.5 }, }, + { pos = { 0.5, -0.5, -0.5 }, }, + { pos = { -0.5, -0.5, -0.5 }, }, - { 0.5, -0.5, 0.5 }, - { 0.5, -0.5, -0.5 }, - { 0.5, 0.5, -0.5 }, - { 0.5, 0.5, 0.5 }, + { pos = { 0.5, -0.5, 0.5 }, }, + { pos = { 0.5, -0.5, -0.5 }, }, + { pos = { 0.5, 0.5, -0.5 }, }, + { pos = { 0.5, 0.5, 0.5 }, }, - { -0.5, -0.5, 0.5 }, - { -0.5, -0.5, -0.5 }, - { -0.5, 0.5, -0.5 }, - { -0.5, 0.5, 0.5 }, + { pos = { -0.5, -0.5, 0.5 }, }, + { pos = { -0.5, -0.5, -0.5 }, }, + { pos = { -0.5, 0.5, -0.5 }, }, + { pos = { -0.5, 0.5, 0.5 }, }, } vertex_buffer := sg.make_buffer({ data = sg_range(cube_vertices) @@ -167,7 +168,7 @@ render_system_init :: proc(render_system: ^RenderSystem, user_entity: EntityID) sg.setup({ environment = sh.glue_environment(), allocator = sg.Allocator(sh.allocator(&default_context)), - logger = sg.Logger(sh.logger(&default_context)), + logger = sg.Logger( { func = sl.func } ), }) render_system.materials = make(map[MaterialID]Material) @@ -205,8 +206,8 @@ CLEAR_SCREEN_ACTION :: sg.Pass_Action{ 0 = { load_action = .CLEAR, clear_value = program_config.BACKGROUND_COLOR, - } - } + }, + }, } @(private="file") @@ -293,8 +294,8 @@ render_system_update :: proc(render_system: ^RenderSystem, coordinator: ^Coordin view := linalg.matrix4_look_at_f32(camera.position, camera.target, { 0, 1, 0 } ) sg.begin_pass({ swapchain = sh.glue_swapchain(), action = CLEAR_SCREEN_ACTION }) - outline_pass(render_system, coordinator, proj, view) cube_pass(render_system, coordinator, proj, view) + outline_pass(render_system, coordinator, proj, view) sg.end_pass() sg.commit() diff --git a/main.odin b/main.odin index 5501542..c32f5c9 100644 --- a/main.odin +++ b/main.odin @@ -18,6 +18,8 @@ import "core:math/rand" import stbi "vendor:stb/image" import sa "sokol/app" +import sg "sokol/app" +import sl "sokol/log" import sh "sokol/helpers" import "ecs" @@ -54,7 +56,9 @@ main :: proc() { window_title = program_config.WINDOW_TITLE, allocator = sa.Allocator(sh.allocator(&default_context)), - logger = sa.Logger(sh.logger(&default_context)), + logger = sg.Logger( { func = sl.func } ), + + sample_count = 4, init_cb = init_cb, frame_cb = frame_cb,