A few questions

Started by zammbi, August 19, 2010, 08:28:48 AM

Previous topic - Next topic

zammbi

Finally can post, forum trouble?

1) So I been thinking to use toXML when I get to that stage. Is there any documentation on this? I couldn't find any what exactly it exports.

2)Why does my hardware switcher crash, when going from hardware to software mode.

I get this crash:
QuoteOpenGL renderer disposed
Software renderer (OpenGL mode) initialized
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
   at com.threed.jpct.SoftGLRenderer.drawPolygon(Unknown Source)
   at com.threed.jpct.SoftGLRenderer.drawPolygon(Unknown Source)
   at com.threed.jpct.SoftGLRenderer.drawVertexArray(Unknown Source)
   at com.threed.jpct.World.draw(Unknown Source)
   at com.threed.jpct.World.draw(Unknown Source)
   at com.threed.jpct.World.draw(Unknown Source)
   at base.GameWindow.<init>(GameWindow.java:179)
   at base.GameWindow.main(GameWindow.java:739)


which is at this line:



if(switchHardware)
switchHardwareMode();
for (int i = 0; i < numOfUpdates; i++) {
updateEntities();
moveCamera();
}
state = null;
while (!talkfield.isActive() && (state = keyMapper.poll()) != KeyState.NONE) {
processKeyEvent(state); // Process key events here using the 'state' object
}
processMouseEvent();

window.evaluateInput(mouse, keyMapper);
buf.clear();
world.renderScene(buf);
world.draw(buf); <-----crashes here.
window.draw(buf);
if(wireframe)
world.drawWireframe(buf, Color.WHITE);


My switcher code is:

private void switchHardwareMode(){
switchHardware = false;
Config.glFullscreen = fullscreen;


if (!hardware) { //hardware mode
hardware = true;
buf.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buf.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
world.setFoggingMode(World.FOGGING_PER_PIXEL);

cleanUpWindow();
mouse = new MouseMapper(height);
keyMapper = new KeyMapper();
} else { //software mode
hardware = false;
       if (fullscreen) {
           device.setFullScreenWindow(null);
       }
       buf.disableRenderer(IRenderer.RENDERER_OPENGL);
buf.enableRenderer(IRenderer.RENDERER_SOFTWARE, IRenderer.MODE_OPENGL);
world.setFoggingMode(World.FOGGING_PER_VERTEX);

cleanUpWindow();
createSoftwareAWTWindow();
mouse = new MouseMapper(frame);
keyMapper = new KeyMapper(frame);

}
}


3) How can I have child lights to a object? I want to have a light follow a object but not worry about this myself as I'll be tracking a lot of of lights. Is this possible? or will be possible?  ;)


EgonOlsen

Quote
Finally can post, forum trouble?
None that i'm aware of...

Quote
1) So I been thinking to use toXML when I get to that stage. Is there any documentation on this? I couldn't find any what exactly it exports.
I don't really recommend to use toXML... What exactly do you want to use it for?

Quote
2)Why does my hardware switcher crash, when going from hardware to software mode.
Have you compiled and/or stripped the objects? In that case, you can't switch to software anymore. Compiled objects and software renderer don't mix. Just decide at startup which mode to use. It doesn't make much sense to switch in between anyway IMHO.


Quote
3) How can I have child lights to a object? I want to have a light follow a object but not worry about this myself as I'll be tracking a lot of of lights. Is this possible? or will be possible?  ;)
There's no build in functionality to do this. You can extends Object3D for your objects and attach a light yourself that way. I did that in Paradroidz IIRC. However, take care of the light count. If possible, you should limit it to 8 lights per scene if you are using compiled objects or otherwise, the renderer will drop lights that are farer away.

zammbi

#2
QuoteNone that i'm aware of...
Odd. Its all fine now. I was just missing CSS files and it wouldn't let me post.

QuoteI don't really recommend to use toXML... What exactly do you want to use it for?
For saving my level.

