4 Replies Latest reply on Mar 12, 2010 8:12 AM by 843853

    no primitive is displayed on canvas

      I am using jogl to draw primitives to a canvas which I added to the content pane of a JFrame. The JFrame gets displayed but no primitive is drawn on th canvas. Here is the source code
      import java.awt.*;
      import java.awt.color.*;
      import java.awt.event.*;
      // Needed for ByteBuffers
      import java.nio.*;
      // The main JOGL import
      import net.java.games.jogl.*;
      // Needed for special type of empty ByteBuffer
      // used of Vertex Buffer Objects
      import net.java.games.jogl.util.*;
      public class Winta implements GLEventListener
           Winta()    // sorry for using the name of my gf as a class name
                Frame frame =  new Frame("GL TRial");
                GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
                frame.setSize(500, 400);
                frame.addWindowListener(new WindowAdapter()
                     public void windowClosing(WindowEvent e)
                frame.add(canvas, BorderLayout.CENTER);
           public static void main(String[] args)
                new Winta();
           public void display(GLDrawable drawable)
                GL gl = drawable.getGL();
                GLU glu = drawable.getGLU();
                //gl.glClearColor(0f, 0f, 0f, 0f);
                gl.glColor3f(0, 0, 0);
           public void displayChanged(GLDrawable gLDrawable, boolean modeChanged, boolean deviceChanged)
           public void init(GLDrawable drawable)
                GL gl = drawable.getGL();
                //gl.glClearColor(0f, 0f, 0f, 1f); // Black Background
                gl.glColor3f(1f, 1, 1);
           public void reshape(GLDrawable gLDrawable, int x, int y, int width, int height)
           protected void drawSomeLines(GL gl)
                     //gl.glColor3f(0f, 0f, 0.0f); 
                     gl.glVertex2f(50, 300);
                     gl.glVertex2f(75, 450);
                     gl.glVertex2f(60, 310);
                     gl.glVertex2f(85, 460);               
      well, you may see some lines of code that I commented out. It means I was desperately trying each combination.

      I have set the back ground of the frame to 'red' just to see what is going on. As it turns out, I see the red frame for a fraction of a second it then becomes black with no line or what so ever.

      Thanks in advance for your help.