Fix: OpenGL changes of Nuklear

This commit is contained in:
PedroEdiaz
2024-11-07 14:14:20 -06:00
parent 46869cbcde
commit 03796fdaff
3 changed files with 12 additions and 3 deletions

View File

@@ -4,10 +4,14 @@
void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b) void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b)
{ {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glClearColor((float)r / 0xff, (float)g / 0xff, (float)b / 0xff, 1.0); glClearColor((float)r / 0xff, (float)g / 0xff, (float)b / 0xff, 1.0);
} }
int init_context(void) { return glewInit(); } int init_context(void) { return glewInit(); }
void clean_context(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void clean_context(void)
{
/* This is important cos, Nuklear Disable DEPTH TEST */
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

View File

@@ -140,7 +140,7 @@ int main(void)
mlog("[GUI] Inicializando...\n"); mlog("[GUI] Inicializando...\n");
{ {
struct nk_font_atlas* atlas; struct nk_font_atlas* atlas;
context = nk_glfw3_init(&glfw, window, NK_GLFW3_INSTALL_CALLBACKS); context = nk_glfw3_init(&glfw, window, NK_GLFW3_DEFAULT );
nk_glfw3_font_stash_begin(&glfw, &atlas); nk_glfw3_font_stash_begin(&glfw, &atlas);
nk_glfw3_font_stash_end(&glfw); nk_glfw3_font_stash_end(&glfw);
} }

View File

@@ -72,8 +72,13 @@ window_t init_window(unsigned int width, unsigned int height, const char *title)
void use_window(window_t window) { glfwMakeContextCurrent((void *)window); } void use_window(window_t window) { glfwMakeContextCurrent((void *)window); }
extern int window_width, window_height;
int is_open_window(window_t window) int is_open_window(window_t window)
{ {
/* Restore window proportions if Nuklear breaks it */
__window_callback_input((GLFWwindow *)window, window_width, window_height);
glfwSwapBuffers((void *)window); glfwSwapBuffers((void *)window);
glfwPollEvents(); glfwPollEvents();