Giter Site home page Giter Site logo

Comments (6)

Dav1dde avatar Dav1dde commented on June 12, 2024 1

Mh that should work, can you debug into glad_gl_find_core_gl either via a debugger or just add a few printf's, I am mainly interested in the version string before the GLAD_IMPL_UTIL_SSCANF call and the major, minor variables after.

from glad.

Dav1dde avatar Dav1dde commented on June 12, 2024

What does glGetString(GL_VERSION) return?

from glad.

zaruhev avatar zaruhev commented on June 12, 2024

Hello Dav1dde, thank you for responding so quickly.

glGetString(GL_VERSION) returns "4.6.0 Core Profile Context 24.1.1.231127", I think as expected.

from glad.

zaruhev avatar zaruhev commented on June 12, 2024

Thank you for the advice. I was able to find the source of the problem. As it turns out, glad_gl_find_core_gl and GLAD_IMPL_UTIL_SSCANF are not called at any point.

It seems that GLAD_GL_IMPLEMENTATION must be defined before gl.h is included in order to be called, so I assume the version is not set otherwise. After adding #define GLAD_GL_IMPLEMENTATION before #include <glad/gl.h>, the version is properly set:
image

Should I fork and PR the example with the definition of GLAD_GL_IMPLEMENTATION?

Revised source file:

#include <stdlib.h>
#include <stdio.h>

#define GLAD_GL_IMPLEMENTATION
#include <glad/gl.h>

#include <GLFW/glfw3.h>


const GLuint WIDTH = 800, HEIGHT = 600;

void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) {
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);
}

int main(void) {
    glfwInit();

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // GL version edited for version test
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "[glad] GL with GLFW", NULL, NULL);
    glfwMakeContextCurrent(window);

    glfwSetKeyCallback(window, key_callback);

    int version = gladLoadGL(glfwGetProcAddress);
    printf("GL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));

    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();

        glClearColor(0.7f, 0.9f, 0.1f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);

        glfwSwapBuffers(window);
    }

    glfwTerminate();

    return 0;
}

from glad.

zaruhev avatar zaruhev commented on June 12, 2024

Issue possibly resolved by fork in PR #464. Please let me know if there are any issues.

Thank you @Dav1dde

from glad.

Dav1dde avatar Dav1dde commented on June 12, 2024

As discussed in #464 (comment) we cannot re-produce the issue, closing it until reproducible.

from glad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.