@Override
protected void onInit() {
int screen = X11.XDefaultScreen(windowConnection);
int[] xvi_attrs = new int[]{
GLX.GLX_RGBA,
GLX.GLX_DOUBLEBUFFER,
GLX.GLX_STENCIL_SIZE, 1,
0};
GLXCapabilities glxcaps = GL.createCapabilitiesGLX(windowConnection, screen);
if(glxcaps.GLX13 && glxcaps.GLX_ARB_create_context && glxcaps.GLX_ARB_create_context_profile) {
PointerBuffer fbc = GLX13.glXChooseFBConfig(windowConnection, screen, new int[] {0});
if(fbc == null || fbc.capacity() < 1) throw new Error("GLX could not find any FBConfig!");
int i = debug ? 0 : 3;
while(context == 0 && ctx_attrs.length > i) {
context = GLXARBCreateContext.glXCreateContextAttribsARB(windowConnection, fbc.get(), 0, true, ctx_attrs[i]);
}
} else {
if(debug) throw new Error("GLX could not create a debug context!");
XVisualInfo xvi = GLX.glXChooseVisual(windowConnection, screen, xvi_attrs);
context = GLX.glXCreateContext(windowConnection, xvi, 0, true);
}
if (context == 0) throw new Error("Could not create GLX context!");
parent.wrapNewContext();
}