In my graphics engine, based on OpenGL ES 2.0 I am using standardized name for shader attributes like it is done in libGDX (such as a_position, a_normal, etc.).

When 'activating' my vertex buffer for drawing, just before I call glVertexAttribPointer() I need to enable an attribute I'm going to use by calling glEnableVertexAttribArray(), and then disable unused ones. Let's say there's two shaders I'm gonna use:

  1. Shader1 is simple texture shader, which single attribute is a_position_uv which is vec4, xy are for position, and the remaining zw are for texture coordinates (attribute location is bound by name to 0).
  2. Shader2 is solid shader, which single attribute is a_position which is vec2 (attribute location is bound by name to 1).

Then something strange happens. When I'm drawing with Shader1, I'm enabling 0th, and disabling 1st attribute, and it worked just fine. But then, when I'm drawing with Shader2 (and obviously I'm enabling 1st, and disabling 0th attributes) it draws nothing. Just nothing.

In fact: when I'm not disabling 0th attribute for solid shader it works fine. In both cases the remaining code is identical.

In fact (2): this happens only when deploying game on devices (iPhone simulator too). I'm not a newbie in graphics programming and OpenGL, but in this case the behaviour is very strange for me.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.