Search in sources :

Example 21 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project narchy by automenta.

the class CanvasOpenGLMaker method newGLCanvas.

/**
 * Constructs a canvas for 3D
 *
 * @return Canvas constructed
 */
public GLCanvas newGLCanvas() {
    if (this.capabilities != null) {
        return new GLCanvas(this.capabilities);
    }
    GLCapabilities capabilities = new GLCapabilities(GLProfile.getDefault());
    capabilities.setHardwareAccelerated(true);
    capabilities.setAlphaBits(8);
    capabilities.setNumSamples(1);
    // //capabilities.setDepthBits(32);
    return this.newGLCanvas(capabilities);
}
Also used : GLCanvas(com.jogamp.opengl.awt.GLCanvas) GLCapabilities(com.jogamp.opengl.GLCapabilities)

Example 22 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project narchy by automenta.

the class DesktopOverlay method main.

public static void main(String[] args) throws IOException {
    // Indeed, use GLJPanel instead of GLCanvas
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities glcap = new GLCapabilities(glp);
    glcap.setAlphaBits(8);
    GLJPanel pane = new GLJPanel(glcap);
    pane.setOpaque(false);
    NWindow n = new NWindow("x", pane).show(500, 500);
}
Also used : GLCapabilities(com.jogamp.opengl.GLCapabilities) GLJPanel(com.jogamp.opengl.awt.GLJPanel) NWindow(automenta.vivisect.swing.NWindow) GLProfile(com.jogamp.opengl.GLProfile)

Example 23 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project narchy by automenta.

the class Test method main.

