Card supports OpenGL 4.1 but no GL4 implementation on thread?

最后都变了- 提交于 2019-12-02 02:12:51

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);
}

For running the book's examples on a Mac, I have placed instructions on this website: http://athena.ecs.csus.edu/~gordonvs/errataMac.html

In summary, you need to:

  • make sure you've installed the latest Java SE
  • place the relevant JOGL libraries into System/Library/Java/Extensions (the particular ones required are listed in the above website)
  • add the code described above by Julien (thanks!)
  • change the version numbers on the shaders to 410 (or whatever your Mac supports)
  • in the examples that use textures, replace the binding layout qualifiers in the shaders to appropriate calls to glUniform1i() in the Java application (for compatibility with version 4.1)

If more idiosyncrasies are identified, I'll add them to the instructions in the website.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!