android-gpuimage-plus icon indicating copy to clipboard operation
android-gpuimage-plus copied to clipboard

FrameRenderer initialization disrupts my OpenGL context

Open mroncka opened this issue 7 years ago • 3 comments

I have OpenGL context setup successfully, and I can draw texture on screen, but once I initialize the FrameRenderer (just instantiation and calling init) I am unable to render anything else on screen. Any idea why?

This works

if (frameRenderer == null) {
    frameRenderer = new CGEFrameRenderer();
    frameRenderer.init(width, height, width, height);
}

EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);

This doesn't

EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);

if (frameRenderer == null) {
    frameRenderer = new CGEFrameRenderer();
    frameRenderer.init(width, height, width, height);
}

What I want to do is apply filters on multiple textures using frameRenderer, and then use the results to draw multiple images on a screen. The second part I got figured out and renders just fine, but once I initialize any frameRenderer, I am unable to render anything.

Before rendering I make sure I use the same eglContext, my compiled shader program, reset the viewport and bind the default framebuffer.

EGLContext currentContext = EGL14.eglGetCurrentContext();
if (currentContext.equals(eglContext)) {
    EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
}

GLES20.glUseProgram(shaderProgram);
GLES20.glViewport(0, 0, w.width, w.height);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);

mroncka avatar Jul 26 '18 09:07 mroncka

You can make a fork to produce your problem, and I can help you.

wysaid avatar Jul 27 '18 09:07 wysaid

Hey, sorry for the delay, I was using the library in my own project, from what I've gathered it seems to be a problem with the way I used to render the on scree quad, by dynamically sending the vertex, and texture coordinates and the way you're doing this in the library by setting STATIC_DRAW vertexBuffer, also i dynamically queried the attribute locations, and I noticed that you're setting the vertex attribute location to 0 (which I guess is pretty common practice). Since then I transitioned to using only your classes for rendering so the issue is gone 👍

mroncka avatar Aug 03 '18 09:08 mroncka

Hi @wysaid @mroncka When I try draw other bitmap on GLSurfaceView using OpenGL after using CGEFrameRenderer , it had this problem . Can you share information detail of it ? Thanks

kekhong95 avatar Jun 06 '21 17:06 kekhong95