1
您可以融合Java和本機OpenGL調用。例如,在onSurfaceCreated中進行設置,但將onDraw調用到本機代碼(甚至是兩者)?我遇到了麻煩本地代碼來呈現,但不能告訴我們,如果這可能是一個問題,如果我拋出C++異常,但他們沒有泡沫了......使用Java和C++的Android OpenGL
private static native void drawFromJni();
public void onDrawFrame(GL10 gl) {
try{
drawFromJni();
//gl.glDrawArrays... also
}
catch (Exception ex){
ex.printStackTrace();
Log.e("sv", ex.getMessage());
}
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
float ratio = (float) width/height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glDisable(GL10.GL_DITHER);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
gl.glClearColor(0,0,0,0);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
}
有什麼好處? – CommonMan 2012-06-21 22:24:18