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!!!