Skip to content

Instantly share code, notes, and snippets.

@davegurnell
Created July 15, 2012 09:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davegurnell/3116055 to your computer and use it in GitHub Desktop.
Save davegurnell/3116055 to your computer and use it in GitHub Desktop.
LWJGL OpenGL version test case
import org.lwjgl.*;
import org.lwjgl.opengl.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.util.glu.GLU.*;
import static org.lwjgl.BufferUtils.*;
public class GLTest {
public static void main(String[] args) {
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAttributes = new ContextAttribs(3, 2);
contextAttributes.withForwardCompatible(true);
contextAttributes.withProfileCore(true);
Display.setDisplayMode(new DisplayMode(800,600));
Display.create(pixelFormat, contextAttributes);
System.out.println("OS name " + System.getProperty("os.name"));
System.out.println("OS version " + System.getProperty("os.version"));
System.out.println("LWJGL version " + org.lwjgl.Sys.getVersion());
System.out.println("OpenGL version " + glGetString(GL_VERSION));
// On my laptop, this outputs:
//
// OS name Mac OS X
// OS version 10.7.4
// LWJGL version 2.8.4
// OpenGL version 2.1 NVIDIA-7.18.18
//
// Later on I use GL30.glGenVertexArrays and I get a
// "Function is not supported" exception.
//
// I assume this is due to the OptnGL version.
//
// From what I can tell, LWJGL 2.8.0+ should try to select OptnGL 3.2.
// This doesn't appear to be the case (or maybe I'm not getting something).
}
}
@saolsen
Copy link

saolsen commented Mar 6, 2013

Hey, did you figure out how to get openGL 3+ working with osx and lwjgl? I found this gist while searching for a solution to this same problem.

@AlexModGuy
Copy link

thanks, really helped me with shader version errors.

@JamesJr91
Copy link

Should have a try-catch around Display.setDisplayMode and Display.create

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment