예제 #1
0
 public void setFrameRate(float fps) {
   if (animator != null) {
     animator.stop();
     animator.setFPS((int) fps);
     pgl.setFps(fps);
     animator.start();
   }
 }
예제 #2
0
  protected void initGL() {
    //  System.out.println("*******************************");
    if (profile == null) {
      if (PJOGL.profile == 2) {
        try {
          profile = GLProfile.getGL2ES2();
        } catch (GLException ex) {
          profile = GLProfile.getMaxProgrammable(true);
        }
      } else if (PJOGL.profile == 3) {
        try {
          profile = GLProfile.getGL2GL3();
        } catch (GLException ex) {
          profile = GLProfile.getMaxProgrammable(true);
        }
        if (!profile.isGL3()) {
          PGraphics.showWarning("Requested profile GL3 but is not available, got: " + profile);
        }
      } else if (PJOGL.profile == 4) {
        try {
          profile = GLProfile.getGL4ES3();
        } catch (GLException ex) {
          profile = GLProfile.getMaxProgrammable(true);
        }
        if (!profile.isGL4()) {
          PGraphics.showWarning("Requested profile GL4 but is not available, got: " + profile);
        }
      } else throw new RuntimeException(PGL.UNSUPPORTED_GLPROF_ERROR);
    }

    // Setting up the desired capabilities;
    GLCapabilities caps = new GLCapabilities(profile);
    caps.setAlphaBits(PGL.REQUESTED_ALPHA_BITS);
    caps.setDepthBits(PGL.REQUESTED_DEPTH_BITS);
    caps.setStencilBits(PGL.REQUESTED_STENCIL_BITS);

    //  caps.setPBuffer(false);
    //  caps.setFBO(false);

    pgl.reqNumSamples = PGL.smoothToSamples(graphics.smooth);
    caps.setSampleBuffers(true);
    caps.setNumSamples(pgl.reqNumSamples);
    caps.setBackgroundOpaque(true);
    caps.setOnscreen(true);
    pgl.capabilities = caps;
  }
예제 #3
0
  public void placePresent(int stopColor) {

    //    if (presentMode) {
    //      System.err.println("Present mode");
    //    System.err.println("WILL USE FBO");
    presentMode = pgl.presentMode = true;
    offsetX = pgl.offsetX = 0.5f * (screenRect.width - sketchWidth);
    offsetY = pgl.offsetY = 0.5f * (screenRect.height - sketchHeight);
    pgl.requestFBOLayer();

    window.setSize(screenRect.width, screenRect.height);
    PApplet.hideMenuBar();
    window.setTopLevelPosition(sketchX + screenRect.x, sketchY + screenRect.y);
    //    window.setTopLevelPosition(0, 0);
    window.setFullscreen(true);

    placedWindow = true;
    if (requestedStart) startThread();

    //    }
  }
예제 #4
0
 public void setSmooth(int level) {
   pgl.reqNumSamples = level;
   GLCapabilities caps = new GLCapabilities(profile);
   caps.setAlphaBits(PGL.REQUESTED_ALPHA_BITS);
   caps.setDepthBits(PGL.REQUESTED_DEPTH_BITS);
   caps.setStencilBits(PGL.REQUESTED_STENCIL_BITS);
   caps.setSampleBuffers(true);
   caps.setNumSamples(pgl.reqNumSamples);
   caps.setBackgroundOpaque(true);
   caps.setOnscreen(true);
   NativeSurface target = window.getNativeSurface();
   MutableGraphicsConfiguration config =
       (MutableGraphicsConfiguration) target.getGraphicsConfiguration();
   config.setChosenCapabilities(caps);
 }