Search in sources :

Example 1 with GL3SharedResources

use of maspack.render.GL.GL3.GL3SharedResources in project artisynth_core by artisynth.

the class MultiViewer method addGL3Viewer.

public void addGL3Viewer(String title, int x, int y, int w, int h) {
    if (gl3resources == null) {
        GLProfile glp3 = GLProfile.get(GLProfile.GL3);
        GLCapabilities cap = new GLCapabilities(glp3);
        cap.setSampleBuffers(true);
        cap.setNumSamples(8);
        // get attribute map from GLSL generator
        StringIntPair[] attributes = GLSLGenerator.ATTRIBUTES;
        GL3VertexAttributeMap attributeMap = new GL3VertexAttributeMap(new GL3VertexAttributeInfo(attributes[0].getString(), attributes[0].getInt()), new GL3VertexAttributeInfo(attributes[1].getString(), attributes[1].getInt()), new GL3VertexAttributeInfo(attributes[2].getString(), attributes[2].getInt()), new GL3VertexAttributeInfo(attributes[3].getString(), attributes[3].getInt()));
        for (int i = 4; i < attributes.length; ++i) {
            attributeMap.add(new GL3VertexAttributeInfo(attributes[i].getString(), attributes[i].getInt()));
        }
        gl3resources = new GL3SharedResources(cap, attributeMap);
    }
    GLViewer viewer = new GL3Viewer(null, gl3resources, w, h);
    addViewer(title, viewer, x, y, w, h);
}
Also used : GL3VertexAttributeInfo(maspack.render.GL.GL3.GL3VertexAttributeInfo) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLViewer(maspack.render.GL.GLViewer) GL3SharedResources(maspack.render.GL.GL3.GL3SharedResources) GL3Viewer(maspack.render.GL.GL3.GL3Viewer) GL3VertexAttributeMap(maspack.render.GL.GL3.GL3VertexAttributeMap) StringIntPair(maspack.render.GL.GL3.GLSLGenerator.StringIntPair) GLProfile(com.jogamp.opengl.GLProfile)

Example 2 with GL3SharedResources

use of maspack.render.GL.GL3.GL3SharedResources in project artisynth_core by artisynth.

the class GL3JPanelTest method main.

public static void main(String[] args) {
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);
    caps.setSampleBuffers(true);
    caps.setNumSamples(8);
    caps.setPBuffer(false);
    // GLCanvas canvas = new GLCanvas(caps);
    progManager = new GL3ProgramManager();
    if (resources == null) {
        // get attribute map from GLSL generator
        StringIntPair[] attributes = GLSLGenerator.ATTRIBUTES;
        GL3VertexAttributeMap attributeMap = new GL3VertexAttributeMap(new GL3VertexAttributeInfo(attributes[0].getString(), attributes[0].getInt()), new GL3VertexAttributeInfo(attributes[1].getString(), attributes[1].getInt()), new GL3VertexAttributeInfo(attributes[2].getString(), attributes[2].getInt()), new GL3VertexAttributeInfo(attributes[3].getString(), attributes[3].getInt()));
        for (int i = 4; i < attributes.length; ++i) {
            attributeMap.add(new GL3VertexAttributeInfo(attributes[i].getString(), attributes[i].getInt()));
        }
        resources = new GL3SharedResources(caps, attributeMap);
    }
    lightManager = new GLLightManager();
    setDefaultLights();
    final GLJPanel canvas = resources.createPanel();
    final Frame frame = new Frame("AWT Window Test");
    frame.setSize(width, height);
    frame.setLocation(30, 30);
    frame.add(canvas);
    frame.setVisible(true);
    resources.registerViewer(frame);
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            frame.remove(canvas);
            resources.deregisterViewer(frame);
            frame.dispose();
            System.exit(0);
        }
    });
    canvas.addGLEventListener(new GL3JPanelTest());
    FPSAnimator animator = new FPSAnimator(canvas, 60);
    animator.start();
}
Also used : GL3ProgramManager(maspack.render.GL.GL3.GL3ProgramManager) Frame(java.awt.Frame) GL3SharedResources(maspack.render.GL.GL3.GL3SharedResources) WindowAdapter(java.awt.event.WindowAdapter) GLLightManager(maspack.render.GL.GLLightManager) StringIntPair(maspack.render.GL.GL3.GLSLGenerator.StringIntPair) GL3VertexAttributeInfo(maspack.render.GL.GL3.GL3VertexAttributeInfo) FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLJPanel(maspack.render.GL.jogl.GLJPanel) WindowEvent(java.awt.event.WindowEvent) GL3VertexAttributeMap(maspack.render.GL.GL3.GL3VertexAttributeMap) GLProfile(com.jogamp.opengl.GLProfile)

Aggregations

GLCapabilities (com.jogamp.opengl.GLCapabilities)2 GLProfile (com.jogamp.opengl.GLProfile)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 FPSAnimator (com.jogamp.opengl.util.FPSAnimator)1 Frame (java.awt.Frame)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 GL3ProgramManager (maspack.render.GL.GL3.GL3ProgramManager)1 GL3Viewer (maspack.render.GL.GL3.GL3Viewer)1 GLLightManager (maspack.render.GL.GLLightManager)1 GLViewer (maspack.render.GL.GLViewer)1 GLJPanel (maspack.render.GL.jogl.GLJPanel)1