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

java
  • 1,165
  • 1
  • 25
  • 50

1 Answers1

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.

bernie
  • 9,820
  • 5
  • 62
  • 92
  • 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!!! – java Jun 11 '18 at 15:47