fix core opengl ODIN_OS reference and pointer math stuff

This commit is contained in:
Joshua Mark Manton
2018-06-03 11:25:46 -07:00
parent f0a4526250
commit 2570296b01
+7 -6
View File
@@ -1,15 +1,16 @@
package opengl package opengl
when ODIN_OS == "windows" { import "core:os"
import "core:mem"
when os.OS == "windows" {
foreign import lib "system:opengl32.lib" foreign import lib "system:opengl32.lib"
import win32 "core:sys/win32" import win32 "core:sys/win32"
} else when ODIN_OS == "linux" { } else when os.OS == "linux" {
foreign import lib "system:gl" foreign import lib "system:gl"
} }
export "core:opengl_constants.odin" #assert(os.OS != "osx");
#assert(ODIN_OS != "osx");
@(default_calling_convention="c", link_prefix="gl") @(default_calling_convention="c", link_prefix="gl")
foreign lib { foreign lib {
@@ -48,7 +49,7 @@ get_gl_proc_address :: proc(name: string) -> rawptr {
name = name[..len(name)-1]; name = name[..len(name)-1];
} }
// NOTE(bill): null terminated // NOTE(bill): null terminated
assert((&name[0] + len(name))^ == 0); assert(mem.ptr_offset(&name[0], cast(uintptr)len(name))^ == 0);
res := win32.get_gl_proc_address(cstring(&name[0])); res := win32.get_gl_proc_address(cstring(&name[0]));
if res == nil { if res == nil {
res = win32.get_proc_address(_libgl, cstring(&name[0])); res = win32.get_proc_address(_libgl, cstring(&name[0]));