Card supports OpenGL 4.1 but no GL4 implementation on thread?

前端 未结 2 1447
旧时难觅i
旧时难觅i 2021-01-22 11:53

When I run my test JOGL app, it says that I only have GL2 available on the thread when my system supports up to OpenGL 4.1 according to the OpenGl Extensions Vi

2条回答
  •  面向向阳花
    2021-01-22 12:42

    It turns out that OSX falls back to OpenGL 2.1 so you need to set the core profile yourself.

    $ glxinfo | grep OpenGL
    OpenGL vendor string: ATI Technologies Inc.
    OpenGL renderer string: AMD Radeon R9 M370X OpenGL Engine
    OpenGL version string: 2.1 ATI-1.42.15
    OpenGL shading language version string: 1.20
    

    I was able to set the core version (OpenGL 4.1) by passing GLCapabilities into the GLCanvas constructor.

    Here is the new, fixed constructor:

    public Code() {
        setTitle("Chapter 2 - program1");
        setSize(600, 400);
        setLocation(200, 200);
    
        // This was the fix
        GLProfile glp = GLProfile.getMaxProgrammableCore(true);
        GLCapabilities caps = new GLCapabilities(glp);
        myCanvas = new GLCanvas(caps);
    
        myCanvas.addGLEventListener(this);
        this.add(myCanvas);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }
    

提交回复
热议问题