Ejemplo n.º 1
0
  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);
  }