QuoteHave you compiled and/or stripped the objects? In that case, you can't switch to software anymore. Compiled objects and software renderer don't mix. Just decide at startup which mode to use. It doesn't make much sense to switch in between anyway IMHO.
Ah right, thanks its works now. Do you have any sample code which picks hardware mode and if it fails fall back to software mode? Or a uncompile way?

QuoteThere's no build in functionality to do this. You can extends Object3D for your objects and attach a light yourself that way. I did that in Paradroidz IIRC.
Yeah I was thinking of doing this. Wouldn't this be a easy thing to add official support or don't want the class to get larger?

QuoteHowever, take care of the light count. If possible, you should limit it to 8 lights per scene if you are using compiled objects or otherwise, the renderer will drop lights that are farer away.
Shouldn't it drop the light that would least affects the object? I want a whole lot of small lights for a creature. Or I guess I wont use compiled objects for this map.

EgonOlsen

Quote
For saving my level.
Like saving the level to represent a game state on disc or just saving the mesh data?

Quote
Ah right, thanks its works now. Do you have any sample code which picks hardware mode and if it fails fall back to software mode? Or a uncompile way?
There is a decompile()-method in Object3D. As long as don't strip an object, that should do the trick. However, i would try to avoid this if i were you. About the software fallback: Set the onError-mode of the Logger to ON_ERROR_THROW_EXCEPTION and catch the excpetion when initializing the renderer. So if that fails, you can fall back to software mode. In addition, you can query the framebuffer after setting the renderer by calling    isInitialized(). If this returns false on the hardware renderer, you might have a problem as well. However, that won't work if enabling hardware mode causes the system to hang. I think that letting the user decide at startup and using intelligent defaults might be the best option.

Quote
Yeah I was thinking of doing this. Wouldn't this be a easy thing to add official support or don't want the class to get larger?
I don't think that i'm going to add this. I agree that it might be handy in some situations, but...no, i don't think so.

Quote
Shouldn't it drop the light that would least affects the object? I want a whole lot of small lights for a creature. Or I guess I wont use compiled objects for this map.
It tries too. However, this decision is solely based on distance, i.e. if you have 8 lights surrounding an object, the sun might get ignored if it's number 9 but farer away. And keep in mind that more lights mean less performance. It might not be a problem though.

zammbi

Ok thanks. I might just not use complied objects for now and worry about all that later.

QuoteLike saving the level to represent a game state on disc or just saving the mesh data?
Thinking in making a basic map editor, should I use toXml to the save the map?

zammbi

#5
How do you get the child objects from a object? There is a getParent method but no getChild method.
For now I'll have to save the children.

I remember reading that you can't remove lights from a world is this still true? I see it is. How many is many disabled lights for the software renderer?
Ah I guess I'll use pooling: http://www.jpct.net/forum2/index.php/topic,1288.0.html


I'm stuck on moving lights:

I'm setting the light position:

Quotelight.setPosition(model.getTransformedCenter());
But the light doesn't seem to be following.
Seems to be working now. I forgot about setting it in my gravity method.

EgonOlsen

Quote from: zammbi on August 19, 2010, 02:58:35 PM
Thinking in making a basic map editor, should I use toXml to the save the map?
toXml might be an option for that, but you should consider to use the DeSerializer class instead. The format should be more compact and faster to load.

zammbi

A few more questions:

I noticed quite a few examples using SimpleStream. When actually should I use SimpleStream?

Do textures compress in memory when not in use?

Has the hold down mouse button been fixed in lwjgl? As in do I need to do this anymore:
Quoteif(hardware){// Avoid entering the level while the mouse button is being pressed
           while (mouse.buttonDown(0)) {
               org.lwjgl.input.Mouse.poll();
               try {
               Thread.sleep(10);
            } catch (InterruptedException e) {}
           }
      }

