forked from organicmaps/organicmaps
Make stub fuctions for Java<->C++ interop.
This commit is contained in:
parent
2bcd892aeb
commit
253e62eda6
4 changed files with 74 additions and 29 deletions
|
@ -10,8 +10,8 @@ namespace jni_help
|
|||
// Some examples of sig:
|
||||
// "()V" - void function returning void;
|
||||
// "(Ljava/lang/String;)V" - String function returning void;
|
||||
jmethodID GetJavaMethodID(JNIEnv * env, jobject obj, char const * fn,
|
||||
char const * sig)
|
||||
jmethodID GetJavaMethodID(JNIEnv * env, jobject obj,
|
||||
char const * fn, char const * sig)
|
||||
{
|
||||
jclass cls = env->GetObjectClass(obj);
|
||||
jmethodID mid = env->GetMethodID(cls, fn, sig);
|
||||
|
@ -72,6 +72,19 @@ extern "C"
|
|||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MWMActivity
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring path)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MainGLView
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainGLView_nativeInit(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
|
@ -88,4 +101,23 @@ extern "C"
|
|||
jobject thiz, jint mode, jdouble x1, jdouble y1, jdouble x2, jdouble y2)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MainRenderer
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeInit(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeResize(JNIEnv * env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeDraw(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ public class GesturesProcessor
|
|||
{
|
||||
getPointsMove(e);
|
||||
nativeMove(PROCESS, m_pt1.x, m_pt1.y);
|
||||
} else if (m_mode == ZOOM)
|
||||
}
|
||||
else if (m_mode == ZOOM)
|
||||
{
|
||||
getPointsZoom(e);
|
||||
nativeZoom(PROCESS, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y);
|
||||
|
@ -79,7 +80,5 @@ public class GesturesProcessor
|
|||
}
|
||||
|
||||
private native void nativeMove(int mode, double x, double y);
|
||||
|
||||
private native void nativeZoom(int mode, double x1, double y1, double x2,
|
||||
double y2);
|
||||
private native void nativeZoom(int mode, double x1, double y1, double x2, double y2);
|
||||
}
|
||||
|
|
|
@ -9,11 +9,18 @@ public class MWMActivity extends Activity
|
|||
{
|
||||
private MainGLView m_view;
|
||||
|
||||
private String getResourcePath()
|
||||
{
|
||||
return new String("todo: get data path");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
nativeInit(getResourcePath());
|
||||
|
||||
m_view = new MainGLView(getApplication());
|
||||
|
||||
setContentView(m_view);
|
||||
|
@ -37,4 +44,6 @@ public class MWMActivity extends Activity
|
|||
{
|
||||
System.loadLibrary("mapswithme");
|
||||
}
|
||||
|
||||
private native void nativeInit(String path);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import javax.microedition.khronos.opengles.GL10;
|
|||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.util.Log;
|
||||
//import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public class MainGLView extends GLSurfaceView
|
||||
|
@ -29,34 +29,13 @@ public class MainGLView extends GLSurfaceView
|
|||
// Do native initialization with OpenGL.
|
||||
nativeInit();
|
||||
|
||||
setRenderer(new Renderer());
|
||||
setRenderer(new MainRenderer());
|
||||
|
||||
// When renderMode is RENDERMODE_WHEN_DIRTY, the renderer only rendered
|
||||
// when the surface is created, or when requestRender() is called.
|
||||
setRenderMode(RENDERMODE_WHEN_DIRTY);
|
||||
}
|
||||
|
||||
private static class Renderer implements GLSurfaceView.Renderer
|
||||
{
|
||||
@Override
|
||||
public void onDrawFrame(GL10 gl)
|
||||
{
|
||||
Log.i(TAG, "Renderer::onDrawFrame");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height)
|
||||
{
|
||||
Log.i(TAG, "Renderer::onSurfaceChanged");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config)
|
||||
{
|
||||
Log.i(TAG, "Renderer::onSurfaceCreated");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e)
|
||||
{
|
||||
|
@ -66,3 +45,29 @@ public class MainGLView extends GLSurfaceView
|
|||
|
||||
private native void nativeInit();
|
||||
}
|
||||
|
||||
|
||||
class MainRenderer implements GLSurfaceView.Renderer
|
||||
{
|
||||
@Override
|
||||
public void onDrawFrame(GL10 gl)
|
||||
{
|
||||
nativeDraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h)
|
||||
{
|
||||
nativeResize(w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config)
|
||||
{
|
||||
nativeInit();
|
||||
}
|
||||
|
||||
private native void nativeInit();
|
||||
private native void nativeResize(int w, int h);
|
||||
private native void nativeDraw();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue