I want to select the best available OpenGL context for the GPU by reading the capabilities. Here is my current solution.
public static void main(String[] args)
{
try
{
Display.create();
System.out.println("Compatibility Mode");
checkGLCaps();
Display.destroy();
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 2);
contextAtrributes.withForwardCompatible(true);
contextAtrributes.withProfileCore(true);
Display.create(pixelFormat, contextAtrributes);
System.out.println("Core Mode");
checkGLCaps();
Display.destroy();
}
catch (LWJGLException e)
{
e.printStackTrace();
}
}
static void checkGLCaps()
{
System.out.println("OpenGL 1.1: " + GLContext.getCapabilities().OpenGL11);
System.out.println("OpenGL 1.2: " + GLContext.getCapabilities().OpenGL12);
System.out.println("OpenGL 1.3: " + GLContext.getCapabilities().OpenGL13);
System.out.println("OpenGL 1.4: " + GLContext.getCapabilities().OpenGL14);
System.out.println("OpenGL 1.5: " + GLContext.getCapabilities().OpenGL15);
System.out.println("OpenGL 2.0: " + GLContext.getCapabilities().OpenGL20);
System.out.println("OpenGL 2.1: " + GLContext.getCapabilities().OpenGL21);
System.out.println("OpenGL 3.0: " + GLContext.getCapabilities().OpenGL30);
System.out.println("OpenGL 3.1: " + GLContext.getCapabilities().OpenGL31);
System.out.println("OpenGL 3.2: " + GLContext.getCapabilities().OpenGL32);
System.out.println("OpenGL 3.3: " + GLContext.getCapabilities().OpenGL33);
System.out.println("OpenGL 4.0: " + GLContext.getCapabilities().OpenGL40);
}
But this requires the window to be created before the capabilities are reported which results in blinking windows before launching the game. Is it possible to do this efficiently and without creating the Display?