ARTICLE AD BOX
I would like to know the reason why i can't execute this JAVA OpenGL project, first, i push on compile and execute and secondly, i receive the next message:
Error: no se ha encontrado o cargado la clase principal BasicFrame16
Causado por: java.lang.NoClassDefFoundError: com/jogamp/opengl/GLEventListener
Here it can to see the process as far as i am at the moment:
https://redspot.es/curso-de-creacion-de-videojuegos/creating-the-project/
My code:
import java.awt.Frame; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.io.InputStream; import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; public class BasicFrame16 implements GLEventListener{ GL2 gl; GLU glu; float incx, incy, incxEnemy; static boolean miraarriba, miraabajo, mueveizquierda, muevederecha, saltar; @Override public void display(GLAutoDrawable glad){ final GL2 gl = glad.getGL().getGL2();//Se genera un objeto tipo GL2 gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); gl.glPointSize(3.0f); gl.glColor3d(24/255.0,128/255.0, 21/255.0); if(muevederecha) { incx=incx + 1; incxEnemy = incxEnemy + 1; muevederecha = false; //reiniciamos muevederecha, para otro keypress de teclado } if(mueveizquierda) { incx=incx- 1; mueveizquierda = false; } } @Override public void dispose(GLAutoDrawable arg0) { //method body } @Override public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { } @Override public void init(GLAutoDrawable glad){ final GL2 gl = glad.getGL().getGL2(); //Se genera un objeto de tipo GL2 final GLU glu = new GLU(); //Se genera un objeto de tipo GLU incx=incy=0; muevederecha=false; mueveizquierda=false; saltar=false; } 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); BasicFrame16 b = new BasicFrame16(); glcanvas.addGLEventListener(b); //glcanvas.addKeyListener( new BasicFrame4()); glcanvas.setSize(400, 400); //creating frame final Frame frame = new Frame (" Basic Frame"); frame.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent ke) { switch(ke.getKeyCode()) { case KeyEvent.VK_CONTROL:saltar = true; System.out.println(muevederecha); break; case KeyEvent.VK_DOWN:miraabajo = true; break; case KeyEvent.VK_UP:miraarriba = true; break; case KeyEvent.VK_LEFT:mueveizquierda = true; System.out.println(mueveizquierda); break; case KeyEvent.VK_RIGHT:muevederecha = true; System.out.println("muevederecha: "+muevederecha); break; } } public void keyReleased(KeyEvent ke) { } public void keyTyped(KeyEvent ke) { } }); final Animator animator = new Animator(glcanvas); 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() { if (animator.isStarted()) animator.stop(); System.exit(0); } }.start(); } }); animator.start(); //adding canvas to frame frame.add(glcanvas); //frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setSize( 640, 480 ); frame.setVisible(true); } }