Closed ghost closed 7 years ago
NanoGUI is OpenGL 3.x or higher, so it's very unlikely you will ever get this to work :/ Of you're new to OpenGL, 3.x got rid of the "fixed function pipeline", and is not backwards compatible with 2.x and earlier. So you're ultimately going to have to decide: update your OpenGL code, or don't use nanogui. Pros and cons to both, switching to OpenGL 3 has some overhead for sure. But there's a long list of reasons why it went down like this, first and foremost is performance.
You can try using the explicit screen constructor and request 2.something. this example shows how to get a 4.1 profile, but I seriously doubt you will be able to get nanogui to work with OpenGL 2.x. Good luck, sorry for the bad news
Thanks a lot for the answer. The only problem is that all this code runs within a VM/Docker image. Nuklear and imGUI both work with lower OpenGL versions, but i want to use NanoGUI. I will have to scratch my head around it. This is the project I am working on: https://github.com/QuantScientist/DeepSleep
The underliyng nanovg engine can run on OpenGL2, so it should not be too hard to get it working for nanogui
I agree that it might be possible based on the NanoVG support for OpenGl 2.x. This is really not a priority for us, so: patches are welcomed that add (optional) OpenGL 2.x support. For now I'll go ahead and close this issue since there is no problem with NanoGUI itself.
Agreed and understandable.
For what it's worth, if you decide to go down this route, the following is what I know based off the long-ago attempt I made to do this. I was working with a medium sized framework and was hopeful to get NanoGUI to 2.x, but ultimately ended up concluding it was less work to re-do the framework for 3.x instead.
There are many gl*
calls in nanogui, each of which would need to be checked for compatibility. It's a rather long list. Many are available since 2.0
, and instead of trying to implement equivalent functionality, since implementing 2.x would be a compat feature anyway, #error
maybe?
You can find the relevant calls to check against with
$ cd /path/to/nanogui
# acquire the list of gl calls from the include directory
$ egrep -Hn --color=auto -r ^[[:space:]]*gl[[:alnum:]]+\(.*\) include/
# acquire the list of gl calls from the src/ directory
$ egrep -Hn --color=auto -r ^[[:space:]]*gl[[:alnum:]]+\(.*\) src/
The file of closest focus should be src/screen.cpp
, since that's where all the magic happens. A random selection gives glGetFramebufferAttachmentParameteriv
, which is 3.x or higher
To get something working, you'll need conditional compilation. The easiest way would be to create another CMake option that defaults to OFF
, something like NANOGUI_GL2_COMPAT
or something. Then right before this one, something like
if(NANOGUI_GL2_COMPAT)
list(APPEND NANOGUI_EXTRA_DEFS NANOGUI_GL2_COMPAT)
endif()
Using this, despite the comment (bad merge from the GLES stuff?) define NANOVG_GL2_IMPLEMENTATION
instead
#if defined(NANOGUI_GL2_COMPAT)
#define NANOVG_GL2_IMPLEMENTATION
#else
#define NANOVG_GL3_IMPLEMENTATION
#endif
#include <nanovg_gl.h>
3. Figure out what to do with glfw
. The submodule being used in this library only provides glfw3. On the other hand, the glad
stuff should all be kosher.
As @phicore said, it technically is possible. I include it only to help kick-start if you're new to the framework, but I'm honestly only familiar with the build system and a few core classes...
I resolved this issue. See: https://github.com/ocornut/imgui/issues/1094
@QuantScientist Can you explain what steps did you need to perform in order to get it working under OpenGL 2.x? I also require OpenGL 2.x, because sometimes you really need your program to be run on a virtual machine, and there you don't have 3.x.
Also, I don't understand the link to the imgui issue... are nanogui and imgui related in some way?
Thanks!
Hi, I have successfully compiled all the examples, however during run-time, I get the following error:
How can I change the settings so that I can use OpenGl-2? I can compile and run Nuklear with X11 on the same machine. Thanks,