Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch to add Haiku support #8143

Open
smallstepforman opened this issue Nov 9, 2024 · 4 comments
Open

Patch to add Haiku support #8143

smallstepforman opened this issue Nov 9, 2024 · 4 comments

Comments

@smallstepforman
Copy link

Version/Branch of Dear ImGui:

any

Back-ends:

imgui_impl_opengl3

Compiler, OS:

gcc 13.3

Full config/build information:

No response

Details:

To support Haiku OS, all that is required is to append the following code to imgui_impl_opengl3.cpp (near the top)

#if defined(HAIKU)
#define GL_GLEXT_PROTOTYPES 1
#include <GL/gl.h>
#include <GL/glext.h>
#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#endif

Haiku doesn't require the OpenGL function pointer dance. The app should link to libGL.so (tested with libglfw.so)

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@smallstepforman
Copy link
Author

Markup swallowed the _ _ HAIKU _ _

@ocornut
Copy link
Owner

ocornut commented Nov 9, 2024

Can you clarify precisely what happens if you try to compile the backend as is?
I believe if anything a potential change for Haiku should be reported in the _loader.h file and gl3w.

@smallstepforman
Copy link
Author

smallstepforman commented Nov 9, 2024

Without the header files, it fails to find any GL functions. If I only add #include "imgui_impl_opengl3_loader.h", then it fails to link due to unresolved imgl3wProcs.

The entire point of the function pointer dance is to allow the existance of OS vendor libopengl32.dll and HW vendor accelerated opengl, and the function dance maps to both (since you can actually mix and match GL functions from libopengl and HW version). MS being MS, they are stuck on ancient version of opengl headers. Early Linux copied this behaviour from Win32, hence why you still need extension wranglers like glew, glee and siblings. Haiku has none of this nonsense, it allows runtime mixing and overridding, the ELF loader does late binding based on link order. It just works. With environmental variables you can even specify GL version override, so you can go from 1.1 to 4.5 on same binary. You can patch any system library using this technique, so much so that the naive application innocently believes that it is calling a harmless system library function like printf( ), while the injected shared library will override this and send data across the internet (or similar). For hacker devs, this is fantastic, but for security minded folks, this is a No-No, hence why some OS's dont allow late library overriding.

So what does my patch do?
It defines GL_GLEXT_PROTOTYPES to specify that we need all GL extensions. It includes the system GL headers (you dont need to include imgui_impl_opengl3_loader.h). This was tested with core profile. And the final line helps imgui to bypass the function pointer dance. I added this patch to the top of imgui_impl_opengl3.cpp, it may be possible to put it elsewhere but you know us devs, we get our problem solved and move on to the next problem. A project I'm working on has a test gui using ImGui and it works in Haiku now (as well as Linux and Windows)

@ocornut
Copy link
Owner

ocornut commented Nov 9, 2024

Without the header files, it fails to find any GL functions. If I only add #include "imgui_impl_opengl3_loader.h", then it fails to link due to unresolved imgl3wProcs.

You shouldn’t have to “add” any include. It’s already included by the backend. Please report exact build error on the system with vanilla files, thanks!

I am not denying that your setup may have more complete headers but presumably we should be able to use the loader and get things to still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants