Java Code Examples for com.jogamp.opengl.GLProfile#get()

The following examples show how to use com.jogamp.opengl.GLProfile#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLForm.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public GLForm(Plot3DGL plt) {
    this.plt = plt;
    final GLProfile gp = GLProfile.get(GLProfile.GL2);
    GLCapabilities cap = new GLCapabilities(gp);

    glcp = new GLChartPanel(cap, plt);
    glcp.setSize(400, 400);
    
    this.getContentPane().add(glcp);
    
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing();
        }
    });
    
    glcp.animator_start();
}
 
Example 2
Source File: J3DBasic.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        J3DBasic b = new J3DBasic();
        gc.addGLEventListener(b);
        gc.setSize(600, 400);

        final JFrame frame = new JFrame("JOGL 3D");

        frame.getContentPane().add(gc);
        frame.setSize(frame.getContentPane().getPreferredSize());
        frame.setVisible(true);
    }
 
Example 3
Source File: J3DTriangle.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        J3DTriangle triangle = new J3DTriangle();

        gc.addGLEventListener(triangle);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("3D Triangle");

        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);

        final FPSAnimator animator = new FPSAnimator(gc, 400, true);
        animator.start();
    }
 
Example 4
Source File: JLight.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        JLight tr = new JLight();
        gc.addGLEventListener(tr);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Lighting");
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);

        final FPSAnimator animator = new FPSAnimator(gc, 400, true);
        animator.start();
    }
 
Example 5
Source File: JPaddle.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        JPaddle paddle = new JPaddle();

        gc.addGLEventListener(paddle);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("Motor Paddle");
        frame.add(gc);
        frame.setSize(600, 500);
        frame.setVisible(true);

        final FPSAnimator animator = new FPSAnimator(gc, 200, true);
        animator.start();
    }
 
Example 6
Source File: J3DCube.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLJPanel gc = new GLJPanel(cap);
        J3DCube cube = new J3DCube();

        gc.addGLEventListener(cube);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame(" 3D cube");
        frame.add(gc);
        frame.setSize(600, 500);
        frame.setVisible(true);

        final FPSAnimator animator = new FPSAnimator(gc, 200, true);
        animator.start();
    }
 
Example 7
Source File: Rhombus.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        //getting the capabilities object of GL2 profile
        final GLProfile profile = GLProfile.get(GLProfile.GL2);
        GLCapabilities capabilities = new GLCapabilities(profile);

        // The canvas
        final GLCanvas glcanvas = new GLCanvas(capabilities);
        Rhombus b = new Rhombus();
        glcanvas.addGLEventListener(b);
        glcanvas.setSize(400, 400);

        //creating frame
        final JFrame frame = new JFrame(" Rhombus 3d");

        //adding canvas to it
        frame.getContentPane().add(glcanvas);
        frame.setSize(frame.getContentPane().getPreferredSize());
        frame.setVisible(true);
    }
 
Example 8
Source File: Triangle.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        Triangle tr = new Triangle();
        gc.addGLEventListener(tr);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Triangle");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent windowevent) {
                frame.dispose();
                System.exit(0);
            }
        });
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);
    }
 
Example 9
Source File: JRotation.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        JRotation jr = new JRotation();
        gc.addGLEventListener(jr);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Rotation");

        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);

        final FPSAnimator animator = new FPSAnimator(gc, 400, true);
        animator.start();

    }
 
Example 10
Source File: JCudaDriverSimpleJOGL.java    From jcuda-samples with MIT License 5 votes vote down vote up
/**
 * Entry point for this sample.
 * 
 * @param args not used
 */
public static void main(String args[])
{
    GLProfile profile = GLProfile.get(GLProfile.GL3);
    final GLCapabilities capabilities = new GLCapabilities(profile);
    SwingUtilities.invokeLater(new Runnable()
    {
        public void run()
        {
            new JCudaDriverSimpleJOGL(capabilities);
        }
    });
}
 
Example 11
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void test11RegionRendererMSAA02() throws InterruptedException {
    if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) { // FIXME
        // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
        // FIXME: Also the GLSL code for VARIABLE_CURVE is not fit for mobile yet!
        System.err.println("disabled on non desktop (x86) arch for now ..");
        return;
    }
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02");
    window.addGLEventListener(listener);

    listener.setTech(-20, 00, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 00, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 00,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 12
Source File: JMColor.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        JMColor jc = new JMColor();
        gc.addGLEventListener(jc);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Mixed Coloring");
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);
    }
 
