Getting GL10 instance in a separate thread on Android

I make a game, and I created a separate thread for loading assets, 3d models, etc. So the UI thread will not block while it is loading. However, loading a stream requires an instance of GL10 to load and display textures correctly.

Here is an overview of the problem so that you can better understand my predicament:
1. my Renderer class creates and starts the download thread.
2. The boot thread loads the models and textures from the assets
3. To load the textures, glGenTextures is required , but there is no GL10 instance in the load stream

I tried just providing the bootstrap with the GL10 instance specified by the Renderers onSurfaceCreated method, but it does not work. (I think it is deleted or messed up or something happens when the function is completed)

So how can I pass a working instance of GL10 to a loadable stream?

+3
source share
2 answers

Your answer cannot.

In opengl android, the gl / context object exists only in the render loop. As far as I know, you cannot use gl functions outside this thread.

opengl - , , , - , , - , , -...

, , - , ( ...) if (- ) {...} , , , - .

+5

iOS OSX, GL, , Android . , , . , ...

0

Source: https://habr.com/ru/post/1785815/


All Articles