From 2e2c57a8c04575eec164279a49947cfdba250853 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:15:22 +1000 Subject: scenes and pbr cleanup to handle missing texture of param --- src/new_render/render.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/new_render/render.c') diff --git a/src/new_render/render.c b/src/new_render/render.c index cfe68d7..5202cd3 100644 --- a/src/new_render/render.c +++ b/src/new_render/render.c @@ -40,6 +40,7 @@ struct Renderer { // Text_Storage text; ResourcePools* resource_pools; arena frame_arena; + TextureHandle white_1x1; }; Renderer* get_renderer() { return g_core.renderer; } @@ -62,6 +63,7 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window INFO("GLFWwindow pointer was provided!!!! Skipping generic glfw init.."); window = optional_window; } else { + INFO("No GLFWwindow provided - creating one"); // NOTE: all platforms use GLFW at the moment but thats subject to change glfwInit(); @@ -95,11 +97,11 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window ren->window = window; *out_window = window; - // glfwMakeContextCurrent(ren->window); + glfwMakeContextCurrent(ren->window); // FIXME // DEBUG("Set up GLFW window callbacks"); - // glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); + glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); // set the RAL backend up if (!GPU_Backend_Init(config.window_name, window, ren->resource_pools)) { @@ -126,6 +128,9 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window ren->terrain = malloc(sizeof(Terrain_Storage)); // Terrain_Init(ren->terrain); + // load default textures + ren->white_1x1 = TextureLoadFromFile("assets/textures/white1x1.png"); + return true; } @@ -273,4 +278,14 @@ Shadow_Storage* Render_GetShadowStorage() { Terrain_Storage* Render_GetTerrainStorage() { Renderer* ren = Core_GetRenderer(&g_core); return ren->terrain; +} + +TextureHandle Render_GetWhiteTexture() { + Renderer* ren = Core_GetRenderer(&g_core); + return ren->white_1x1; +} + +arena* Render_GetFrameArena() { + Renderer* ren = Core_GetRenderer(&g_core); + return &ren->frame_arena; } \ No newline at end of file -- cgit v1.2.3-70-g09d2