public static void main(String[] args) {
    Environment environment = new Environment();
    JavascriptDescriptor javascriptDescriptor = new JavascriptDescriptor();
    javascriptDescriptor.engine = new JavascriptEngine();
    javascriptDescriptor.environmentScriptingAccessor = new EnvironmentScriptingAccessor(environment);
    javascriptDescriptor.helperScriptingAccessor = new HelperScriptingAccessor();
    javascriptDescriptor.componentManipulationScriptingAccessor = new ComponentManipulationScriptingAccessor();
    // execute the initialisation script
    final String worldInitialisationScript = "function initializeWorld(environment) {" + "   environmentScriptingAccessor.physics2dCreateWorld();" + "}";
    WorldInitialisation.executeWorldInitialisationScript(environment, javascriptDescriptor, worldInitialisationScript);
    final String spawnScript = "function spawn() {" + "   var resultEntity = environmentScriptingAccessor.createNewEntity(helperScriptingAccessor.create2dArrayRealVector(0.0, 0.0));\n" + "   // create physics body of a rover body and set physics parameters\n" + "   var verticesPoints = helperScriptingAccessor.createList();\n" + "   verticesPoints.add(helperScriptingAccessor.create2dArrayRealVector(3.0, 0.0));\n" + "   verticesPoints.add(helperScriptingAccessor.create2dArrayRealVector(-1.0, 2.0));\n" + "   verticesPoints.add(helperScriptingAccessor.create2dArrayRealVector(-1.0, -2.0));\n" + "   var linearDamping = 0.9;\n" + "   var angularDamping = 0.6;\n" + "   var restitution = 0.9; // bounciness\n" + "   var friction = 0.5;\n" + "   var mass = 5.0;\n" + "   var static = false;\n" + "   var position = helperScriptingAccessor.create2dArrayRealVector(0.0, 0.0);\n" + "   resultEntity.physics2dBody = environmentScriptingAccessor.physics2dCreateBodyWithShape(static, position, verticesPoints, linearDamping, angularDamping, mass, restitution, friction);\n" + "   " + "   var physicsComponent = componentManipulationScriptingAccessor.createTopDownViewWheeledPhysicsComponent(8.0, 0.44 * 0.25);" + "   resultEntity.components.addComponent(physicsComponent);\n" + "   var controllerComponent = componentManipulationScriptingAccessor.createTopDownViewWheeledControllerComponent(1.0);" + "   controllerComponent.physicsComponent = physicsComponent;" + "   resultEntity.components.addComponent(controllerComponent);\n" + "   var biasedRandomAIComponent = componentManipulationScriptingAccessor.createBiasedRandomAIComponent(3.0, 0.5, 0.5);" + "   biasedRandomAIComponent.topDownViewWheeledControllerComponent = controllerComponent;" + "   resultEntity.components.addComponent(biasedRandomAIComponent);\n" + "   " + "   return resultEntity;\n" + "}\n";
    EntityDescriptor entityDescriptor = EntitySpawner.spawn(javascriptDescriptor, spawnScript, new ArrayList<>());
    environment.entities.add(entityDescriptor);
    // spawn testboxes manually
    final List<ArrayRealVector> boxPositions = RandomSampler.sample(new ArrayRealVector(new double[] { 10.0, 10.0 }), 10);
    for (final ArrayRealVector boxPosition : boxPositions) {
        EntityDescriptor createdEntity = javascriptDescriptor.environmentScriptingAccessor.createNewEntity(javascriptDescriptor.helperScriptingAccessor.create2dArrayRealVector(0.0f, 0.0f));
        // create physics body of a rover body and set physics parameters
        List verticesPoints = javascriptDescriptor.helperScriptingAccessor.createList();
        verticesPoints.add(javascriptDescriptor.helperScriptingAccessor.create2dArrayRealVector(-.5f, 0.5f));
        verticesPoints.add(javascriptDescriptor.helperScriptingAccessor.create2dArrayRealVector(0.5f, 0.5f));
        verticesPoints.add(javascriptDescriptor.helperScriptingAccessor.create2dArrayRealVector(0.5f, -0.5f));
        verticesPoints.add(javascriptDescriptor.helperScriptingAccessor.create2dArrayRealVector(-0.5f, -0.5f));
        float linearDamping = 0.9f;
        float angularDamping = 0.6f;
        float restitution = 0.9f;
        float friction = 0.5f;
        float mass = 5.0f;
        boolean isStatic = false;
        ArrayRealVector position = boxPosition;
        createdEntity.physics2dBody = javascriptDescriptor.environmentScriptingAccessor.physics2dCreateBodyWithShape(isStatic, position, verticesPoints, linearDamping, angularDamping, mass, restitution, friction);
        environment.entities.add(createdEntity);
    }
    final float timeDelta = 0.1f;
    final float cameraZoomScaleDiff = 2.0f;
    final float initScale = 50.0f;
    final Vec2 initPosition = new Vec2(-10.0f, -10.0f);
    PhysicsCamera physicsCamera = new PhysicsCamera(initPosition, initScale, cameraZoomScaleDiff);
    JoglAbstractDraw debugDraw = new JoglDraw(physicsCamera);
    GLCapabilities config = new GLCapabilities(GLProfile.getDefault());
    config.setHardwareAccelerated(true);
    config.setAlphaBits(8);
    config.setAccumAlphaBits(8);
    config.setAccumRedBits(8);
    config.setAccumGreenBits(8);
    config.setAccumBlueBits(8);
    config.setNumSamples(1);
    // config.setBackgroundOpaque(false);
    JoglPanel panel = new JoglPanel(environment.physicsWorld2d, debugDraw, null, config);
    debugDraw.setPanel(panel);
    DrawerRunnable drawerRunnable = new DrawerRunnable();
    drawerRunnable.panel = panel;
    JFrame window = new JFrame();
    window.setTitle("Testbed");
    window.setLayout(new BorderLayout());
    window.add(panel, "Center");
    window.pack();
    window.setVisible(true);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    for (; ; ) {
        environment.stepFrame(timeDelta, javascriptDescriptor);
        for (EntityDescriptor iterationEntity : environment.entities) {
            if (iterationEntity.physics2dBody == null) {
                continue;
            }
        }
        // draw
        SwingUtilities.invokeLater(drawerRunnable);
        try {
            Thread.sleep((int) (timeDelta * 1000.0f));
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
    }
}
Also used : ArrayRealVector(org.apache.commons.math3.linear.ArrayRealVector) PhysicsCamera(nars.rover.physics.PhysicsCamera) JavascriptEngine(ptrman.difficultyEnvironment.JavascriptEngine) EnvironmentScriptingAccessor(ptrman.difficultyEnvironment.scriptAccessors.EnvironmentScriptingAccessor) JoglDraw(ptrman.difficultyEnvironment.view.JoglDraw) DrawerRunnable(ptrman.difficultyEnvironment.view.DrawerRunnable) ComponentManipulationScriptingAccessor(ptrman.difficultyEnvironment.scriptAccessors.ComponentManipulationScriptingAccessor) EntityDescriptor(ptrman.difficultyEnvironment.EntityDescriptor) GLCapabilities(com.jogamp.opengl.GLCapabilities) HelperScriptingAccessor(ptrman.difficultyEnvironment.scriptAccessors.HelperScriptingAccessor) Vec2(spacegraph.space2d.phys.common.Vec2) JoglPanel(ptrman.difficultyEnvironment.view.JoglPanel) JavascriptDescriptor(ptrman.difficultyEnvironment.JavascriptDescriptor) Environment(ptrman.difficultyEnvironment.Environment) ArrayList(java.util.ArrayList) List(java.util.List) JoglAbstractDraw(nars.rover.physics.gl.JoglAbstractDraw)

Example 24 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project javacv by bytedeco.

the class JavaCVCL method getDefaultGLCapabilities.

public static GLCapabilities getDefaultGLCapabilities(GLProfile profile) {
    GLCapabilities caps = new GLCapabilities(profile != null ? profile : GLProfile.getDefault());
    // Without line below, there is an error on Windows.
    caps.setDoubleBuffered(false);
    return caps;
}
Also used : GLCapabilities(com.jogamp.opengl.GLCapabilities)

Example 25 with GLCapabilities

use of com.jogamp.opengl.GLCapabilities in project tdme by andreasdr.

the class PhysicsTest3 method main.

/**
 * Main
 * @param args
 */
public static void main(String[] args) {
    Logger.getLogger("").setLevel(Level.WARNING);
    // create GL canvas
    GLProfile glp = Engine.getProfile();
    GLCapabilities caps = new GLCapabilities(glp);
    // create GL window
    GLWindow glWindow = GLWindow.create(caps);
    glWindow.setTitle("PhysicsTest3");
    // animator
    FPSAnimator animator = new FPSAnimator(glWindow, 60);
    // tdme level editor
    PhysicsTest3 physicsTest3 = new PhysicsTest3();
    // GL Window
    glWindow.addGLEventListener(physicsTest3);
    glWindow.setSize(800, 600);
    glWindow.setVisible(true);
    glWindow.addKeyListener(physicsTest3);
    glWindow.addMouseListener(physicsTest3);
    glWindow.addWindowListener(physicsTest3);
    // start animator
    animator.setUpdateFPSFrames(3, null);
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLWindow(com.jogamp.newt.opengl.GLWindow) 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