The problem I kept running into is that we had hard coded our window mode and window size in our main.c source code. This mainly because writing a GUI could be a tutorial series all by itself and it detracts to what I'm trying to do here.
But then my eye fell on this library called AntTweakBar which is listed on the GLFW site. It is a really neat little library but it has a few rather troublesome drawbacks:
- it doesn't compile on the Mac anymore, lucky these were easy to fix up after a bit of reading on the support forum
- the mappings to GLFW are still based on GLFW 2.7, not 3.0. I've got them working except for our keyboard mappings. To properly fix this I'll also have to recompile the windows binaries
- there isn't a lot of freedom in the controls and layout of the window
- it is no longer maintained
I'm planning to do more with the library as time goes by and do a proper tutorial writeup if I do enjoy using it. If so I might be tempted to start enhancing it. But equally so I may end up replacing it.
So for now I'm just going to give a very brief overview of the changes that I've checked into our tutorial project.
First off, all the new support code is embedded into two new files:
- setup.h - our header
- setup.c - our source code
The library has a single public function which is SetupGLFW and all it does is open up a window that provides 3 dropdowns:
- choosing the monitor to use for running in fullscreen, or the option to choosing windowed mode
- choosing the resolution (if fullscreen)
- choosing the stereo mode for optional 3D stereo rendering
... if (!SetupGLFW(&info)) { glfwTerminate(); exit(EXIT_FAILURE); }; // make sure we're using OpenGL 3.2+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); if (info.monitor != NULL) { glfwWindowHint(GLFW_RED_BITS, info.vidmode.redBits); glfwWindowHint(GLFW_GREEN_BITS, info.vidmode.greenBits); glfwWindowHint(GLFW_BLUE_BITS, info.vidmode.blueBits); glfwWindowHint(GLFW_REFRESH_RATE, info.vidmode.refreshRate); if (info.stereomode == 2) { glfwWindowHint(GLFW_STEREO, GL_TRUE); }; errorlog(0, "Initializing fullscreen mode %i, %i - %i",info.vidmode.width, info.vidmode.height, info.stereomode); window = glfwCreateWindow(info.vidmode.width, info.vidmode.height, "GLFW Tutorial", info.monitor, NULL); } else { errorlog(0, "Initializing windowed mode %i, %i - %i",info.vidmode.width, info.vidmode.height, info.stereomode); window = glfwCreateWindow(info.vidmode.width, info.vidmode.height, "GLFW Tutorial", NULL, NULL); }; if (window == NULL) { errorlog(-1, "Couldn''t construct GLFW window"); } else { ...
The end result looks like this:
No comments:
Post a Comment