LWJGL 3 更改 OpenGL 上下文/ContextAttribs 替代

LWJGL 3 change OpenGL context / ContextAttribs alternative

在 LWJGL 2 中,我可以使用较旧的 OpenGL 配置文件来执行此操作:

PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 2) //<--
            .withProfileCore(true)
            .withForwardCompatible(true);

Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.setTitle(WINDOW_TITLE);
Display.create(pixelFormat, contextAtrributes);

LWJGL 3 中没有显示 class,我该怎么做?

ContextAttribs 使用 glfwWindowHint:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);

然后

glfwCreateWindow(width, height, title, 0, 0)

glfwWindowHint 也可以更改 PixelFormat 中的选项,默认值不同,因此您可能需要。

您还需要先致电 glfwInit()

可以在此处找到更完整的指南:http://www.lwjgl.org/guide