Author Topic: Pre loader for opengl  (Read 3089 times)

Offline Gopinath

  • byte
  • *
  • Posts: 22
    • View Profile
Pre loader for opengl
« on: January 10, 2014, 04:33:42 pm »
I have lots of objects (.pbj) to be loaded along with its texture. It is taking more time around 7 secs to load everything. I would like to add a loading message meanwhile for the user to know whats happening. I am clueless on how to show this in opengl / jpct-ae. It can be even simple text like "Loading...." at the center of the screen

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Pre loader for opengl
« Reply #1 on: January 10, 2014, 05:06:18 pm »
The simplest way might be to use Toast (it's a class in the Android SDK). It displays little text blobs on screen that fade away automatically.

Offline Gopinath

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Pre loader for opengl
« Reply #2 on: January 10, 2014, 06:27:29 pm »
Thank you for your suggestion. Will use that to indicate user

Offline Gopinath

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Pre loader for opengl
« Reply #3 on: January 12, 2014, 10:47:33 pm »
I had included the Toast with duration as Toast.LONG. Still it is too short for my need as it takes more time around 10 secs to finish loading. So after certain reference I looped the toast 3-4 times so it displays little longer duration. Is this good method?

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Pre loader for opengl
« Reply #4 on: January 13, 2014, 01:36:54 pm »
I'd initialize the object in another thread and display a message while this thread is running. For longer load times, you even must do something like that if you want to avoid the dreaded "application deadlock" message.
Take a look at this pretty similar thread:
http://www.jpct.net/forum2/index.php/topic,3772.0.html

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Pre loader for opengl
« Reply #5 on: January 13, 2014, 08:17:36 pm »
I had included the Toast with duration as Toast.LONG. Still it is too short for my need as it takes more time around 10 secs to finish loading.
The Toast doesn't have to use one of the constants. You can define your own value (not sure if this really helps, but it might be worth a try).

Offline Gopinath

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Pre loader for opengl
« Reply #6 on: January 16, 2014, 06:18:33 pm »
EgonOlsen & Irony, my customer is expecting to have a progress bar indicator or a pre-loader similar to web application or in the gaming applications while the objects are being loaded. So the idea of Toast does not solve the purpose here. So need assistance to figure this out.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Pre loader for opengl
« Reply #7 on: January 16, 2014, 08:25:49 pm »
If you are already in an OpenGL enabled Activity, you could simply put the loading part in a different thread and render an empty world while it works (and blit that progress bar of course). Just make sure that the switching after the loading is synchronized or done in the render thread.

Have you considered to use serialized objects (http://www.jpct.net/wiki/index.php/Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects) to speed up the loading process (just in case you haven't done this already)?

Offline Gopinath

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Pre loader for opengl
« Reply #8 on: February 09, 2014, 02:01:25 pm »
Thanks for your inputs. That seems to be the best option. But I have not tried it. Rather I had optimized & reduced the texture images to load little faster to meet the customer expectation. On the other side, will try your suggestion.