Raspberry pi 5: cannot create a glfw window (GLXBadFBConfig) => use OpenGL 3.1 instead of OpenGL 3.3
Hello everyone, I'm trying to use Imgui_bundle with glfw in a raspberry pi 5 with Python that has OpenGL ES 3.1 So I used this code:
from imgui_bundle import hello_imgui, imgui, glfw_utils
import glfw
def gui():
imgui.text("Hello")
if imgui.button("maximize window"):
win = glfw_utils.glfw_window_hello_imgui() # get the main glfw window used by HelloImGui
glfw.maximize_window(win)
glfw.init() # needed by glfw_utils.glfw_window_hello_imgui
hello_imgui.run(gui)
But I had this error:
Glfw Error 65543: GLX: Failed to create context: GLXBadFBConfig
Traceback (most recent call last):
File "/home/maul7456/Documents/prueba.py", line 18, in <module>
hello_imgui.run(gui)
File "/home/maul7456/.local/lib/python3.11/site-packages/imgui_bundle/_patch_runners_add_save_screenshot_param.py", line 38, in patched_run
run_backup(*args, **kwargs)
RuntimeError: IM_ASSERT( false && "Failed to create temporary window." ) --- opengl_setup_glfw.cpp:26
I have also encountered your problem(However, I compiled in c++). I wonder if my solution can be of help to you。 This issue is due to the fact that the bundle uses openGL3.3 by default I modified the following parts:
This is the mistake I encountered:
Finally, I wish you could solve your problem perfectly😀😀😀
Hi,
Thanks for your input @Analysiszaj
You are right, this is because Raspberry Pi do not support OpenGL 3.3, but Open GL 3.1.
Solution:
- Update ImGui Bundle from source: I pushed a necessary change to ImGui Bundle
- Specify OpenGL 3.1 in the file
hello_imgui.ini. Below is a template for the hello_imgui.ini file - Edit the values to match your needs
- Place this file hello_imgui.ini in the current working directory of your application, or any parent directory of the current working directory.
hello_imgui.ini:
; This is an example configuration file for hello_imgui
; To use it:
[OpenGlOptions]
; OpenGlOptions contains advanced options used at the startup of OpenGL.
; These parameters are reserved for advanced users.
; By default, Hello ImGui will select reasonable default values, and these parameters are not used.
; Use at your own risk, as they make break the multi-platform compatibility of your application!
; All these parameters are platform dependent.
; For real multiplatform examples, see
; hello_imgui/src/hello_imgui/internal/backend_impls/opengl_setup_helper/opengl_setup_glfw.cpp
; and
; hello_imgui/src/hello_imgui/internal/backend_impls/opengl_setup_helper/opengl_setup_sdl.cpp
; GlslVersion = 130
MajorVersion = 3
MinorVersion = 1
UseCoreProfile = false
; UseForwardCompat = false
; `AntiAliasingSamples`
; If > 0, this value will be used to set the number of samples used for anti-aliasing.
; This is used only when running with Glfw + OpenGL (which is the default)
; Notes:
; - we query the maximum number of samples supported by the hardware, via glGetIntegerv(GL_MAX_SAMPLES)
; - if you set this value to a non-zero value, it will be used instead of the default value of 8
; (except if it is greater than the maximum supported value, in which case a warning will be issued)
; - if you set this value to 0, anti-aliasing will be disabled
;
; AntiAliasingSamples has a strong impact on the quality of the text rendering
; - 0: no anti-aliasing
; - 8: optimal
; - 16: optimal if using imgui-node-editor and you want to render very small text when unzooming
;AntiAliasingSamples=8
This is really wonderful!🎉🎉
Thanks a lot, It really works with my Python project