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

  • Home
  • SEARCH
  • 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 6728301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:09:14+00:00 2026-05-26T10:09:14+00:00

I am experimenting with writing a small game engine for Android using OpenGL ES.

  • 0

I am experimenting with writing a small game engine for Android using OpenGL ES. I have created a Game Thread which updates the game objects and the GLThread with draws the scene. I had read that you need to load the textures in onSurfaceCreated method of GLSurfaceView. I am following that but for some debugging purpose I was trying to load textures from my Game Thread instead of the GLThread. I got no errors and the texture were not showing up on the screen. I spent my entire day trying to figure out the problem and finally I read the below here

“Just be sure to only use OpenGL in the main thread.” Very important. You cannot call in your Game Engine (which may be in another thread) a texture-loading function which is not synchronized with the gl-thread. Set there a flag to signal your gl-thread to load a new texture (for example, you can place a function in OnDrawFrame(GL gl) which checks if there must be a new texture loaded.

I will modify my code so that the textures will be loaded from the GL Thread. I just could not understand why is it so? Why do the OpenGL functions do not work from another thread?

I know how to create threads but I do not know what synchronization means. The above extract mentions, “You cannot call in your Game Engine (which may be in another thread) a texture-loading function which is not synchronized with the gl-thread.” So I guess my Game Thread might not be synchronized with the GL Thread. Is it possible to create another thread which is synchronized to the GL Thread so that GL functions can be called from it? What should I learn in threading to understand these concepts?

  • 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-05-26T10:09:15+00:00Added an answer on May 26, 2026 at 10:09 am

    quixoto’s comment is closest, I think. The traditional reason that OpenGL contexts are thread specific on pretty much every platform is that OpenGL is heavily dependent on states and has no semantics for making a series of changes atomic. So, for example, the draw operation on one thread might be:

    glVertexPointer(... supply vertex positions ...)
    glTexCoordPointer(... provide texture positions ...)
    /* and supply a few other pointers, maybe bind a texture */
    
    glDrawArrays(... draw some geometry ...)
    

    So the final call provides predictable results only in the context of the preceding calls. If you allow for that bit of code being paused after, say, glVertexPointer, another thread hopping in and doing much the same sequence to draw its geometry and then this code proceeding, it’ll draw with quite the wrong geometry, possibly even causing out-of-bounds memory accesses if some of the replaced arrays are smaller than the originals.

    Android supplies EGL, which supports the common concept of an OpenGL share group (although implicitly; you supply an existing context that you want a new context to be in a common group with via the third argument to eglCreateContext). If two contexts are in a share group then each of them has an independent state and is safe to call from only one thread but named objects such as textures or vertex buffer objects are available to each of them. So using share groups you can perform OpenGL actions on multiple threads simultaneously so as to be able to combine the results on a single thread.

    Tying a context to a single thread therefore isn’t so much of an issue. Planning for the issue in OpenGL itself would also be a non-starter because part of the reason that OpenGL contexts are created, managed and disposed of in an OS-specific fashion is that some OSs need to handle this stuff in radically different ways to others or are able to offer better solutions by exposing their own unique solutions.

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

Sidebar

Related Questions

I have been experimenting with woopra.com A web analytics tool. Which requires a piece
I've been experimenting with the 32Feet library, which enables support for using IrDA using
I'm currently experimenting with build script, and since I have an ASP.net Web Part
I have been experimenting with WPF and rendering strict XAML markup in a web
I have zero experience writing applications with Swing, but I have one application with
I'm writing a small program to convert a standard definition 4:3 video to a
I experimenting with writing Vista/W7 gadgets. In my experiment I want to write the
I'm experimenting with writing Javascript/JSONP queries against an WCF oData API. For performance reasons,
I've been experimenting with the Android SDK over the past few days, in readiness
I'm experimenting with WeakReference, and I'm writing a code that checks if a weak

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.