SOLVED: Help with splash/loading screen

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

SOLVED: Help with splash/loading screen

Postby mark@project8games.com » Mon May 03, 2010 4:24 am

Hello all, I have a simple problem that I'm hoping I can get a solution for. I'm currently using a modified version of the replica island opengl code for the opengl version of my application. Everything is working great, and I'm getting the FPS I would like, the only problem is that on initial load, when I'm loading the textures into opengl, my application is just displaying a black screen :shock: .

Obviously, after the textures load the renderer thread can continue on to onDrawFrame(), then everything looks and works great. So my question is, how can I put up a loading screen while opengl is loading the textures in the background?

I've tried starting out with a canvas view, then background loading the textures. However the renderer does not have a surface when its in the background and therefore does not load the textures. The call to switch from the canvas view to the surface view therefore never happens and my application is left stuck at the loading screen.

The loadTextures() call, at least in the replica island code, blocks the renderer thread, and as far as I can see you can't really do more than one thing at a time with opengl anyways.

Any help would be much appreciated. Thank you.
Last edited by mark@project8games.com on Fri May 07, 2010 5:34 pm, edited 1 time in total.
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Top

Postby MichaelEGR » Mon May 03, 2010 4:03 pm

A quick reply..

You can load a texture and go into ortho mode, draw it full screen, exit ortho, swap buffers and then start the Replica Island engine loading. This should leave your intro texture on screen until the next swap buffer call.
Founder & Principal Architect; EGR Software LLC
http://www.typhonrt.org
http://www.egrsoftware.com
User avatar
MichaelEGR
Senior Developer
Senior Developer
 
Posts: 147
Joined: Thu Jan 21, 2010 5:30 am
Location: San Francisco, CA

Postby mark@project8games.com » Tue May 04, 2010 5:36 am

MichaelEGR wrote:A quick reply..

You can load a texture and go into ortho mode, draw it full screen, exit ortho, swap buffers and then start the Replica Island engine loading. This should leave your intro texture on screen until the next swap buffer call.


After spending some time researching this issue, it seems that swapping the buffer outside of the replica island rendering thread is impossible. Its nested very deep in there. I'm still learning the ropes though, so I will continue to try and see if I can figure out a way to make everything get along well. Thanks for the suggestion though, as your way seems like the ideal way to do things, so I will continue to try and make it work.
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Postby mark@project8games.com » Wed May 05, 2010 8:35 pm

I've continued to play around with this, and am noticing a very strange thing.

After the eglSwapBuffers() call, I attempt to take the same GL reference I have and load the textures. This works fine, and the textures get loaded, but then, for whatever reason, the last texture I loaded is painted onto the screen. Am I suppose to flush a buffer or something after I load a texture that's in the same method as a draw command? I do correctly bind a new texture to redraw, but this texture for whatever reason remains on the screen.

Thanks in advance for any help/
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Postby MichaelEGR » Fri May 07, 2010 2:00 am

It's unclear exactly what is happening without source or better yet a demo apk.

I'll take a stab though insofar that you may want to unbind the last texture loaded before continuing rendering. You may also try disabling GL_TEXTURE_2D. As you see I do that in the snippet below.

Here is what I do on starting a GL activity for Auriga3D. "glUtil" is a utility class. At the end "auriga3DGameLoop.initialize();" is called and that will load a Quake3 level and a bunch of data / textures. After this executes things are resumed and start running.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.    public void start(Object source)
  3.  
  4.    {
  5.  
  6.       if (source != null && source instanceof GLSurfaceView)
  7.  
  8.       {
  9.  
  10.          setRuntimeLoopSubDiv(s_SUB1);
  11.  
  12.  
  13.  
  14.          // Optional: disable dither to boost performance
  15.  
  16.          gl.glDisable(GL_DITHER);
  17.  
  18.  
  19.  
  20.          Texture introScreen = TextureLoader.loadTexture2D(R.drawable.load_screen, GL_REPEAT, GL_REPEAT, GL_LINEAR,
  21.  
  22.           GL_NEAREST, GL_MODULATE);
  23.  
  24.  
  25.  
  26.          glUtil.setOrtho(viewDim.width, viewDim.height);
  27.  
  28.  
  29.  
  30.          gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  31.  
  32.          gl.glEnableClientState(GL_VERTEX_ARRAY);
  33.  
  34.          gl.glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  35.  
  36.          gl.glEnable(GL_TEXTURE_2D);
  37.  
  38.          introScreen.setTexParameters();
  39.  
  40.          Texture.drawTexturedQuad(0, 0, viewDim.width, viewDim.height);
  41.  
  42.          gl.glDisableClientState(GL_VERTEX_ARRAY);
  43.  
  44.          gl.glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  45.  
  46.          gl.glDisable(GL_TEXTURE_2D);
  47.  
  48.          glUtil.resetOrtho();
  49.  
  50.          glUtil.swapBuffers();
  51.  
  52.  
  53.  
  54.          auriga3DGameLoop.initialize();
  55.  
  56.       }
  57.  
  58.    }
  59.  
  60.  
  61.  
  62.  
Parsed in 0.072 seconds, using GeSHi 1.0.8.4
Founder & Principal Architect; EGR Software LLC
http://www.typhonrt.org
http://www.egrsoftware.com
User avatar
MichaelEGR
Senior Developer
Senior Developer
 
Posts: 147
Joined: Thu Jan 21, 2010 5:30 am
Location: San Francisco, CA

Postby mark@project8games.com » Fri May 07, 2010 5:34 pm

Micheal, thanks a lot. Actually, right before you made your post I finished implementing it. You were entirely correct on the swapBuffers(). It was the key to getting it correct. There were definitely a couple of things I learned though
such as

    *Swapping buffers when all you did was load textures causes a lot of weird flickering issues
    *Always be aware of whats in the buffer from before, because it might end up coming back right when do a swapBuffer()


Btw here's the psuedo-code I used to do a loading bar in my game. The loop counts are in reference to iterations that GLThread makes (from replica island code)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. //loop 1
  3.  
  4. loadTextures(); //draw initial screen
  5.  
  6. swapBuffers();
  7.  
  8.  
  9.  
  10. //loop iteration 2
  11.  
  12. loadTextures();
  13.  
  14. updateCounts();//for next iteration %calculation
  15.  
  16. //DO NOT SWAP BUFFERS
  17.  
  18.  
  19.  
  20. //loop iteration 3
  21.  
  22. updateScreen();
  23.  
  24. swapBuffers();
  25.  
  26.  
  27.  
  28.  
Parsed in 0.063 seconds, using GeSHi 1.0.8.4


Here's a screen shot of what the above code ended up rendering:

Image


And once again thanks again MichaelEGR. Your advice was definitely key to solving this problem.
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Top

Re: SOLVED: Help with splash/loading screen

Postby zuerst » Thu Nov 03, 2011 12:10 pm

many thanks!! have solved the problem and everything works perfect now :run:
zuerst
Freshman
Freshman
 
Posts: 4
Joined: Wed Nov 02, 2011 8:06 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests