Skip to content

Instantly share code, notes, and snippets.

@gingerBill
Last active October 13, 2019 13:34
Show Gist options
  • Save gingerBill/809f008ab1afe1b5463c4ec8b89c5362 to your computer and use it in GitHub Desktop.
Save gingerBill/809f008ab1afe1b5463c4ec8b89c5362 to your computer and use it in GitHub Desktop.
Odin package glfw
package glfw
import "core:fmt"
import "core:math"
import "core:mem"
when ODIN_OS == "linux" do foreign import glfw "system:glfw";
when ODIN_OS == "darwin" do foreign import glfw {
"macos/libglfw3.a",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
"system:CoreVideo.framework",
};
when ODIN_OS == "windows" do foreign import glfw "glfw3dll.lib";
/*** Structs/types ***/
Window :: opaque rawptr;
Monitor :: opaque rawptr;
Cursor :: opaque rawptr;
VidMode :: struct {
width: i32,
height: i32,
red_bits: i32,
green_bits: i32,
blue_bits: i32,
refresh_rate: i32,
};
GammaRamp :: struct {
red, green, blue: ^u16,
size: u32,
};
Image :: struct {
width, height: i32,
pixels: ^u8,
};
/*** Procedure type declarations ***/
WindowIconifyProc :: #type proc "c" (window: Window, iconified: b32);
WindowRefreshProc :: #type proc "c" (window: Window);
WindowFocusProc :: #type proc "c" (window: Window, focused: b32);
WindowCloseProc :: #type proc "c" (window: Window);
WindowSizeProc :: #type proc "c" (window: Window, width, height: i32);
WindowPosProc :: #type proc "c" (window: Window, xpos, ypos: i32);
FramebufferSizeProc :: #type proc "c" (window: Window, width, height: i32);
DropProc :: #type proc "c" (window: Window, count: i32, paths: ^cstring);
MonitorProc :: #type proc "c" (window: Window);
KeyProc :: #type proc "c" (window: Window, key, scancode, action: i32, mods: ModifierSet);
MouseButtonProc :: #type proc "c" (window: Window, button, action: i32, mods: ModifierSet);
CursorPosProc :: #type proc "c" (window: Window, xpos, ypos: f64);
ScrollProc :: #type proc "c" (window: Window, xoffset, yoffset: f64);
CharProc :: #type proc "c" (window: Window, codepoint: rune);
CharModsProc :: #type proc "c" (window: Window, codepoint: rune, mods: i32);
CursorEnterProc :: #type proc "c" (window: Window, entered: b32);
JoystickProc :: #type proc "c" (joy, event: i32);
ErrorProc :: #type proc "c" (error: i32, description: cstring);
/*** Functions ***/
@(default_calling_convention="c")
@(link_prefix="glfw")
foreign glfw {
Init :: proc() -> b32 ---
Terminate :: proc() ---
GetPrimaryMonitor :: proc() -> Monitor ---
GetVideoMode :: proc(monitor: Monitor) -> ^VidMode ---
SetGamma :: proc(monitor: Monitor, gamma: f32) ---
GetGammaRamp :: proc(monitor: Monitor) -> ^GammaRamp ---
SetGammaRamp :: proc(monitor: Monitor, ramp: ^GammaRamp) ---
DestroyWindow :: proc(window: Window) ---
WindowHint :: proc(hint, value: i32) ---
DefaultWindowHints :: proc() ---
WindowShouldClose :: proc(window: Window) -> b32 ---
SetWindowShouldClose :: proc(window: Window, value: b32) ---
SwapInterval :: proc(interval: b32) ---
SwapBuffers :: proc(window: Window) ---
SetWindowIcon :: proc(window: Window, count: i32, images: ^Image) ---
SetWindowPos :: proc(window: Window, xpos, ypos: i32) ---
SetWindowSizeLimits :: proc(window: Window, minwidth, minheight, maxwidth, maxheight: i32) ---
SetWindowAspectRatio :: proc(window: Window, numer, denom: i32) ---
SetWindowSize :: proc(window: Window, width, height: i32) ---
IconifyWindow :: proc(window: Window) ---
RestoreWindow :: proc(window: Window) ---
MaximizeWindow :: proc(window: Window) ---
ShowWindow :: proc(window: Window) ---
HideWindow :: proc(window: Window) ---
FocusWindow :: proc(window: Window) ---
GetWindowMonitor :: proc(window: Window) ---
SetWindowMonitor :: proc(window: Window, monitor: Monitor, xpos, ypos, width, height, refresh_rate: i32) ---
GetWindowAttrib :: proc(window: Window, attrib: i32) -> i32 ---
SetWindowUserPointer :: proc(window: Window, pointer: rawptr) ---
GetWindowUserPointer :: proc(window: Window) -> rawptr ---
PollEvents :: proc() ---
WaitEvents :: proc() ---
WaitEventsTimeout :: proc(timeout: f64) ---
PostEmptyEvent :: proc() ---
GetInputMode :: proc(window: Window, mode: i32) -> i32 ---
SetInputMode :: proc(window: Window, mode, value: i32) ---
GetMouseButton :: proc(window: Window, button: i32) -> b32 ---
SetCursorPos :: proc(window: Window, xpos, ypos: f64) ---
CreateCursor :: proc(image: ^Image, xhot, yhot: i32) -> Cursor ---
DestroyCursor :: proc(cursor: Cursor) ---
SetCursor :: proc(window: Window, cursor: Cursor) ---
CreateStandardCursor :: proc(shape: i32) -> Cursor ---
SetClipboardString :: proc(window: Window, str: cstring) ---
GetTime :: proc() -> f64 ---
SetTime :: proc(time: f64) ---
GetTimerValue :: proc() -> u64 ---
GetTimerFrequency :: proc() -> u64 ---
MakeContextCurrent :: proc(window: Window) ---
GetCurrentContext :: proc() -> Window ---
GetProcAddress :: proc(name: cstring) -> rawptr ---
ExtensionSupported :: proc(extension: cstring) -> b32 ---
SetWindowIconifyCallback :: proc(window: Window, cbfun: WindowIconifyProc) -> WindowIconifyProc ---
SetWindowRefreshCallback :: proc(window: Window, cbfun: WindowRefreshProc) -> WindowRefreshProc ---
SetWindowFocusCallback :: proc(window: Window, cbfun: WindowFocusProc) -> WindowFocusProc ---
SetWindowCloseCallback :: proc(window: Window, cbfun: WindowCloseProc) -> WindowCloseProc ---
SetWindowSizeCallback :: proc(window: Window, cbfun: WindowSizeProc) -> WindowSizeProc ---
SetWindowPosCallback :: proc(window: Window, cbfun: WindowPosProc) -> WindowPosProc ---
SetFramebufferSizeCallback :: proc(window: Window, cbfun: FramebufferSizeProc) -> FramebufferSizeProc ---
SetDropCallback :: proc(window: Window, cbfun: DropProc) -> DropProc ---
SetMonitorCallback :: proc(window: Window, cbfun: MonitorProc) -> MonitorProc ---
SetKeyCallback :: proc(window: Window, cbfun: KeyProc) -> KeyProc ---
SetMouseButtonCallback :: proc(window: Window, cbfun: MouseButtonProc) -> MouseButtonProc ---
SetCursorPosCallback :: proc(window: Window, cbfun: CursorPosProc) -> CursorPosProc ---
SetScrollCallback :: proc(window: Window, cbfun: ScrollProc) -> ScrollProc ---
SetCharCallback :: proc(window: Window, cbfun: CharProc) -> CharProc ---
SetCharModsCallback :: proc(window: Window, cbfun: CharModsProc) -> CharModsProc ---
SetCursorEnterCallback :: proc(window: Window, cbfun: CursorEnterProc) -> CursorEnterProc ---
SetJoystickCallback :: proc(window: Window, cbfun: JoystickProc) -> JoystickProc ---
SetErrorCallback :: proc(cbfun: ErrorProc) -> ErrorProc ---
GetKey :: proc(window: Window, key: i32) -> b32 ---
JoystickPresent :: proc(joy: i32) -> b32 ---
VulkanSupported :: proc() -> b32 ---
}
// Odin Wrappers
GetVersion :: proc() -> (major, minor, rev: i32) {
foreign glfw {
glfwGetVersion :: proc "c" (major, minor, rev: ^i32) ---
}
glfwGetVersion(&major, &minor, &rev);
return major, minor, rev;
}
GetVersionString :: proc() -> string {
foreign glfw {
glfwGetVersionString :: proc "c" () -> cstring ---
}
return string(glfwGetVersionString());
}
GetMonitors :: proc() -> []Monitor {
foreign glfw {
glfwGetMonitors :: proc "c" (count: ^i32) -> ^Monitor ---
}
count: i32;
data := glfwGetMonitors(&count);
return mem.slice_ptr(data, int(count));
}
GetMonitorPos :: proc(monitor: Monitor) -> (xpos, ypos: i32) {
foreign glfw {
glfwGetMonitorPos :: proc "c" (monitor: Monitor, xpos, ypos: ^i32) ---
}
glfwGetMonitorPos(monitor, &xpos, &ypos);
return xpos, ypos;
}
GetMonitorPhysicalSize :: proc(monitor: Monitor) -> (widthMM, heightMM: i32) {
foreign glfw {
glfwGetMonitorPhysicalSize :: proc "c" (monitor: Monitor, widthMM, heightMM: ^i32) ---
}
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
return widthMM, heightMM;
}
GetMonitorName :: proc(monitor: Monitor) -> string {
foreign glfw {
glfwGetMonitorName :: proc "c" (monitor: Monitor) -> cstring ---
}
return string(glfwGetMonitorName(monitor));
}
CreateWindow :: inline proc(width, height: i32, title: string, monitor: Monitor = nil, share: Window = nil) -> Window {
foreign glfw {
glfwCreateWindow :: proc "c" (width, height: i32, title: cstring, monitor: Monitor, share: Window) -> Window ---
}
title := fmt.tprint(title, "\x00");
ctitle := cstring(&title[0]);
return glfwCreateWindow(width, height, ctitle, monitor, share);
}
GetClipboardString :: proc(window: Window) -> string {
foreign glfw {
glfwGetClipboardString :: proc "c" (window: Window) -> cstring ---
}
return string(glfwGetClipboardString(window));
}
GetVideoModes :: proc(monitor: Monitor) -> []VidMode {
foreign glfw {
glfwGetVideoModes :: proc "c" (monitor: Monitor, count: ^i32) -> ^VidMode ---
}
count: i32;
data := glfwGetVideoModes(monitor, &count);
return mem.slice_ptr(data, int(count));
}
GetCurrentMonitor :: proc(window: Window) -> Monitor {
wx, wy := GetWindowPos(window);
ww, wh := GetWindowSize(window);
monitors := GetMonitors();
best_overlap: i32 = 0;
best_monitor: Monitor;
for monitor in monitors {
mode := GetVideoMode(monitor);
mx, my := GetMonitorPos(monitor);
mw, mh := mode.width, mode.height;
overlap := max(0, min(wx + ww, mx + mw) - max(wx, mx)) *
max(0, min(wy + wh, my + mh) - max(wy, my));
if (best_overlap < overlap) {
best_overlap = overlap;
best_monitor = monitor;
}
}
return best_monitor;
}
GetKeyName :: proc(key, scancode: i32) -> string {
foreign glfw {
glfwGetKeyName :: proc "c" (key, scancode: i32) -> cstring ---
}
return string(glfwGetKeyName(key, scancode));
}
GetCursorPos :: proc(window: Window) -> (xpos, ypos: f64) {
foreign glfw {
glfwGetCursorPos :: proc "c" (window: Window, xpos, ypos: ^f64) ---
}
glfwGetCursorPos(window, &xpos, &ypos);
return xpos, ypos;
}
SetWindowTitle :: proc(window: Window, fmt_string: string, args: ..any) {
foreign glfw {
glfwSetWindowTitle :: proc "c" (window: Window, title: cstring) ---
}
title := fmt.tprintf(fmt_string, ..args);
if len(title) > 0 {
glfwSetWindowTitle(window, cstring(&title[0]));
} else {
glfwSetWindowTitle(window, "");
}
}
GetWindowPos :: proc(window: Window) -> (xpos, ypos: i32) {
foreign glfw {
glfwGetWindowPos :: proc "c" (window: Window, xpos, ypos: ^i32) ---
}
glfwGetWindowPos(window, &xpos, &ypos);
return xpos, ypos;
}
GetWindowSize :: proc(window: Window) -> (width, height: i32) {
foreign glfw {
glfwGetWindowSize :: proc "c" (window: Window, width, height: ^i32) ---
}
glfwGetWindowSize(window, &width, &height);
return width, height;
}
GetFramebufferSize :: proc(window: Window) -> (width, height: i32) {
foreign glfw {
glfwGetFramebufferSize :: proc "c" (window: Window, width, height: ^i32) ---
}
glfwGetFramebufferSize(window, &width, &height);
return width, height;
}
GetWindowFrameSize :: proc(window: Window) -> (left, top, right, bottom: i32) {
foreign glfw {
glfwGetWindowFrameSize :: proc "c" (window: Window, left, top, right, bottom: ^i32) ---
}
glfwGetWindowFrameSize(window, &left, &top, &right, &bottom);
return left, top, right, bottom;
}
GetJoystickAxes :: proc(joy: i32) -> []f32 {
foreign glfw {
glfwGetJoystickAxes :: proc "c" (joy: i32, count: ^i32) -> ^f32 ---
}
count: i32;
data := glfwGetJoystickAxes(joy, &count);
return mem.slice_ptr(data, int(count));
}
GetJoystickButtons :: proc(joy: i32) -> []u8 {
foreign glfw {
glfwGetJoystickButtons :: proc "c" (joy: i32, count: ^i32) -> ^u8 ---
}
count: i32;
data := glfwGetJoystickButtons(joy, &count);
return mem.slice_ptr(data, int(count));
}
GetJoystickName :: proc(joy: i32) -> string {
foreign glfw {
glfwGetJoystickName :: proc "c" (joy: i32) -> cstring ---
}
return string(glfwGetJoystickName(joy));
}
GetRequiredInstanceExtensions :: proc() -> []cstring {
foreign glfw {
glfwGetRequiredInstanceExtensions :: proc "c" (count: ^u32) -> ^cstring ---
}
count: u32;
data := glfwGetRequiredInstanceExtensions(&count);
return mem.slice_ptr(data, int(count));
}
calculate_frame_timings :: proc(window: Window, title_prefix: string) {
@static persistent_timing_data := struct {
t1, avg_dt, avg_dt2, last_frame_time: f64,
num_samples, counter: int,
}{0.0, 0.0, 0.0, 1.0/60, 60, 0};
using persistent_timing_data;
t2 := GetTime();
dt := t2-t1;
t1 = t2;
avg_dt += dt;
avg_dt2 += dt*dt;
counter += 1;
last_frame_time = dt;
if counter == num_samples {
avg_dt /= f64(num_samples);
avg_dt2 /= f64(num_samples);
std_dt := math.sqrt(avg_dt2 - avg_dt*avg_dt);
ste_dt := std_dt/math.sqrt(f64(num_samples));
// if title_prefix != "" {
// SetWindowTitle(window, "%s - frame timings: avg = %.3fms, std = %.3fms, ste = %.4fms. fps = %.1f\x00", title_prefix, 1e3*avg_dt, 1e3*std_dt, 1e3*ste_dt, 1.0/avg_dt);
// } else {
// SetWindowTitle(window, "frame timings: avg = %.3fms, std = %.3fms, ste = %.4fms. fps = %.1f\x00", 1e3*avg_dt, 1e3*std_dt, 1e3*ste_dt, 1.0/avg_dt);
// }
num_samples = int(1.0/avg_dt);
avg_dt = 0.0;
avg_dt2 = 0.0;
counter = 0;
}
}
set_proc_address :: proc(p: rawptr, name: cstring) {
foreign glfw {
glfwGetProcAddress :: proc "c" (name: cstring) -> rawptr ---
}
(^rawptr)(p)^ = GetProcAddress(name);
}
/*** Constants ***/
/* Versions */
VERSION_MAJOR :: 3;
VERSION_MINOR :: 2;
VERSION_REVISION :: 1;
/* Button/Key states */
RELEASE :: 0;
PRESS :: 1;
REPEAT :: 2;
/* The unknown key */
KEY_UNKNOWN :: -1;
/** Printable keys **/
/* Named printable keys */
KEY_SPACE :: 32;
KEY_APOSTROPHE :: 39; /* ' */
KEY_COMMA :: 44; /* , */
KEY_MINUS :: 45; /* - */
KEY_PERIOD :: 46; /* . */
KEY_SLASH :: 47; /* / */
KEY_SEMICOLON :: 59; /* ; */
KEY_EQUAL :: 61; /* = */
KEY_LEFT_BRACKET :: 91; /* [ */
KEY_BACKSLASH :: 92; /* \ */
KEY_RIGHT_BRACKET :: 93; /* ] */
KEY_GRAVE_ACCENT :: 96; /* ` */
KEY_WORLD_1 :: 161; /* non-US #1 */
KEY_WORLD_2 :: 162; /* non-US #2 */
/* Alphanumeric characters */
KEY_0 :: 48;
KEY_1 :: 49;
KEY_2 :: 50;
KEY_3 :: 51;
KEY_4 :: 52;
KEY_5 :: 53;
KEY_6 :: 54;
KEY_7 :: 55;
KEY_8 :: 56;
KEY_9 :: 57;
KEY_A :: 65;
KEY_B :: 66;
KEY_C :: 67;
KEY_D :: 68;
KEY_E :: 69;
KEY_F :: 70;
KEY_G :: 71;
KEY_H :: 72;
KEY_I :: 73;
KEY_J :: 74;
KEY_K :: 75;
KEY_L :: 76;
KEY_M :: 77;
KEY_N :: 78;
KEY_O :: 79;
KEY_P :: 80;
KEY_Q :: 81;
KEY_R :: 82;
KEY_S :: 83;
KEY_T :: 84;
KEY_U :: 85;
KEY_V :: 86;
KEY_W :: 87;
KEY_X :: 88;
KEY_Y :: 89;
KEY_Z :: 90;
/** Function keys **/
/* Named non-printable keys */
KEY_ESCAPE :: 256;
KEY_ENTER :: 257;
KEY_TAB :: 258;
KEY_BACKSPACE :: 259;
KEY_INSERT :: 260;
KEY_DELETE :: 261;
KEY_RIGHT :: 262;
KEY_LEFT :: 263;
KEY_DOWN :: 264;
KEY_UP :: 265;
KEY_PAGE_UP :: 266;
KEY_PAGE_DOWN :: 267;
KEY_HOME :: 268;
KEY_END :: 269;
KEY_CAPS_LOCK :: 280;
KEY_SCROLL_LOCK :: 281;
KEY_NUM_LOCK :: 282;
KEY_PRINT_SCREEN :: 283;
KEY_PAUSE :: 284;
/* Function keys */
KEY_F1 :: 290;
KEY_F2 :: 291;
KEY_F3 :: 292;
KEY_F4 :: 293;
KEY_F5 :: 294;
KEY_F6 :: 295;
KEY_F7 :: 296;
KEY_F8 :: 297;
KEY_F9 :: 298;
KEY_F10 :: 299;
KEY_F11 :: 300;
KEY_F12 :: 301;
KEY_F13 :: 302;
KEY_F14 :: 303;
KEY_F15 :: 304;
KEY_F16 :: 305;
KEY_F17 :: 306;
KEY_F18 :: 307;
KEY_F19 :: 308;
KEY_F20 :: 309;
KEY_F21 :: 310;
KEY_F22 :: 311;
KEY_F23 :: 312;
KEY_F24 :: 313;
KEY_F25 :: 314;
/* Keypad numbers */
KEY_KP_0 :: 320;
KEY_KP_1 :: 321;
KEY_KP_2 :: 322;
KEY_KP_3 :: 323;
KEY_KP_4 :: 324;
KEY_KP_5 :: 325;
KEY_KP_6 :: 326;
KEY_KP_7 :: 327;
KEY_KP_8 :: 328;
KEY_KP_9 :: 329;
/* Keypad named function keys */
KEY_KP_DECIMAL :: 330;
KEY_KP_DIVIDE :: 331;
KEY_KP_MULTIPLY :: 332;
KEY_KP_SUBTRACT :: 333;
KEY_KP_ADD :: 334;
KEY_KP_ENTER :: 335;
KEY_KP_EQUAL :: 336;
/* Modifier keys */
KEY_LEFT_SHIFT :: 340;
KEY_LEFT_CONTROL :: 341;
KEY_LEFT_ALT :: 342;
KEY_LEFT_SUPER :: 343;
KEY_RIGHT_SHIFT :: 344;
KEY_RIGHT_CONTROL :: 345;
KEY_RIGHT_ALT :: 346;
KEY_RIGHT_SUPER :: 347;
KEY_MENU :: 348;
KEY_LAST :: KEY_MENU;
/* Bitmask for modifier keys */
Modifier :: enum i16 {
Shift = 0,
Control = 1,
Alt = 2,
Super = 3,
}
ModifierSet :: bit_set[Modifier; i32];
/* Mouse buttons */
MOUSE_BUTTON_1 :: 0;
MOUSE_BUTTON_2 :: 1;
MOUSE_BUTTON_3 :: 2;
MOUSE_BUTTON_4 :: 3;
MOUSE_BUTTON_5 :: 4;
MOUSE_BUTTON_6 :: 5;
MOUSE_BUTTON_7 :: 6;
MOUSE_BUTTON_8 :: 7;
/* Mousebutton aliases */
MOUSE_BUTTON_LAST :: MOUSE_BUTTON_8;
MOUSE_BUTTON_LEFT :: MOUSE_BUTTON_1;
MOUSE_BUTTON_RIGHT :: MOUSE_BUTTON_2;
MOUSE_BUTTON_MIDDLE :: MOUSE_BUTTON_3;
/* Joystick buttons */
JOYSTICK_1 :: 0;
JOYSTICK_2 :: 1;
JOYSTICK_3 :: 2;
JOYSTICK_4 :: 3;
JOYSTICK_5 :: 4;
JOYSTICK_6 :: 5;
JOYSTICK_7 :: 6;
JOYSTICK_8 :: 7;
JOYSTICK_9 :: 8;
JOYSTICK_10 :: 9;
JOYSTICK_11 :: 10;
JOYSTICK_12 :: 11;
JOYSTICK_13 :: 12;
JOYSTICK_14 :: 13;
JOYSTICK_15 :: 14;
JOYSTICK_16 :: 15;
JOYSTICK_LAST :: JOYSTICK_16;
/* Error constants */
NOT_INITIALIZED :: 0x00010001;
NO_CURRENT_CONTEXT :: 0x00010002;
INVALID_ENUM :: 0x00010003;
INVALID_VALUE :: 0x00010004;
OUT_OF_MEMORY :: 0x00010005;
API_UNAVAILABLE :: 0x00010006;
VERSION_UNAVAILABLE :: 0x00010007;
PLATFORM_ERROR :: 0x00010008;
FORMAT_UNAVAILABLE :: 0x00010009;
NO_WINDOW_CONTEXT :: 0x0001000A;
/* Window attributes */
FOCUSED :: 0x00020001;
ICONIFIED :: 0x00020002;
RESIZABLE :: 0x00020003;
VISIBLE :: 0x00020004;
DECORATED :: 0x00020005;
AUTO_ICONIFY :: 0x00020006;
FLOATING :: 0x00020007;
MAXIMIZED :: 0x00020008;
/* Pixel window attributes */
RED_BITS :: 0x00021001;
GREEN_BITS :: 0x00021002;
BLUE_BITS :: 0x00021003;
ALPHA_BITS :: 0x00021004;
DEPTH_BITS :: 0x00021005;
STENCIL_BITS :: 0x00021006;
ACCUM_RED_BITS :: 0x00021007;
ACCUM_GREEN_BITS :: 0x00021008;
ACCUM_BLUE_BITS :: 0x00021009;
ACCUM_ALPHA_BITS :: 0x0002100A;
AUX_BUFFERS :: 0x0002100B;
STEREO :: 0x0002100C;
SAMPLES :: 0x0002100D;
SRGB_CAPABLE :: 0x0002100E;
REFRESH_RATE :: 0x0002100F;
DOUBLEBUFFER :: 0x00021010;
/* Context window attributes */
CLIENT_API :: 0x00022001;
CONTEXT_VERSION_MAJOR :: 0x00022002;
CONTEXT_VERSION_MINOR :: 0x00022003;
CONTEXT_REVISION :: 0x00022004;
CONTEXT_ROBUSTNESS :: 0x00022005;
OPENGL_FORWARD_COMPAT :: 0x00022006;
OPENGL_DEBUG_CONTEXT :: 0x00022007;
OPENGL_PROFILE :: 0x00022008;
CONTEXT_RELEASE_BEHAVIOR :: 0x00022009;
CONTEXT_NO_ERROR :: 0x0002200A;
CONTEXT_CREATION_API :: 0x0002200B;
/* APIs */
NO_API :: 0;
OPENGL_API :: 0x00030001;
OPENGL_ES_API :: 0x00030002;
/* Robustness? */
NO_ROBUSTNESS :: 0;
NO_RESET_NOTIFICATION :: 0x00031001;
LOSE_CONTEXT_ON_RESET :: 0x00031002;
/* OpenGL Profiles */
OPENGL_ANY_PROFILE :: 0;
OPENGL_CORE_PROFILE :: 0x00032001;
OPENGL_COMPAT_PROFILE :: 0x00032002;
/* Cursor draw state and whether keys are sticky */
CURSOR :: 0x00033001;
STICKY_KEYS :: 0x00033002;
STICKY_MOUSE_BUTTONS :: 0x00033003;
/* Cursor draw state */
CURSOR_NORMAL :: 0x00034001;
CURSOR_HIDDEN :: 0x00034002;
CURSOR_DISABLED :: 0x00034003;
/* Behavior? */
ANY_RELEASE_BEHAVIOR :: 0;
RELEASE_BEHAVIOR_FLUSH :: 0x00035001;
RELEASE_BEHAVIOR_NONE :: 0x00035002;
/* Context API ? */
NATIVE_CONTEXT_API :: 0x00036001;
EGL_CONTEXT_API :: 0x00036002;
/* Types of cursors */
ARROW_CURSOR :: 0x00036001;
IBEAM_CURSOR :: 0x00036002;
CROSSHAIR_CURSOR :: 0x00036003;
HAND_CURSOR :: 0x00036004;
HRESIZE_CURSOR :: 0x00036005;
VRESIZE_CURSOR :: 0x00036006;
/* Joystick? */
CONNECTED :: 0x00040001;
DISCONNECTED :: 0x00040002;
/* */
DONT_CARE :: -1;
package glfw
import "core:sys/win32"
when ODIN_OS == "windows" do foreign import glfw "glfw3dll.lib";
@(default_calling_convention="c")
foreign glfw {
@(link_name="glfwGetWGLContext") GetWGLContext :: proc(window: Window) -> win32.Hglrc ---
@(link_name="glfwGetWin32Window") GetWin32Window :: proc(window: Window) -> win32.Hwnd ---
@(link_name="glfwGetWin32Monitor") GetWin32Monitor :: proc(window: Window) -> cstring ---
@(link_name="glfwGetWin32Adapter") GetWin32Adapter :: proc(window: Window) -> cstring ---
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment