OpenGL 函数给出 FunctionNotSupported 错误

OpenGL functions give FunctionNotSupported error

我正在尝试使用 LWJGL 2 制作 2D OpenGL 项目,但我在基本渲染方面遇到了问题。

主要class:

public class ScratchCord {
private Renderer renderer;
public TextureManager manager;
private int i = 0;
private int i2 = 0;

private ScratchCord() {
    renderer = new Renderer(this);
    manager = new TextureManager();
    ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
    try {
        Display.setDisplayMode(new DisplayMode(1240, 740));
        Display.create(new PixelFormat(), attribs);
        Display.setTitle("ScratchCord");
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    GL11.glViewport(0, 0, 1240, 740);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 1240, 740, 0, -1, 1);
}

private void start() {
    while (!Display.isCloseRequested()) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        renderer.draw(i, i2, "ScratchCord/src/main/resources/textures/download.jpg", 200, 200);
        Display.sync(60);
        Display.update();
        i += 1;
        i2 += 1;
    }
}

public static void main(String[] args) {
    System.setProperty("org.lwjgl.util.NoChecks","true");
    ScratchCord scratchCord = new ScratchCord();
    scratchCord.start();
}
}

出于某种原因,我收到 FunctionNotSupported 错误,但代码在 http://www.cokeandcode.com/info/tut2d-4.html 中有效。 我尝试将 OpenGl 版本设置为 2.0,但在 Display.create 中出现错误并且未创建 OpenGL 上下文。 我听说有时图形驱动程序会破坏 LWJGL,但我的已经更新,我的其他项目也能正常工作。 还有一些人说这个功能只是不在 3.2 中,如果是这样我该怎么办?

您的机器可能不支持 Legacy GL,使其成为 "Core" 上下文。核心上下文已弃用遗留功能,如矩阵运算,不可用。

查找适用于现代核心 opengl 的教程。