Example 13
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
    final GLProfile profile = GLProfile.get(GLProfile.GL2);
    GLCapabilities capabilities = new GLCapabilities(profile);
    // The canvas 
    final GLJPanel glcanvas = new GLJPanel(capabilities);
    CubeTexture r = new CubeTexture();
    glcanvas.addGLEventListener(r);
    glcanvas.setSize(400, 400);
    final JFrame frame = new JFrame(" Textured Cube");
    frame.getContentPane().add(glcanvas);
    frame.setSize(600, 600);
    frame.setVisible(true);
    final FPSAnimator animator = new FPSAnimator(glcanvas, 300, true);
    animator.start();
}
 
Example 14
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void test01RegionRendererNONE02() throws InterruptedException {
    if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) { // FIXME
        // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
        // FIXME: Also the GLSL code for VARIABLE_CURVE is not fit for mobile yet!
        System.err.println("disabled on non desktop (x86) arch for now ..");
        return;
    }
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02");
    window.addGLEventListener(listener);

    listener.setTech(-20, 0, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 0, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 0,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 15
Source File: BasicLine.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLJPanel gc = new GLJPanel(cap);
        BasicLine bl = new BasicLine();
        gc.addGLEventListener(bl);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Line");
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);
    }
 
Example 16
Source File: Test.java    From jogl-samples with MIT License 5 votes vote down vote up
private GLProfile getGlProfile() {
    switch (profile) {
        case ES:
            switch (major) {
                case 1:
                    return GLProfile.get(GLProfile.GL2ES1);
                case 2:
                    return GLProfile.get(GLProfile.GL2ES2);
                case 3:
                    return GLProfile.get(GLProfile.GL4ES3);
                default:
                    return GLProfile.getDefault();
            }
        case CORE:
            switch (major) {
                case 1:
                    return GLProfile.get(GLProfile.GL2);
                case 2:
                    return GLProfile.get(GLProfile.GL2);
                case 3:
                    if (profile == Profile.COMPATIBILITY) {
                        return GLProfile.get(GLProfile.GL3bc);
                    } else {
                        return GLProfile.get(GLProfile.GL3);
                    }
                case 4:
                    if (profile == Profile.COMPATIBILITY) {
                        return GLProfile.get(GLProfile.GL4bc);
                    } else {
                        return GLProfile.get(GLProfile.GL4);
                    }
            }
    }
    return GLProfile.getDefault();
}
 
Example 17
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
@Test
public void test10RegionRendererMSAA01() throws InterruptedException {
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
//    caps.setOnscreen(false);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
    window.addGLEventListener(listener);

    listener.setTech(-20, 00, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 00, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 00,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 18
Source File: TestTextRendererNEWT01.java    From jogl-samples with MIT License 4 votes vote down vote up
@Test
public void testTextRendererMSAA01() throws InterruptedException {
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);
    System.err.println("Requested: "+caps);

    final GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
    window.display();
    System.err.println("Chosen: "+window.getChosenGLCapabilities());

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final TextGLListener textGLListener = new TextGLListener(rs, 0, DEBUG, TRACE);
    textGLListener.attachInputListenerTo(window);
    window.addGLEventListener(textGLListener);

    if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
        textGLListener.setTech(-400, -30, 0f, -1000, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -30, 0,   -380, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -20, 0,    -80, 0);
        window.display();
        sleep();
    }

    if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
        textGLListener.setTech(-400, -30, 0f, -1000, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -30, 0,   -380, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -20, 0,    -80, 0);
        window.display();
        sleep();
    }

    destroyWindow(window);
}
 
