Hi,
How can I resize FrameBuffer when the canvas get resized (or emulate this painting the Frame buffer in the whole resized canvas)??,
Im creating a thread per created panel to update the objects, I was thinking about:
1-Remove the canvas from the panel
2-Destroy the FrameBuffer,
3-Recreate the Frame buffer with the new size
4-add the canvas again to the panel.
I dont know how to paint it in the whole resized canvas, it is possible??
Here is the main parts of my Panel code:
public class PointCloudPanel extends javax.swing.JPanel {
public void initCanvas()
{
world = new World();
world.setAmbientLight(255, 255, 0);
TextureManager.getInstance().addTexture("box", new Texture("c:\\1191.jpg"));
box = Primitives.getBox(13f, 2f);
box.setTexture("box");
box.setEnvmapped(Object3D.ENVMAP_ENABLED);
box.build();
world.addObject(box);
world.getCamera().setPosition(50,50, 50);
world.getCamera().lookAt(box.getTransformedCenter());
this.setSize(320, 240);
buffer = new FrameBuffer(this.getWidth(), this.getHeight(), FrameBuffer.SAMPLINGMODE_GL_AA_4X);
canvas = buffer.enableGLCanvasRenderer();
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
this.add(canvas);
IPaintListener listener = new IPaintListener() {
public void finishedPainting() {}
};
buffer.setPaintListener(listener);
canvas.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent ce) {
System.out.println("RESIZED");
}
});
Thread thread = new LoopThread(this);
thread.start();
}
public PointCloudPanel() {
initComponents();
initCanvas();
}
class LoopThread extends Thread {
LoopThread(PointCloudPanel jp) {
}
@Override
public void run() {
while (true) {
box.rotateY(0.01f);
world.getCamera().lookAt(box.getTransformedCenter());
buffer.clear(java.awt.Color.GRAY);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
canvas.repaint();
try {
LoopThread.sleep(10);
increment += 1;
} catch (InterruptedException ex) {
}
}
}
}
private World world;
private FrameBuffer buffer;
private Object3D box;
private Canvas canvas;
private float increment = 0;
}
Let me know if you know another method please.
Thanks for any help!