I've added one, and now I can see the cube. However, the code in startPainting and finishedPainting isn't being called.
package orthogonal_test;
import com.threed.jpct.*;
import org.lwjgl.opengl.GL11;
import javax.swing.*;
import java.awt.*;
/**
* A simple HelloWorld using the OpenGL-renderer.
* @author EgonOlsen
*
*/
public class Main implements IPaintListener {
private World world;
private FrameBuffer buffer;
private Object3D box;
private Camera cam;
public static void main(String[] args) throws Exception {
new Main().loop();
}
public Main() throws Exception {
world = new World();
world.setAmbientLight(0, 255, 0);
box = Primitives.getBox(1f, 1f);
box.build();
world.addObject(box);
float dist = 30f;
cam = world.getCamera();
cam.setPosition( new SimpleVector( dist, dist, dist ) );
cam.lookAt( box.getTransformedCenter() );
}
private void loop() throws Exception {
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
buffer.setPaintListener(this);
JFrame frame = new JFrame();
frame.setSize( 800, 600 );
frame.setResizable(false);
Canvas canvas = buffer.enableGLCanvasRenderer();
frame.add(canvas);
frame.setVisible(true);
frame.setDefaultCloseOperation( JFrame.HIDE_ON_CLOSE );
while ( frame.isVisible() ) {
buffer.clear(java.awt.Color.BLACK);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
canvas.repaint();
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
System.exit(0);
}
public void startPainting()
{
System.out.println("here");
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(-13, 13, -1, 10, -30, 100);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
GL11.glScalef(1.0f, 1.0f, -1.0f);
GL11.glTranslatef( 0, 0, 0 );
GL11.glBegin(GL11.GL_LINES);
GL11.glColor3f(1.0f, 0.0f, 0.0f);
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d(10, 0, 0);
GL11.glEnd();
GL11.glBegin(GL11.GL_LINES);
GL11.glColor3f(0.0f, 1.0f, 0.0f);
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d(0, 10, 0);
GL11.glEnd();
GL11.glBegin(GL11.GL_LINES);
GL11.glColor3f(0.0f, 0.0f, 1.0f);
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d(0, 0, -10);
GL11.glEnd();
}
public void finishedPainting()
{
System.out.println("here");
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(-13, 13, -1, 10, -30, 100);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
GL11.glScalef(1.0f, 1.0f, -1.0f);
GL11.glTranslatef( 0, 0, 0 );
GL11.glBegin(GL11.GL_LINES);
GL11.glColor3f(1.0f, 0.0f, 0.0f);
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d(10, 0, 0);
GL11.glEnd();
GL11.glBegin(GL11.GL_LINES);
GL11.glColor3f(0.0f, 1.0f, 0.0f);
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d(0, 10, 0);
GL11.glEnd();
GL11.glBegin(GL11.GL_LINES);
GL11.glColor3f(0.0f, 0.0f, 1.0f);
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d(0, 0, -10);
GL11.glEnd();
}
}