android - NDK call in a GLSurfaceView class -
i trying render opengl es surface ndk, got halted in work. have setup similar 3d example in ndk. have class inheriting glsurface view , 1 inheriting glsurfaceview.renderer. in .c file, have simple method nothing. void function nothing in it. can call function in class inherit activity oncreate method.
private static native void nativesetup();
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); mglview = new graphglsurfaceview(this); setcontentview(mglview); nativesetup(); }
the program works fine. however, if put call (and declaration) in 1 of glsurfaceview classes, program fails (nativesetup call in question). have verified working fine without native call (a colored surface drawn). have ideas why cannot call native code glsurface classes?
my c file:
#include <string.h> #include <jni.h> void java_com_test_intro_nativesetup( jnienv* env ){}
my java file in non working manner:
package com.test; import javax.microedition.khronos.egl.eglconfig; import javax.microedition.khronos.opengles.gl10; import android.app.activity; import android.content.context; import android.opengl.glsurfaceview; import android.os.bundle; import android.util.log; import android.view.window; public class intro extends activity { static{ system.loadlibrary("graphrender"); } private glsurfaceview mglview; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); mglview = new graphglsurfaceview(this); setcontentview(mglview); } } class graphglsurfaceview extends glsurfaceview { graphrenderer mrenderer; public graphglsurfaceview(context context) { super(context); mrenderer = new graphrenderer(); setrenderer(mrenderer); } } class graphrenderer implements glsurfaceview.renderer { private static native void nativesetup(); private float _red = 0.9f; private float _green = 0.2f; private float _blue = 0.2f; public void onsurfacecreated(gl10 gl, eglconfig config) { log.d("intro", "got intro 4" ); } public void onsurfacechanged(gl10 gl, int w, int h) { gl.glviewport(0, 0, w, h); nativesetup(); //log.d("intro", "got intro 2" + debugstr); } public void ondrawframe(gl10 gl) { log.d("intro", "got intro 3"); gl.glclearcolor(_red, _green, _blue, 1.0f); // clear color buffer show clearcolor called above... gl.glclear(gl10.gl_color_buffer_bit); } }
in c file did rename native function?maybe problem related issues, cause jni uses particular naming navtive functions.
have here , try use javah -jni $class-file-with-native-methods$
obtain c files.
hope helps.
ciao
Comments
Post a Comment