My system reports that im using OpenGL 4.2: https://pastebin.com/uXu3BLxX But when i try to use that OpenGL vesion to write a program with it, it fails, the maximum version i can use for that is OpenGL 2.1, why does that happen?

  • e0qdk@kbin.social
    link
    fedilink
    arrow-up
    4
    ·
    9 months ago
    • You are running Wayland
    • Your GLFW programs are using EGL, not GLX, to talk to your graphics drivers/hardware
    • glxinfo is talking to a software implementation, not your hardware
    • glxinfo’s output is irrelevant if you want to talk to your hardware with your current configuration; if you want to use the software implementation recompile GLFW targeting GLX and it should match that (but will be VERY slow).
    • One of your old posts describes your GPU as: Intel GMA3100 (G31) – is this the same system you’re running on now? If so, that is ancient. It looks like that came out in 2007 – which predates the existence of OpenGL 3.0; so, getting 2.1 as the newest context available when talking to actual hardware is not surprising…
      • e0qdk@kbin.social
        link
        fedilink
        arrow-up
        2
        ·
        9 months ago

        Try compiling GLFW from source against GLX instead of EGL. If glxinfo is talking to a software implementation running on your system, I’d expect GLFW built to use GLX would use the same implementation on your computer.

          • e0qdk@kbin.social
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            9 months ago
            • GLFW is intended to be built with cmake.
            • After unzipping the source, make a build directory, and configure glfw3
            • ^^ I like using ccmake to do this interactively, but you can also just pass flags to cmake if you know what they are
            • You should build with GLFW_USE_WAYLAND and GLFW_USE_OSMESA turned off to get it to try to build against X11.
            • You will probably also want to turn off GLFW_BUILD_DOCS, GLFW_BUILD_EXAMPLES, GLFW_BUILD_TESTS
            • You can adjust CMAKE_INSTALL_PREFIX if you don’t want to use the /usr/local default install path.
            • After generating a Makefile, run make and make install
            • glfw3 generates a pkg-config compatible .pc file as part of its build process that lists flags needed for compilation and linking against the library. Normally, you’d just call pkg-config --cflags --libs --static glfw3 to get this info as part of your own build process (in a Makefile, for example) or else require glfw3 as part of a cmake-based build, but you can read what’s generated in there if that program is not available to you for some reason. In case it’s helpful for comparison, what I get with a custom build of the static library version of glfw3 installed into /usr/local on a slightly old version of Ubuntu is output like -I/usr/local/include -L/usr/local/lib -lglfw -lrt -lm -ldl -lX11 -lpthread -lxcb -lXau -lXdmcp but you may need something different for your particular configuration.

            Basically, something like this, probably, to do the compilation and get the flags to pass to g++:

            wget 'https://github.com/glfw/glfw/releases/download/3.3.8/glfw-3.3.8.zip'
            unzip glfw-3.3.8.zip
            mkdir build
            cd build
            cmake -D GLFW_BUILD_DOCS=OFF -D GLFW_BUILD_EXAMPLES=OFF -D GLFW_BUILD_TESTS=OFF -D GLFW_USE_OSMESA=OFF -D GLFW_USE_WAYLAND=OFF -D GLFW_VULKAN_STATIC=OFF ../glfw-3.3.8
            make
            make install
            
            pkg-config --cflags --libs --static glfw3
            
            

            If you want to just compile a single cpp file after building and install, you can do something like

            g++ main.cpp `pkg-config --cflags --libs --static glfw3` -lGL
            
            
  • tony@lemmy.hoyle.me.uk
    link
    fedilink
    arrow-up
    3
    ·
    9 months ago

    2.1 is ancient.

    A heck of a lot of old stuff has been deprecated in the intervening years… it’s possible your drivers don’t support emulating that old… although I’d found most can still do 1.x (because it was relatively simple, fixed pipeline).

    TBH though if you’re writing anything new I’d start with vulkan, as it’s really the next gen and nowadays supported everywhere.

  • Rustmilian@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    9 months ago

    It’s more than likely that your hardware doesn’t support OpenGL 4.2. While your system may be reporting that it’s using version 4.2, llvmpipe is a software implementation of OpenGL rather than a hardware implementation.

    Looking at your paste bin you can see it’s using Core Profile & Compatibility Profile which means that it only supports the core features of OpenGL 4.2 and provides backward compatibility with older versions of OpenGL. If you want to use the compatibility profile, the highest version you can request is 3.0, however your hardware/driver probably only supports 3.0 as Core Profiles and to why you’re stuck with OpenGL 2.1.