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

using #ifdef GL_SAMPLER_BINDING instead of if (glBindSampler) #1985

Merged
merged 1 commit into from
Jul 30, 2018

Conversation

ziocleto
Copy link
Contributor

OpenGL ES (2.0/3.0)

This fixes a pedantic compiler error and encapsulates better OpenGL ES API.

if (glBindSampler) glBindSampler(0, 0);

Fails on Clang5.0+ (C++17) with warning as errors:

error: address of function 'glBindSampler' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

And equally the "fix":

if (&glBindSampler) glBindSampler(0, 0);

Will fail on GCC 8.1.0+ (and probably earlier)

error: the address of '__glewBindSampler' will never be NULL [-Werror=address]

Using #ifdef GL_SAMPLER_BINDING fixes those errors.

@ocornut ocornut merged commit 81562b2 into ocornut:master Jul 30, 2018
@ocornut
Copy link
Owner

ocornut commented Jul 30, 2018

Will fail on GCC 8.1.0+ (and probably earlier)
error: the address of '__glewBindSampler' will never be NULL [-Werror=address]

I overlooked in your previous message that those are actually warning and not actual errors, it is just that you have error-on-warning, in which case we could possibly disable that warning in the code?
(btw thanks for posting the precise logs!)

I merged this, and then realized that it might be faulty, as some loaders might define all the constants and not bind the functions depending on GL version support.

@matrefeytontias This is a followup to our discussion in #1806, would it be possible to confirm that this is working well with your setup? Aka the #ifdef GL_SAMPLER_BINDING test is evaluating to false and the glBindSampler() call that was crashing in your setup is not called? To double-check you may comment out the #ifdef check and make sure that it DOES crash without it. Thank you!

@ok-what
Copy link

ok-what commented Apr 23, 2020

Hi, I'm not sure where to say this but I'll comment here as this is about the same issue.
On my setup, with glad and OpenGL 300 ES the code inside the #ifdef gets executed and calling glBindSampler causes a segfault.

@weike20
Copy link

weike20 commented Aug 20, 2020

300 ES the code inside the #ifdef gets executed and calling glBindSampler causes a segfault.

I have same questions

@jjwebb
Copy link
Contributor

jjwebb commented Sep 10, 2020

Hi guys, I found this thread through Google because I was having exactly the same issue with the #ifdef code executing and causing a segfault in OpenGL 310 ES. I tracked down the bug and submitted a pull request which fixes this problem. See here:
#3467

ocornut pushed a commit that referenced this pull request Sep 17, 2020
…<= 3.2 (#3467, #1985)

(nb: GLEW sets the define we previously used)
ocornut added a commit that referenced this pull request Sep 17, 2020
ocornut added a commit that referenced this pull request Sep 17, 2020
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.

None yet

5 participants