Search in sources :

Example 16 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project jmonkeyengine by jMonkeyEngine.

the class JoglAbstractDisplay method initGLCanvas.

protected void initGLCanvas() {
    device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    GLCapabilities caps;
    if (settings.getRenderer().equals(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE)) {
        caps = new GLCapabilities(GLProfile.getMaxProgrammable(true));
    } else {
        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);
}
Also used : GLCanvas(com.jogamp.opengl.awt.GLCanvas) GLAutoDrawable(com.jogamp.opengl.GLAutoDrawable) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLRunnable(com.jogamp.opengl.GLRunnable)

Example 17 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project processing by processing.

the class PSurfaceJOGL method setSmooth.

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);
}
Also used : GLCapabilities(com.jogamp.opengl.GLCapabilities) NativeSurface(com.jogamp.nativewindow.NativeSurface) MutableGraphicsConfiguration(com.jogamp.nativewindow.MutableGraphicsConfiguration)

Example 18 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project processing by processing.

the class PSurfaceJOGL method initGL.

protected void initGL() {
    //  System.out.println("*******************************");
    if (profile == null) {
        if (PJOGL.profile == 1) {
            try {
                profile = GLProfile.getGL2ES1();
            } catch (GLException ex) {
                profile = GLProfile.getMaxFixedFunc(true);
            }
        } else 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.smoothToSamples(graphics.smooth));
    caps.setBackgroundOpaque(true);
    caps.setOnscreen(true);
    pgl.setCaps(caps);
}
Also used : GLCapabilities(com.jogamp.opengl.GLCapabilities) GLException(com.jogamp.opengl.GLException)

Example 19 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project artisynth_core by artisynth.

the class GL3Sample method newJFrame.

public static JFrame newJFrame(String name, GLEventListener sample, int x, int y, int width, int height) {
    JFrame frame = new JFrame(name);
    frame.setBounds(x, y, width, height);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GLProfile glp = GLProfile.get(GLProfile.GL3);
    GLCapabilities glCapabilities = new GLCapabilities(glp);
    // GLCanvas canvas = new GLCanvas(glCapabilities);
    GLJPanel canvas = new GLJPanel(glCapabilities);
    canvas.addGLEventListener(sample);
    frame.add(canvas);
    return frame;
}
Also used : GLCapabilities(com.jogamp.opengl.GLCapabilities) JFrame(javax.swing.JFrame) GLJPanel(com.jogamp.opengl.awt.GLJPanel) GLProfile(com.jogamp.opengl.GLProfile)

Example 20 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project artisynth_core by artisynth.

the class GLCanvasTest method main.

public static void main(String[] args) {
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);
    GLCanvas canvas = new GLCanvas(caps);
    final Frame frame = new Frame("AWT Window Test");
    frame.setSize(300, 300);
    frame.setLocation(30, 30);
    frame.add(canvas);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            frame.dispose();
            System.exit(0);
        }
    });
    canvas.addGLEventListener(new GLCanvasTest());
    FPSAnimator animator = new FPSAnimator(canvas, 60);
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCanvas(com.jogamp.opengl.awt.GLCanvas) GLCapabilities(com.jogamp.opengl.GLCapabilities) Frame(java.awt.Frame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) GLProfile(com.jogamp.opengl.GLProfile)

Aggregations

GLCapabilities (com.jogamp.opengl.GLCapabilities)27 GLProfile (com.jogamp.opengl.GLProfile)18 FPSAnimator (com.jogamp.opengl.util.FPSAnimator)12 GLWindow (com.jogamp.newt.opengl.GLWindow)8 GLJPanel (com.jogamp.opengl.awt.GLJPanel)4 GLAutoDrawable (com.jogamp.opengl.GLAutoDrawable)3 GLCanvas (com.jogamp.opengl.awt.GLCanvas)3 Frame (java.awt.Frame)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3 GLRunnable (com.jogamp.opengl.GLRunnable)2 JFrame (javax.swing.JFrame)2 GL3SharedResources (maspack.render.GL.GL3.GL3SharedResources)2 GL3VertexAttributeInfo (maspack.render.GL.GL3.GL3VertexAttributeInfo)2 GL3VertexAttributeMap (maspack.render.GL.GL3.GL3VertexAttributeMap)2 StringIntPair (maspack.render.GL.GL3.GLSLGenerator.StringIntPair)2 GLJPanel (maspack.render.GL.jogl.GLJPanel)2 NWindow (automenta.vivisect.swing.NWindow)1 MutableGraphicsConfiguration (com.jogamp.nativewindow.MutableGraphicsConfiguration)1 NativeSurface (com.jogamp.nativewindow.NativeSurface)1