#include "img.h" #include "mem_arena.h" #include "mem_utils.h" #include "obj.h" #include "render.h" #include "shader.h" #include "shaders.h" #include #include #include #include #define SIZE 1200 #define RESOURCE(NAME) "resources/" NAME extern ShaderID perspective_phong; extern ShaderID perspective_albedo; extern ShaderID orthographic_phong; extern ShaderID orthographic_albedo; enum { TINY_EXIT_SUCCESS, TINY_EXIT_ARENA_INIT_FAILED, TINY_EXIT_RENDER_INIT_FAILED, TINY_EXIT_MODEL_LOAD_FAILED, }; int main(void) { Arena *arena = NULL; if (!wapp_mem_arena_init(&arena, 10ul * 1024ul * 1024ul * 1024ul, WAPP_MEM_ALLOC_RESERVE, false)) { return TINY_EXIT_ARENA_INIT_FAILED; } Colour bg = {.r = 42, .g = 45, .b = 52, .a = 255}; Colour teal = {.r = 14, .g = 156, .b = 208, .a = 255}; Render render; if (!init_render(arena, &render, SIZE, SIZE)) { return TINY_EXIT_RENDER_INIT_FAILED; } Model obj = load_obj_file(arena, RESOURCE("head.obj"), RESOURCE("head.pnm"), RESOURCE("head_nm.pnm")); if (IS_INVALID_MODEL(obj)) { return TINY_EXIT_MODEL_LOAD_FAILED; } load_shaders(); clear_buffer(&(render.img), &bg); render_model(&obj, &render, perspective_phong, RENDER_TYPE_SHADED, teal); save_image(&(render.img), "result.pam"); wapp_mem_arena_destroy(&arena); return TINY_EXIT_SUCCESS; }