I am trying to make a 2D OpenGL project using LWJGL 2, and I am having trouble with basic rendering.
Main 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();
}
}
For some reason, I get a FunctionNotSupported error, but the code works in http://www.cokeandcode.com/info/tut2d-4.html. I tried setting the OpenGl version to 2.0, and I got an error in Display.create and the OpenGL context was not created. I've heard that sometimes graphics drivers can break LWJGL, but mine are updated and other projects I have works. Also some people say that the function just isn't in 3.2, and if so how would I do this?
Your machine likely does not support Legacy GL, making it a "Core" context. Core contexts have deprecated legacy functions, like matrix operations, unavailable.
Find a tutorial that is for modern core opengl.