Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE A JAVA PONG GAME USING THIS GL TEMPLATE, MUST BE IN THIS FORMAT. PLEASE MAKE IT SO ALL I HAVE TO DO IS COPY

CREATE A JAVA PONG GAME USING THIS GL TEMPLATE, MUST BE IN THIS FORMAT. PLEASE MAKE IT SO ALL I HAVE TO DO IS COPY AND PASTE IT INTO JGRASP TO RUN IT. DOESNT HAVE TO BE FANCY JUST HAS TO RUN.

import java.awt.Frame;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.media.opengl.*;

import javax.media.opengl.awt.GLCanvas;

import com.jogamp.opengl.util.*;

import com.jogamp.opengl.util.gl2.GLUT;

import javax.media.opengl.glu.*;

import java.util.Random;

import java.lang.Math;

import com.jogamp.opengl.util.texture.*;

import java.io.*;

public class templateForProject implements GLEventListener

{

// include public static void main to run it

public static void main(String[] arg){

GLProfile glp = GLProfile.getDefault();

GLCapabilities caps = new GLCapabilities(glp);

GLCanvas canvas = new GLCanvas(caps);

Frame frame = new Frame("AWT Window Test");

frame.setSize(300, 300);

frame.add(canvas);

frame.setVisible(true);

frame.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

templateForProject mp = new templateForProject();

canvas.addGLEventListener(mp);

Animator animator = new Animator(canvas);

animator.add(canvas);

animator.start();

}

//To implement GLEventListener, one

// must tell what to do inside

// four methods listed below.

public void display(GLAutoDrawable drawable){

GL2 gl = drawable.getGL().getGL2();

//gl.glClearColor(255.0f/255, 153.0f/255,153.0f/255,0);

gl.glClearColor(0,0,0,0);

gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

// Provide your drawing here

// either by code

// or by function call

}

public void dispose(GLAutoDrawable drawable){

// provide your response. For now, leave it empty

}

public void init(GLAutoDrawable drawable){

GL2 gl = drawable.getGL().getGL2();

// provide your response

}

public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h){

GL2 gl = drawable.getGL().getGL2();

// provide your response

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions