-
Notifications
You must be signed in to change notification settings - Fork 429
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
Segfault: C 'get_exts()' doesn't differenciate OpenGL context from OpenGLES one #24
Comments
This should not happen, I am also not sure how to fix this, maybe introduce |
Can you paste the result of Is it possible that you use a OpenGL ES context >= 3, but only built Glad to support 2.0? EDIT: Small update, I figured out why this happens and that this should infact not happen, I will push a fix later tonight. |
Thanks for the report! Please test with current master and report back, I reproduced this locally and it seems to be fixed. I will push a new version if you give the ok ;). |
It's not fixed on my side... I built for GL3 and ES2 ; then I ask for an ES 2.0 context to SDL2 but I get an ES 3.0 one. (I don't think it's a bug since there is backwards compatibility.) I put the code generated by glad below. Currently,
Instead, we need to check if we get one of those:
Currently, I don't really get those two new variables ( #if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
#define _GLAD_IS_SOME_NEW_VERSION 1
#endif
static int max_loaded_major;
static int max_loaded_minor;
static const char *exts = NULL;
static int num_exts_i = 0;
static const char **exts_i = NULL;
static void get_exts(void) {
#ifdef _GLAD_IS_SOME_NEW_VERSION
if(max_loaded_major < 3) {
#endif
exts = (const char *)glGetString(GL_EXTENSIONS);
#ifdef _GLAD_IS_SOME_NEW_VERSION
} else {
int index;
num_exts_i = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);
if (num_exts_i > 0) {
exts_i = (const char **)realloc((void *)exts_i, num_exts_i * sizeof *exts_i);
}
for(index = 0; index < num_exts_i; index++) {
exts_i[index] = (const char*)glGetStringi(GL_EXTENSIONS, index);
}
}
#endif
} |
Please try again, I accidently only fixed the same problem with OpenGL contexts.
I thought about clamping GLVersion instead of introducing |
Yep, it works. Thanks! |
I generate glad for OpenGL 3.0 and Open GL ES 2.0 (
--api=gl=3.0,gles2=2.0
).Calling
gladLoadGLES2Loader
within an Open GL ES 3.0 context causes a segfault inget_exts
by trying to callglGetStringi
andglGetIntegerv
(bothNULL
pointers) instead ofglGetString
.Those functions aren't supposed to be loaded.
get_exts
uses them because of the 3.0 context without considering if we're given an OpenGL or an OpenGL ES one.This could be considered a follow up of issue #6.
The text was updated successfully, but these errors were encountered: