4

I'm working on an app that needs to load textures for frame animations at certain times while it's executing, the rendering thread needs to continue to run and I need to load the textures in a bg thread. Is there a way to do this in android? I was able to in ios by creating a separate opengl context on the other thread that used the same sharegroup but am not sure if there is a similar facility on android?

1 Answer 1

3

Yes, you can share textures between contexts (as long as your driver supports it). Create your background loading context like this (meaning you want to share objects with rendering_context):

eglCreateContext(display, config, rendering_context, attrs);

Then after doing something like this in your background context:

glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(...);

You can then bind and use tex from your rendering context.

Sign up to request clarification or add additional context in comments.

2 Comments

ok thanks for quick response, i'm not super familiar with opengl on android, is eglCreateContext a method called from the ndk or java? Is that all i have to do, create the context and the load up the textures, then kill the thread? Thanks
eglCreateContext() is how you create a context in C/C++. I couldn't tell you about Java, but there's probably something similar. So all you have to do is create the context, passing in your rendering context for the share context. Then start making textures and they'll be available in the rendering context with the same GLuint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.