Moving from GLFW2 to GLFW3

Monkey Targets Forums/Desktop/Moving from GLFW2 to GLFW3

DeadFall(Posted 2015) [#1]
I'm testing on 82b and I noticed that GlfwGame class is missing from,

targets\glfw3\modules\monkeytarget.monkey

I was using GlfwGame.GetGlfwGame to access native GLFW functions such as

GlfwGame.GetGlfwGame.GetGlfwDesktopMode.Width
GlfwGame.GetGlfwGame.GetGlfwDesktopMode.Height
GlfwGame.GetGlfwGame().SetGlfwWindow()

And some others. My question is, will it be added back in but functional for GLFW3 or is there another way to call the GLFW3 equivalent functions already that I'm just unaware of. Any help would be much appreciated.


ImmutableOctet(SKNG)(Posted 2015) [#2]
To my knowledge, this functionality was target-dependent to begin with, so Mark wouldn't really be required to re-add it for GLFW3.

Assuming you're using Mojo (Which effectively everybody is), then your best option is to use 'SetDeviceWindow', which recently was "retrofitted" with the same / similar functionality. Unfortunately, the online documentation isn't up to date, so I can't link to it. You can view it yourself through most IDEs, including Ted (Monkey's default editor), which even has a search bar.

Most people (Including myself) already had maximum compatibility in mind, so moving to this as a possible back-end was simply enough. However, if you're porting over less portable segments of your code, then using the new display-management system shouldn't be very difficult. If you want to keep compatibility with GLFW2's specific implementation (It also supports the new display-management), then you can check if 'GLFW_VERSION' is set to 2 (With the preprocessor). In addition to this, you can check if it is zero and/or undefined (Using 'Not') for backward compatibility with earlier Monkey (And Mojo) versions.

That should basically be everything you need to know. It would be nice to hear if support is coming to GLFW3 for this, but it's not really a big deal anymore.

And if you're not using Mojo, you'd already have other options.


DeadFall(Posted 2015) [#3]
Thanks a lot! This seems to have been what I needed. I have no idea how I didn't notice 'SetDeviceWindow'. I also see other functions that I needed within app.monkey.

Thank you for the reply.