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

Glad generated loader does not correctly handle GL implementations with 0 extensions #492

Open
The-Minecraft-Scientist opened this issue Sep 29, 2024 · 0 comments

Comments

@The-Minecraft-Scientist

get_exts treats an implementation having 0 extensions as an error case even though the spec makes no guarantees about the number of extensions provided by an implementation:

    // generated glad.c - get_exts
    ...
        int index;
        num_exts_i = 0;
        glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);
        if (num_exts_i > 0) {
            exts_i = (char **)malloc((size_t)num_exts_i * (sizeof *exts_i));
        }

        if (exts_i == NULL) {
            return 0;
        }

        for(index = 0; index < num_exts_i; index++) {
            const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index);
            size_t len = strlen(gl_str_tmp);

            char *local_str = (char*)malloc((len+1) * sizeof(char));
            if(local_str != NULL) {
                memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char));
            }
            exts_i[index] = local_str;
        }
    return 1;

Admittedly this is not that big of a deal because practically every "real" GL implementation has at least one extension, but I ran into it while testing a program using glad against the translation layer I'm working on (which currently advertises having no extensions).

@The-Minecraft-Scientist The-Minecraft-Scientist changed the title Glad loader does not correctly handle GL implementations with 0 extensions Glad generated loader does not correctly handle GL implementations with 0 extensions Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants