com.jogamp.opengl.awt.GLCanvas Java Examples
The following examples show how to use
com.jogamp.opengl.awt.GLCanvas.
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: JCuboid.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String[] args) { final GLProfile gp = GLProfile.get(GLProfile.GL2); GLCapabilities cap = new GLCapabilities(gp); final GLCanvas gc = new GLCanvas(cap); JCuboid cuboid = new JCuboid(); gc.addGLEventListener(cuboid); gc.setSize(100, 100); final JFrame frame = new JFrame(" JOGL Cuboid"); frame.add(gc); frame.setSize(500, 400); frame.setVisible(true); final FPSAnimator animator = new FPSAnimator(gc, 300, true); animator.start(); }
Example #2
Source File: JRotation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #3
Source File: Triangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #4
Source File: GltfViewerJogl.java From JglTF with MIT License | 6 votes |
/** * Creates a new GltfViewerJogl */ public GltfViewerJogl() { GLProfile profile = getGLProfile(); logger.config("GLProfile: " + profile); GLCapabilities capabilities = new GLCapabilities(profile); capabilities.setNumSamples(2); capabilities.setSampleBuffers(true); glComponent = new GLCanvas(capabilities); glComponent.addGLEventListener(glEventListener); // Without setting the minimum size, the canvas cannot // be resized when it is embedded in a JSplitPane glComponent.setMinimumSize(new Dimension(10, 10)); glContext = new GlContextJogl(); }
Example #5
Source File: Rhombus.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #6
Source File: J3DBasic.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #7
Source File: JPaddle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #8
Source File: J3DTriangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #9
Source File: JLight.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #10
Source File: RenderFrame.java From jaamsim with Apache License 2.0 | 5 votes |
/** * Package level constructor. This will only be created by Renderer */ RenderFrame(int width, int height, String title, GLCanvas canvas) { super(title); setSize(width, height); setLayout(new java.awt.BorderLayout()); add(canvas, java.awt.BorderLayout.CENTER); validate(); setVisible(true); }
Example #11
Source File: GLVisualProcessor.java From constellation with Apache License 2.0 | 5 votes |
/** * Construct a new GLVisualProcessor with a {@link GraphRenderable} and an * {@link AxesRenderable} and a {@link FPSRenderable}. * * @param debugGl Whether or not to utilise a GLContext that includes * debugging. * @param printGlCapabilities Whether or not to print out a list of GL * capabilities upon initialisation. */ public GLVisualProcessor(final boolean debugGl, final boolean printGlCapabilities) { graphRenderable = new GraphRenderable(this); final AxesRenderable axesRenderable = new AxesRenderable(this); final FPSRenderable fpsRenderable = new FPSRenderable(this); renderer = new GLRenderer(this, Arrays.asList(graphRenderable, axesRenderable, fpsRenderable), debugGl, printGlCapabilities); try { canvas = new GLCanvas(SharedDrawable.getGLCapabilities()); } catch (GLException ex) { GLInfo.respondToIncompatibleHardwareOrGL(null); throw ex; } }
Example #12
Source File: DelaunayTriangulationExample.java From delaunay-triangulator with MIT License | 5 votes |
public static void main(String[] args) { Frame frame = new Frame("Delaunay Triangulation Example"); frame.setResizable(false); GLCapabilities caps = new GLCapabilities(GLProfile.get("GL2")); caps.setSampleBuffers(true); caps.setNumSamples(8); GLCanvas canvas = new GLCanvas(caps); DelaunayTriangulationExample ex = new DelaunayTriangulationExample(); MouseListener lister = ex; canvas.addGLEventListener(ex); canvas.setPreferredSize(DIMENSION); canvas.addMouseListener(lister); frame.add(canvas); final FPSAnimator animator = new FPSAnimator(canvas, 25); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { new Thread(new Runnable() { public void run() { animator.stop(); System.exit(0); } }).start(); } }); frame.setVisible(true); frame.pack(); animator.start(); }
Example #13
Source File: JMColor.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
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 #14
Source File: JScaling.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) { final GLProfile gp = GLProfile.get(GLProfile.GL2); GLCapabilities cap = new GLCapabilities(gp); final GLCanvas gc = new GLCanvas(cap); JScaling js = new JScaling(); gc.addGLEventListener(js); gc.setSize(400, 400); final JFrame frame = new JFrame("After Scaling"); frame.add(gc); frame.setSize(500, 400); frame.setVisible(true); }
Example #15
Source File: JColor.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) { final GLProfile gp = GLProfile.get(GLProfile.GL2); GLCapabilities cap = new GLCapabilities(gp); final GLCanvas gc = new GLCanvas(cap); JColor jc = new JColor(); gc.addGLEventListener(jc); gc.setSize(400, 400); final JFrame frame = new JFrame("JOGL Coloring"); frame.add(gc); frame.setSize(500, 400); frame.setVisible(true); }
Example #16
Source File: JQuad.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) { final GLProfile gp = GLProfile.get(GLProfile.GL2); GLCapabilities cap = new GLCapabilities(gp); final GLCanvas gc = new GLCanvas(cap); JQuad jq = new JQuad(); gc.addGLEventListener(jq); gc.setSize(400, 400); final JFrame frame = new JFrame("JOGL Primitive Quadrilateral"); frame.add(gc); frame.setSize(500, 400); frame.setVisible(true); }
Example #17
Source File: Fireworks.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) { // Create the OpenGL rendering canvas final GLProfile gp = GLProfile.get(GLProfile.GL2); GLCapabilities cap = new GLCapabilities(gp); final GLCanvas canvas = new GLCanvas(cap); Fireworks renderer = new Fireworks(); canvas.addGLEventListener(renderer); canvas.addKeyListener(renderer); canvas.setFocusable(true); // To receive key event canvas.requestFocus(); // Create a animator that drives canvas' display() at the specified FPS. final FPSAnimator animator = new FPSAnimator(canvas, FPS, true); // Create the top-level container frame final JFrame frame = new JFrame(); // Swing's JFrame or AWT's Frame frame.getContentPane().add(canvas); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // Use a dedicate thread to run the stop() to ensure that the // animator stops before program exits. new Thread() { @Override public void run() { animator.stop(); // stop the animator loop System.exit(0); } }.start(); } }); frame.setTitle(TITLE); frame.pack(); frame.setSize(640, 480); frame.setVisible(true); animator.start(); // start the animation loop }
Example #18
Source File: NBodyVisualizer.java From gpu-nbody with MIT License | 4 votes |
/** * Creates a new JOCLSimpleGL3 sample. * * @param capabilities * The GL capabilities */ public NBodyVisualizer(final GLCapabilities capabilities) { glComponent = new GLCanvas(capabilities); glComponent.setFocusable(true); glComponent.addGLEventListener(this); // Initialize the mouse and keyboard controls final MouseControl mouseControl = new MouseControl(); glComponent.addMouseMotionListener(mouseControl); glComponent.addMouseWheelListener(mouseControl); final KeyboardControl keyboardControl = new KeyboardControl(); glComponent.addKeyListener(keyboardControl); setFullscreen(); updateModelviewMatrix(); // Create and start an animator animator = new Animator(glComponent); animator.start(); // Create the simulation // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new SerializedUniverseGenerator("universes/sphericaluniverse1.universe")); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new SerializedUniverseGenerator("universes/montecarlouniverse1.universe")); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new RotatingDiskGalaxyGenerator(3.5f, 25, 0)); simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new RotatingDiskGalaxyGenerator(3.5f, 1, 1)); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new SphericalUniverseGenerator()); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new LonLatSphericalUniverseGenerator()); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new RandomCubicUniverseGenerator(5)); // simulation = new GPUBarnesHutNBodySimulation(Mode.GL_INTEROP, 2048 * 16, new MonteCarloSphericalUniverseGenerator()); // simulation = new GpuNBodySimulation(Mode.GL_INTEROP, 2048 * 8, new LonLatSphericalUniverseGenerator()); // simulation = new GpuNBodySimulation(Mode.GL_INTEROP, 2048, new PlummerUniverseGenerator()); // simulation = new GpuNBodySimulation(Mode.GL_INTEROP, 128, new SphericalUniverseGenerator()); // Create the main frame frame = new JFrame("NBody Simulation"); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { runExit(); } }); frame.setLayout(new BorderLayout()); frame.add(glComponent, BorderLayout.CENTER); frame.setUndecorated(true); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); frame.setLocationRelativeTo(null); glComponent.requestFocus(); }
Example #19
Source File: JCudaDriverVolumeRendererJOGL.java From jcuda-samples with MIT License | 4 votes |
/** * Creates a new JCudaTextureSample that displays the given volume * data, which has the specified size. * * @param volumeData The volume data * @param sizeX The size of the data set in X direction * @param sizeY The size of the data set in Y direction * @param sizeZ The size of the data set in Z direction */ public JCudaDriverVolumeRendererJOGL(GLCapabilities capabilities, byte volumeData[], int sizeX, int sizeY, int sizeZ) { this.simpleInteraction = new SimpleInteraction(); h_volume = volumeData; volumeSize.x = sizeX; volumeSize.y = sizeY; volumeSize.z = sizeZ; width = 800; height = 800; // Initialize the GL component glComponent = new GLCanvas(capabilities); glComponent.addGLEventListener(this); // Initialize the mouse controls MouseControl mouseControl = simpleInteraction.getMouseControl(); glComponent.addMouseMotionListener(mouseControl); glComponent.addMouseWheelListener(mouseControl); // Create the main frame frame = new JFrame("JCuda 3D texture volume rendering sample"); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { runExit(); } }); frame.setLayout(new BorderLayout()); glComponent.setPreferredSize(new Dimension(width, height)); frame.add(glComponent, BorderLayout.CENTER); frame.add(createControlPanel(), BorderLayout.SOUTH); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); // Create and start the animator animator = new Animator(glComponent); animator.setRunAsFastAsPossible(true); animator.start(); }
Example #20
Source File: JCudaDriverSimpleJOGL.java From jcuda-samples with MIT License | 4 votes |
/** * Creates a new JCudaDriverSimpleJOGL. * * @param The JOGL OpenGL capabilities */ public JCudaDriverSimpleJOGL(GLCapabilities capabilities) { simpleInteraction = new SimpleInteraction(); // Initialize the GL component and the animator GLCanvas glComponent = new GLCanvas(capabilities); glComponent.setFocusable(true); glComponent.addGLEventListener(this); // Initialize the mouse and keyboard controls MouseControl mouseControl = simpleInteraction.getMouseControl(); glComponent.addMouseMotionListener(mouseControl); glComponent.addMouseWheelListener(mouseControl); KeyboardControl keyboardControl = new KeyboardControl(); glComponent.addKeyListener(keyboardControl); // Create the main frame frame = new JFrame("JCuda / JOGL interaction sample"); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { runExit(); } }); frame.setLayout(new BorderLayout()); glComponent.setPreferredSize(new Dimension(800, 800)); frame.add(glComponent, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); glComponent.requestFocus(); // Create and start the animator animator = new Animator(glComponent); animator.setRunAsFastAsPossible(false); animator.start(); }