WindowContext createWindow(final GLProfile glp, final boolean debugGL) { final GLCapabilities caps = new GLCapabilities(glp); // // Create native windowing resources .. X11/Win/OSX // final Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 Assert.assertNotNull(screen); final Window window = NewtFactory.createWindow(screen, caps); Assert.assertNotNull(window); window.setSize(128, 128); window.setVisible(true); final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); final GLDrawable drawable = factory.createGLDrawable(window); Assert.assertNotNull(drawable); drawable.setRealized(true); final GLContext context = drawable.createContext(null); Assert.assertNotNull(context); context.enableGLDebugMessage(debugGL); final int res = context.makeCurrent(); Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW == res || GLContext.CONTEXT_CURRENT == res); return new WindowContext(window, context); }
void destroyWindow(final WindowContext winctx) { final GLDrawable drawable = winctx.context.getGLDrawable(); Assert.assertNotNull(winctx.context); winctx.context.destroy(); Assert.assertNotNull(drawable); drawable.setRealized(false); Assert.assertNotNull(winctx.window); winctx.window.destroy(); }