Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  I cant even get JPCT to run its 'hello world' tutorial  (Read 2617 times)
0 Members and 1 Guest are viewing this topic.
Offline HighFlyCoder

Senior Newbie





« Posted 2011-07-19 23:05:07 »

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?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
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);
        }
    }
}
Offline EgonOlsen
« Reply #1 - Posted 2011-07-19 23:11:40 »

The window should be created by this line

1  
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...

Offline HighFlyCoder

Senior Newbie





« Reply #2 - Posted 2011-07-19 23:18:11 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
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

Quote
Loading Texture...dirtyrapscallion.png
[ Tue Jul 19 17:17:11 EDT 2011 ] - WARNING: Unsupported Texture width (200)...resizing to a width of 256 pixels!
Java version is: 1.6.0_26
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
[ Tue Jul 19 17:17:12 EDT 2011 ] - WARNING: displayGLOnly() shouldn't be called without OpenGL support being (solely) used (com.threed.jpct.SoftGLRenderer@8bdcd2/null)

That last line then spams itself so it must be something in the loop that is causing it to say that
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline EgonOlsen
« Reply #3 - Posted 2011-07-19 23:31:34 »

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

1  
buffer.enableRenderer(IRenderer.MODE_OPENGL);


it should be

1  
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);

Offline HighFlyCoder

Senior Newbie





« Reply #4 - Posted 2011-07-19 23:43:59 »

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

http://i.imgur.com/9h7Lk.png

http://i.imgur.com/CCuJK.png

is that normal? is there anything i can do to fix that?
Offline EgonOlsen
« Reply #5 - Posted 2011-07-20 00:03:13 »

Yes, it's normal (see also: http://www.jpct.net/forum2/topics/info-needed/1928/msg/14171/view.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/topics/rpg-help/393/msg/2093/view.html#msg2093.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 06:55:21

Zero Volt (29 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (26 views)
2014-07-16 23:30:00

Cero (41 views)
2014-07-16 00:42:17

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (64 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!