I have an android application that uses GLES for rendering. Currently using Java to render stuff, and rendering is fine. Due to limitation in Android Java application memory I plan to integrate native rendering to my Java rendering code.
To do this I followed basic native GLES tutorials. After integrating, Java rendering was not visible, only the things I render in C++ was seen.
The simplest version of the code is at: https://github.com/khedd/JavaCppGLES Java code renders a Triangle, C++ renders a Quad. If both are called only Quad is renderer.
How can I solve this issue? Should I port everything to C++?
Code in a nutshell.
MyGLRenderer(){
mTriangle = new Triangle();
mCppRenderer = new MyCppRenderer();
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
//init java triangle
mTriangle.init();
//init c quad
mCppRenderer.init(); //comment this line to make java triangle appear
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
}
@Override
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
mTriangle.draw();
mCppRenderer.draw ();
}
The problem was caused because of not unbinding the buffers.
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
Adding these two lines to init and render fixes the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With