Search in sources :

Example 1 with GL2ES2

use of com.jogamp.opengl.GL2ES2 in project selenium_java by sergueik.

the class CanvasEx method createContents.

private void createContents(Shell shell) {
    shell.setLayout(new FillLayout());
    animator = new FPSAnimator(60);
    animator.setUpdateFPSFrames(60, System.err);
    @SuppressWarnings("unused") Canvas canvas = new Canvas(shell, SWT.NONE);
    final GLProfile pro = GLProfile.get(GLProfile.GL2GL3);
    final GLCapabilities cap = new GLCapabilities(pro);
    glCanvas = new GLCanvas(shell, 0, cap, (GLCapabilitiesChooser) null);
    glCanvas.addGLEventListener(new GLEventListener() {

        @Override
        public void display(final GLAutoDrawable drawable) {
            final GL2ES2 gl = drawable.getGL().getGL2ES2();
            gl.glClearColor(1.0f, 0f, 1.0f, 1f);
            gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        }

        @Override
        public void dispose(final GLAutoDrawable drawable) {
            System.err.println("dispose");
        }

        @Override
        public void init(final GLAutoDrawable drawable) {
            System.err.println("init");
        }

        @Override
        public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int w, final int h) {
        }
    });
    animator.add(glCanvas);
    glCanvas.setVisible(true);
    shell.addListener(SWT.Close, new Listener() {

        public void handleEvent(Event event) {
            animator.stop();
            glCanvas.destroy();
        // TODO: [ERROR] local variable shell is accessed from within inner
        // class; needs to be declared final
        // shell.setVisible(false);
        }
    });
    animator.start();
}
Also used : GLAutoDrawable(com.jogamp.opengl.GLAutoDrawable) GLEventListener(com.jogamp.opengl.GLEventListener) Listener(org.eclipse.swt.widgets.Listener) GLCanvas(com.jogamp.opengl.swt.GLCanvas) Canvas(org.eclipse.swt.widgets.Canvas) FillLayout(org.eclipse.swt.layout.FillLayout) GLEventListener(com.jogamp.opengl.GLEventListener) FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCanvas(com.jogamp.opengl.swt.GLCanvas) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLCapabilitiesChooser(com.jogamp.opengl.GLCapabilitiesChooser) GL2ES2(com.jogamp.opengl.GL2ES2) Event(org.eclipse.swt.widgets.Event) GLProfile(com.jogamp.opengl.GLProfile)

Example 2 with GL2ES2

use of com.jogamp.opengl.GL2ES2 in project constellation by constellation-app.

the class JoglVersionAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final GLProfile glProfile = SharedDrawable.getGLProfile();
    // Create GLContext and trigger GLContext object creation and native realization.
    final GLAutoDrawable drawable = GLDrawableFactory.getFactory(glProfile).createDummyAutoDrawable(null, true, new GLCapabilities(glProfile), null);
    drawable.display();
    drawable.getContext().makeCurrent();
    final GL gl = drawable.getGL().getGL3();
    final StringBuilder sb = new StringBuilder();
    sb.append(String.format("OpenGL version: %s\n", gl.glGetString(GL.GL_VERSION)));
    sb.append(String.format("Vendor: %s\n", gl.glGetString(GL.GL_VENDOR)));
    sb.append(String.format("Renderer: %s\n", gl.glGetString(GL.GL_RENDERER)));
    if (gl instanceof GL2ES2) {
        sb.append(String.format("Shading language version: %s\n", gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)));
    }
    final JoglVersion jv = JoglVersion.getInstance();
    final Set<?> names = jv.getAttributeNames();
    final ArrayList<String> lines = new ArrayList<>();
    for (final Object name : names) {
        lines.add(String.format("%s: %s\n", name, jv.getAttribute((Attributes.Name) name)));
    }
    Collections.sort(lines);
    sb.append("\nJOGL Attributes\n");
    for (final String line : lines) {
        sb.append(line);
    }
    sb.append("\nGL Strings\n");
    JoglVersion.getGLStrings(gl, sb, true);
    sb.append(SeparatorConstants.NEWLINE);
    final InfoTextPanel itp = new InfoTextPanel(sb.toString());
    final NotifyDescriptor.Message msg = new NotifyDescriptor.Message(itp);
    msg.setTitle(Bundle.CTL_JoglVersionAction());
    DialogDisplayer.getDefault().notify(msg);
}
Also used : GLAutoDrawable(com.jogamp.opengl.GLAutoDrawable) GL(com.jogamp.opengl.GL) JoglVersion(com.jogamp.opengl.JoglVersion) ArrayList(java.util.ArrayList) Attributes(java.util.jar.Attributes) InfoTextPanel(au.gov.asd.tac.constellation.utilities.gui.InfoTextPanel) NotifyDescriptor(org.openide.NotifyDescriptor) GLCapabilities(com.jogamp.opengl.GLCapabilities) GL2ES2(com.jogamp.opengl.GL2ES2) GLProfile(com.jogamp.opengl.GLProfile)

Aggregations

GL2ES2 (com.jogamp.opengl.GL2ES2)2 GLAutoDrawable (com.jogamp.opengl.GLAutoDrawable)2 GLCapabilities (com.jogamp.opengl.GLCapabilities)2 GLProfile (com.jogamp.opengl.GLProfile)2 InfoTextPanel (au.gov.asd.tac.constellation.utilities.gui.InfoTextPanel)1 GL (com.jogamp.opengl.GL)1 GLCapabilitiesChooser (com.jogamp.opengl.GLCapabilitiesChooser)1 GLEventListener (com.jogamp.opengl.GLEventListener)1 JoglVersion (com.jogamp.opengl.JoglVersion)1 GLCanvas (com.jogamp.opengl.swt.GLCanvas)1 FPSAnimator (com.jogamp.opengl.util.FPSAnimator)1 ArrayList (java.util.ArrayList)1 Attributes (java.util.jar.Attributes)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Canvas (org.eclipse.swt.widgets.Canvas)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 NotifyDescriptor (org.openide.NotifyDescriptor)1