diff options
| author | onelin <oscar@nelin.dk> | 2025-03-20 19:46:52 +0000 |
|---|---|---|
| committer | onelin <oscar@nelin.dk> | 2025-03-20 19:46:52 +0000 |
| commit | a44692ef4c0ac49f4b6330a1f53a7f26fb38b864 (patch) | |
| tree | 75d57ef5bcb7acbc9256947eea54287c73d12ee5 /src/rendering | |
| parent | c9728b92149943f1422283ebf9e8e3eef71a13e1 (diff) | |
Fix some warnings
Diffstat (limited to 'src/rendering')
| -rw-r--r-- | src/rendering/include/engine/rendering/window.h | 2 | ||||
| -rw-r--r-- | src/rendering/src/gl.c | 10 | ||||
| -rw-r--r-- | src/rendering/src/rendering.c | 17 | ||||
| -rw-r--r-- | src/rendering/src/window.c | 39 |
4 files changed, 35 insertions, 33 deletions
diff --git a/src/rendering/include/engine/rendering/window.h b/src/rendering/include/engine/rendering/window.h index fff7bc6..561afd6 100644 --- a/src/rendering/include/engine/rendering/window.h +++ b/src/rendering/include/engine/rendering/window.h @@ -41,7 +41,7 @@ Window* init_window_glfw(const char* windowtitle, ivec2 windowsize, const u32 fl void destroy_window(Window* w); // Renderer intializer(s) -void init_render_opengl(Window* w); +void init_render_opengl(Window* w, const u32 flags); void get_mousepos(double *x, double *y); diff --git a/src/rendering/src/gl.c b/src/rendering/src/gl.c index eec56e2..636c70f 100644 --- a/src/rendering/src/gl.c +++ b/src/rendering/src/gl.c @@ -56,7 +56,7 @@ Shader compile_shader(const char* file_path, const ShaderType shader_type) { LOG("CREATED SHADER ID %d", shaderID); if(file != NULL) { - const i64 size = f_get_sz(file); + const usize size = f_get_sz(file); source = calloc((usize)size + 1, sizeof(char)); @@ -240,11 +240,11 @@ RenderObject RenderObject_new( /* For each buffer in the shader, */ /* The shader should be generalied, */ for (usize i = 0; i < num_buffers; i++) { - const isize sz = buffers[i].size_elem * buffers[i].count; + const usize sz = buffers[i].size_elem * buffers[i].count; gl->GenBuffers(1, &(buffers[i].buffername)); gl->BindBuffer(GL_ARRAY_BUFFER, buffers[i].buffername); - gl->BufferData(GL_ARRAY_BUFFER, sz, buffers[i].data, GL_STATIC_DRAW); + gl->BufferData(GL_ARRAY_BUFFER, (isize)sz, buffers[i].data, GL_STATIC_DRAW); } o.shader = *shader; @@ -259,11 +259,7 @@ RenderObject RenderObject_new( return o; } -void RenderObject_generateBuffers(RenderObject *o) { -} - ShaderType guess_shadertype_from_filename(const char *restrict fname) { - u32 stype = 0; const usize path_len = strlen(fname); if (path_len <= 4) { diff --git a/src/rendering/src/rendering.c b/src/rendering/src/rendering.c index 81a9e11..f646297 100644 --- a/src/rendering/src/rendering.c +++ b/src/rendering/src/rendering.c @@ -51,10 +51,7 @@ int renderbatch_new(RenderBatch* renderbatch, usize count) { return -1; } - if (count < 0) { - ERROR("count must be a positive integer!"); - return -1; - } else if (count == 0) { + if (count == 0) { // Just allocate enough for a couple hundred count = 255; } @@ -235,7 +232,6 @@ void render_present(Window* w) { * this whole present GL specific? assign it as a fn ptr in the Window struct? */ GladGLContext *restrict gl = w->context; Camera c = *GLOBAL_PLATFORM->cam; - const f32 ratio = (float)w->windowsize[0] / (float)w->windowsize[1]; mat4 view; // view vec3 angle; // viewing angle / direction of the camera @@ -353,17 +349,6 @@ void r_set_camera(Camera* c) { GLOBAL_PLATFORM->cam = c; } -void engine_window_resize_pointers(i32* w, i32* h) { - //GLOBAL_PLATFORM->window->game_w = w; - GLOBAL_PLATFORM->window->windowsize[0] = *w; - GLOBAL_PLATFORM->window->windowsize[1] = *h; -} - -void engine_window_resize_pointers_reset(void) { - //GLOBAL_PLATFORM->window->game_w = NULL; - //GLOBAL_PLATFORM->window->game_h = NULL; -} - void engine_draw_sprite(Sprite* s, v2_i32* pos, f32 scale) { if (drawcall_len + 1 >= drawcall_limit) return; #ifdef _DEBUG diff --git a/src/rendering/src/window.c b/src/rendering/src/window.c index d1fdbc7..49ff332 100644 --- a/src/rendering/src/window.c +++ b/src/rendering/src/window.c @@ -34,15 +34,16 @@ void glfw_err_callback(int code, const char* description) { } void window_resize_callback(GLFWwindow* window, int width, int height) { + (void)width; (void)height; const GladGLContext* gl = GLOBAL_PLATFORM->window->context; glfwSwapBuffers(window); gl->Finish(); } void window_size_callback(GLFWwindow* window, int width, int height) { + (void)window; const GladGLContext* gl = GLOBAL_PLATFORM->window->context; Camera* c = GLOBAL_PLATFORM->cam; - glfwGetWindowSize(window, &width, &height); gl->Viewport(0,0, width, height); GLOBAL_PLATFORM->window->windowsize[0] = width; GLOBAL_PLATFORM->window->windowsize[1] = height; @@ -56,6 +57,7 @@ void window_size_callback(GLFWwindow* window, int width, int height) { } +/* This is very glfw specific */ GladGLContext* create_context(GLFWwindow *window) { glfwMakeContextCurrent(window); @@ -87,6 +89,9 @@ static inline u64 platform_get_time_usec(void) { } return (u64)(t.tv_sec * 1000000 + t.tv_nsec / 1000); } +#define DAW_WINDOW_VSYNC (1 << 0) +#define DAW_WINDOW_FULLSCREEN (1 << 1) +#define DAW_WINDOW_RESIZEABLE (1 << 2) Window* init_window_glfw( const char* windowtitle, ivec2 windowsize, @@ -109,7 +114,10 @@ Window* init_window_glfw( INFO_("initializing window..."); //glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); + if (!(flags & DAW_WINDOW_RESIZEABLE)) { + glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); + } + glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); glfwWindowHint(GLFW_FLOATING, GLFW_TRUE); @@ -128,8 +136,14 @@ Window* init_window_glfw( #endif /* "On Wayland specifically, you need to swap the buffers - * of a window for it to become visible." */ - window = glfwCreateWindow(windowsize[0], windowsize[1], windowtitle, NULL, NULL); + * once of a window for it to become visible." */ + { + GLFWmonitor* mon = NULL; + if (flags & DAW_WINDOW_FULLSCREEN) mon = glfwGetPrimaryMonitor(); + + window = glfwCreateWindow(windowsize[0], windowsize[1], windowtitle, mon, NULL); + } + if (window == NULL) { ERROR("Failed to create GLFW window!\n"); const char *desc; @@ -161,7 +175,7 @@ Window* init_window_glfw( } /* Initializes opengl using the window */ -void init_render_opengl(Window* w) { +void init_render_opengl(Window* w, const u32 flags) { if (w == NULL || w->window == NULL) { ERROR("Window is not initialized"); return; @@ -180,13 +194,22 @@ void init_render_opengl(Window* w) { // This is GLFW specific GladGLContext *ctx = create_context((GLFWwindow*)w->window); - ctx->Viewport(0, 0, w->windowsize[0], w->windowsize[1]); - if (ctx == NULL) { ERROR("Failed to create glad context"); exit(EXIT_FAILURE); } + if (w->framework == WINDOW_FRAMEWORK_GLFW) { + if (flags & DAW_WINDOW_VSYNC) { + glfwSwapInterval(1); + } else { + glfwSwapInterval(0); + } + + + ctx->Viewport(0, 0, w->windowsize[0], w->windowsize[1]); + } + #ifdef _DEBUG ctx->ClearColor((float)0x10 / 255.f, (float)0x0a / 255.f, (float)0x33 / 255.f, 0.f); #else @@ -198,8 +221,6 @@ void init_render_opengl(Window* w) { ctx->Enable(GL_DEPTH_TEST); ctx->DepthFunc(GL_LESS); - glfwSwapInterval(0); - w->context = ctx; w->renderer = WINDOW_RENDERER_OPENGL; } |
