Reputation: 37
I am using Java version 1.8, and I use lwjgl version 2.9.3. I tried the below code by following a YouTube tutorial to setup OpenGl in Java. Below is the code,
package renderEngin;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;
public class DisplayManager
{
private static final int WIDTH = 1366;
private static final int HEIGHT = 768;
private static final int FPS_MAX = 120;
public static void createDisplay()
{
ContextAttribs attribs = new ContextAttribs(3,2);
attribs.withForwardCompatible(true);
attribs.withProfileCore(true);
try
{
Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
Display.create(new PixelFormat(), attribs);
Display.setTitle("Jigoku");
}
catch (LWJGLException e)
{
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
}
public static void updateDisplay()
{
Display.sync(FPS_MAX);
Display.update();
}
public static void closeDisplay()
{
Display.destroy();
}
}
and the main function in,
package enginTester;
import org.lwjgl.opengl.Display;
import renderEngin.DisplayManager;
public class MainGameLoop {
public static void main(String[] args)
{
DisplayManager.createDisplay();
while(!Display.isCloseRequested())
{
DisplayManager.updateDisplay();
}
DisplayManager.closeDisplay();
}
}
This question may seem like a dumb one, but I am still a rookie in Java and I have no idea where I am going wrong. Also I have searched the web but none of the answers seem to work. Someone answered to change the lwjgl version and so I changed it from 2.9.1 to 2.9.3 but it does not seem to work. Also I use eclipse IDE for the project. Please help me.
Upvotes: 1
Views: 311
Reputation: 23
Maybe this post could help: java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
Try to use a newer version of java, or even switch to lwjgl3(I know i answered late and you probably solved the issue)
edit: If you switch to LWJGL3 here is a book that might help: https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl/content/
Upvotes: 1