fork download
  1. import java.awt.Frame;
  2. import java.awt.event.WindowAdapter;
  3. import java.awt.event.WindowEvent;
  4. import javax.media.opengl.*;
  5. import javax.media.opengl.awt.GLCanvas;
  6.  
  7. import com.jogamp.opengl.util.*;
  8.  
  9. public class SimpleScene implements GLEventListener {
  10.  
  11. private double theta = 0;
  12. private double s = 0;
  13. private double c = 0;
  14.  
  15. public static void main(String[] args) {
  16. GLProfile glp = GLProfile.getDefault();
  17. GLCapabilities caps = new GLCapabilities(glp);
  18. GLCanvas canvas = new GLCanvas(caps);
  19.  
  20. Frame frame = new Frame("AWT Window Test");
  21. frame.setSize(300, 300);
  22. frame.add(canvas);
  23. frame.setVisible(true);
  24.  
  25. frame.addWindowListener(new WindowAdapter() {
  26. public void windowClosing(WindowEvent e) {
  27. System.exit(0);
  28. }
  29. });
  30.  
  31. canvas.addGLEventListener(new SimpleScene());
  32.  
  33. FPSAnimator animator = new FPSAnimator(canvas, 60);
  34. animator.add(canvas);
  35. animator.start();
  36. }
  37.  
  38. @Override
  39. public void display(GLAutoDrawable drawable) {
  40. update();
  41. render(drawable);
  42. }
  43.  
  44. @Override
  45. public void dispose(GLAutoDrawable drawable) {
  46. }
  47.  
  48. @Override
  49. public void init(GLAutoDrawable drawable) {
  50. }
  51.  
  52. @Override
  53. public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
  54. }
  55.  
  56. private void update() {
  57. theta += 0.01;
  58. s = Math.sin(theta);
  59. c = Math.cos(theta);
  60. }
  61.  
  62. private void render(GLAutoDrawable drawable) {
  63. GL2 gl = drawable.getGL().getGL2();
  64.  
  65. gl.glClear(GL.GL_COLOR_BUFFER_BIT);
  66.  
  67. // draw a triangle filling the window
  68. gl.glBegin(GL.GL_TRIANGLES);
  69. gl.glColor3f(1, 0, 0);
  70. gl.glVertex2d(-c, -c);
  71. gl.glColor3f(0, 1, 0);
  72. gl.glVertex2d(0, c);
  73. gl.glColor3f(0, 0, 1);
  74. gl.glVertex2d(s, -s);
  75. gl.glEnd();
  76. }
  77. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: class SimpleScene is public, should be declared in a file named SimpleScene.java
public class SimpleScene implements GLEventListener {
       ^
Main.java:4: error: package javax.media.opengl does not exist
import javax.media.opengl.*;
^
Main.java:5: error: package javax.media.opengl.awt does not exist
import javax.media.opengl.awt.GLCanvas;
                             ^
Main.java:7: error: package com.jogamp.opengl.util does not exist
import com.jogamp.opengl.util.*;
^
Main.java:9: error: cannot find symbol
public class SimpleScene implements GLEventListener {
                                    ^
  symbol: class GLEventListener
Main.java:39: error: cannot find symbol
    public void display(GLAutoDrawable drawable) {
                        ^
  symbol:   class GLAutoDrawable
  location: class SimpleScene
Main.java:45: error: cannot find symbol
    public void dispose(GLAutoDrawable drawable) {
                        ^
  symbol:   class GLAutoDrawable
  location: class SimpleScene
Main.java:49: error: cannot find symbol
    public void init(GLAutoDrawable drawable) {
                     ^
  symbol:   class GLAutoDrawable
  location: class SimpleScene
Main.java:53: error: cannot find symbol
    public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
                        ^
  symbol:   class GLAutoDrawable
  location: class SimpleScene
Main.java:62: error: cannot find symbol
    private void render(GLAutoDrawable drawable) {
                        ^
  symbol:   class GLAutoDrawable
  location: class SimpleScene
Main.java:16: error: cannot find symbol
        GLProfile glp = GLProfile.getDefault();
        ^
  symbol:   class GLProfile
  location: class SimpleScene
Main.java:16: error: cannot find symbol
        GLProfile glp = GLProfile.getDefault();
                        ^
  symbol:   variable GLProfile
  location: class SimpleScene
Main.java:17: error: cannot find symbol
        GLCapabilities caps = new GLCapabilities(glp);
        ^
  symbol:   class GLCapabilities
  location: class SimpleScene
Main.java:17: error: cannot find symbol
        GLCapabilities caps = new GLCapabilities(glp);
                                  ^
  symbol:   class GLCapabilities
  location: class SimpleScene
Main.java:18: error: cannot find symbol
        GLCanvas canvas = new GLCanvas(caps);
        ^
  symbol:   class GLCanvas
  location: class SimpleScene
Main.java:18: error: cannot find symbol
        GLCanvas canvas = new GLCanvas(caps);
                              ^
  symbol:   class GLCanvas
  location: class SimpleScene
Main.java:33: error: cannot find symbol
        FPSAnimator animator = new FPSAnimator(canvas, 60);
        ^
  symbol:   class FPSAnimator
  location: class SimpleScene
Main.java:33: error: cannot find symbol
        FPSAnimator animator = new FPSAnimator(canvas, 60);
                                   ^
  symbol:   class FPSAnimator
  location: class SimpleScene
Main.java:38: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:44: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:48: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:52: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:63: error: cannot find symbol
        GL2 gl = drawable.getGL().getGL2();
        ^
  symbol:   class GL2
  location: class SimpleScene
Main.java:65: error: cannot find symbol
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
                   ^
  symbol:   variable GL
  location: class SimpleScene
Main.java:68: error: cannot find symbol
        gl.glBegin(GL.GL_TRIANGLES);
                   ^
  symbol:   variable GL
  location: class SimpleScene
25 errors
stdout
Standard output is empty