Jogamp
Adapt to JOGL commit ebe980ad6ac40148bc84913d1ba1f7adf6200490 (Bug 741 HiDPI)
authorSven Gothel <sgothel@jausoft.com>
Fri, 6 Jun 2014 17:56:03 +0000 (19:56 +0200)
committerSven Gothel <sgothel@jausoft.com>
Fri, 6 Jun 2014 17:56:03 +0000 (19:56 +0200)
AWTMouseAdapter and AWTMouseAdapter ctor have been changed ..

src/demos/gears/Gears.java
src/demos/tennis/Tennis.java

index b477ffc..51c118d 100644 (file)
@@ -32,7 +32,6 @@ private final float view_rotz = 0.0f;
   private float angle = 0.0f;
   private final int swapInterval;
 
-  private boolean mouseRButtonDown = false;
   private int prevMouseX, prevMouseY;
 
   public static void main(String[] args) {
@@ -178,8 +177,8 @@ public void init(GLAutoDrawable drawable) {
         window.addKeyListener(gearsKeys);
     } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
         java.awt.Component comp = (java.awt.Component) drawable;
-        new AWTMouseAdapter(gearsMouse).addTo(comp);
-        new AWTKeyAdapter(gearsKeys).addTo(comp);
+        new AWTMouseAdapter(gearsMouse, drawable).addTo(comp);
+        new AWTKeyAdapter(gearsKeys, drawable).addTo(comp);
     }
   }
 
@@ -398,22 +397,16 @@ public void display(GLAutoDrawable drawable) {
        public void mousePressed(MouseEvent e) {
         prevMouseX = e.getX();
         prevMouseY = e.getY();
-        if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
-          mouseRButtonDown = true;
-        }
       }
 
       @Override
        public void mouseReleased(MouseEvent e) {
-        if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
-          mouseRButtonDown = false;
-        }
       }
 
       @Override
        public void mouseDragged(MouseEvent e) {
-        int x = e.getX();
-        int y = e.getY();
+        final int x = e.getX();
+        final int y = e.getY();
         int width=0, height=0;
         Object source = e.getSource();
         if(source instanceof Window) {
index 1eb1b6a..7cbd9a0 100644 (file)
@@ -48,26 +48,27 @@ import java.awt.image.BufferedImage;
  * Tennis.java <BR>\r
  * author: Fofonov Alexey <P>\r
  */\r
\r
+\r
 public class Tennis implements GLEventListener {\r
   static {\r
        GLProfile.initSingleton();\r
   }\r
-  private float view_rotx = 0.0f, view_roty = 0.0f, view_rotz = 0.0f;  //View angles\r
+  private float view_rotx = 0.0f, view_roty = 0.0f;    //View angles\r
+private final float view_rotz = 0.0f;\r
   private float sx = 0.0f, sy = 0.0f;                                                                  //X, Y coords of Mydesk\r
   private float spx,spy,spz;                                                                                   //Speed of the ball\r
   private float BallCx = 0.0f, BallCy = 0.0f, BallCz = 0.0f;                   //Coords of the ball\r
   private float EnDeskCx = 0.0f, EnDeskCy = 0.0f;                                              //X, Y coords of Endesk\r
-  private int   cube=0, mydesk=0, endesk=0, ball=0, box=0;                             //Flags of the existence \r
-  private int   swapInterval;\r
+  private int   cube=0, mydesk=0, endesk=0, ball=0, box=0;                             //Flags of the existence\r
+  private final int   swapInterval;\r
   private static Texture[] texture;\r
   private float Bax=0, Bay=0;                                                                                  //Acceleration summands\r
   private float Vec=3;                                                                                                 //Balls direction\r
   private boolean CanF=false;                                                                                  //Ready for play\r
-  \r
-  private int WindowW=0, WindowH=0;    \r
-  \r
-  private float LPositionDX=0, NPositionDX=0;                                                  //Mouse positions \r
+\r
+  private int WindowW=0, WindowH=0;\r
+\r
+  private float LPositionDX=0, NPositionDX=0;                                                  //Mouse positions\r
   private float LPositionDY=0, NPositionDY=0;                                                  //\r
   private float DspeedX=0, DspeedY=0;                                                                  //Speed of Mydesk\r
 \r
@@ -77,7 +78,7 @@ public class Tennis implements GLEventListener {
   public static void main(String[] args) {\r
     // set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example\r
     // <application-desc main-class="demos.j2d.TextCube"/>\r
-    //   <argument>NotFirstUIActionOnProcess</argument> \r
+    //   <argument>NotFirstUIActionOnProcess</argument>\r
     // </application-desc>\r
     // boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;\r
 \r
@@ -110,7 +111,7 @@ public class Tennis implements GLEventListener {
 \r
     frame.add(canvas, java.awt.BorderLayout.CENTER);\r
     frame.validate();\r
-    \r
+\r
     //Hide the mouse cursor\r
     Toolkit t = Toolkit.getDefaultToolkit();\r
     Image i = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);\r
@@ -120,7 +121,7 @@ public class Tennis implements GLEventListener {
     frame.setVisible(true);\r
     animator.start();\r
   }\r
-  \r
+\r
   public Tennis(int swapInterval) {\r
        this.swapInterval = swapInterval;\r
   }\r
@@ -148,14 +149,14 @@ public class Tennis implements GLEventListener {
         { 25.0f };\r
     float light_position[] =\r
         { 1.0f, 1.0f, 1.0f, 0.0f };\r
-        \r
+\r
     float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };\r
     float yellow[] = { 0.8f, 0.75f, 0.0f, 0.7f };\r
     float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };\r
     float brown[] = { 0.8f, 0.4f, 0.1f, 0.7f };\r
-    \r
+\r
     texture = new Texture[5];\r
-    \r
+\r
     //Load textures\r
     try {\r
         System.err.println("Loading texture...");\r
@@ -195,23 +196,23 @@ public class Tennis implements GLEventListener {
     gl.glClearDepth(1.0f);                             // Depth Buffer Setup\r
     gl.glEnable(GL2.GL_DEPTH_TEST);                    // Enables Depth Testing\r
     gl.glDepthFunc(GL2.GL_LEQUAL);                     // The Type Of Depth Testing To Do\r
-    \r
+\r
     // Really Nice Perspective Calculations\r
-    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);  \r
+    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);\r
     gl.glEnable(GL2.GL_TEXTURE_2D);\r
-    \r
+\r
     // Texture filter\r
     gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NONE);\r
     gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NONE);\r
-    \r
+\r
     // Light and material\r
-    gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, mat_specular, 0);  \r
+    gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, mat_specular, 0);\r
     gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SHININESS, mat_shininess, 0);\r
     gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, light_position, 0);\r
     gl.glEnable(GL2.GL_LIGHTING);\r
     gl.glEnable(GL2.GL_LIGHT0);\r
\r
-                   \r
+\r
+\r
     /* make the objects */\r
     if(0>=cube) {\r
         cube = gl.glGenLists(1);\r
@@ -223,7 +224,7 @@ public class Tennis implements GLEventListener {
     } else {\r
         System.err.println("cube list reused: "+cube);\r
     }\r
-    \r
+\r
     if(0>=box) {\r
        box = gl.glGenLists(1);\r
         gl.glNewList(box, GL2.GL_COMPILE);\r
@@ -234,7 +235,7 @@ public class Tennis implements GLEventListener {
     } else {\r
         System.err.println("box list reused: "+box);\r
     }\r
-                   \r
+\r
     if(0>=mydesk) {\r
        mydesk = gl.glGenLists(1);\r
         gl.glNewList(mydesk, GL2.GL_COMPILE);\r
@@ -245,7 +246,7 @@ public class Tennis implements GLEventListener {
     } else {\r
         System.err.println("mydesk list reused: "+mydesk);\r
     }\r
-                   \r
+\r
     if(0>=endesk) {\r
        endesk = gl.glGenLists(1);\r
         gl.glNewList(endesk, GL2.GL_COMPILE);\r
@@ -256,7 +257,7 @@ public class Tennis implements GLEventListener {
     } else {\r
         System.err.println("endesk list reused: "+endesk);\r
     }\r
-    \r
+\r
     if(0>=ball) {\r
        ball = gl.glGenLists(1);\r
         gl.glNewList(ball, GL2.GL_COMPILE);\r
@@ -267,10 +268,10 @@ public class Tennis implements GLEventListener {
     } else {\r
         System.err.println("ball list reused: "+ball);\r
     }\r
-                   \r
+\r
     gl.glEnable(GL2.GL_NORMALIZE);\r
-                       \r
-    MouseListener tennisMouse = new TennisMouseAdapter();    \r
+\r
+    MouseListener tennisMouse = new TennisMouseAdapter();\r
     KeyListener tennisKeys = new TennisKeyAdapter();\r
 \r
     if (drawable instanceof Window) {\r
@@ -279,9 +280,9 @@ public class Tennis implements GLEventListener {
         window.addKeyListener(tennisKeys);\r
     } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {\r
         java.awt.Component comp = (java.awt.Component) drawable;\r
-        new AWTMouseAdapter(tennisMouse).addTo(comp);\r
-        new AWTKeyAdapter(tennisKeys).addTo(comp);\r
-    }          \r
+        new AWTMouseAdapter(tennisMouse, drawable).addTo(comp);\r
+        new AWTKeyAdapter(tennisKeys, drawable).addTo(comp);\r
+    }\r
   }\r
 \r
   public void dispose(GLAutoDrawable drawable) {\r
@@ -292,7 +293,7 @@ public class Tennis implements GLEventListener {
 \r
     // Get the GL corresponding to the drawable we are animating\r
     GL2 gl = drawable.getGL().getGL2();\r
-    \r
+\r
     if (mouseButtonDown == false && control == true)\r
     MovMydesk();\r
     MoveSphere();\r
@@ -302,7 +303,7 @@ public class Tennis implements GLEventListener {
 \r
     // Special handling for the case where the GLJPanel is translucent\r
     // and wants to be composited with other Java 2D content\r
-    if (GLProfile.isAWTAvailable() && \r
+    if (GLProfile.isAWTAvailable() &&\r
         (drawable instanceof javax.media.opengl.awt.GLJPanel) &&\r
         !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() &&\r
         ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) {\r
@@ -310,69 +311,69 @@ public class Tennis implements GLEventListener {
     } else {\r
       gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);\r
     }\r
-    \r
+\r
  // Place the box and call its display list\r
     gl.glDisable(GL2.GL_DEPTH_TEST);\r
     gl.glCallList(box);\r
     gl.glEnable(GL2.GL_DEPTH_TEST);\r
-                   \r
+\r
     // Rotate the entire assembly of tennis based on how the user\r
     // dragged the mouse around\r
     gl.glPushMatrix();\r
     gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);\r
     gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);\r
     gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);\r
-            \r
+\r
     // Place the cube and call its display list\r
     gl.glPushMatrix();\r
     gl.glTranslatef(0.0f, 0.0f, 0.0f);\r
     gl.glRotatef(0.0f, 0.0f, 0.0f, 1.0f);\r
     gl.glCallList(cube);\r
     gl.glPopMatrix();\r
-                   \r
+\r
     // Place the mydesk and call its display list\r
     gl.glPushMatrix();\r
     gl.glTranslatef(sx, sy, 3.0f);\r
     gl.glRotatef(0.0f, 0.0f, 0.0f, 1.0f);\r
     gl.glCallList(mydesk);\r
     gl.glPopMatrix();\r
-            \r
+\r
     // Place the endesk and call its display list\r
     gl.glPushMatrix();\r
     gl.glTranslatef(EnDeskCx, EnDeskCy, -3.0f);\r
     gl.glRotatef(0.0f, 0.0f, 0.0f, 1.0f);\r
     gl.glCallList(endesk);\r
     gl.glPopMatrix();\r
-    \r
+\r
     // Place the ball and call its display list\r
     gl.glPushMatrix();\r
     gl.glTranslatef(BallCx, BallCy, BallCz);\r
     gl.glRotatef(0.0f, 0.0f, 0.0f, 1.0f);\r
     gl.glCallList(ball);\r
     gl.glPopMatrix();\r
-                   \r
+\r
     // Remember that every push needs a pop; this one is paired with\r
     // rotating the entire tennis assembly\r
     gl.glPopMatrix();\r
   }\r
 \r
-  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) \r
+  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)\r
   {\r
-         \r
+\r
        System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);\r
        GL2 gl = drawable.getGL().getGL2();\r
 \r
        gl.setSwapInterval(swapInterval);\r
 \r
        float h = (float)height / (float)width;\r
-       \r
+\r
        WindowW = width;\r
        WindowH = height;\r
-                   \r
+\r
        gl.glMatrixMode(GL2.GL_PROJECTION);\r
 \r
        gl.glLoadIdentity();\r
-       \r
+\r
        if (h<1)\r
                gl.glFrustum(-1.0f, 1.0f, -h, h, 1.0f, 60.0f);\r
        else\r
@@ -380,13 +381,13 @@ public class Tennis implements GLEventListener {
                h = 1.0f/h;\r
                gl.glFrustum(-h, h, -1.0f, 1.0f, 1.0f, 60.0f);\r
        }\r
-       \r
+\r
        gl.glMatrixMode(GL2.GL_MODELVIEW);\r
        gl.glLoadIdentity();\r
        gl.glTranslatef(0.0f, 0.0f, -6.0f);\r
-       \r
+\r
   }\r
-  \r
+\r
   public static void cube(GL2 gl)\r
   {\r
 \r
@@ -394,13 +395,13 @@ public class Tennis implements GLEventListener {
 \r
        /* draw left sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(1.0f, 0.0f, 0.0f);\r
                gl.glVertex3f(-2.0f, -1.5f, -3.0f);\r
                gl.glVertex3f(-2.0f,  1.5f, -3.0f);\r
                gl.glVertex3f(-2.0f,  1.5f,  3.0f);\r
                gl.glVertex3f(-2.0f, -1.5f,  3.0f);\r
-               \r
+\r
                gl.glNormal3f(-1.0f, 0.0f, 0.0f);\r
                gl.glVertex3f(-2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f(-2.05f,  1.55f, -3.0f);\r
@@ -408,16 +409,16 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f(-2.05f, -1.55f,  3.0f);\r
 \r
        gl.glEnd();\r
-       \r
+\r
        if (texture[0] != null) {\r
              texture[0].enable(gl);\r
              texture[0].bind(gl);\r
              gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);\r
              TextureCoords coords = texture[0].getImageTexCoords();\r
-       \r
+\r
        /* draw up sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(0.0f, -1.0f, 0.0f);\r
                gl.glTexCoord2f(coords.left(), coords.top());\r
                gl.glVertex3f(-2.0f, 1.5f, -3.0f);\r
@@ -427,14 +428,14 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f( 2.0f, 1.5f,  3.0f);\r
                gl.glTexCoord2f(coords.right(), coords.top());\r
                gl.glVertex3f( 2.0f, 1.5f, -3.0f);\r
-               \r
+\r
        gl.glEnd();\r
-       \r
+\r
                texture[0].disable(gl);\r
-       }       \r
-               \r
+       }\r
+\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 1.0f, 0.0f);\r
                gl.glVertex3f(-2.05f, 1.55f, -3.0f);\r
                gl.glVertex3f(-2.05f, 1.55f,  3.0f);\r
@@ -442,16 +443,16 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f( 2.05f, 1.55f, -3.0f);\r
 \r
        gl.glEnd();\r
-       \r
+\r
        /* draw right sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(-1.0f, 0.0f, 0.0f);\r
                gl.glVertex3f(2.0f, -1.5f, -3.0f);\r
                gl.glVertex3f(2.0f,  1.5f, -3.0f);\r
                gl.glVertex3f(2.0f,  1.5f,  3.0f);\r
                gl.glVertex3f(2.0f, -1.5f,  3.0f);\r
-               \r
+\r
                gl.glNormal3f(1.0f, 0.0f, 0.0f);\r
                gl.glVertex3f(2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f(2.05f,  1.55f, -3.0f);\r
@@ -459,16 +460,16 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f(2.05f, -1.55f,  3.0f);\r
 \r
        gl.glEnd();\r
-       \r
+\r
        if (texture[1] != null) {\r
              texture[1].enable(gl);\r
              texture[1].bind(gl);\r
              gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);\r
              TextureCoords coords = texture[1].getImageTexCoords();\r
-       \r
+\r
        /* draw down sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 1.0f, 0.0f);\r
                gl.glTexCoord2f(coords.left(), coords.top());\r
                gl.glVertex3f(-2.0f, -1.5f, -3.0f);\r
@@ -478,7 +479,7 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f( 2.0f, -1.5f,  3.0f);\r
                gl.glTexCoord2f(coords.right(), coords.top());\r
                gl.glVertex3f( 2.0f, -1.5f, -3.0f);\r
-               \r
+\r
                gl.glNormal3f(0.0f, -1.0f, 0.0f);\r
                gl.glVertex3f(-2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f(-2.05f, -1.55f,  3.0f);\r
@@ -486,81 +487,81 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f( 2.05f, -1.55f, -3.0f);\r
 \r
        gl.glEnd();\r
-       \r
+\r
                texture[1].disable(gl);\r
        }\r
-       \r
+\r
        /* draw back sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 0.0f, -1.0f);\r
-               \r
+\r
                gl.glVertex3f(-2.05f, 1.55f, -3.0f);\r
                gl.glVertex3f( 2.05f, 1.55f, -3.0f);\r
                gl.glVertex3f( 2.0f, 1.5f, -3.0f);\r
                gl.glVertex3f(-2.0f, 1.5f, -3.0f);\r
-               \r
+\r
                gl.glVertex3f(-2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f( 2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f( 2.0f, -1.5f, -3.0f);\r
                gl.glVertex3f(-2.0f, -1.5f, -3.0f);\r
-               \r
+\r
                gl.glVertex3f(-2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f(-2.05f, 1.55f, -3.0f);\r
                gl.glVertex3f(-2.0f, 1.5f, -3.0f);\r
                gl.glVertex3f(-2.0f, -1.5f, -3.0f);\r
-               \r
+\r
                gl.glVertex3f(2.05f, -1.55f, -3.0f);\r
                gl.glVertex3f(2.05f, 1.55f, -3.0f);\r
                gl.glVertex3f(2.0f, 1.5f, -3.0f);\r
                gl.glVertex3f(2.0f, -1.5f, -3.0f);\r
 \r
        gl.glEnd();\r
-       \r
+\r
        /* draw front sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 0.0f, 1.0f);\r
-               \r
+\r
                gl.glVertex3f(-2.05f, 1.55f, 3.0f);\r
                gl.glVertex3f( 2.05f, 1.55f, 3.0f);\r
                gl.glVertex3f( 2.0f, 1.5f, 3.0f);\r
                gl.glVertex3f(-2.0f, 1.5f, 3.0f);\r
-               \r
+\r
                gl.glVertex3f(-2.05f, -1.55f, 3.0f);\r
                gl.glVertex3f( 2.05f, -1.55f, 3.0f);\r
                gl.glVertex3f( 2.0f, -1.5f, 3.0f);\r
                gl.glVertex3f(-2.0f, -1.5f, 3.0f);\r
-               \r
+\r
                gl.glVertex3f(-2.05f, -1.55f, 3.0f);\r
                gl.glVertex3f(-2.05f, 1.55f, 3.0f);\r
                gl.glVertex3f(-2.0f, 1.5f, 3.0f);\r
                gl.glVertex3f(-2.0f, -1.5f, 3.0f);\r
-               \r
+\r
                gl.glVertex3f(2.05f, -1.55f, 3.0f);\r
                gl.glVertex3f(2.05f, 1.55f, 3.0f);\r
                gl.glVertex3f(2.0f, 1.5f, 3.0f);\r
                gl.glVertex3f(2.0f, -1.5f, 3.0f);\r
 \r
        gl.glEnd();\r
-        \r
+\r
   }\r
-  \r
+\r
   public static void box(GL2 gl)       //Usually "box" mean box, but there only one side is enough\r
   {\r
-         \r
+\r
        gl.glShadeModel(GL2.GL_FLAT);\r
-       \r
+\r
        if (texture[4] != null) {\r
              texture[4].enable(gl);\r
              texture[4].bind(gl);\r
              gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);\r
              gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);\r
              gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);\r
-       \r
+\r
        /* draw the side */\r
        gl.glBegin(GL2.GL_QUADS);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 0.0f, 1.0f);\r
                gl.glTexCoord2f(0, 0);\r
                gl.glVertex3f(-8.0f, -8.0f, 0.0f);\r
@@ -572,15 +573,15 @@ public class Tennis implements GLEventListener {
                gl.glVertex3f( 8.0f, -8.0f, 0.0f);\r
 \r
        gl.glEnd();\r
-       \r
+\r
                texture[4].disable(gl);\r
        }\r
-        \r
+\r
   }\r
-  \r
+\r
   public static void desk(GL2 gl, int two_or_three)\r
   {\r
-         \r
+\r
        int i;\r
        float temp1;\r
 \r
@@ -592,94 +593,94 @@ public class Tennis implements GLEventListener {
              gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);\r
              gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);\r
              gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);\r
-       \r
+\r
        /* draw the front */\r
        gl.glBegin(GL2.GL_QUAD_STRIP);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 0.0f, 1.0f);\r
                for (i=0; i<25; i++)\r
                {\r
                        temp1 = (float) Math.pow(Math.sin(i/24.0f*Math.PI), 0.4d);\r
-                        \r
+\r
                        gl.glTexCoord2f((i-12)/40.0f, temp1/4 + 0.75f);\r
-                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , 0.01f + temp1/25);        \r
+                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , 0.01f + temp1/25);\r
                        gl.glTexCoord2f((i-12)/40.0f, -temp1/4 + 0.25f);\r
-                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, 0.01f + temp1/25);        \r
+                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, 0.01f + temp1/25);\r
                }\r
 \r
        gl.glEnd();\r
-       \r
+\r
        /* draw the back */\r
        gl.glBegin(GL2.GL_QUAD_STRIP);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 0.0f, -1.0f);\r
                for (i=0; i<25; i++)\r
                {\r
                        temp1 = (float) Math.pow(Math.sin(i/24.0f*Math.PI), 0.4d);\r
-                       \r
+\r
                        gl.glTexCoord2f((i-12)/40.0f, temp1/4 + 0.75f);\r
-                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , -0.01f - temp1/25);       \r
+                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , -0.01f - temp1/25);\r
                        gl.glTexCoord2f((i-12)/40.0f, -temp1/4 + 0.25f);\r
-                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, -0.01f - temp1/25);       \r
-                       \r
+                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, -0.01f - temp1/25);\r
+\r
                }\r
 \r
        gl.glEnd();\r
-       \r
+\r
        texture[2].disable(gl);\r
        }\r
-       \r
+\r
        /* draw the top side */\r
        gl.glBegin(GL2.GL_QUAD_STRIP);\r
-       \r
+\r
                gl.glNormal3f(0.0f, 1.0f, 0.0f);\r
                for (i=0; i<25; i++)\r
                {\r
                        temp1 = (float) Math.pow(Math.sin(i/24.0f*Math.PI), 0.4d);\r
-                       \r
-                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , -0.01f - temp1/25);                                       \r
-                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , 0.01f + temp1/25);        \r
+\r
+                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , -0.01f - temp1/25);\r
+                       gl.glVertex3f((i-12)/40.0f, temp1/10 + 0.1f , 0.01f + temp1/25);\r
                }\r
-               \r
+\r
        gl.glEnd();\r
-               \r
+\r
        /* draw the bottom side */\r
        gl.glBegin(GL2.GL_QUAD_STRIP);\r
-                       \r
+\r
                gl.glNormal3f(0.0f, -1.0f, 0.0f);\r
                for (i=0; i<25; i++)\r
-               {       \r
+               {\r
                        temp1 = (float) Math.pow(Math.sin(i/24.0f*Math.PI), 0.4d);\r
-                       \r
-                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, 0.01f + temp1/25);                        \r
-                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, -0.01f - temp1/25);       \r
+\r
+                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, 0.01f + temp1/25);\r
+                       gl.glVertex3f((i-12)/40.0f, -temp1/10 - 0.1f, -0.01f - temp1/25);\r
                }\r
 \r
        gl.glEnd();\r
-       \r
+\r
        /* draw the left and right sides */\r
        gl.glBegin(GL2.GL_QUADS);\r
-                       \r
+\r
                        gl.glNormal3f(-1.0f, 0.0f, 0.0f);\r
                        gl.glVertex3f((-12)/40.0f, -0.1f, 0.01f);\r
-                       gl.glVertex3f((-12)/40.0f, +0.1f, 0.01f);                       \r
+                       gl.glVertex3f((-12)/40.0f, +0.1f, 0.01f);\r
                        gl.glVertex3f((-12)/40.0f, +0.1f, -0.01f);\r
-                       gl.glVertex3f((-12)/40.0f, -0.1f, -0.01f);      \r
-                       \r
+                       gl.glVertex3f((-12)/40.0f, -0.1f, -0.01f);\r
+\r
                        gl.glNormal3f(1.0f, 0.0f, 0.0f);\r
                        gl.glVertex3f((+12)/40.0f, -0.1f, 0.01f);\r
-                       gl.glVertex3f((+12)/40.0f, +0.1f, 0.01f);                       \r
+                       gl.glVertex3f((+12)/40.0f, +0.1f, 0.01f);\r
                        gl.glVertex3f((+12)/40.0f, +0.1f, -0.01f);\r
-                       gl.glVertex3f((+12)/40.0f, -0.1f, -0.01f);                      \r
+                       gl.glVertex3f((+12)/40.0f, -0.1f, -0.01f);\r
 \r
 \r
        gl.glEnd();\r
-       \r
+\r
   }\r
-  \r
+\r
   public static void ball(GL2 gl)\r
   {\r
-         \r
+\r
        int i,j;\r
        float y1,y2,r1,r2,x,z;\r
 \r
@@ -687,21 +688,21 @@ public class Tennis implements GLEventListener {
 \r
        /* draw the ball */\r
        gl.glBegin(GL2.GL_QUAD_STRIP);\r
-       \r
+\r
                for (i=0; i<20; i++)\r
                {\r
                        y1 = (float) Math.cos((i)/20.0f*Math.PI)/10;\r
                        y2 = (float) Math.cos((i+1)/20.0f*Math.PI)/10;\r
                        r1 = (float) Math.sqrt(Math.abs(0.01f-y1*y1));\r
                        r2 = (float) Math.sqrt(Math.abs(0.01f-y2*y2));\r
-                       \r
+\r
                        for (j=0; j<21; j++)\r
                        {\r
                                x = (float) (r1*Math.cos((float)j/21*2.0f*Math.PI));\r
                                z = (float) (r1*Math.sin((float)j/21*2.0f*Math.PI));\r
                                gl.glNormal3f(10*x, 10*y1, 10*z);\r
                                gl.glVertex3f(x, y1, z);\r
-                               \r
+\r
                                x = (float) (r2*Math.cos((float)j/21*2.0f*Math.PI));\r
                                z = (float) (r2*Math.sin((float)j/21*2.0f*Math.PI));\r
                                gl.glNormal3f(10*x, 10*y2, 10*z);\r
@@ -710,19 +711,19 @@ public class Tennis implements GLEventListener {
                }\r
 \r
        gl.glEnd();\r
-       \r
+\r
   }\r
-  \r
+\r
   public void MoveSphere()\r
   {\r
-         \r
+\r
        // Ball out\r
 \r
                if ((BallCz>3)||(BallCz<-3))\r
                {\r
-                       \r
+\r
                        Vec=BallCz;\r
-                       \r
+\r
                        BallCx = 0.0f;\r
                        BallCy = 0.0f;\r
                        BallCz = 0.0f;\r
@@ -732,7 +733,7 @@ public class Tennis implements GLEventListener {
                        spy=0;\r
 \r
                        CanF=false;\r
-                       \r
+\r
                        Bax=0;\r
                        Bay=0;\r
 \r
@@ -742,20 +743,20 @@ public class Tennis implements GLEventListener {
 \r
                if ((spz<0)&&(BallCz+spz<-2.8)&&(BallCx+spx<EnDeskCx+0.3)&&(BallCx+spx>EnDeskCx-0.3)&&(BallCy+spy<EnDeskCy+0.2)&&(BallCy+spy>EnDeskCy-0.2))\r
                {\r
-               \r
+\r
                        spz=-spz+0.002f;\r
                        spx=spx+(BallCx-EnDeskCx)/10;\r
-                       spy=spy+(BallCy-EnDeskCy)/10;   \r
-               \r
+                       spy=spy+(BallCy-EnDeskCy)/10;\r
+\r
                }\r
 \r
                if ((spz>0)&&(BallCz+spz>2.8)&&(BallCx+spx<sx+0.3)&&(BallCx+spx>sx-0.3)&&(BallCy+spy<sy+0.2)&&(BallCy+spy>sy-0.2))\r
                {\r
-                       \r
+\r
                        spz=-spz-0.002f;\r
                        spx=spx+(BallCx-sx)/10;\r
                        spy=spy+(BallCy-sy)/10;\r
-                       \r
+\r
                        Bax=DspeedX/100;\r
                        Bay=DspeedY/100;\r
 \r
@@ -775,23 +776,23 @@ public class Tennis implements GLEventListener {
        // Ball move\r
 \r
            if (CanF==true)\r
-               \r
+\r
            BallCx += spx;\r
                BallCy += spy;\r
                BallCz += spz;\r
-               \r
+\r
        //Less the acceleration\r
 \r
                Bax=Bax-Bax/100;\r
                Bay=Bay-Bay/100;\r
-         \r
+\r
   }\r
-  \r
+\r
   public void MoveEnDesk()\r
   {\r
 \r
          //Just follow for the ball\r
-         \r
+\r
   float sx,sy;\r
   double gip=Math.sqrt((BallCx-EnDeskCx)*(BallCx-EnDeskCx)+(BallCy-EnDeskCy)*(BallCy-EnDeskCy));\r
 \r
@@ -806,7 +807,7 @@ public class Tennis implements GLEventListener {
   sy=Math.abs((BallCy-EnDeskCy))/((float) gip)*0.07f;\r
   }\r
 \r
-  if ((BallCx-EnDeskCx>0)&&(EnDeskCx+sx<=1.7)) \r
+  if ((BallCx-EnDeskCx>0)&&(EnDeskCx+sx<=1.7))\r
          EnDeskCx += sx;\r
 \r
   if ((BallCx-EnDeskCx<0)&&(EnDeskCx-sx>=-1.7))\r
@@ -819,32 +820,32 @@ public class Tennis implements GLEventListener {
          EnDeskCy -= sy;\r
 \r
   }\r
-  \r
+\r
   public void MovMydesk() {\r
-         \r
+\r
          LPositionDX = sx;\r
          LPositionDY = sy;\r
-         \r
-         int x = MouseInfo.getPointerInfo().getLocation().x; \r
+\r
+         int x = MouseInfo.getPointerInfo().getLocation().x;\r
       int y = MouseInfo.getPointerInfo().getLocation().y;\r
 \r
-      sx = sx + (float)(x-500.0f)/300.0f;\r
-      sy = sy + (float)(400.0f-y)/300.0f;  \r
-      \r
+      sx = sx + (x-500.0f)/300.0f;\r
+      sy = sy + (400.0f-y)/300.0f;\r
+\r
       //Check cube borders\r
-      \r
+\r
       if (sx<-1.7f || sx>1.7f)\r
-       { \r
+       {\r
          if (sx>0) sx = 1.7f;\r
          else     sx = -1.7f;\r
        }\r
-      \r
+\r
       if (sy<-1.3 || sy>1.3)\r
-       { \r
+       {\r
          if (sy>0) sy = 1.3f;\r
          else     sy = -1.3f;\r
        }\r
-       \r
+\r
       //Return the mouse back from screen borders\r
        try {\r
           Robot r = new Robot();\r
@@ -855,66 +856,66 @@ public class Tennis implements GLEventListener {
        NPositionDY=sy;\r
 \r
        DspeedX=NPositionDX-LPositionDX;\r
-       DspeedY=NPositionDY-LPositionDY;      \r
-      \r
+       DspeedY=NPositionDY-LPositionDY;\r
+\r
     }\r
-  \r
-  class TennisKeyAdapter extends KeyAdapter {      \r
+\r
+  class TennisKeyAdapter extends KeyAdapter {\r
            public void keyPressed(KeyEvent e) {\r
                int kc = e.getKeyCode();\r
                if(KeyEvent.VK_ESCAPE == kc) {\r
                    System.exit(0);\r
-               } \r
+               }\r
                if(KeyEvent.VK_CONTROL == kc) {\r
                    control = false;\r
-               } \r
+               }\r
                if(KeyEvent.VK_SPACE == kc) {           //Ready for play\r
                        if (CanF==false)\r
-                       {       \r
+                       {\r
                                if (Vec<0)\r
-                                       spz=-0.07f;                     \r
+                                       spz=-0.07f;\r
                                else\r
                                        spz=0.07f;\r
                        }\r
                        CanF=true;\r
                }\r
            }\r
-           \r
-           public void keyReleased(KeyEvent e) {    //Give the mouse control to the user    \r
+\r
+           public void keyReleased(KeyEvent e) {    //Give the mouse control to the user\r
                int kc = e.getKeyCode();\r
                if(KeyEvent.VK_CONTROL == kc) {\r
                    control = true;\r
-               }               \r
+               }\r
            }\r
-           \r
+\r
          }\r
-         \r
+\r
   class TennisMouseAdapter extends MouseAdapter {\r
       public void mousePressed(MouseEvent e) {\r
         prevMouseX = e.getX();\r
         prevMouseY = e.getY();\r
-        \r
+\r
         mouseButtonDown = true;\r
       }\r
-               \r
+\r
       public void mouseReleased(MouseEvent e) {\r
           mouseButtonDown = false;\r
       }\r
-               \r
+\r
       public void mouseDragged(MouseEvent e) {\r
-         \r
+\r
         int x = e.getX();\r
         int y = e.getY();\r
-        \r
+\r
         float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)WindowW);\r
         float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)WindowH);\r
-               \r
+\r
         prevMouseX = x;\r
-        prevMouseY = y;       \r
-        \r
+        prevMouseY = y;\r
+\r
         view_rotx += thetaX;\r
         view_roty += thetaY;\r
       }\r
   }\r
-  \r
+\r
 }\r
http://JogAmp.org git info: FAQ, tutorial and man pages.