abstraction step 2

This commit is contained in:
Edouard Dupin 2011-12-14 13:57:46 +01:00
parent 87759817ab
commit 62a4079957
3 changed files with 297 additions and 208 deletions

View File

@ -76,22 +76,20 @@ int32_t m_previous_y = -1;
int64_t m_previousTime = 0;
bool m_previousDouble = false;
extern "C"
{
/* Call to initialize the graphics state */
void Java_com_example_ewolAbstraction_EwolRenderer_nativeInit( JNIEnv* env )
{
/* Call to initialize the graphics state */
void EWOL_NativeInit(void)
{
EWOL_INFO("Init : Start All Application");
gAppAlive = 1;
sDemoStopped = 0;
sTimeOffsetInit = 0;
ewol::TextureOGLContext(true);
}
}
void Java_com_example_ewolAbstraction_EwolRenderer_nativeResize( JNIEnv* env, jobject thiz, jint w, jint h )
{
void EWOL_NativeResize(int w, int h )
{
m_width = w;
m_height = h;
EWOL_INFO("Resize w=" << w << " h=" << h);
@ -101,17 +99,17 @@ extern "C"
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
m_uniqueWindows->SetOrigin(0.0, 0.0);
}
}
}
/* Call to finalize the graphics state */
void Java_com_example_ewolAbstraction_EwolRenderer_nativeDone( JNIEnv* env )
{
/* Call to finalize the graphics state */
void EWOL_NativeDone(void)
{
EWOL_INFO("Renderer : Close All Application");
ewol::TextureOGLContext(false);
}
}
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeEventInputMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
{
void EWOL_NativeEventInputMotion(int pointerID, float x, float y )
{
//EWOL_INFO("Event : Input Motion ID=" << pointerID << " x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
if (true == inputIsPressed[pointerID]) {
@ -121,10 +119,10 @@ extern "C"
}
}
}
}
}
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeEventInputState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
{
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
{
if (isUp) {
//EWOL_INFO("Event : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
@ -233,17 +231,16 @@ extern "C"
}
}
}
}
}
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeEventUnknow( JNIEnv* env, jobject thiz, jint eventID)
{
void EWOL_NativeEventUnknow(int eventID)
{
EWOL_WARNING("Event : Unknow ID=" << eventID);
}
}
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeParamSetArchiveDir( JNIEnv* env, jobject thiz, jint mode, jstring myString)
{
const char* str = env->GetStringUTFChars(myString,0);
void EWOL_NativeParamSetArchiveDir(int mode, const char* str)
{
switch(mode)
{
case 0:
@ -265,24 +262,23 @@ extern "C"
EWOL_WARNING("Directory mode=???? path=" << str);
break;
}
//env->ReleaseStringUTFChars(str,myString,0);
}
}
static bool isAlreadyInit = false;
static bool isAlreadyInit = false;
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env)
{
void EWOL_NativeApplicationInit(void)
{
EWOL_WARNING("Event : Init Application");
if (false == isAlreadyInit) {
ewol::Init(0, NULL);
APP_Init(0, NULL);
isAlreadyInit = true;
}
}
}
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeApplicationUnInit( JNIEnv* env)
{
void EWOL_NativeApplicationUnInit(void)
{
EWOL_WARNING("Event : UnInit application");
// unset all windows
ewol::DisplayWindows(NULL);
@ -290,11 +286,11 @@ extern "C"
APP_UnInit();
// uninit Ewol
ewol::UnInit();
}
}
/* Call to render the next GL frame */
void Java_com_example_ewolAbstraction_EwolRenderer_nativeRender( JNIEnv* env )
{
/* Call to render the next GL frame */
void EWOL_NativeRender(void)
{
long curTime;
/* NOTE: if sDemoStopped is TRUE, then we re-render the same frame
@ -312,13 +308,12 @@ extern "C"
}
Draw();
}
}
static void Setwindow(ewol::Windows* newWindows)
{
m_uniqueWindows = newWindows;

View File

@ -1,7 +1,7 @@
package com.__PROJECT_VENDOR__.ewolAbstraction;
package com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
@ -37,7 +37,7 @@ public class __PROJECT_NAME__ extends Activity {
private GLSurfaceView mGLView;
static {
System.loadLibrary("ewolabstraction");
System.loadLibrary("__PROJECT_PACKAGE__");
}
@Override protected void onCreate(Bundle savedInstanceState) {
@ -91,7 +91,7 @@ class EwolGLSurfaceView extends GLSurfaceView {
ApplicationInfo appInfo = null;
PackageManager packMgmr = context.getPackageManager();
try {
appInfo = packMgmr.getApplicationInfo("com.__PROJECT_VENDOR__.ewolAbstraction", 0);
appInfo = packMgmr.getApplicationInfo("com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__", 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException("Unable to locate assets, aborting...");

View File

@ -0,0 +1,94 @@
/**
*******************************************************************************
* @file ewolAndroidAbstraction.cpp
* @brief User abstraction for Android (Sources)
* @author Edouard DUPIN
* @date 14/12/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <jni.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
// declaration of the ewol android abstraction ...
void EWOL_NativeInit(void);
void EWOL_NativeResize(int w, int h );
void EWOL_NativeDone(void);
void EWOL_NativeEventInputMotion(int pointerID, float x, float y );
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y );
void EWOL_NativeParamSetArchiveDir(int mode, const char* str);
void EWOL_NativeApplicationInit(void);
void EWOL_NativeApplicationUnInit(void);
void EWOL_NativeRender(void);
extern "C"
{
/* Call to initialize the graphics state */
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeInit( JNIEnv* env )
{
EWOL_NativeInit();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeResize( JNIEnv* env, jobject thiz, jint w, jint h )
{
EWOL_NativeResize(w, h);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeDone( JNIEnv* env )
{
EWOL_NativeDone();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeEventInputMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
{
EWOL_NativeEventInputMotion(pointerID, x, y);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeEventInputState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
{
EWOL_NativeEventInputState(pointerID, isUp, x, y);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeParamSetArchiveDir( JNIEnv* env, jobject thiz, jint mode, jstring myString)
{
const char* str = env->GetStringUTFChars(myString,0);
EWOL_NativeParamSetArchiveDir(mode, str);
//env->ReleaseStringUTFChars(str,myString,0);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env)
{
EWOL_NativeApplicationInit();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeApplicationUnInit( JNIEnv* env)
{
EWOL_NativeApplicationUnInit();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeRender( JNIEnv* env )
{
EWOL_NativeRender();
}
}