diff options
-rw-r--r-- | examples/demo/demo.c | 22 | ||||
-rw-r--r-- | examples/obj_loading/ex_obj_loading.c | 22 | ||||
-rw-r--r-- | src/renderer/render_types.h | 34 | ||||
-rw-r--r-- | xmake.lua | 14 |
4 files changed, 90 insertions, 2 deletions
diff --git a/examples/demo/demo.c b/examples/demo/demo.c new file mode 100644 index 0000000..3b2354a --- /dev/null +++ b/examples/demo/demo.c @@ -0,0 +1,22 @@ +#include <glfw3.h> + +#include "core.h" +#include "render.h" + +int main() { + core* core = core_bringup(); + + // Main loop + while (!glfwWindowShouldClose(core->renderer.window)) { + input_update(&core->input); + threadpool_process_results(&core->threadpool, 1); + + render_frame_begin(&core->renderer); + + // insert work here + + render_frame_end(&core->renderer); + } + + return 0; +} diff --git a/examples/obj_loading/ex_obj_loading.c b/examples/obj_loading/ex_obj_loading.c new file mode 100644 index 0000000..3b2354a --- /dev/null +++ b/examples/obj_loading/ex_obj_loading.c @@ -0,0 +1,22 @@ +#include <glfw3.h> + +#include "core.h" +#include "render.h" + +int main() { + core* core = core_bringup(); + + // Main loop + while (!glfwWindowShouldClose(core->renderer.window)) { + input_update(&core->input); + threadpool_process_results(&core->threadpool, 1); + + render_frame_begin(&core->renderer); + + // insert work here + + render_frame_end(&core->renderer); + } + + return 0; +} diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h index e24fc24..f63f3f8 100644 --- a/src/renderer/render_types.h +++ b/src/renderer/render_types.h @@ -57,7 +57,7 @@ typedef struct mesh { u32 *indices; u32 indices_len; size_t material_index; - u32 vbo, vao; /** OpenGL data */ + u32 vbo, vao; /** OpenGL data. TODO: dont leak OpenGL details */ } mesh; #ifndef TYPED_MESH_ARRAY @@ -67,9 +67,39 @@ KITC_DECL_TYPED_ARRAY(mesh) // creates "mesh_darray" typedef struct model { str8 name; + mesh_darray meshes; + aabb_3d bbox; + // TODO: materials + bool is_loaded; + bool is_uploaded; } model; #ifndef TYPED_MODEL_ARRAY KITC_DECL_TYPED_ARRAY(model) // creates "model_darray" #define TYPED_MODEL_ARRAY -#endif
\ No newline at end of file +#endif + +// --- Graphics API related + +typedef enum cel_primitive_topology { + CEL_PRIMITIVE_TOPOLOGY_POINT, + CEL_PRIMITIVE_TOPOLOGY_LINE, + CEL_PRIMITIVE_TOPOLOGY_LINE_STRIP, + CEL_PRIMITIVE_TOPOLOGY_TRIANGLE, + CEL_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, + CEL_PRIMITIVE_TOPOLOGY_COUNT +} cel_primitive_topology; + +typedef enum gpu_texture_type { + TEXTURE_TYPE_2D, + TEXTURE_TYPE_3D, + TEXTURE_TYPE_2D_ARRAY, + TEXTURE_TYPE_CUBE_MAP, + TEXTURE_TYPE_COUNT +} gpu_texture_type; + +typedef enum gpu_texture_format { + TEXTURE_FORMAT_8_8_8_8_RGBA_UNORM, + TEXTURE_FORMAT_DEPTH_DEFAULT, + TEXTURE_FORMAT_COUNT +} gpu_texture_format;
\ No newline at end of file @@ -94,4 +94,18 @@ target("std") set_group("examples") add_deps("core_static") add_files("examples/standard_lib/ex_std.c") + set_rundir("$(projectdir)") + +target("obj_loading") + set_kind("binary") + set_group("examples") + add_deps("core_static") + add_files("examples/obj_loading/ex_obj_loading.c") + set_rundir("$(projectdir)") + +target("demo") + set_kind("binary") + set_group("examples") + add_deps("core_static") + add_files("examples/demo/demo.c") set_rundir("$(projectdir)")
\ No newline at end of file |