我正在寻找一种解决方案来获取存储在GPU端的纹理线。
这是属性(in) - 传递给着色器的纹理线 通过floatbuffer
mCubeTextureCoordinates.position(0);
GLES20.glVertexAttribPointer(mTextureCoordinateHandle, GLfields.TEXTURE_COORD_DATASIZE, GLES20.GL_FLOAT, false,
0, mCubeTextureCoordinates);
在glsl-program
中attribute vec2 a_TexCoordinate;
我可以在某个阶段获取cpu端的vec2数据,如..
int textAttr = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate");
GLES20.glGetFloatv(textAttr, xy, 0);
其中xy是float-vector(float [] xy = new ...)
只是猜测,根据调试器,数组没有填充任何数据 但我想你明白了 - 从GPU获取texturecoord-vector
答案 0 :(得分:1)
您正在使用glVertexAttribPointer
与客户端侧顶点数组。据我所知,这并没有提供回读数据的方法。
但是,这种使用模式已被弃用了很长时间,转而支持顶点缓冲区对象(以及顶点数组对象)。粗略地说,使用模式是:
glVertexAttribPointer
和glEnableVertexAttribArray
将VBO数据绑定到顶点属性 VBO允许通过glGetBufferSubData
读取其内容。
有关更多信息,请查看其他问题:
此外,getFloatv
and friends用于获取OpenGL参数值(如当前混合模式),而不是顶点属性值。