Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:10:08+00:00 2026-06-08T12:10:08+00:00

I try to write loading screen for my Android NDK game project – to

  • 0

I try to write loading screen for my Android NDK game project – to preload all textures.
If create texture in other thread, i get values like texture width set correctly, but get just black sprite instead of textured one, even if glGetError return 0. In same thread everything works ok, so assume there are no errors in sprite or texture code.

I think that is because i try to call opengl es 2.0 functions from another thread, without context provided by EGL. But how then get opengl es 2.0 context from EGL, which created in Java (Android) and bind it to use in opengl es 2.0 functions in native C?

Java(Android)

public class OGLES2View extends GLSurfaceView
{
 private static final int OGLES_VERSION = 2;

 public OGLES2View(Context context)
 {
  super(context);
  setEGLContextClientVersion(OGLES_VERSION);
  setRenderer(new OGLES2Renderer());
 }

private GLSurfaceView ogles2SurfaceView = null;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    ogles2SurfaceView = new OGLES2View(this);
    setContentView(ogles2SurfaceView);
}

C

#define TRUE 1
#define FALSE 0

typedef unsigned char bool;

typedef struct game_data
{
 bool loaded;
 tex* t;
}game_data;

static void* loader_thread_func(void* arg)
{
 JavaVM* jvm = get_java_vm(); //get java VM to detach in the end
 JNIEnv* env = get_jni_env(); //== attach current thread
 game_data* to_load = (game_data*) arg;
 to_load->t = malloc(sizeof(tex));
 set_tex(to_load->t,"textures/bonus.png");//textures width and height set correctly
 to_load->loaded = TRUE;
 (*jvm)->DetachCurrentThread(jvm);
 return NULL;
}

void load_game_data(game_data* res)
{
 pthread_t loader_thread;
 pthread_create(&loader_thread, NULL, loader_thread_func, res);
}

/*in render manager file*/
static game_data* g_d = NULL;

/*in onInit func*/
g_d = malloc(sizeof(game_data));
g_d->loaded = FALSE;
load_game_data(g_d);

/*in onDraw function*/
 if(g_d->loaded)
 /*draw sprite*/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:10:10+00:00Added an answer on June 8, 2026 at 12:10 pm

    To call OpenGL ES functions from another thread you have to create a shared OpenGL ES context between 2 threads.

    There is an easier solution – send the event to the thread that owns the OpenGL ES context to update the texture as soon as it is loaded in the second thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement a loading screen in blackberry. I try the code from
I'm trying to write a number guessing game in Lisp as a time-killing project.
try to write a composite component that allows mutltiple text inputs. I read that
I try to write Activator action for changing current song rating. I now that
I try to write a Facebook app. This app will communicate with a rfid
I try to write a javascript Self-Executing Anonymous Function window.App = window.App || {}
I try to write DSL class Warcraft class << self def config unless @instance
I try to write a macro in clojure that sets up a namespace and
I try to write a simple user script to enlarge the picture when you
I try to write the following in latex: \begin{itemize} \item \textbf{insert(element|text)} inserts the element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.