From e4b918b38407401d2129b01b3271b2df00136e7b Mon Sep 17 00:00:00 2001 From: Alberto Torres Date: Wed, 4 Sep 2024 02:44:26 +0200 Subject: [PATCH] Call `gladLoadGLES2` in mobile to properly detect supported extensions. --- src/platform/generic.nim | 4 ++++ src/platform/glfm_wrap.nim | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/platform/generic.nim b/src/platform/generic.nim index 83ea793..be693ba 100644 --- a/src/platform/generic.nim +++ b/src/platform/generic.nim @@ -103,6 +103,10 @@ proc init_graphics*(engine: MyouEngine, width, height: int32, title: string, let rev = opengl_version mod 10 assert major >= 3 + if not gladLoadGLES2(nil): + echo "Could not initialize OpenGL" + quit -1 + engine.renderer.enqueue proc()= when not defined(release) and not defined(emscripten): proc f(source: GLenum, etype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: cstring, userParam: pointer) {.stdcall.} = diff --git a/src/platform/glfm_wrap.nim b/src/platform/glfm_wrap.nim index 28ec0ef..d8b68a4 100644 --- a/src/platform/glfm_wrap.nim +++ b/src/platform/glfm_wrap.nim @@ -227,10 +227,14 @@ proc init_graphics*(engine: MyouEngine, width, height: int32, title: string, window.glfmSetSurfaceCreatedFunc proc(window: Window, w,h: cint) {.cdecl.} = # force resize window.screen = window.screen + if not gladLoadGLES2(nil): + echo "Could not initialize OpenGL" + quit -1 window.screen.engine.renderer.initialize() window.glfmSetSurfaceDestroyedFunc proc(window: Window) {.cdecl.} = window.screen.engine.renderer.uninitialize() + when not defined(release) and not defined(emscripten): proc f(source: GLenum, etype: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: cstring, userParam: pointer) {.stdcall.} =