Programming  >  STUDY GUIDE  >  University of Maryland, University CollegeCMSC 405My3DScene.java (All)

University of Maryland, University CollegeCMSC 405My3DScene.java

Document Content and Description Below

package joglsamples; import com.jogamp.opengl.*; import com.jogamp.opengl.awt.GLJPanel; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionLi ... stener; @SuppressWarnings("serial") public class My3DScene extends JPanel implements GLEventListener { public static void main(String[] args) { JFrame window = new JFrame("My 3D Graphics Scene"); My3DScene panel = new My3DScene(); window.setContentPane(panel); window.pack(); // Set window size based on the preferred sizes of its contents. window.setResizable(false); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation( // Center window on screen. (screen.width - window.getWidth())/2, (screen.height - window.getHeight())/2 ); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); } private MyShapes myShapes = new MyShapes(); // An instance of the MyShpaes class containing all the shapes that I have drawn. private int frameNumber; // Current frame number, increases by 1 in each frame. private Timer animationTimer; public My3DScene() { GLCapabilities caps = new GLCapabilities(null); GLJPanel display = new GLJPanel(caps); display.setPreferredSize( new Dimension(640,480) ); //sets display size of the viewing screen to 640-by-480 display.addGLEventListener(this); setLayout(new BorderLayout()); add(display, BorderLayout.CENTER); //start the animation animationTimer = new Timer(20, new ActionListener() { public void actionPerformed(ActionEvent evt) { frameNumber++; display.repaint(); } }); animationTimer.start(); } //Methods of the GLEventListener interface public void init(GLAutoDrawable drawable) { // called when the panel is created GL2 gl2 = drawable.getGL().getGL2(); gl2.glEnable(GL2.GL_DEPTH_TEST); // Required for 3D drawing, not usually for 2D. gl2.glLineWidth(2); [Show More]

Last updated: 3 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of University of Maryland, University CollegeCMSC 405My3DScene.java document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$8.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

81
0

Document information


Connected school, study & course


About the document


Uploaded On

Jun 08, 2021

Number of pages

4

Written in

All

Seller


Profile illustration for d.occ
d.occ

Member since 4 years

232 Documents Sold

Reviews Received
30
8
4
1
7
Additional information

This document has been written for:

Uploaded

Jun 08, 2021

Downloads

 0

Views

 81

Document Keyword Tags

Recommended For You

Get more on STUDY GUIDE »

$8.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·