Should I use Toolkit.getDefaultToolkit().sync()? It had no effect for me, but I hear that Linux needs it.

What would be the best way to do blur? Say for if object is speeding (single object), or if a player is drunk (whole screen, ignoring GUI).

Hardware mode targets what OpenGL version? aka does it work on OpenGL 1.1?

EgonOlsen

Quote
I noticed quite a few examples using SimpleStream. When actually should I use SimpleStream?
SimpleStream is my way to unify access to resources, so that i don't have to care if they are located in a jar or somewhere in the file system. It's just something that eases development for me. If you don't need it that way, then you don't need SimpleStream.

Quote
Do textures compress in memory when not in use?
Simple one: No.

Quote
Has the hold down mouse button been fixed in lwjgl? As in do I need to do this anymore:
That's nothing that has to be fixed in LWJGL. It just that i didn't want the mouse click from some "click to play" action to trigger the mouse click event in game, so i'm waiting for the button being released.

Quote
Should I use Toolkit.getDefaultToolkit().sync()? It had no effect for me, but I hear that Linux needs it.
For hardware mode, this isn't needed for sure, because LWJGL's native display has nothing to do with awt. For the software renderer...no idea. I never used it IIRC and never had a need to.

Quote
What would be the best way to do blur? Say for if object is speeding (single object), or if a player is drunk (whole screen, ignoring GUI).
To blur the whole screen in software, you can write a pixel based blur filter for that. It might be a bit slow though. For hardware mode, you can (ab)use the BloomGLProcessor in procs. Look out for the method setCombining(). About motion blur...no real idea.

Quote
Hardware mode targets what OpenGL version? aka does it work on OpenGL 1.1?
More like 1.3 with feature support up to 2.0. It might work to a degree with 1.1, but you'll have a hard time finding some hardware/drivers that implement these 13 years old specs only. 1.3 is minimum even for the crappiest chipsets.

zammbi

QuoteSimpleStream is my way to unify access to resources, so that i don't have to care if they are located in a jar or somewhere in the file system. It's just something that eases development for me. If you don't need it that way, then you don't need SimpleStream.
Ah k. I usually do something like so: 'loadMD2(ClientSprite.class.getResourceAsStream("...', so I be closing the stream like what SimpleStream does?

That's nothing that has to be fixed in LWJGL. It just that i didn't want the mouse click from some "click to play" action to trigger the mouse click event in game, so i'm waiting for the button being released.
Haha k, I thought I read this as a bug somewhere. I'll remove this code then.

QuoteFor hardware mode, this isn't needed for sure, because LWJGL's native display has nothing to do with awt. For the software renderer...no idea. I never used it IIRC and never had a need to.
I guess it wont hurt for software renderer. I thought it limited the fps to the screen refresh rate, but it didn't have that affect...

QuoteTo blur the whole screen in software, you can write a pixel based blur filter for that. It might be a bit slow though. For hardware mode, you can (ab)use the BloomGLProcessor in procs. Look out for the method setCombining().
What about not clearing the screen and draw the screen which is partly transparent or so? Wouldn't that be faster?

QuoteMore like 1.3 with feature support up to 2.0. It might work to a degree with 1.1, but you'll have a hard time finding some hardware/drivers that implement these 13 years old specs only. 1.3 is minimum even for the crappiest chipsets.
I was just wondering, good to know. I know if a person has faulty OpenGL drivers it might use the Microsoft ones, which the version can be 1.1.

EgonOlsen

Quote
Ah k. I usually do something like so: 'loadMD2(ClientSprite.class.getResourceAsStream("...', so I be closing the stream like what SimpleStream does?
No need to close it. The loader closes the stream anyway.

Quote
What about not clearing the screen and draw the screen which is partly transparent or so? Wouldn't that be faster?
Faster than what? And it won't give you a real blur.

zammbi

QuoteFaster than what? And it won't give you a real blur.
Ah yep. I'll just play around later I guess and see what I can come up with.