0

I am looking for a solution to fetch the texturecoords that is stored on the GPU-side.

that is the attribute (in) - the texturecoords that are passed in to the shader through a floatbuffer

  mCubeTextureCoordinates.position(0);
  GLES20.glVertexAttribPointer(mTextureCoordinateHandle, GLfields.TEXTURE_COORD_DATASIZE, GLES20.GL_FLOAT, false,
            0, mCubeTextureCoordinates);

in glsl-program

attribute vec2 a_TexCoordinate;

Could I fetch the vec2-data on the cpu-side at some stage like ..

int textAttr = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate");

GLES20.glGetFloatv(textAttr, xy, 0);

where xy is a float-vector (float[] xy = new ...)

Just a guess, the array is not filled with any data according to the debugger but I guess you get the point - fetch the texturecoord-vector from the GPU

1 Answer 1

1

You are using glVertexAttribPointer with client-side vertex arrays. To my knowledge, this does not provide a way to read back the data.

However, this usage mode has been deprecated for a long time in favor of vertex buffer objects (and vertex array objects). Roughly, the usage pattern is:

  • Create a VBO (this allocates memory on the GPU)
  • Fill the VBO with vertex data
  • Use glVertexAttribPointer and glEnableVertexAttribArray to bind the VBO data to a vertex attribute

A VBO does allow reading its contents via glGetBufferSubData.

Have a look at these other questions for more information:

Also, getFloatv and friends is used to get OpenGL parameter values (like the current blend mode), not vertex attribute values.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I'´ve used VBO before - just came back to OpenGL after a longer break - I´ll look into this and may accept the answer then. thanks!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.