I made an Android App in which I render everything with OpenGL-ES 2.0 and C++ over JNI and it all works fine except for one thing. It seems as if the Renderbuffers somehow get out of order and the image looks like its trailing a shadow. Somehow like motion blur and I don’t know whats causing this.
I only create an Activity with a GLSurfaceView that has a Renderer class in which the render calls for drawing are. What could be causing this strange behaviour ?
The Java code (minus some irrelevant things) that creates all things looks like this:
public class Main extends Activity
{ static MainLoop mloop = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
mloop = new MainLoop()
setContentView(mloop);
}
.
.
.
}
The Java code that renders looks like this (again minus some irrelevant things):
public class MainLoop extends GLSurfaceView
{ .
.
public MainLoop()
{ super(parent);
setEGLContextClientVersion(2);
setEGLConfigChooser(8, 8, 8, 8, 0, 0)
//
this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
//
setRenderer(new Renderer());
}
.
.
private static class Renderer implements GLSurfaceView.Renderer
{ public void onDrawFrame(GL10 gl)
{ JNIRender();
}
public void onSurfaceChanged(GL10 gl, int width, int height)
{ JNIChanged();
}
public void onSurfaceCreated(GL10 gl, EGLConfig config)
{ JNICreate();
}
}
}
The whole rendering is done with the JNIRender call in C++ and looks fine except for the out-of-order thing where all looks as if its trailing a shadow. Is there something I have to take into account or that I am doing wrong ?
I checked and found that I have a swapbuffer command in my c++ code which is bad when used in java because the buffer is being displayed automatically anyway and this confuses things.
I encased my swapbuffer command in an ifdef that its never being used when compiling with the gcc.