1. GLFW3 Wrapper Issue
- Posted by Lone_EverGreen_Ranger Jun 08, 2014
- 2596 views
Hello,
I have recently finished writing a wrapper for the GLFW3 library. However whenever I try to run the sample program I made with it, the window appears briefly, then disappears. I'm not sure why. I'll post my code below. If you need to see the wrapper's code I can post that as well.
without warning without type_check include std/machine.e include EuGLFW3.ew atom win glfwInit() win = glfwCreateWindow(640,480,"EuGLFW3",0,0) glfwMakeContextCurrent(win) while not glfwWindowShouldClose(win) do glfwSwapBuffers(win) glfwPollEvents() end while glfwDestroyWindow(win) glfwTerminate()
2. Re: GLFW3 Wrapper Issue
- Posted by ghaberek (admin) Jun 08, 2014
- 2537 views
You're not checking the result of glfwInit() like in the demo. I'm curious if that's the issue: maybe the library hasn't initialized properly.
/* Initialize the library */ if not glfwInit() then abort(-1) -- or crash()? end if
Or your while loop in actually exiting for some reason. Try tracing the code, or just outputting the result of glfwWindowShouldClose().
atom should_close while not should_close with entry do /* Render here */ /* Swap front and back buffers */ glfwSwapBuffers(window); /* Poll for and process events */ glfwPollEvents(); entry /* Loop until the user closes the window */ should_close = glfwWindowShouldClose(win) printf( 2, "should_close = %d\n", {should_close} ) end while
I would still be curious to see your wrapper code.
-Greg
3. Re: GLFW3 Wrapper Issue
- Posted by Lone_EverGreen_Ranger Jun 08, 2014
- 2682 views
I tried tracing as you did, but it still did the same thing. I'll post my wrapper code.
without warning without type_check include std/machine.e include std/dll.e atom glfw = open_dll("glfw3.dll") if glfw = -1 then puts(1,"Could not load glfw3.dll!\n") abort(1) end if public constant GLFW_VERSION_MAJOR = 3, GLFW_VERSION_MINOR = 0, GLFW_VERSION_REVISION = 4 public constant GLFW_RELEASE = 0, GLFW_PRESS = 1, GLFW_REPEAT = 2 public constant GLFW_KEY_UNKNOWN = -1, GLFW_KEY_SPACE = 32, GLFW_KEY_APOSTROPHE = 39, GLFW_KEY_COMMA = 44, GLFW_KEY_MINUS = 45, GLFW_KEY_PERIOD = 46, GLFW_KEY_SLASH = 47, GLFW_KEY_0 = 48, GLFW_KEY_1 = 49, GLFW_KEY_2 = 50, GLFW_KEY_3 = 51, GLFW_KEY_4 = 52, GLFW_KEY_5 = 53, GLFW_KEY_6 = 54, GLFW_KEY_7 = 55, GLFW_KEY_8 = 56, GLFW_KEY_9 = 57, GLFW_KEY_SEMICOLON = 59, GLFW_KEY_EQUAL = 61, GLFW_KEY_A = 65, GLFW_KEY_B = 66, GLFW_KEY_C = 67, GLFW_KEY_D = 68, GLFW_KEY_E = 69, GLFW_KEY_F = 70, GLFW_KEY_G = 71, GLFW_KEY_H = 72, GLFW_KEY_I = 73, GLFW_KEY_J = 74, GLFW_KEY_K = 75, GLFW_KEY_L = 76, GLFW_KEY_M = 77, GLFW_KEY_N = 78, GLFW_KEY_O = 79, GLFW_KEY_P = 80, GLFW_KEY_Q = 81, GLFW_KEY_R = 82, GLFW_KEY_S = 83, GLFW_KEY_T = 84, GLFW_KEY_U = 85, GLFW_KEY_V = 86, GLFW_KEY_W = 87, GLFW_KEY_X = 88, GLFW_KEY_Y = 89, GLFW_KEY_Z = 90, GLFW_KEY_LEFT_BRACKET = 91, GLFW_KEY_BACKSLASH = 92, GLFW_KEY_RIGHT_BRACKET = 93, GLFW_KEY_GRAVE_ACCENT = 96, GLFW_KEY_WORLD_1 = 161, GLFW_KEY_WORLD_2 = 162 public constant GLFW_KEY_ESCAPE = 256, GLFW_KEY_ENTER = 257, GLFW_KEY_TAB = 258, GLFW_KEY_BACKSPACE = 259, GLFW_KEY_INSERT = 260, GLFW_KEY_DELETE = 261, GLFW_KEY_RIGHT = 262, GLFW_KEY_LEFT = 263, GLFW_KEY_DOWN = 264, GLFW_KEY_UP = 265, GLFW_KEY_PAGE_UP = 266, GLFW_KEY_PAGE_DOWN = 267, GLFW_KEY_HOME = 268, GLFW_KEY_END = 269, GLFW_KEY_CAPS_LOCK = 280, GLFW_KEY_SCROLL_LOCK = 281, GLFW_KEY_NUM_LOCK = 282, GLFW_KEY_PRINT_SCREEN = 283, GLFW_KEY_PAUSE = 284, GLFW_KEY_F1 = 290, GLFW_KEY_F2 = 291, GLFW_KEY_F3 = 292, GLFW_KEY_F4 = 293, GLFW_KEY_F5 = 294, GLFW_KEY_F6 = 295, GLFW_KEY_F7 = 296, GLFW_KEY_F8 = 297, GLFW_KEY_F9 = 298, GLFW_KEY_F10 = 299, GLFW_KEY_F11 = 300, GLFW_KEY_F12 = 301, GLFW_KEY_F13 = 302, GLFW_KEY_F14 = 303, GLFW_KEY_F15 = 304, GLFW_KEY_F16 = 305, GLFW_KEY_F17 = 306, GLFW_KEY_F18 = 307, GLFW_KEY_F19 = 308, GLFW_KEY_F20 = 309, GLFW_KEY_F21 = 310, GLFW_KEY_F22 = 311, GLFW_KEY_F23 = 312, GLFW_KEY_F24 = 313, GLFW_KEY_F25 = 314, GLFW_KEY_F26 = 315, GLFW_KEY_F27 = 316, GLFW_KEY_F28 = 317, GLFW_KEY_KP_0 = 320, GLFW_KEY_KP_1 = 321, GLFW_KEY_KP_2 = 322, GLFW_KEY_KP_3 = 323, GLFW_KEY_KP_4 = 324, GLFW_KEY_KP_5 = 325, GLFW_KEY_KP_6 = 326, GLFW_KEY_KP_7 = 327, GLFW_KEY_KP_8 = 328, GLFW_KEY_KP_9 = 329, GLFW_KEY_KP_DECIMAL = 330, GLFW_KEY_KP_DIVIDE = 331, GLFW_KEY_KP_MULTIPLY = 332, GLFW_KEY_KP_SUBTRACT = 333, GLFW_KEY_KP_ADD = 334, GLFW_KEY_KP_ENTER = 335, GLFW_KEY_KP_EQUAL = 336, GLFW_KEY_LEFT_SHIFT = 340, GLFW_KEY_LEFT_CONTROL = 341, GLFW_KEY_LEFT_ALT = 342, GLFW_KEY_LEFT_SUPER = 343, GLFW_KEY_RIGHT_SHIFT = 344, GLFW_KEY_RIGHT_CONTROL = 345, GLFW_KEY_RIGHT_ALT = 346, GLFW_KEY_RIGHT_SUPER = 347, GLFW_KEY_MENU = 348, GLFW_KEY_LAST = GLFW_KEY_MENU public constant GLFW_MOD_SHIFT = 1, GLFW_MOD_CONTROL = 2, GLFW_MOD_ALT = 4, GLFW_MOD_SUPER = 8 public constant GLFW_MOUSE_BUTTON_1 = 0, GLFW_MOUSE_BUTTON_2 = 1, GLFW_MOUSE_BUTTON_3 = 2, GLFW_MOUSE_BUTTON_4 = 3, GLFW_MOUSE_BUTTON_5 = 4, GLFW_MOUSE_BUTTON_6 = 5, GLFW_MOUSE_BUTTON_7 = 6, GLFW_MOUSE_BUTTON_8 = 7, GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8, GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1, GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2, GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3 public constant GLFW_JOYSTICK_1 = 0, GLFW_JOYSTICK_2 = 1, GLFW_JOYSTICK_3 = 2, GLFW_JOYSTICK_4 = 3, GLFW_JOYSTICK_5 = 4, GLFW_JOYSTICK_6 = 5, GLFW_JOYSTICK_7 = 6, GLFW_JOYSTICK_8 = 7, GLFW_JOYSTICK_9 = 8, GLFW_JOYSTICK_10 = 9, GLFW_JOYSTICK_11 = 10, GLFW_JOYSTICK_12 = 11, GLFW_JOYSTICK_13 = 12, GLFW_JOYSTICK_14 = 13, GLFW_JOYSTICK_15 = 14, GLFW_JOYSTICK_16 = 15, GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16 public constant GLFW_NOT_INITIALIZED = 65537, GLFW_NO_CURRENT_CONTEXT = 65538, GLFW_INVALID_ENUM = 65539, GLFW_INVALID_VALUE = 65540, GLFW_OUT_OF_MEMORY = 65541, GLFW_API_UNAVAILABLE = 65542, GLFW_VERSION_UNAVAILABLE = 65543, GLFW_PLATFORM_ERROR = 65544, GLFW_FORMAT_UNAVAILABLE = 65545 public constant GLFW_FOCUSED = 131073, GLFW_ICONIFIED = 131074, GLFW_RESIZABLE = 131075, GLFW_VISIBLE = 131076, GLFW_DECORATED = 131077 public constant GLFW_RED_BITS = 135169, GLFW_GREEN_BITS = 135170, GLFW_BLUE_BITS = 135171, GLFW_ALPHA_BITS = 135172, GLFW_DEPTH_BITS = 135173, GLFW_STENCIL_BITS = 135174, GLFW_ACCUM_RED_BITS = 1315175, GLFW_ACCUM_GREEN_BITS = 1315176, GLFW_ACCUM_BLUE_BITS = 131577, GLFW_ACCUM_ALPHA_BITS = 131578, GLFW_AUX_BUFFERs = 131579, GLFW_STEREO = 131580, GLFW_SAMPLES = 131581, GLFW_SRGB_CAPABLE = 131582, GLFW_REFRESH_RATE = 131583 public constant GLFW_CLIENT_API = 139265, GLFW_CONTEXT_VERSION_MAJOR = 139266, GLFW_CONTEXT_VERSION_MINOR = 139267, GLFW_CONTEXT_REVISION = 139268, GLFW_CONTEXT_ROBUSTNESS = 139269, GLFW_OPENGL_FORWARD_COMPAT = 139270, GLFW_OPENGL_DEBUG_CONTEXT = 139271, GLFW_OPENGL_PROFILE = 139272 public constant GLFW_OPENGL_API = 196609, GLFW_OPENGL_ES_API = 196610 public constant GLFW_NO_ROBUSTNESS = 0, GLFW_NO_RESET_NOTIFICATION = 200705, GLFW_LOSE_CONTEXT_ON_RESET = 200706 public constant GLFW_OPENGL_ANY_PROFILE = 0, GLFW_OPENGL_CORE_PROFILE = 204801, GLFW_OPENGL_COMPAT_PROFILE = 204802 public constant GLFW_CURSOR = 208897, GLFW_STICKY_KEYS = 208898, GLFW_STICKY_MOUSE_BUTTONS = 208899 public constant GLFW_CURSOR_NORMAL = 212993, GLFW_CURSOR_HIDDEN = 212994, GLFW_CURSOR_DISABLED = 212995 public constant GLFW_CONNECTED = 262145, GLFW_DISCONNECTED = 262146 public constant xglfwInit = define_c_func(glfw,"glfwInit",{},C_INT), xglfwTerminate = define_c_proc(glfw,"glfwTerminate",{}), xglfwGetVersion = define_c_proc(glfw,"glfwGetVersion",{C_POINTER,C_POINTER,C_POINTER}), xglfwGetVersionString = define_c_func(glfw,"glfwGetVersionString",{},C_POINTER) public function glfwInit() return c_func(xglfwInit,{}) end function public procedure glfwTerminate() c_proc(xglfwTerminate,{}) end procedure public procedure glfwGetVersion(atom maj,atom min,atom rev) c_proc(xglfwGetVersion,{maj,min,rev}) end procedure public function glfwGerVersionString() return c_func(xglfwGetVersionString,{}) end function public constant xglfwDefaultWindowHints = define_c_proc(glfw,"glfwDefaultWindowHints",{}), xglfwWindowHint = define_c_proc(glfw,"glfwWindowHint",{C_INT,C_INT}), xglfwCreateWindow = define_c_func(glfw,"glfwCreateWindow",{C_INT,C_INT,C_POINTER,C_POINTER,C_POINTER},C_POINTER), xglfwDestroyWindow = define_c_proc(glfw,"glfwDestroyWindow",{C_POINTER}), xglfwWindowShouldClose = define_c_func(glfw,"glfwWindowShouldClose",{C_POINTER},C_INT), xglfwSetWindowShouldClose = define_c_proc(glfw,"glfwSetWindowShouldClose",{C_POINTER,C_INT}), xglfwSetWindowTitle = define_c_proc(glfw,"glfwSetWindowTitle",{C_POINTER,C_POINTER}), xglfwGetWindowPos = define_c_proc(glfw,"glfwGetWindowPos",{C_POINTER,C_POINTER,C_POINTER}), xglfwSetWindowPos = define_c_proc(glfw,"glfwSetWindowPos",{C_POINTER,C_INT,C_INT}), xglfwGetWindowSize = define_c_proc(glfw,"glfwGetWindowSize",{C_POINTER,C_POINTER,C_POINTER}), xglfwSetWindowSize = define_c_proc(glfw,"glfwSetWindowSize",{C_POINTER,C_INT,C_INT}), xglfwGetFramebufferSize = define_c_proc(glfw,"glfwGetFramebufferSize",{C_POINTER,C_POINTER,C_POINTER}), xglfwIconifyWindow = define_c_proc(glfw,"glfwIconifyWindow",{C_POINTER}), xglfwRestoreWindow = define_c_proc(glfw,"glfwRestoreWindow",{C_POINTER}), xglfwShowWindow = define_c_proc(glfw,"glfwShowWindow",{C_POINTER}), xglfwHideWindow = define_c_proc(glfw,"glfwHideWindow",{C_POINTER}), xglfwGetWindowMonitor = define_c_func(glfw,"glfwGetWindowMonitor",{C_POINTER},C_POINTER), xglfwGetWindowAttrib = define_c_func(glfw,"glfwGetWindowAttrib",{C_POINTER,C_INT},C_INT), xglfwSetWindowUserPointer = define_c_proc(glfw,"glfwSetWindowUserPointer",{C_POINTER,C_POINTER}), xglfwGetWindowUserPointer = define_c_proc(glfw,"glfwGetWindowUserPointer",{C_POINTER}), xglfwSetWindowPosCallback = define_c_func(glfw,"glfwSetWindowPosCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetWindowSizeCallback = define_c_func(glfw,"glfwSetWindowSizeCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetWindowCloseCallback = define_c_func(glfw,"glfwSetWindowCloseCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetWindowRefreshCallback = define_c_func(glfw,"glfwSetWindowRefreshCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetWindowFocusCallback = define_c_func(glfw,"glfwSetWindowFocusCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetWindowIconifyCallback = define_c_func(glfw,"glfwSetWindowIconifyCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetFramebufferSizeCallback = define_c_func(glfw,"glfwSetFramebufferSizeCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwPollEvents = define_c_proc(glfw,"glfwPollEvents",{}), xglfwWaitEvents = define_c_proc(glfw,"glfwWaitEvents",{}) public function glfwCreateWindow(integer w,integer h,sequence title,atom mon,atom win) atom str str = allocate_string(title) return c_func(xglfwCreateWindow,{w,h,str,mon,win}) end function public procedure glfwDefaultWindowHints() c_proc(xglfwDefaultWindowHints,{}) end procedure public procedure glfwDestroyWindow(atom win) c_proc(xglfwDestroyWindow,{win}) end procedure public procedure glfwGetFramebufferSize(atom win,atom w,atom h) c_proc(xglfwGetFramebufferSize,{win,w,h}) end procedure public function glfwGetWindowAttrib(atom win,atom att) return c_func(xglfwGetWindowAttrib,{win,att}) end function public function glfwGetWindowMonitor(atom win) return c_func(xglfwGetWindowMonitor,{win}) end function public procedure glfwGetWindowPos(atom win,atom x,atom y) c_proc(xglfwGetWindowPos,{win,x,y}) end procedure public procedure glfwGetWindowSize(atom win,atom w,atom h) c_proc(xglfwGetWindowSize,{win,w,h}) end procedure public procedure glfwGetWindowUserPointer(atom win) c_proc(xglfwGetWindowUserPointer,{win}) end procedure public procedure glfwHideWindow(atom win) c_proc(xglfwHideWindow,{win}) end procedure public procedure glfwIconifyWindow(atom win) c_proc(xglfwIconifyWindow,{win}) end procedure public procedure glfwPollEvents() c_proc(xglfwPollEvents,{}) end procedure public procedure glfwRestoreWindow(atom win) c_proc(xglfwRestoreWindow,{win}) end procedure public function glfwSetFramebufferSizeCallback(atom win,atom fun) return c_func(xglfwSetFramebufferSizeCallback,{win,fun}) end function public function glfwSetWindowCloseCallback(atom win,atom fun) return c_func(xglfwSetWindowCloseCallback,{win,fun}) end function public function glfwSetWindowFocusCallback(atom win,atom fun) return c_func(xglfwSetWindowFocusCallback,{win,fun}) end function public function glfwSetWindowIconifyCallback(atom win,atom fun) return c_func(xglfwSetWindowIconifyCallback,{win,fun}) end function public procedure glfwSetWindowPos(atom win,atom x,atom y) c_proc(xglfwSetWindowPos,{win,x,y}) end procedure public function glfwSetWindowPosCallback(atom win,atom fun) return c_func(xglfwSetWindowPosCallback,{win,fun}) end function public function glfwSetWindowRefreshCallback(atom win,atom fun) return c_func(xglfwSetWindowRefreshCallback,{win,fun}) end function public procedure glfwSetWindowShouldClose(atom win,atom val) c_proc(xglfwSetWindowShouldClose,{win,val}) end procedure public procedure glfwSetWindowSize(atom win,atom w,atom h) c_proc(xglfwSetWindowSize,{win,w,h}) end procedure public function glfwSetWindowSizeCallback(atom win,atom fun) return c_func(xglfwSetWindowSizeCallback,{win,fun}) end function public procedure glfwSetWindowTitle(atom win,sequence title) atom str str = allocate_string(title) c_proc(xglfwSetWindowTitle,{win,str}) end procedure public procedure glfwSetWindowUserPointer(atom win,atom ptr) c_proc(xglfwSetWindowUserPointer,{win,ptr}) end procedure public procedure glfwShowWindow(atom win) c_proc(xglfwShowWindow,{win}) end procedure public procedure glfwWaitEvents() c_proc(xglfwWaitEvents,{}) end procedure public procedure glfwWindowHint(atom tar,atom hin) c_proc(xglfwWindowHint,{tar,hin}) end procedure public function glfwWindowShouldClose(atom win) return c_func(xglfwWindowShouldClose,{win}) end function public constant xglfwGetClipboardString = define_c_func(glfw,"glfwGetClipboardString",{C_POINTER},C_POINTER), xglfwSetClipboardString = define_c_proc(glfw,"glfwSetClipboardString",{C_POINTER,C_POINTER}) public function glfwGetClipboardString(atom win) return c_func(xglfwGetClipboardString,{win}) end function public procedure glfwSetClipboardString(atom win,sequence title) atom str str = allocate_string(title) c_proc(xglfwSetClipboardString,{win,str}) end procedure public constant xglfwMakeContextCurrent = define_c_proc(glfw,"glfwMakeContextCurrent",{C_POINTER}), xglfwGetCurrentContext = define_c_func(glfw,"glfwGetCurrentContext",{},C_POINTER), xglfwSwapBuffers = define_c_proc(glfw,"glfwSwapBuffers",{C_POINTER}), xglfwSwapInterval = define_c_proc(glfw,"glfwSwapInterval",{C_INT}), xglfwExtensionSupported = define_c_func(glfw,"glfwExtensionSupported",{C_POINTER},C_INT), xglfwGetProcAddress = define_c_func(glfw,"glfwGetProcAddress",{C_POINTER},C_POINTER) public procedure glfwMakeContextCurrent(atom win) c_proc(xglfwMakeContextCurrent,{win}) end procedure public function glfwGetCurrentContext() return c_func(xglfwGetCurrentContext,{}) end function public procedure glfwSwapBuffers(atom win) c_proc(xglfwSwapBuffers,{win}) end procedure public procedure glfwSwapInterval(atom val) c_proc(xglfwSwapInterval,{val}) end procedure public function glfwExtensionSupported(sequence ext) atom str str = allocate_string(ext) return c_func(xglfwExtensionSupported,{str}) end function public function glfwGetProcAddress(sequence name) atom str str = allocate_string(name) return c_func(xglfwGetProcAddress,{name}) end function public constant xglfwSetErrorCallback = define_c_func(glfw,"glfwSetErrorCallback",{C_POINTER},C_POINTER) public function glfwSetErrorCallback(atom fun) return c_func(xglfwSetErrorCallback,{fun}) end function public constant xglfwGetInputMode = define_c_func(glfw,"glfwGetInputMode",{C_POINTER,C_INT},C_INT), xglfwSetInputMode = define_c_proc(glfw,"glfwSetInputMode",{C_POINTER,C_INT,C_INT}), xglfwGetKey = define_c_func(glfw,"glfwGetKey",{C_POINTER,C_INT},C_INT), xglfwGetMouseButton = define_c_func(glfw,"glfwGetMouseButton",{C_POINTER,C_INT},C_INT), xglfwGetCursorPos = define_c_proc(glfw,"glfwGetCursorPos",{C_POINTER,C_POINTER,C_POINTER}), xglfwSetCursorPos = define_c_proc(glfw,"glfwSetCursorPos",{C_POINTER,C_DOUBLE,C_DOUBLE}), xglfwSetKeyCallback = define_c_func(glfw,"glfwSetKeyCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetCharCallback = define_c_func(glfw,"glfwSetCharCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetMouseButtonCallback = define_c_func(glfw,"glfwSetMouseButtonCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetCursorPosCallback = define_c_func(glfw,"glfwSetCursorPosCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetCursorEnterCallback = define_c_func(glfw,"glfwSetCursorEnterCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwSetScrollCallback = define_c_func(glfw,"glfwSetScrollCallback",{C_POINTER,C_POINTER},C_POINTER), xglfwJoystickPresent = define_c_func(glfw,"glfwJoystickPresent",{C_INT},C_INT), xglfwGetJoystickAxes = define_c_func(glfw,"glfwGetJoystickAxes",{C_INT,C_POINTER},C_POINTER), xglfwGetJoystickButtons = define_c_func(glfw,"glfwGetJoystickButtons",{C_INT,C_POINTER},C_POINTER), xglfwGetJoystickName = define_c_func(glfw,"glfwGetJoystickName",{C_INT},C_POINTER) public function glfwGetInputMode(atom win,atom mode) return c_func(xglfwGetInputMode,{win,mode}) end function public procedure glfwSetInputMode(atom win,atom mode,atom val) c_proc(xglfwSetInputMode,{win,mode,val}) end procedure public function glfwGetKey(atom win,atom xkey) return c_func(xglfwGetKey,{win,xkey}) end function public function glfwGetMouseButton(atom win,atom but) return c_func(xglfwGetMouseButton,{win,but}) end function public procedure glfwGetCursorPos(atom win,atom x,atom y) c_proc(xglfwGetCursorPos,{win,x,y}) end procedure public procedure glfwSetCursorPos(atom win,atom x,atom y) c_proc(xglfwSetCursorPos,{win,x,y}) end procedure public function glfwSetKeyCallback(atom win,atom fun) return c_func(xglfwSetKeyCallback,{win,fun}) end function public function glfwSetCharCallback(atom win,atom fun) return c_func(xglfwSetCharCallback,{win,fun}) end function public function glfwSetMouseButtonCallback(atom win,atom fun) return c_func(xglfwSetMouseButtonCallback,{win,fun}) end function public function glfwSetCursorPosCallback(atom win,atom fun) return c_func(xglfwSetCursorPosCallback,{win,fun}) end function public function glfwSetCursorEnterCallback(atom win,atom fun) return c_func(xglfwSetCursorEnterCallback,{win,fun}) end function public function glfwSetScrollCallback(atom win,atom fun) return c_func(xglfwSetScrollCallback,{win,fun}) end function public function glfwJoystickPresent(atom joy) return c_func(xglfwJoystickPresent,{joy}) end function public function glfwGetJoystickAxes(atom joy,atom cnt) return c_func(xglfwGetJoystickAxes,{joy,cnt}) end function public function glfwGetJoystickButtons(atom joy,atom cnt) return c_func(xglfwGetJoystickButtons,{joy,cnt}) end function public function glfwGetJoystickName(atom joy) return c_func(xglfwGetJoystickName,{joy}) end function public constant xglfwGetMonitors = define_c_func(glfw,"glfwGetMonitors",{C_POINTER},C_POINTER), xglfwGetPrimaryMonitor = define_c_func(glfw,"glfwGetPrimaryMonitor",{},C_POINTER), xglfwGetMonitorPos = define_c_proc(glfw,"glfwGetMonitorPos",{C_POINTER,C_POINTER,C_POINTER}), xglfwGetMonitorPhysicalSize = define_c_proc(glfw,"glfwGetMonitorPhysicalSize",{C_POINTER,C_POINTER,C_POINTER}), xglfwGetMonitorName = define_c_func(glfw,"glfwGetMonitorName",{C_POINTER},C_POINTER), xglfwSetMonitorCallback = define_c_func(glfw,"glfwSetMonitorCallback",{C_POINTER},C_POINTER), xglfwGetVideoModes = define_c_func(glfw,"glfwGetVideoModes",{C_POINTER,C_POINTER},C_POINTER), xglfwGetVideoMode = define_c_func(glfw,"glfwGetVideoMode",{C_POINTER},C_POINTER), xglfwSetGamma = define_c_proc(glfw,"glfwSetGamma",{C_POINTER,C_FLOAT}), xglfwGetGammaRamp = define_c_func(glfw,"glfwGetGammaRamp",{C_POINTER},C_POINTER), xglfwSetGammaRamp = define_c_proc(glfw,"glfwSetGammaRamp",{C_POINTER,C_POINTER}) public function glfwGetMonitors(atom count) return c_func(xglfwGetMonitors,{count}) end function public function glfwGetPrimaryMonitor() return c_func(xglfwGetPrimaryMonitor,{}) end function public procedure glfwGetMonitorPos(atom mon,atom x,atom y) c_proc(xglfwGetMonitorPos,{mon,x,y}) end procedure public procedure glfwGetMonitorPhysicalSize(atom mon,atom w,atom h) c_proc(xglfwGetMonitorPhysicalSize,{mon,w,h}) end procedure public function glfwGetMonitorName(atom mon) return c_func(xglfwGetMonitorName,{mon}) end function public function glfwSetMonitorCallback(atom fun) return c_func(xglfwSetMonitorCallback,{fun}) end function public function glfwGetVideoModes(atom mon,atom cnt) return c_func(xglfwGetVideoModes,{mon,cnt}) end function public function glfwGetVideoMode(atom mon) return c_func(xglfwGetVideoMode,{mon}) end function public procedure glfwSetGamma(atom mon,atom gam) c_proc(xglfwSetGamma,{mon,gam}) end procedure public function glfwGetGammaRamp(atom mon) return c_func(xglfwGetGammaRamp,{mon}) end function public procedure glfwSetGammaRamp(atom mon,atom ramp) c_proc(xglfwSetGammaRamp,{mon,ramp}) end procedure public constant xglfwGetWin32Window = define_c_func(glfw,"glfwGetWin32Window",{C_POINTER},C_POINTER), xglfwGetWGLContext = define_c_func(glfw,"glfwGetWGLContext",{C_POINTER},C_POINTER), xglfwGetCocoaWindow = define_c_func(glfw,"glfwGetCocoaWindow",{C_POINTER},C_POINTER), xglfwGetNSGLContext = define_c_func(glfw,"glfwGetNSGLContext",{C_POINTER},C_POINTER), xglfwGetX11Display = define_c_func(glfw,"glfwGetX11Display",{},C_POINTER), xglfwGetX11Window = define_c_func(glfw,"glfwGetX11Window",{C_POINTER},C_POINTER), xglfwGetGLXContext = define_c_func(glfw,"glfwGetGLXContext",{C_POINTER},C_POINTER), xglfwGetEGLDisplay = define_c_func(glfw,"glfwGetEGLDisplay",{},C_POINTER), xglfwGetEGLContext = define_c_func(glfw,"glfwGetEGLContext",{C_POINTER},C_POINTER), xglfwGetEGLSurface = define_c_func(glfw,"glfwGetEGLSurface",{C_POINTER},C_POINTER) public function glfwGetWin32Window(atom win) return c_func(xglfwGetWin32Window,{win}) end function public function glfwGetWGLContext(atom win) return c_func(xglfwGetWGLContext,{win}) end function public function glfwGetCocoaWindow(atom win) return c_func(xglfwGetCocoaWindow,{win}) end function public function glfwGetNSGLContext(atom win) return c_func(xglfwGetNSGLContext,{win}) end function public function glfwGetX11Display() return c_func(xglfwGetX11Display,{}) end function public function glfwGetX11Window(atom win) return c_func(xglfwGetX11Window,{win}) end function public function glfwGetGLXContext(atom win) return c_func(xglfwGetGLXContext,{win}) end function public function glfwGetEGLDisplay() return c_func(xglfwGetEGLDisplay,{}) end function public function glfwGetEGLContext(atom win) return c_func(xglfwGetEGLContext,{win}) end function public function glfwGetEGLSurface(atom win) return c_func(xglfwGetEGLSurface,{win}) end function public constant xglfwGetTime = define_c_func(glfw,"glfwGetTime",{},C_DOUBLE), xglfwSetTime = define_c_proc(glfw,"glfwSetTime",{C_DOUBLE}) public function glfwGetTime() return c_func(xglfwGetTime,{}) end function public procedure glfwSetTime(atom xtime) c_proc(xglfwSetTime,{xtime}) end procedure
4. Re: GLFW3 Wrapper Issue
- Posted by ghaberek (admin) Jun 08, 2014
- 2667 views
Everything works fine with your code on my PC (the window stays open). I am using the MinGW build of glfw3.dll. One thing I noticed is that you're checking for -1, but open_dll() returns 0 if the library cannot be found. I am going to guess that the "window" you're seeing is really a command line window popping up with an error and then quickly vanshing. Maybe your code cannot find the library from where you're running it? Try copying glfw3.dll into the same directory (that's what I did after I downloaded it). Also, try running your code from the command line with eui instead of euiw so the errors report to the current console.
atom glfw = open_dll("glfw3.dll") -- if glfw = -1 then if glfw = 0 then -- check for 0 on error puts(1,"Could not load glfw3.dll!\n") abort(1) end if
-Greg
5. Re: GLFW3 Wrapper Issue
- Posted by ghaberek (admin) Jun 08, 2014
- 2574 views
Also, just a tip: add ", 1" to your calls to allocate_string() to allow automatic clean-up. Otherwise you've got a (very tiny) memory leak in those functions. Depending on how many times you call such functions, your program could eventually crash because it's out of memory.
public function glfwCreateWindow(integer w,integer h,sequence title,atom mon,atom win) atom str str = allocate_string(title, 1) -- cleanup = 1 return c_func(xglfwCreateWindow,{w,h,str,mon,win}) end function
-Greg
6. Re: GLFW3 Wrapper Issue
- Posted by Lone_EverGreen_Ranger Jun 08, 2014
- 2585 views
Thanks for the tip, I added the "1" in the allocate strings. I was using the VS2012 DLL, I then switched to the MingW DLL, still though, the window briefly appears, then vanishes. I even ran it from the command line with eui, no errors appeared in the console. I'm not sure why it runs under your system and not mine. I'm using Windows 7 Ultimate 64-bit, 4GB RAM. I also changed the open_dll to equal zero if it is not found, still no errors when I ran it from the command line. I wonder if it is just some weird bug on my end?