对于使用GL_TEXTURE_2D的图像,GL_REPEAT可以正常工作,但是对于使用GL_TEXTURE_EXTERNAL_OES的mp4而言,GL_REPEAT不能正常工作。我需要这样做,以便创建无限类型的滚动效果来移动像素并导出更改。
在片段着色器中,可以通过以下方式实现无限的水平滚动效果:
println(s"Weighted precision: ${metrics.weightedPrecision}")
println(s"Weighted recall: ${metrics.weightedRecall}")
println(s"Weighted F1 score: ${metrics.weightedFMeasure}")
println(s"Weighted false positive rate: ${metrics.weightedFalsePositiveRate}")
在我的GlSurface中,我的几何形状和初始gl设置定义如下:
uniform float scroll;
void main() {
vec2 coord = vec2(v_TexCoordinate.x + scroll, v_TexCoordinate.y);
gl_FragColor = texture2D(u_Texture, coord);
}
和onDrawFame():
private static final float squareVertices[] = {
-1.0f, 1.0f, // top left
-1.0f, -1.0f, // bottom left
1.0f, -1.0f, // bottom right
1.0f, 1.0f // top right
};
private static final float textureVertices[] = { // in counterclockwise order:
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
private void glSetup() {
final String vertexShader = Utils.readTextFileFromRawResource(mMainActivity,
R.raw.media_vertex_shader);
String fragmentShader = null;
if (isVideo) {
fragmentShader = Utils.readTextFileFromRawResource(mMainActivity,
R.raw.media_fragment_shader_video);
} else {
fragmentShader = Utils.readTextFileFromRawResource(mMainActivity,
R.raw.media_fragment_shader_image);
}
final int vertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER,
vertexShader);
final int fragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER,
fragmentShader);
int[] textures = new int[1];
GLES20.glGenTextures(1, textures, 0);
mTextureId = textures[0];
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glUniform1i(mTextureUniformHandle, 0);
if (isVideo) {
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_REPEAT);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_REPEAT);
mSurfaceTexture = new SurfaceTexture(mTextureId);
mMediaPlayer.setSurface(mSurfaceTexture);
mSurfaceTexture.setOnFrameAvailableListener(this);
} else { //image
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureId);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_REPEAT);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_REPEAT);
}
mScrollHandle = GLES20.glGetUniformLocation(mProgramHandle, "scroll");
Matrix.setIdentityM(mSTMatrix, 0);
}
登录GLES20.glGetError()时看到GL_INVALID_ENUM
我尝试做的事情:
不确定GL_Repeat是否应在mp4文件的目标GL_Texture_External_OES上运行。根据{{3}}
听起来应该是可重复的欢迎尝试其他建议!
答案 0 :(得分:0)