Exemplo n.º 1
0
 /** Returns the default, desired OpenGL capabilities needed for this component. */
 public static GLCapabilities getDefaultCapabalities() {
   GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
   caps.setRedBits(8);
   caps.setGreenBits(8);
   caps.setBlueBits(8);
   caps.setAlphaBits(8);
   caps.setDoubleBuffered(true);
   caps.setHardwareAccelerated(true);
   caps.setNumSamples(4);
   caps.setBackgroundOpaque(false);
   caps.setSampleBuffers(true);
   return caps;
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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;
  }