Esempio n. 1
0
 @Test
 public void test01_DefaultNorm()
     throws AWTException, InterruptedException, InvocationTargetException {
   final GLProfile glp;
   if (forceGL3) {
     glp = GLProfile.get(GLProfile.GL3);
   } else if (forceES3) {
     glp = GLProfile.get(GLProfile.GLES3);
   } else if (forceES2) {
     glp = GLProfile.get(GLProfile.GLES2);
   } else if (forceGLFFP) {
     glp = GLProfile.getMaxFixedFunc(true);
   } else {
     glp = GLProfile.getDefault();
   }
   final GLCapabilities caps = new GLCapabilities(glp);
   if (useMSAA) {
     caps.setNumSamples(msaaNumSamples);
     caps.setSampleBuffers(true);
   }
   if (shallUsePBuffer) {
     caps.setPBuffer(true);
   }
   if (shallUseBitmap) {
     caps.setBitmap(true);
   }
   runTestGL(caps);
 }
  protected void initGLCanvas() {
    loadNatives();

    device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

    // FIXME use the settings to know whether to use the max programmable profile
    // then call GLProfile.getMaxProgrammable(true);
    GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
    caps.setHardwareAccelerated(true);
    caps.setDoubleBuffered(true);
    caps.setStencilBits(settings.getStencilBits());
    caps.setDepthBits(settings.getDepthBits());

    if (settings.getSamples() > 1) {
      caps.setSampleBuffers(true);
      caps.setNumSamples(settings.getSamples());
    }

    canvas =
        new GLCanvas(caps) {
          @Override
          public void addNotify() {
            super.addNotify();
            onCanvasAdded();
          }

          @Override
          public void removeNotify() {
            onCanvasRemoved();
            super.removeNotify();
          }
        };
    canvas.invoke(
        false,
        new GLRunnable() {
          public boolean run(GLAutoDrawable glad) {
            canvas.getGL().setSwapInterval(settings.isVSync() ? 1 : 0);
            return true;
          }
        });
    canvas.setFocusable(true);
    canvas.requestFocus();
    canvas.setSize(settings.getWidth(), settings.getHeight());
    canvas.setIgnoreRepaint(true);
    canvas.addGLEventListener(this);

    // FIXME not sure it is the best place to do that
    renderable.set(true);

    // TODO remove this block once for all when the unified renderer is stable
    /*if (settings.getBoolean("GraphicsDebug")) {
        canvas.invoke(false, new GLRunnable() {
            public boolean run(GLAutoDrawable glad) {
                GL gl = glad.getGL();
                if (gl.isGLES()) {
                    if (gl.isGLES1()) {
                        glad.setGL(new DebugGLES1(gl.getGLES1()));
                    } else {
                        if (gl.isGLES2()) {
                            glad.setGL(new DebugGLES2(gl.getGLES2()));
                        } else {
                            if (gl.isGLES3()) {
                            	glad.setGL(new DebugGLES3(gl.getGLES3()));
                            }
                        }
                    }
                } else {
                    if (gl.isGL4bc()) {
                        glad.setGL(new DebugGL4bc(gl.getGL4bc()));
                    } else {
                        if (gl.isGL4()) {
                            glad.setGL(new DebugGL4(gl.getGL4()));
                        } else {
                            if (gl.isGL3bc()) {
                                glad.setGL(new DebugGL3bc(gl.getGL3bc()));
                            } else {
                                if (gl.isGL3()) {
                                    glad.setGL(new DebugGL3(gl.getGL3()));
                                } else {
                                    if (gl.isGL2()) {
                                        glad.setGL(new DebugGL2(gl.getGL2()));
                                    }
                                }
                            }
                        }
                    }
                }
                return true;
            }
        });
    }

    renderer = new JoglRenderer();

    canvas.invoke(false, new GLRunnable() {
        public boolean run(GLAutoDrawable glad) {
            renderer.setMainFrameBufferSrgb(settings.getGammaCorrection());
            return true;
        }
    });*/
  }