Use GlBindable.bind() in MultiFilter

egloo2
Mattia Iavarone 5 years ago
parent bbf12c7e0d
commit c6744444d7
  1. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/filter/MultiFilter.java
  2. 12
      demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java

@ -226,7 +226,7 @@ public class MultiFilter implements Filter, OneParameterFilter, TwoParameterFilt
// Each filter outputs into its own framebuffer object, except the // Each filter outputs into its own framebuffer object, except the
// last filter, which outputs into the default framebuffer. // last filter, which outputs into the default framebuffer.
if (!isLast) { if (!isLast) {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, state.outputFramebuffer.getId()); state.outputFramebuffer.bind();
GLES20.glClearColor(0, 0, 0, 0); GLES20.glClearColor(0, 0, 0, 0);
} else { } else {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
@ -245,9 +245,10 @@ public class MultiFilter implements Filter, OneParameterFilter, TwoParameterFilt
// It is the framebuffer texture from this cycle. If this is the last // It is the framebuffer texture from this cycle. If this is the last
// filter, reset this value just to cleanup. // filter, reset this value just to cleanup.
if (!isLast) { if (!isLast) {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, state.outputTexture.getId()); state.outputTexture.bind();
} else { } else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
} }
GLES20.glUseProgram(0); GLES20.glUseProgram(0);

@ -47,7 +47,7 @@ import java.util.List;
public class CameraActivity extends AppCompatActivity implements View.OnClickListener, OptionView.Callback { public class CameraActivity extends AppCompatActivity implements View.OnClickListener, OptionView.Callback {
private final static CameraLogger LOG = CameraLogger.create("DemoApp"); private final static CameraLogger LOG = CameraLogger.create("DemoApp");
private final static boolean USE_FRAME_PROCESSOR = false; private final static boolean USE_FRAME_PROCESSOR = true;
private final static boolean DECODE_BITMAP = false; private final static boolean DECODE_BITMAP = false;
private CameraView camera; private CameraView camera;
@ -372,13 +372,13 @@ public class CameraActivity extends AppCompatActivity implements View.OnClickLis
message(filter.toString(), false); message(filter.toString(), false);
// Normal behavior: // Normal behavior:
// camera.setFilter(filter.newInstance()); camera.setFilter(filter.newInstance());
// To test MultiFilter: // To test MultiFilter:
DuotoneFilter duotone = new DuotoneFilter(); // DuotoneFilter duotone = new DuotoneFilter();
duotone.setFirstColor(Color.RED); // duotone.setFirstColor(Color.RED);
duotone.setSecondColor(Color.GREEN); // duotone.setSecondColor(Color.GREEN);
camera.setFilter(new MultiFilter(duotone, filter.newInstance())); // camera.setFilter(new MultiFilter(duotone, filter.newInstance()));
} }
@Override @Override

Loading…
Cancel
Save