Example 19
Source File: TestTextRendererNEWT10.java    From jogl-samples with MIT License 4 votes vote down vote up
void testTextRendererImpl(final int renderModes, final int sampleCount) throws InterruptedException, GLException, IOException {
    final GLProfile glp;
    if(forceGL3) {
        glp = GLProfile.get(GLProfile.GL3);
    } else if(forceES2) {
        glp = GLProfile.get(GLProfile.GLES2);
    } else {
        glp = GLProfile.getGL2ES2();
    }

    final GLCapabilities caps = new GLCapabilities( glp );
    caps.setAlphaBits(4);
    if( 0 < sampleCount && !Region.isVBAA(renderModes) ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(sampleCount);
    }
    System.err.println("Requested: "+caps);
    System.err.println("Requested: "+Region.getRenderModeString(renderModes));

    final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(caps, 800, 400, true);
    final GLDrawable drawable = winctx.context.getGLDrawable();
    final GL2ES2 gl = winctx.context.getGL().getGL2ES2();

    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    System.err.println("Chosen: "+winctx.window.getChosenCapabilities());

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
    rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
    final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes);

    // init
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    renderer.init(gl, 0);
    rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
    screenshot = new GLReadBufferUtil(false, false);

    // reshape
    gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());

    // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
    renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f);

    final int[] sampleCountIO = { sampleCount };
    // display
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    if( null == customStr ) {
        renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0,  0, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000,sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000, sampleCountIO);

        int c = 0;
        renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000, sampleCountIO);
    } else {
        renderString(drawable, gl, renderer, textRenderUtil, customStr, 0,  0, -1000, sampleCountIO);
    }
    drawable.swapBuffers();
    printScreen(renderModes, drawable, gl, false, sampleCount);

    sleep();

    // dispose
    screenshot.dispose(gl);
    renderer.destroy(gl);

    NEWTGLContext.destroyWindow(winctx);
}
 
Example 20
Source File: TestTextRendererNEWTBugXXXX.java    From jogl-samples with MIT License 4 votes vote down vote up
void testTextRendererImpl(final Font[] fonts, final int renderModes, final int sampleCount, final boolean onlyIssues) throws InterruptedException, GLException, IOException {
    final GLProfile glp;
    if(forceGL3) {
        glp = GLProfile.get(GLProfile.GL3);
    } else if(forceES2) {
        glp = GLProfile.get(GLProfile.GLES2);
    } else {
        glp = GLProfile.getGL2ES2();
    }

    final GLCapabilities caps = new GLCapabilities( glp );
    caps.setAlphaBits(4);
    if( 0 < sampleCount && !Region.isVBAA(renderModes) ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(sampleCount);
    }
    caps.setOnscreen(false);
    System.err.println("Requested: "+caps);
    System.err.println("Requested: "+Region.getRenderModeString(renderModes));

    final int totalHeight = ( (int)fontSize + 1 ) * ( onlyIssues ? 3 : 6 ) * fonts.length;
    final NEWTGLContext.WindowContext winctx =
            NEWTGLContext.createWindow(caps, 800, totalHeight, true);
    final GLDrawable drawable = winctx.context.getGLDrawable();
    final GL2ES2 gl = winctx.context.getGL().getGL2ES2();

    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    System.err.println("Chosen: "+winctx.window.getChosenCapabilities());

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
    rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
    final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes);

    // init
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    renderer.init(gl, 0);
    rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
    screenshot = new GLReadBufferUtil(false, false);

    // reshape
    gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());

    // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
    renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f);

    final int[] sampleCountIO = { sampleCount };
    // display
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    for(int i=0; i<fonts.length; i++) {
        final Font font = fonts[i];
        renderString(drawable, gl, renderer, font, textRenderUtil, font.getFullFamilyName(null).toString()+": "+issues, 0,  0==i?0:-1, -1000, sampleCountIO);
        if(!onlyIssues) {
            renderString(drawable, gl, renderer, font, textRenderUtil, "012345678901234567890123456789", 0,  -1, -1000, sampleCountIO);
            renderString(drawable, gl, renderer, font, textRenderUtil, "abcdefghijklmnopqrstuvwxyz", 0, -1, -1000, sampleCountIO);
            renderString(drawable, gl, renderer, font, textRenderUtil, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, -1, -1000, sampleCountIO);
        }
        renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO);
        renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO);
    }

    drawable.swapBuffers();
    printScreen(renderModes, drawable, gl, false, sampleCount);

    sleep();

    // dispose
    screenshot.dispose(gl);
    renderer.destroy(gl);

    NEWTGLContext.destroyWindow(winctx);
}