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

GL version define + runtime checks #2866

Closed
wants to merge 6 commits into from

Conversation

dpilawa
Copy link
Contributor

@dpilawa dpilawa commented Oct 23, 2019

@ocornut
Copy link
Owner

ocornut commented Oct 24, 2019

Hello @dpilawa, thanks for looking into this!

(MY INTENDED FIRST ANSWER, FEEL FREE TO IGNORE :)

Some feedback:

  • I might be misreading the code but it seems that the PR would now disable IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX for any loader other than Glad. Most loaders are not auto-generated per GL version and wouldn't be subject to the issue discussed in glDrawElementsBaseVertex is not available in GL 3.1 #2852, so afaik we have a regression here.
  • I would suggest to default the define to 3.2.
  • I am not sure I understand why you #undef IMGUI_IMPL_OPENGL_VERSION at the top of the .cpp file maybe the user unable to override it.

I think the flow should be;

  • Let user define it.
  • Try to auto-detect based on GL_VERSION_ defines.
  • Otherwise default to 3.2
  • And later we can improve this for other loaders if we find similar issues like the one you spotted and they don't use standard GL_VERSION_XX defines, but this sounds unlikely?

Additionally:

  • In order to make the code look as simple as it could be, I would suggest to avoid caring about the versions above 3.2 since we are not testing for them.
  • Would also suggest to clarify the #define IMGUI_IMPL_OPENGL_VERSION XX lines with something like // Compatible with GL X.X and above.

(10 MINUTES LATER - ACTUAL ANSWER)

Both glew.h and gl3w.h use the same set of GL_VERSION_ defines.
I think the better action should be much simpler:

So GL_VERSION_3_2 will lead to IMGUI_IMPL_OPENGL_MAY_HAVE_DRAW_WITH_BASE_VERTEX and we still query actual runtime version in ImGui_ImplOpenGL3_Init().

What do you think?

@dpilawa
Copy link
Contributor Author

dpilawa commented Oct 24, 2019

Thanks for your feedback, @ocornut !

Regarding regression - the IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX would actually be unset when neither User nor GLAD (indirectly by GL_VERSION_) defined IMGUI_IMPL_OPENGL_VERSION. So this is not a bug per se, but would effectively disable the use of glDrawElementsBaseVertex for anyone who does not set the new optional define explicitly, or uses GLAD. So yes, that's regression.

Now that we know that GLEW and GL3W use the same GL_VERSION_ defines the problem would not be that big, but there is no guarantee anyway on the existence of these in the future. And there are still custom loaders.

So bottom line is - I agree with your suggestion to simplify and still use runtime safety-net in ImGui_ImplOpenGL3_Init() and in ImGui_ImplOpenGL3_RenderDrawData(). Let me get back to you with updated PR.

@dpilawa dpilawa changed the title new optional define IMGUI_IMPL_OPENGL_VERSION GL version define + runtime checks Oct 24, 2019
@ocornut
Copy link
Owner

ocornut commented Oct 25, 2019

Hi @dpilawa was just merging that now at the same time you updated the changelog :)
Will be merged in a minute, thanks again!

ocornut pushed a commit that referenced this pull request Oct 25, 2019
ocornut added a commit that referenced this pull request Oct 25, 2019
… expose glDrawElementsBaseVertex(), using runtime GL version to decide if we set ImGuiBackendFlags_RendererHasVtxOffset. (#2866, #2852) [@dpilawa]
@ocornut ocornut closed this Oct 25, 2019
ocornut added a commit that referenced this pull request Apr 12, 2020
… instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset, leaving 3.2 contexts without it. (#3119, #2866, #2852)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants