OpenGL - Donut

Boas pessoal, gostava de saber o que se encontra mal no codigo do donut, nao entendo o que falta para completar o desenho (gldonut).

package org.yourorghere;

import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;



/**
 * Hilfe.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */
public class Hilfe implements GLEventListener {
    double PI = Math.PI;
    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();
        
        canvas.addGLEventListener(new Hilfe());
        frame.add(canvas);
        frame.setSize(1024, 768);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
                // make sure the call to Animator.stop() completes before
                // exiting
                new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
        // drawable.setGL(new DebugGL(drawable.getGL()));

        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
        gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        GLU glu = new GLU();

        if (height <= 0) { // avoid a divide by zero error!
        
            height = 1;
        }
        final float h = (float) width / (float) height;
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, h, 1.0, 20.0);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
    }
    
     public void display(GLAutoDrawable drawable) 
        {GL gl = drawable.getGL();
         gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
         gl.glLoadIdentity();
         gl.glTranslatef(-1.5f, 0.0f, -6.0f);
         //contorno_sphere(gl,1,1);
         //contorno_oval(gl,1,1);
         //contorno_praboloid(gl,1,1);
         //contorno_cone(gl,1,1);
         //contorno_cilindro(gl,1,1);
         //Desenhar_Donut(gl, 100, 100, 25, 20);
         glDonut(gl,500, 500, 45, 20, 0.0f, 0.0f, 1.0f, 0.3f);
         //int max=100;
         //for (int n=0;n<max;++n) 
         //    pontos_circulo(gl,10000,n*(float)(1)/max);
        
         gl.glFlush();
        }

    
    
    
    public void triangulo(GL gl) {
        gl.glBegin(GL.GL_TRIANGLES);
            gl.glColor3f(1.0f, 0.0f, 0.0f);    // Set the current drawing color to red
            gl.glVertex3f(0.0f, 1.0f, 0.0f);   // Top
            gl.glColor3f(0.0f, 1.0f, 0.0f);    // Set the current drawing color to green
            gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
            gl.glColor3f(0.0f, 0.0f, 1.0f);    // Set the current drawing color to blue
            gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
        // Finished Drawing The Triangle
        gl.glEnd(); 
                                 }
     
     public void quadrado(GL gl) {
        gl.glBegin(GL.GL_QUADS);
            gl.glColor3f(0.5f, 0.5f, 1.0f);    // Set the current drawing color to light blue
            gl.glVertex3f(-1.0f, 1.0f, 0.0f);  // Top Left
            gl.glVertex3f(1.0f, 1.0f, 0.0f);   // Top Right
            gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
            gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
        // Done Drawing The Quad
        gl.glEnd();
                                  }
     private void polygon_circulo(GL gl,int n)
         {
            gl.glBegin(GL.GL_POLYGON);
            for (int i=0;i<n;++i)
              {gl.glColor3f(1.0f-(float)(i)/n,(float)(i)/n, 1.0f); 
               gl.glVertex3f((float)(Math.sin((Double)(i*6.283/n))),(float)(Math.cos((Double)(i*6.283/n))), 0.0f);
              }
            gl.glEnd();
         }

     private void contorno_circulo(GL gl,int n)
         {
            gl.glBegin(GL.GL_POINTS);
            for (int i=0;i<n;++i)
              {gl.glColor3f(1.0f-(float)(i)/n,(float)(i)/n, 1.0f); 
               gl.glVertex3f((float)(Math.sin((Double)(i*6.283/n))),(float)(Math.cos((Double)(i*6.283/n))), 0.0f);
               gl.glVertex3f((float)(Math.sin((Double)((i+1)*6.283/n))),(float)(Math.cos((Double)((i+1)*6.283/n))), 0.0f);
              }
            gl.glEnd();
         }

          private void pontos_circulo(GL gl,int n,float r)
         {
            gl.glBegin(GL.GL_POINTS);
            for (int i=0;i<n;++i)
              {gl.glColor3f(1.0f-(float)(i)/n,(float)(i)/n, 1.0f); 
               gl.glVertex3f(r*(float)(Math.sin((Double)(i*6.283/n))),r*(float)(Math.cos((Double)(i*6.283/n))), 0.0f);
               gl.glVertex3f(r*(float)(Math.sin((Double)((i+1)*6.283/n))),r*(float)(Math.cos((Double)((i+1)*6.283/n))), 0.0f);
              }
            gl.glEnd();
         }
          
          /*
           * Largura (larg) e altura (alt) pretendida do contorno da esfera
           */
      private void contorno_sphere(GL gl, float larg, float alt)
         {
            gl.glBegin(GL.GL_POINTS);
            int n=1000; int m=1000;
            for (int j=0;j<m;++j)
               for (int i=0;i<n;++i)
                {gl.glColor3f(1.0f,(float)(j)/m, 1.0f); 
                 gl.glVertex3f(larg*(float)(Math.sin((Double)((float)(i)/n*PI))*Math.cos((Double)((float)(j)/m*(2*PI)))),
                               alt*(float)(Math.cos((Double)((float)(i)/n*PI))),
                              (float)(Math.sin((Double)((float)(i)/n*PI))*Math.sin((Double)((float)(j)/m*(2*PI)))));
                                                 //(float)(Math.cos((Double)(j*6.283/m)))
                }
            gl.glEnd();
         }
      /*
       * Largura (larg) e altura (alt) pretendida do contorno do oval
       */
       private void contorno_oval(GL gl, float larg, float alt)
         {  int n=700; int m=700;
            gl.glBegin(GL.GL_POINTS);
            for (int j=0;j<m;++j)
               for (int i=0;i<n;++i)
                {gl.glColor3f(1.0f, 1.0f,(float)(j)/m); //
                 gl.glVertex3f(larg*(float)(Math.sin((Double)((float)(i)/n*PI))*Math.cos((Double)((float)(j)/m*(2*PI)))),
                               alt*(float)(Math.cos((Double)((float)(i)/n*PI))),
                               1.5f*(float)(Math.sin((Double)((float)(i)/n*PI))*Math.sin((Double)((float)(j)/m*(2*PI)))));         
                }
            gl.glEnd();           
         }
       /*
        * Raio do circulo (rad) sobreposto e a altura (alt).
        */
       
      private void contorno_praboloid(GL gl, float rad, float alt)
         {
            gl.glBegin(GL.GL_POINTS);
            int n=1000; int m=1000;
            for (int j=0;j<m;++j)
               for (int i=0;i<n;++i)
                {gl.glColor3f(1.0f,(float)(j)/m, 1.0f); 
                 gl.glVertex3f(rad*(float)(i)/n*(float)(Math.cos((Double)((float)(j)/m*(2*PI)))),
                            alt*(float)(i*i)/(n*n),
                            (float)(i)/n*(float)(Math.sin((2*PI)*j/m)));
                                                 //(float)(Math.cos((Double)(j*6.283/m)))
                }
            gl.glEnd();
         }
      /*
       * Raio (rad) do circulo sobreposto no cone e a altura (alt) do mesmo
       */

       private void contorno_cone(GL gl, float rad, float alt)
         {
            gl.glBegin(GL.GL_POINTS);
            int n=1000; int m=1000;
            for (int j=0;j<m;++j)
               for (int i=0;i<n;++i)
                {gl.glColor3f(1.0f,(float)(j)/m, 1.0f); 
                 gl.glVertex3f(rad*(float)(i)/n*(float)(Math.cos((Double)((float)(j)/m*(2*PI)))),
                                alt*(float)(i)/n,
                                (float)(i)/n*(float)(Math.sin((2*PI)*j/m)));
                                                 // /(float)(Math.cos((Double)(j*6.283/m)))
                }
            gl.glEnd();
         }
       /*
        * Raio (rad) do circulo sobreposto no cilindro e a altura (alt) do cilindro.
        */
      
     private void contorno_cilindro(GL gl, float rad, float alt)
         {
            gl.glBegin(GL.GL_POINTS);
            int n=1000; int m=1000;
            for (int j=0;j<m;++j)
               for (int i=0;i<n;++i)
                {gl.glColor3f(1.0f,(float)(j)/m, 1.0f); 
                 gl.glVertex3f(rad*(float)(Math.cos((Double)((float)(j)/m*(2*PI)))),
                               alt*(float)(i)/n, 
                               0.2f*(float)(Math.sin((2*PI)*j/m)));
                                                 //(float)(Math.cos((Double)(j*6.283/m)))
                }
            gl.glEnd();
         }     
   
    
    
     
    
float xRotated, yRotated, zRotated;
double innerRaidus=0.5;
double outterRaidus=1;
int sides =50;
int rings =50;


/* private void donut(GL gl)
{

    gl.glMatrixMode(GL.GL_MODELVIEW);
    // clear the drawing buffer.
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    // clear the identity matrix.
    gl.glLoadIdentity();
    // traslate the draw by z = -4.0
    // Note this when you decrease z like -8.0 the drawing will looks far , or smaller.
    gl.glTranslatef(0.0f,0.0f,0.0f);
    // Red color used to draw.
    gl.glColor3f(0.0f, 0.0f, 0.1f); 
    // changing in transformation matrix.
    // rotation about X axis
    gl.glRotatef(xRotated,1.0f,0.0f,0.0f);
    // rotation about Y axis
    gl.glRotatef(yRotated,0.0f,1.0f,0.0f);
    // rotation about Z axis
    gl.glRotatef(zRotated,0.0f,0.0f,1.0f);
    // scaling transfomation 
    gl.glScalef(1.0f,1.0f,1.0f);
    // built-in (glut library) function , draw you a Torus.
 

    gl.glutWireTorus(innerRaidus,outterRaidus,sides,rings);
    // Flush buffers to screen
     
    gl.glFlush();        
    // sawp buffers called because we are using double buffering 
   // glutSwapBuffers();
} */

void glDonut(GL gl, int x, int y, int rad, int inrad, float r, float g, float b, float a) 
{  
    gl.glPushMatrix(); 
    gl.glLoadIdentity();  
    gl.glDisable(GL.GL_TEXTURE_2D); 
    gl.glEnable(GL.GL_BLEND); 
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); 
    gl.glColor4f(r, g, b, a);  
    gl.glLineWidth(1.0f); 
    gl.glBegin(GL.GL_LINES);  
    for(int i = 0; i < rad+1; i++) 
    { 
        for(int j=0; j<rad+1;j++) 
        { 
            //used to see if the point is between the outer and inner radius 
            if(Math.sqrt(rad*rad-i*i) > j && Math.sqrt(inrad*inrad-i*i) < j) 
            { 
                gl.glVertex2i(x+i,y+j); 
                gl.glVertex2i(x+i+1,y+j); 
                //used to mimic on the bottom of the circle 
                gl.glVertex2i(x+i,y-j); 
                gl.glVertex2i(x+i+1,y-j); 
                //used to mimic on left side of the circle 
                if(i!=0) 
                { 
                    gl.glVertex2i(x-i,y+j); 
                    gl.glVertex2i(x-i+1,y+j); 
                    gl.glVertex2i(x-i,y-j); 
                    gl.glVertex2i(x-i+1,y-j); 
                } 
            } 
            //see if the point is under the outer rad even tho the inner radius has terminated. 
            else if(Math.sqrt(rad*rad-i*i) > j && i > inrad && j >= 0) 
            { 
                gl.glVertex2i(x+i,y+j); 
                gl.glVertex2i(x+i+1,y+j); 
                gl.glVertex2i(x-i,y+j); 
                gl.glVertex2i(x-i+1,y+j); 
                 
                //used so no overlapping at the shared point 0 
                if(j!=0) 
                { 
                    gl.glVertex2i(x+i,y-j); 
                    gl.glVertex2i(x+i+1,y-j); 
                    gl.glVertex2i(x-i,y-j); 
                    gl.glVertex2i(x-i+1,y-j); 
                } 
            } 
        } 
    } 
    gl.glEnd(); 
    gl.glDisable(GL.GL_BLEND); 
    gl.glEnable(GL.GL_TEXTURE_2D);  
    gl.glPopMatrix(); 
}  


    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }
}