Browse Source

Merge pull request #2231 from ftphikari/master

sys/windows: fix wgl function loading in accordance with OpenGL wiki
Jeroen van Rijn 2 years ago
parent
commit
37ec3d7006
1 changed files with 8 additions and 1 deletions
  1. 8 1
      core/sys/windows/wgl.odin

+ 8 - 1
core/sys/windows/wgl.odin

@@ -87,6 +87,13 @@ foreign Opengl32 {
 }
 
 // Used by vendor:OpenGL
+// https://www.khronos.org/opengl/wiki/Load_OpenGL_Functions#Windows
 gl_set_proc_address :: proc(p: rawptr, name: cstring) {
-	(^rawptr)(p)^ = wglGetProcAddress(name)
+	func := wglGetProcAddress(name)
+	switch uintptr(func) {
+	case 0, 1, 2, 3, ~uintptr(0):
+		module := LoadLibraryW(L("opengl32.dll"))
+		func = GetProcAddress(module, name)
+	}
+	(^rawptr)(p)^ = func
 }