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 9194865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:30:47+00:00 2026-06-17T21:30:47+00:00

System: Android 4.03, OpenGL ES 2.0 Problem: When glAttachShader is invoked after the first

  • 0

System: Android 4.03, OpenGL ES 2.0

Problem: When glAttachShader is invoked after the first frame has already been rendered with another program / shader, some devices (Galaxy S3) crash with a “GL_INVALID_VALUE” error (no further details are available in the error stack). Other devices (Asus eee TF101) are perfectly fine with that. The error does not always occur and sometimes it’s also a “GL_INVALID_ENUM” instead.
If I force all shaders to be compiled right at the first call to onDrawFrame, it works on all (my) devices.

Questions:
Are there states in which the openGL(ES) machine is incapable of compiling a shader?
Is it possible that bound buffers, textures or enabled attribute arrays interfere with attaching a shader to a program?
If so, what is the ideal state one must ensure before attaching shaders and linking the program?
Is it even valid to compile shaders after other objects have already been rendered with other shaders?

Background: I’m developing an Android library that will allow me to use openGL graphics in a more object oriented way (using objects like “scene”, “material”, “model” etc.), utlimatively to write games easily. The scenes, models etc. are created in a thread different to the GL context. Only when onDrawFrame encounters one of these objects it will do the buffer object binding, texture binding and shader compilation, within the right thread.
I would like to avoid to compile all shaders at the beginning of my code. The shader source is assembled depending on the requirements of the material, the model and the scene (eg: Material: include bump-mapping, Model: include matrix-palette-skimming, scene: include fog). When a model is removed from a scene, I’m going to delete the shader again – and if I add another model, the new shader should be compiled ad-hoc.

At this point I’m trying to be as concise as possible without posting code – you can imagine that extracting the relevant parts from this library is difficult.

  • 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-17T21:30:48+00:00Added an answer on June 17, 2026 at 9:30 pm

    If you copy the BasicGLSurfaceView sample code that comes with the Android development kit to start your project, then the first call to

    checkGlError
    

    is after attaching the vertex shader. However, you might have used an invalid value or enum a lot earlier or in a different location in your code. But this will only be picked up by this call, after glAttachShader.

    In my case I deleted a texture which was still linked as render target for a framebuffer. My older Android device which runs slower compiled the shader before deleting, my newer device somehow managed to call

    glFramebufferTexture2D
    

    before compiling the shader. The whole thing somehow links to queueEvent and my poor understanding of thread-safety.

    Thanks for your efforts, TraxNet and Prateek Nina.

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

Sidebar

Related Questions

Android System has a builtin certificate Store. The certificates from this store are for
I've been modifying/editing parts of the Android platform, but have run into a problem
I'm trying to program a Login-System for Android (in Eclipse) and have to get
I am now working on android system using opengl es 2.0. I know that
I am having a problem with my Android system. It is running on a
I have the following problem: I'm trying to create a solar system in OpenGL
I'm developing a game for android and this is my first experience with OpenGL.
Android comes with lots of system resources ( android.R ) that can be used
I'm trying to learn android system and was looking into standard (default) DescClock application
Can I get the Contents in Android System's Back Stack so I can print

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.