I cant even get JPCT to run its 'hello world' tutorial

Yeah i get the error,
Exception in thread “main” java.lang.IllegalStateException: Cannot determine close requested state of uncreated window
at org.lwjgl.opengl.Display.isCloseRequested(Display.java:583)
at jpcttest.JPCTtest.create(JPCTtest.java:23)
at jpcttest.JPCTtest.main(JPCTtest.java:41)
Java Result: 1

obviously im missing something from that tutorial because it does make sense since there is nothing actually making a window, here is my code, do you guys know what im missing?


package jpcttest;
import com.threed.jpct.*;
import java.awt.Color;
import java.util.logging.Level;
public class JPCTtest {
    FrameBuffer buffer;
    public void create() throws InterruptedException{
        World world = new World();
        world.setAmbientLight(0, 255, 0);
        TextureManager.getInstance().addTexture("steve-stand", new Texture("steve_standing.png"));
        Object3D box = Primitives.getBox(13f, 2f);
        box.setTexture("steve_stand");
        box.setEnvmapped(Object3D.ENVMAP_ENABLED);
        box.build();
        world.addObject(box);
        world.getCamera().setPosition(50, -50, -5);
        world.getCamera().lookAt(box.getTransformedCenter());
        
        buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
        buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
        buffer.enableRenderer(IRenderer.MODE_OPENGL);
        
        while(!org.lwjgl.opengl.Display.isCloseRequested()){
            box.rotateY(.01f);
            buffer.clear(Color.BLUE);
            world.renderScene(buffer);
            world.draw(buffer);
            buffer.update();
            buffer.displayGLOnly();
            Thread.sleep(10);
        }
        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
        System.exit(0);
        
    }
    
    
    public static void main(String[] args) {
        try {
            new JPCTtest().create();
        } catch (InterruptedException ex) {
            java.util.logging.Logger.getLogger(JPCTtest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}


The window should be created by this line


buffer.enableRenderer(IRenderer.MODE_OPENGL);

Maybe that doesn’t happen for some reason…any log output before the exception? Or are you using the multithreaded renderer? In that case, the window won’t be created at this stage and the query will fail until the creation happens in another thread, which may take some ms.

Edit: BTW, maybe the actual jPCT forums are a better place to ask these questions…


package jpcttest;
import com.threed.jpct.*;
import java.awt.Color;
import java.util.logging.Level;
import org.lwjgl.input.Keyboard;
public class JPCTtest {
    FrameBuffer buffer;
    boolean isClosedRequest = false;
    public void create() throws InterruptedException{
        World world = new World();
        world.setAmbientLight(0, 255, 0);
        TextureManager.getInstance().addTexture("dirty", new Texture("dirtyrapscallion.png"));
        Object3D box = Primitives.getBox(13f, 2f);
        box.setTexture("dirty");
        box.setEnvmapped(Object3D.ENVMAP_ENABLED);
        box.build();
        world.addObject(box);
        world.getCamera().setPosition(50, -50, -5);
        world.getCamera().lookAt(box.getTransformedCenter());
        
        buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
        buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
        buffer.enableRenderer(IRenderer.MODE_OPENGL);
        
        while(!isClosedRequest){
            box.rotateY(.01f);
            buffer.clear(Color.BLUE);
            world.renderScene(buffer);
            world.draw(buffer);
            buffer.update();
            buffer.displayGLOnly();
            Thread.sleep(10);
        }
        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
        System.exit(0);
        
    }
    
    
    public static void main(String[] args) {
        try {
            new JPCTtest().create();
        } catch (InterruptedException ex) {
            java.util.logging.Logger.getLogger(JPCTtest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

I just changed some things up to fix some weird errors like the LWJGL problem and just changed it to a boolean for now. I also chaanged the image, here is all the stuff the console prints out

That last line then spams itself so it must be something in the loop that is causing it to say that

Now i see…my bad that i haven’t noticed this earlier…you are mixing the contants. Instead of your


buffer.enableRenderer(IRenderer.MODE_OPENGL);

it should be


buffer.enableRenderer(IRenderer.RENDERER_OPENGL);

woot! that worked (i fell like an idiot for not noticing the wrong constant), now my only major problem is what the box itself looks like, here ive uploaded an image of both the texture and what it looks like on the box

is that normal? is there anything i can do to fix that?

Yes, it’s normal (see also: http://www.jpct.net/forum2/index.php/topic,1928.msg14171.html#msg14171). The meshes created by Primitives have no proper texture coordinates and that is why the HelloWorld example enables environment mapping on them to show at least some texturing. If you want proper coordinates, load a model with proper coordinates instead or do it yourself in code like so: http://www.jpct.net/forum2/index.php/topic,393.msg2093.html#msg2093.