Hi, I am trying to get a program to render into a Canvas with the GLRenderer, and then when the container around the Canvas becomes bigger, I need to remove the canvas from its container, create a new framebuffer, and add the new canvas from the framebuffer into the container where the old canvas was. I have everything working up to the point where the canvas is removed. Whenver I try to remove the canvas, the program crashes: no exception or anything just Windows tells me java.exe has caused an error and needs to close. I created some code that is like my real code, and creates the crash.
import java.awt.*;
import javax.swing.*;
import com.threed.jpct.*;
class CanTest {
public static void main(String args[]){
final JPanel top = new JPanel();
World w = new World();
Object3D o = new Object3D(200);
o.addTriangle(new SimpleVector(0,0,0),new SimpleVector(0,300,0),new SimpleVector(300,0,0));
o.build();
w.addObject(o);
w.setAmbientLight(200,200,200);
w.newCamera();
Camera cam = w.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT,100);
JFrame f = new JFrame();
f.setLayout(new GridLayout(1,1));
f.add(top);
f.setVisible(true);
f.setSize(500,500);
top.setBackground(Color.blue);
try{ Thread.sleep } catch(Exception e){}
FrameBuffer b = new FrameBuffer(top.getWidth(),top.getHeight(),FrameBuffer.SAMPLINGMODE_NORMAL);
final Canvas c = b.enableGLCanvasRenderer();
b.disableRenderer(IRenderer.RENDERER_SOFTWARE);
top.setLayout(new GridLayout(1,1));
top.add(c);
int i = 0;
i=0;
while(i<5000){
b.clear();
//System.out.println("RENDERSCENE");
w.renderScene(b);
//System.out.println("DRAW");
w.draw(b);
//System.out.println("UPDATE");
b.update();
//System.out.println("GLONLY");
b.displayGLOnly();
//System.out.println("CANVAS__REPAINT");
c.repaint();
System.out.println("" + ++i);
}
b.dispose();
FrameBuffer framebuffer =new FrameBuffer(top.getWidth(),top.getHeight(),FrameBuffer.SAMPLINGMODE_NORMAL);
System.out.println("E");
System.out.println("l1");
framebuffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
System.out.println("About to crash...");
/** Uncommenting the line below makes the program crash. */
//top.remove(c);
/**It doesn't matter is you try this. Still the same result: a crash*/
/*
SwingUtilities.invokeLater(new Runnable(){
public void run(){
top.remove(c);
}
});
*/
}
}
Anybody, know why this happens?
JMan
I tried this little program on another computer, and the jre printed out this message before exiting the program, but windows didn't put up that error dialog
About to crash...
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x696a0508, pid=3752, tid=2748
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
# Problematic frame:
# C [nvoglnt.dll+0x1a0508]
#
# An error report file with more information is saved as hs_err_pid3752.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
[error occurred during error reporting, step 270, id 0xc0000005]