Author Topic: A few questions  (Read 2385 times)

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
A few questions
« on: August 19, 2010, 08:28:48 am »
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:
Quote
OpenGL 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:


Code: [Select]
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:

Code: [Select]
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?  ;)

« Last Edit: August 19, 2010, 08:32:19 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A few questions
« Reply #1 on: August 19, 2010, 09:33:54 am »
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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: A few questions
« Reply #2 on: August 19, 2010, 10:22:12 am »
Quote
None that i'm aware of...
Odd. Its all fine now. I was just missing CSS files and it wouldn't let me post.

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

Quote
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.
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?

Quote
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.
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?

Quote
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.
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.
« Last Edit: August 19, 2010, 10:34:19 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A few questions
« Reply #3 on: August 19, 2010, 02:39:19 pm »
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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: A few questions
« Reply #4 on: August 19, 2010, 02:58:35 pm »
Ok thanks. I might just not use complied objects for now and worry about all that later.

Quote
Like 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?

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: A few questions
« Reply #5 on: August 19, 2010, 04:01:47 pm »
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:

Quote
light.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.
« Last Edit: August 19, 2010, 07:00:45 pm by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A few questions
« Reply #6 on: August 19, 2010, 08:04:52 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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: A few questions
« Reply #7 on: August 25, 2010, 05:26:08 pm »
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:
Quote
      if(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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A few questions
« Reply #8 on: August 25, 2010, 08:32:44 pm »
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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: A few questions
« Reply #9 on: August 26, 2010, 08:07:19 am »
Quote
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.
Ah k. I usually do something like so: 'loadMD2(ClientSprite.class.getResourceAsStream("...', so I be closing the stream like what SimpleStream does?

Code: [Select]
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.

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

Quote
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().
What about not clearing the screen and draw the screen which is partly transparent or so? Wouldn't that be faster?

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A few questions
« Reply #10 on: August 26, 2010, 07:49:57 pm »
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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: A few questions
« Reply #11 on: August 26, 2010, 08:32:13 pm »
Quote
Faster 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.