www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Mr_Chaos on November 08, 2017, 08:03:17 am

Title: Changing world and all objects
Post by: Mr_Chaos on November 08, 2017, 08:03:17 am
Hi.

I have an android app using JPCT-AE where the user can select different worlds, when a world is selected I want to show a progressdialog while the data is loading (data is loading asynchroniously using background tasks).
My problem is that sometimes when I change "world" I get exception, that I can see are because jpct-ae is not multi threaded, but how do I fix this.
I have a volatile variable in my renderer, that only allows rendering once the data is loaded, but for some reason i still get crashed in JPCT.
Do I have to pause the GLSurfaceView while loading or ? any ideas on how to do this
Title: Re: Changing world and all objects
Post by: EgonOlsen on November 08, 2017, 03:00:25 pm
You have to stop all jPCT related things (i.e. rendering and processing) while loading. Anything else will cause troubles.
Title: Re: Changing world and all objects
Post by: Mr_Chaos on November 08, 2017, 04:40:55 pm
How do I do that ?
Currently I'm making sure I don't render anything, but is that enough or do I have to do something else when I'm adding new objects ?
Title: Re: Changing world and all objects
Post by: MichaelJPCT on November 09, 2017, 03:05:14 am
glsurfaceview has a rendermode: WHEN_DIRTY. use this mode and request render every frame.
or put all operations in OnDrawFrame() method.
Title: Re: Changing world and all objects
Post by: EgonOlsen on November 09, 2017, 10:09:33 am
How do I do that ?
Currently I'm making sure I don't render anything, but is that enough or do I have to do something else when I'm adding new objects ?
If it crashes when adding new objects, you are rendering something. Can you simply synchronize both code blocks on the same object?