Author Topic: Changing world and all objects  (Read 2614 times)

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
Changing world and all objects
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Changing world and all objects
« Reply #1 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.

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
Re: Changing world and all objects
« Reply #2 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 ?

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: Changing world and all objects
« Reply #3 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Changing world and all objects
« Reply #4 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?