Java Code Examples for com.jogamp.opengl.awt.GLCanvas#addMouseMotionListener()

The following examples show how to use com.jogamp.opengl.awt.GLCanvas#addMouseMotionListener() . 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: NBodyVisualizer.java    From gpu-nbody with MIT License 4 votes vote down vote up
/**
 * 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 2
Source File: JCudaDriverVolumeRendererJOGL.java    From jcuda-samples with MIT License 4 votes vote down vote up
/**
 * 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 3
Source File: JCudaDriverSimpleJOGL.java    From jcuda-samples with MIT License 4 votes vote down vote up
/**
 * 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();
    
}