OpenGL函数会给出FunctionNotSupported错误

时间:2018-10-10 23:58:49

标签: java opengl lwjgl

我正在尝试使用LWJGL 2创建2D OpenGL项目,但是在基本渲染方面遇到了麻烦。

主类:

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中,如果可以,我该怎么做?

1 个答案:

答案 0 :(得分:-2)

您的计算机可能不支持Legacy GL,使其成为“ Core”上下文。核心上下文已弃用了旧功能,例如矩阵运算,不可用。

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

相关问题