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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:07:09+00:00 2026-06-16T02:07:09+00:00

I have the following shader: protected final static String vertexShaderCode = attribute vec4 vPosition;

  • 0

I have the following shader:

protected final static String vertexShaderCode =
    "attribute vec4 vPosition;" +
    "attribute vec2 texCoord;" +
    "attribute mat4 uMVPMatrix;   \n" +

    "varying vec2 vTexCoord;" +

    "void main() {" +
    "  gl_Position = uMVPMatrix * vPosition;" +
    "  vTexCoord = texCoord;" +
    "}";

I want to pass in the mvp matrix as an attribute, however it doesn’t seem to be bound correctly. I’m using auto-assigned binding. When I query the attribute locations after linking the program as follows:

// program linked previously
GLES20.glUseProgram(program);
GLES20.glEnable(GLES20.GL_TEXTURE_2D);

GLES20.glEnable(GLES20.GL_BLEND);
mPositionHandle = GLES20.glGetAttribLocation(program, "vPosition");
mTextureHandle = GLES20.glGetAttribLocation(program, "texCoord");
mtextureSampHandle = GLES20.glGetAttribLocation(program, "textureSamp");
mMVPMatrixHandle = GLES20.glGetAttribLocation(program, "uMVPMatrix");

The returned handles are:

mTextureHandle: 0

mMVPMatrixHandle: 1

mPositionHandle: 2

However, from the documention here: http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindAttribLocation.xml, mMVPMatrixHandle should be assigned 4 consecutive handles, one for each column of the matrix (i.e. mMVPMatrix should have handles 1,2,3,4). This isn’t the case and I have no idea why…

As a result, I’m unable to draw anything to the screen. For completeness, I’m attempting to load the matrix as follows:

    GLES20.glVertexAttribPointer(mMVPMatrixHandle2, 4, GLES20.GL_FLOAT, false, 0, t1);
    GLES20.glVertexAttribPointer(mMVPMatrixHandle2 + 1, 4, GLES20.GL_FLOAT, false, 0, t2);
    GLES20.glVertexAttribPointer(mMVPMatrixHandle2 + 2, 4, GLES20.GL_FLOAT, false, 0, t3);        
    GLES20.glVertexAttribPointer(mMVPMatrixHandle2 + 3, 4, GLES20.GL_FLOAT, false, 0, t4);

where t1-t4 are buffers that contain the individual rows of the mvp matrix:

{
    1.74f, 0, 0, 0,
    0, 2.9f, 0, 0,
    0, 0, -2.414f, -1f,
    -2.088f, 0, -2.66f, 3
}

which works when I define uMVPMatrix as a uniform mat4 and load it in with glUniformMatrix4fv.

  • 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-16T02:07:09+00:00Added an answer on June 16, 2026 at 2:07 am

    Turns out that the issue wasn’t with my card, but the phone. When tried on a Samsung Galaxy S2, the attributes were properly assigned and it worked as expected.

    The phone in question is the HTC Incredible S, which had an Adreno 205 graphics card. I imagine that there must be an issue with the Opengl implementation on the phone/graphics card. A solution could be to define the matrix as four vec4s in the shader and calculate the position element by element.

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

Sidebar

Related Questions

I have the following vertex shader: uniform mat4 uMVP; attribute vec4 aPosition; attribute vec4
I have the following vertex shader : uniform mediump mat4 projMx; attribute vec2 a_position;
I have the following vertex shader: attribute vec4 Position; attribute vec4 SourceColor; varying vec4
I'm developing an Android application. I have the following vertex shader. attribute vec4 vertexPosition;
I have the following shader taken from the android SDK sampele: final String vertexShader
I have a fragment shader with the following attributes: varying highp vec2 coordinate; precision
I have the following GLSL vertex shader: attribute vec3 a_vTangent; attribute vec3 a_vBinormal; attribute
I have the following code in the Fragment Shader: precision lowp float; varying vec2
I have an GLSL geometry shader that looks like the following: #version 150 uniform
I am completely stumped here. I have the following fragment shader working: varying lowp

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.