From: Brendan Hansen Date: Mon, 1 Mar 2021 20:20:52 +0000 (-0600) Subject: working on this again X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=fd8f6c9ce73d5ca3b153fdaa723aacc115de8ce4;p=onyx-imgui.git working on this again --- diff --git a/.gitignore b/.gitignore index 3805cfc..677129f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +*.sublime-project *.sublime-workspace *.wasm diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 1d3687f..f75d1e5 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/bin/sh -onyx -r js -V --use-post-mvp-features test/basic.onyx -o imgui.wasm \ No newline at end of file +onyx -r js -V --use-post-mvp-features test/basic.onyx -o imgui.wasm diff --git a/lib/gl/gl_utils.onyx b/lib/gl/gl_utils.onyx index beb5c16..2d0ddd7 100644 --- a/lib/gl/gl_utils.onyx +++ b/lib/gl/gl_utils.onyx @@ -27,7 +27,7 @@ Shader :: struct { vertex_shader, _ := compile_shader(vertex_source, gl.VERTEX_SHADER); fragment_shader, _ := compile_shader(fragment_source, gl.FRAGMENT_SHADER); - // @Robustness: Errors in linkning the program are ignored right now. + // @Robustness: Errors in linking the program are ignored right now. shader_program, _ := link_program(vertex_shader, fragment_shader); program = shader_program; diff --git a/lib/imgui.onyx b/lib/imgui.onyx index 7b8db6d..385f9b1 100644 --- a/lib/imgui.onyx +++ b/lib/imgui.onyx @@ -16,4 +16,6 @@ package imgui +#load "lib/gl/gl_utils" #load "lib/immediate_renderer" + diff --git a/lib/immediate_renderer.onyx b/lib/immediate_renderer.onyx index 2b7840d..5c3528d 100644 --- a/lib/immediate_renderer.onyx +++ b/lib/immediate_renderer.onyx @@ -58,6 +58,10 @@ Immediate_Renderer :: struct { verticies = memory.make_slice(Immediate_Vertex, max_verticies); } + // As a small note, I love the pattern matching style of programming that + // can be done in situtations like this. Now, this isn't the most efficient + // because it is mostly just marshalling the arguments around, but the + // pattern matching at compile-time is very cool, I think at least. push_vertex :: proc { // If a color is not provided, the previous color is used. (use ir: ^Immediate_Renderer, position: Vector2) { @@ -70,6 +74,7 @@ Immediate_Renderer :: struct { vertex_ptr.position = position; vertex_ptr.color = color; + vertex_ptr.texture = Vector2.{ 0, 0 }; }, } @@ -83,6 +88,11 @@ Immediate_Renderer :: struct { + +// While the immediate renderer can be used on its own, below is a set of wrapping functions +// that operate on a global immediate renderer. This is probably the most common way that +// it will be used. + #private immediate_renderer : Immediate_Renderer; diff --git a/onyx-imgui.sublime-project b/onyx-imgui.sublime-project index 21fd46a..b72505a 100644 --- a/onyx-imgui.sublime-project +++ b/onyx-imgui.sublime-project @@ -5,7 +5,7 @@ "path": "." }, { - "path": "C:\\dev\\onyx\\core" + "path": "/home/brendan/dev/c/onyx/core" } ] } diff --git a/test/basic.onyx b/test/basic.onyx index 1a1a32f..21b3825 100644 --- a/test/basic.onyx +++ b/test/basic.onyx @@ -31,13 +31,18 @@ update :: () { } draw :: () { + use imgui; + + immediate_vertex(.{ 0, 0 }, color=.{ 1, 0, 0, 1 }); + immediate_vertex(.{ 1, 0 }); + immediate_vertex(.{ 0, 1 }); } loop :: () { poll_events(); - //update(); - //draw(); + update(); + draw(); } main :: (args: [] cstr) {