GLFW context error - Is there a way to request a context version below 3.3?

Hi, I'm new to raylib, learned about it this day.

Downloaded the installer, tryed the core example and it turned out that it crashes during initialization. The error message is the folllowing:

INFO: Initializing raylib (v1.8.0)
WARNING: [GLFW3 Error] Code: 65543 Description: WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable

My OpenGL version is 3.1, unfortunately, so that's probably the cause of the error.

I believe that the following functions are being called internally by raylib window before the window is actually created

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

so I wonder if there is a way to choose a context version that my hardware supports. Any suggestions?

Comments

  • edited October 25
    Hey 80'sJay!

    You're right, that issue is due to OpenGL version. You can just modify that line and set minor version to 1: glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);

    And then recompile the library using Notepad++ last script.

    Another option would be using that same script to select another version of OpenGL, and recompile... but first option is better for your case because on lower versions you could lose some library functionality.
  • I'll do that. Thank you, raysan5.
  • Sorry to bother you once again, raysan5.

    The problem shifted form initialization to immediately after initialization. The error message is the following:

    INFO: Initializing raylib (v1.8.0)
    INFO: Display device initialized successfully
    INFO: Display size: 1366 x 768
    INFO: Render size: 800 x 450
    INFO: Screen size: 800 x 450
    INFO: Viewport offsets: 0, 0
    INFO: GLAD: OpenGL extensions loaded successfully
    ERROR: OpenGL 3.3 Core profile not supported

    I commented the whole if/else block that selects the OpenGL version and added two lines that calls directly glfwWindowHint with the desired context version.

    But it seems that some other small changes need to be made. I have very little experience in C and I'm trying to figure out the problem without making stupid questions, but I need some directions.

    I have one questions.

    1. The command to compile rlgl.c contains this argument (or flag, IDK), -DGRAPHICS_API_OPENGL_33. Can I replace it by something else, e.g. a custom define?

    While writing this, I guess I came to understand the whole thing. Let me describe the steps so you can correct me if I'm wrong or missing something:

    a) in rlgl.h: add a new custom #define below the line 70, where the GRAPHICS_API_OPENGL_* are defined. I intend to add GRAPHICS_API_OPENGL_31, according to the logic in those lines, and to add OPENGL_31 to the GlVersion enum in line 139.

    b) in rlgl.c: make the changes to rlGetVersion() to return the GlVersion enum member matching the new custom #define.

    c) in raylib_source_compile script: change SET GRAPHICS_API= value to the new custom #define.

    d) in core.c: change the if/else statement in line 1716 and below to set context version accordingly to the rlGetVersion() return value.

    e) compile, run, enjoy and be happy, I suppose.
  • I forgot one step. In shader_distortion.h: append
    "|| defined(GRAPHICS_API_OPENGL_*)"
    at the end of every
    "#elif defined(GRAPHICS_API_OPENGL_33)"
    where GRAPHICS_API_OPENGL_* is the new custom #define.
  • Hi 80'sJay, sorry, I was wrong, been checking it more carefully and it really requires some more changes than expected...

    Best options is just use Notepad++ source compiling script changing at the beginning:
    SET GRAPHIC_API=GRAPHICS_API_OPENGL_33
    to
    SET GRAPHIC_API=GRAPHICS_API_OPENGL_21

    It's not OpenGL 1.1 and keeps most of the functionality of OpenGL 3.3...
  • Oh, don't worry. It runs just fine in 2.1. :smile:

    raylib brought back my excitement to learn C programming. I'm having a hard time trying to run the examples in 3.1 context but is not that bad, you know? I spent a good amount of time just starring at the sources (core and rlgl) and now I have a more clear vision of what and where I need to tweak. As you said, it requires a lot more changes but I being careful. :wink:

  • Glad to read it finally worked! :smiley:

    It's really difficult to support all OpenGL version...

    Hope you enjoy using raylib! Keep me updated!
Sign In or Register to comment.