-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
sdl_opengl3_example requires GL 3.2 but shaders require GLSL 3.30 #1466
Comments
I suggest that this is fixed by bumping the version to OpenGL 3.3, which seems to be the de-facto minimal version for modern OpenGL. There should also be the forward compatibility flag set and the shaders should use |
Thanks @jiri for your PR. I am summoning @flibitijibibo in this thread, who doesn't work on this project but since he is sympathetic toward dear imgui maybe he can share some of his empirical knowledge regarding Mac/Linux compatibility of OpenGL? Thanks Ethan :) |
Definitely aim for GL 3.2 Core + GLSL 1.50. Linux doesn't care about this too much thanks to overrides but macOS OpenGL profiles are kind of a horrid mess and require very specific versions for both the context and the EDIT: Also for macOS you either have 3.2 or 4.1, nothing in between. |
I've tweaked the versions in my PR to reflect this, so it's now OpenGL 3.2 + GLSL 1.50, which works fine for me on macOS. Thanks for the info! |
Thank you @flibitijibibo ! |
I believe Mesa is okay with mismatched versions, but macOS definitely will complain if the versions aren't exactly aligned across the board, so each context version gets to have its own shaders too :/ |
OK I think we could aim at adding a |
@flibitijibibo Can you explain why you can not have opengl 3.3 on macOS in more detail as I did not find any info about that on the internet? Did you make that statement because macOS 10.7.5. supports up to 3.2 and only macOS 10.9 added support for 3.3 and 4.1 as can be seen on https://developer.apple.com/opengl/OpenGL-Capabilities-Tables.pdf#page=24 ? |
@Stfx The TL;DR version: Because Apple said so, no real legitimate reason. The long version: Apple's drivers are really strange in that they have three totally separate paths in them: 2.1 Compat, 3.2 Core, and 4.1 Core. I'm not talking about specifications, I'm talking literal separate code paths in OpenGL.Framework where each context version gets a completely 100% different pile of code in them. If you look up backtraces for macOS driver crashes you'll see lots of call stacks where C functions are even namespaced like So while extension lists for certain specifications are supported, the actual set of features supported by each context is entirely different, and the number of contexts is limited to those three (AFAIK). The best part is that the limitations of all three are simultaneously very restricted and very loose at the same time. A good example of the former is GLSL, where the GLSL version absolutely must match to the letter. If you do anything other than 150 on 3.2 Core, 410 on 4.1 Core, or 110/120 on 2.1 Compat, it will crash. However, in the latter scenario, you'll find that even 2.1 Compat has support for stuff like ARB_framebuffer_object, ARB_draw_instanced, and even ARB_instanced_arrays! So on macOS if you want to target 3.3, you basically can since 3.2 Core has pretty much all the extensions you'll care about while also targeting pre-Mavericks machines, with the exception of GLSL 3.30 extensions like ARB_explicit_attrib_location and ARB_shader_bit_encoding (the former being really easy to replace and the latter not being terribly important unless you like type casting a whooole lot). It's very confusing and anyone at Apple that would have ever cared about making this clearer has long since moved on to either Metal or just a different company entirely. |
There is one advantage that ImGui uses 3.3 profile. [1] https://www.khronos.org/opengl/wiki/Texture#Swizzle_mask |
@y-fujii That's an interesting feature, thanks for posting that! (And actually, as flibitijibibo posted, the 3.2 Core profile of OSX may even support that. According to https://developer.apple.com/opengl/OpenGL-Capabilities-Tables.pdf since macOS 10.8.5 the 3.2 profile include the texture_swizzle extension.) |
I'm closing it, applied the initial fix suggested to both both SDL and GLFW examples to use OpenGL 3.2 Core + GLSL 150. What I didn't do: expose the GLSL version string to the imgui_impl_xxx API. Will wait until someone can confirm and repro a problem with using GLSL 150 with their driver/version of GL. Thanks everyone for helping with it! |
FYI |
FYI in fff014d I have
|
In
sdl_opengl3_example/main.cpp
the OpenGL context version is set to 3.2:However, in the vertex and fragment shaders, GLSL version 3.30 is required:
According to Khronos wiki, OpenGL 3.2 should be associated with GLSL 1.50: https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#OpenGL_and_GLSL_versions
I've got no knowledge of GLSL, but changing
#version 330
to#version 150
makes it run withMESA_GLSL_VERSION_OVERRIDE=150
set.The text was updated successfully, but these errors were encountered: