john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.18k stars 63 forks source link

Add Linux build of example for OpenGL 3.3 context #48

Closed eliasdaler closed 3 years ago

eliasdaler commented 3 years ago

Hello. This implements a Linux build of example.

It uses glfw to do it. I think it might be beneficial to port Windows build to it so that the code is the same for all platforms and a lot of OS-spefic code will be removed (I might do it in the next PR)

GLFW implementation of Dear ImGui was mostly taken from here. If we port all platform code to GLFW then I'll be able to use this implementation (I'd like to do the same with DirectX and OpenGL code specific to rendering ImGui - it'll be good to use "official" implementations of DirectX and OpenGL rendering so that we don't need to write our own ImGui renderer and use the standard solution)

There was also an issue that I can't setup context after creating glfw window, so I put OpenGL context creation in InitWindow.


P.S. Maybe we should switch to git submodules for both Dear ImGui and glfw later to not have to keep their code in this repo to keep it lighter...

john-chapman commented 3 years ago

I don't think it's worth introducing a dependency on such a big 3rd party lib just to make the example base code cleaner. Also GLFW is OpenGL-specific, which means that other APIs would need separate backend code anyway.

eliasdaler commented 3 years ago

GLFW is not OpenGL specific, you can create Vulkan and DirectX contexts with it. It's possible to create a window without OpenGL context and then setup all the needed state afterwards.

I just don't think there's a smaller library which provides a cross-platform windowing and input reading functionality. Of course, I can do implementation which uses X11 directly, but that'll add quite a lot of code which is already nicely wrapped in glfw.