Michael Wojcik
Michael Wojcik

Reputation: 341

Rendering opengl es while performing a long cpu process on Android

I am in the works of making a game (and game engine) on the Android platform using opengl es 1.x. While loading a level's data and building it, I want to render another scene so the player can have something to look at while the level loading code does it's work. I thought of using a hook system where the level loading code would from time to time call a callback function that could so some rendering.

The problem is how can I manually get OpenGL ES to display the contents of the backbuffer since the level loading code is performing its work on the opengl thread, since it too uses opengl es calls to perform it's work?

Any advice is greatly appreciated, Thanks

Upvotes: 0

Views: 150

Answers (1)

Carl-Emil Kjellstrand
Carl-Emil Kjellstrand

Reputation: 1243

You could try to do the opposite of having your loading code call the rendering code (let the rendering code call the loading code when there is some time in-between fames). Divide (and conquer) your loading up into as small fractions as possible, (only read 100 bytes of a image buffer and so on) and call a general load() method that will do the smallest amount of work possible before returning, and then if you have time to call again before rendering the next frame, call it again and just iterate until your running low on time (to keep some target fps). This will only work well if you can divide pretty much all your loading into small chunks and create a queue for the loading "tasks".

Upvotes: 1

Related Questions