ERROR PLZ HELP!!!

hello
this is the error i get when i try to run my java project!
it happens that whenever i run either nothing is displayed or strange shapes !!
`net.java.games.jogl.GLException: Error freeing OpenGL context

at net.java.games.jogl.impl.windows.WindowsGLContext.free(WindowsGLContext.java:151)

at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.free(WindowsOnscreenGLContext.java:132)

at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:203)

at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:182)

at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)

at net.java.games.jogl.Animator$1.run(Animator.java:104)

at java.lang.Thread.run(Thread.java:536)`

this is my code, i really didnt write anything yet, however whenever i change the screen claer color its always black!!!

package proj;

import net.java.games.jogl.*;

public class projListener implements GLEventListener {
  int buttonFlag=0;

  public void init(GLDrawable drawable) {
    GL gl = drawable.getGL();
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();
  }

  public void display(GLDrawable drawable) {
    GL gl = drawable.getGL();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();






  }

  public void reshape(GLDrawable drawable, int int1, int int2, int width,
                      int height) {
    GL gl = drawable.getGL();
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrtho( -width, width, -height, height, -1, 1);


  }

  public void displayChanged(GLDrawable gLDrawable, boolean boolean1,
                             boolean boolean2) {
  }
}
package proj;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import net.java.games.jogl.*;

public class proj1 extends JFrame {
  JPanel contentPane;
  JPanel jPanel1 = new JPanel();
  TitledBorder titledBorder1;
  JPanel jPanel2 = new JPanel();
  JLabel label1 = new JLabel();
  JTextField txt1 = new JTextField();
  JButton jButton1 = new JButton();

  projListener listen = new projListener();

  GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());

  //Construct the frame
  public proj1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  public static void main(String[] args) {
   new proj1();
}


  //Component initialization
  private void jbInit() throws Exception  {
    contentPane = (JPanel) this.getContentPane();
    titledBorder1 = new TitledBorder("");
    contentPane.setLayout(null);
    this.setSize(new Dimension(500, 500));
    this.setTitle("Graphics Project");
    jPanel1.setBorder(BorderFactory.createRaisedBevelBorder());
    jPanel1.setBounds(new Rectangle(2, 3, 495, 320));
    jPanel2.setBorder(BorderFactory.createLoweredBevelBorder());
    jPanel2.setBounds(new Rectangle(7, 333, 485, 154));
    jPanel2.setLayout(null);
    label1.setBackground(Color.lightGray);
    label1.setBorder(BorderFactory.createEtchedBorder());
    label1.setDebugGraphicsOptions(0);
    label1.setText("");
    label1.setBounds(new Rectangle(11, 13, 284, 55));
    txt1.setBounds(new Rectangle(11, 77, 281, 51));
    jButton1.setBounds(new Rectangle(314, 46, 130, 44));
    jButton1.setText("OK!");
    jButton1.addMouseListener(new proj1_jButton1_mouseAdapter(this));
    canvas.setForeground(SystemColor.activeCaptionText);
    contentPane.add(jPanel1, null);
    jPanel1.add(canvas); //adding the canvas to the panel
    contentPane.add(jPanel2, null);
    jPanel2.add(label1, null);
    jPanel2.add(txt1, null);
    jPanel2.add(jButton1, null);


    canvas.setSize(jPanel1.getSize()); //setting the size of the canvas to the size of the panel
    canvas.setLocation(0,0);
    jPanel1.setVisible(true);
    this.setVisible(true);//making the frame visible

    canvas.addGLEventListener(listen);

    Animator anim = new Animator(canvas);
    anim.start();
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }

  void jButton1_mousePressed(MouseEvent e) {

    listen.buttonFlag=1;

  }




}

class proj1_jButton1_mouseAdapter extends java.awt.event.MouseAdapter {
  proj1 adaptee;

  proj1_jButton1_mouseAdapter(proj1 adaptee) {
    this.adaptee = adaptee;
  }
  public void mousePressed(MouseEvent e) {
    adaptee.jButton1_mousePressed(e);
  }

}

Anyy ideas!!!

You are using a very old version of jogl. Go to the jogl homepage (https://jogl.dev.java.net/) and download the JSR-231 version, which is the official “successor” to jogl. Since it is now somewhat of an official sun extension, it has a new namespace javax.media.opengl

You can use the following code as a starter:


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;



/**
 * SimpleJOGL.java 

 * 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 SimpleJOGL implements GLEventListener {

    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(new SimpleJOGL());
        frame.add(canvas);
        frame.setSize(640, 480);
        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();

        // Clear the drawing area
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        // Reset the current matrix to the "identity"
        gl.glLoadIdentity();

        // Move the "drawing cursor" around
        gl.glTranslatef(-1.5f, 0.0f, -6.0f);

        // Drawing Using Triangles
        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();

        // Move the "drawing cursor" to another position
        gl.glTranslatef(3.0f, 0.0f, 0.0f);
        // Draw A Quad
        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();

        // Flush all drawing operations to the graphics card
        gl.glFlush();
    }

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

You can also use our support pack for Netbeans 6, if you are using this IDE or would like to try it. It contains all neccessary jars and natives and includes most of the official JOGL demos as template projects.

so if i use the new version will it solve this problem?!
the point is that projects done on another pc work perfectly fine, (the same version), the problem is when i write the code on my pc!!
ps: am using jbuilder not net beans

Cylab is right, whatever your IDE.

I think in the long run you would be better of porting to the new version. The old jogl version is not really supported anymore and you won’t get bug fixes for it.