Android: init work corectly but not really well written

This commit is contained in:
Edouard Dupin 2011-12-04 22:34:44 +01:00
parent 278fc2712f
commit 7595fbf424
8 changed files with 45 additions and 208 deletions

View File

@ -74,8 +74,6 @@ extern "C"
void Java_com_example_ewolAbstraction_EwolRenderer_nativeInit( JNIEnv* env )
{
EWOL_INFO("Init : Start All Application");
ewol::Init(0, NULL);
APP_Init(0, NULL);
gAppAlive = 1;
sDemoStopped = 0;
sTimeOffsetInit = 0;
@ -96,12 +94,6 @@ extern "C"
void Java_com_example_ewolAbstraction_EwolRenderer_nativeDone( JNIEnv* env )
{
EWOL_INFO("Renderer : Close All Application");
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// uninit Ewol
ewol::UnInit();
}
/* This is called to indicate to the render loop that it should
@ -131,7 +123,7 @@ extern "C"
m_uniqueWindows->GenEventInput(ewol::FLAG_EVENT_INPUT_1, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y);
m_uniqueWindows->GenEventInput(ewol::FLAG_EVENT_INPUT_1 | ewol::FLAG_EVENT_INPUT_CLICKED, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y);
m_uniqueWindows->GenEventInput(ewol::FLAG_EVENT_INPUT_1, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y);
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
//m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
}
}
}
@ -150,6 +142,29 @@ extern "C"
EWOL_WARNING("Event : Unknow ID=" << eventID);
}
static bool isAlreadyInit = false;
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env)
{
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)
{
EWOL_WARNING("Event : UnInit application");
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// uninit Ewol
ewol::UnInit();
}
/* Call to render the next GL frame */
void Java_com_example_ewolAbstraction_EwolRenderer_nativeRender( JNIEnv* env )
{

View File

@ -1,173 +0,0 @@
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include "importgl.h"
#include "app.h"
// Called from the app framework.
void appInit()
{
// initialisation of the application :
// glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
//glEnableClientState(GL_VERTEX_ARRAY);
//glEnableClientState(GL_COLOR_ARRAY);
}
// Called from the app framework.
void appDeinit()
{
// close the application ...
}
#include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "====> EWOL", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "====> EWOL", __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "====> EWOL", __VA_ARGS__))
void glOrtho(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal);
GLfloat gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
GLfloat gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
void appMove(double x, double y)
{
gTriangleVertices5[0] = x;
gTriangleVertices5[1] = y;
gTriangleVertices5[2] = x - 100.0f;
gTriangleVertices5[3] = y;
gTriangleVertices5[4] = x;
gTriangleVertices5[5] = y - 100.0f;
gTriangleVertices5[6] = x;
gTriangleVertices5[7] = y;
gTriangleVertices5[8] = x + 100.0f;
gTriangleVertices5[9] = y;
gTriangleVertices5[10] = x;
gTriangleVertices5[11] = y + 100.0f;
//LOGI("move To ... (%f,%f)",x,y);
}
void appRender(long timestamp, int width, int height)
{
if (!gAppAlive) {
return;
}
// to terminate application :
// set : gAppAlive = true; and return ...
//EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
// set the size of the open GL system
glViewport(0,0,width,height);
// Clear the screen with transparency ...
glClearColor(0.0,0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0., width, 0., -height, 1., 20.);
glOrtho(-width/2, width/2, height/2, -height/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-width/2, -height/2, -1.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
glEnableClientState( GL_VERTEX_ARRAY );
//LOGI("engine_draw_frame (%d,%d)",width,height);
glColor4f(0.0, 1.0, 1.0, 1.0);
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices5 );
glDrawArrays( GL_TRIANGLES, 0, 6);
static int vallllll = 0;
static float transparency = 0.0;
if (vallllll <= 1) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 0.0, 0.0, 1.0);
} else {
glColor4f(1.0, 0.0, 0.0, transparency);
}
} else if (vallllll <= 2) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 1.0, 0.0, 1.0);
} else {
glColor4f(1.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 3) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 0.0, 1.0);
} else {
glColor4f(0.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 4) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 1.0, 1.0);
} else {
glColor4f(0.0, 1.0, 1.0, transparency);
}
} else if (vallllll <= 5) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 0.0, 1.0, 1.0);
} else {
glColor4f(0.0, 0.0, 1.0, transparency);
}
} else {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll = 0;
transparency = 0.0;
glColor4f(1.0, 0.0, 1.0, 1.0);
} else {
glColor4f(1.0, 0.0, 1.0, transparency);
}
}
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices );
glDrawArrays( GL_TRIANGLES, 0, 3);
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND);
glFlush();
}

View File

@ -157,7 +157,7 @@ void etk::File::SetCompleateName(etk::String &newFilename)
// Get the command came from the running of the program :
char cCurrentPath[FILENAME_MAX];
#if __PLATFORM__ == Android
strcpy(cCurrentPath, "./");
strcpy(cCurrentPath, "/data/" PACKAGE_NAME "/raw/");
#else
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
return;

View File

@ -29,6 +29,8 @@
#define MAX_FILE_NAME (10240)
//http://developer.android.com/guide/topics/data/data-storage.html
namespace etk
{
class File

View File

@ -68,7 +68,7 @@ bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
{
bool ended = false;
EWOL_WARNING("Input event : " << IdInput << " pos(" << x << "," << y << ")");
//EWOL_WARNING("Input event : " << IdInput << " pos(" << x << "," << y << ")");
for(int32_t iii=m_inputEvent.Size()-1; iii>=0; iii--) {
if (EWOL_EVENT_AREA == m_inputEvent[iii].mode) {
if( m_inputEvent[iii].area.origin.x <= x

View File

@ -134,24 +134,6 @@ bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, e
void ewol::Windows::SysDraw(void)
{
#if defined(__PLATFORM__Android)
// set the size of the open GL system
glViewport(0,0,m_size.x,m_size.y);
// Clear the screen with transparency ...
glClearColor(0.0,0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0., width, 0., -height, 1., 20.);
glOrtho(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
#else
//EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
// set the size of the open GL system
glViewport(0,0,m_size.x,m_size.y);
@ -162,6 +144,13 @@ void ewol::Windows::SysDraw(void)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
#if defined(__PLATFORM__Android)
glOrtho(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
#else
glOrtho(0., m_size.x, 0., -m_size.y, 1., 20.);
glMatrixMode(GL_MODELVIEW);

View File

@ -8,14 +8,15 @@ LOCAL_MODULE := ewolabstraction
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../Sources
LOCAL_CFLAGS := -D__PLATFORM__Android -Wno-write-strings -DETK_DEBUG_LEVEL=3 -DEWOL_DEBUG_LEVEL=3 -DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" -DVERSION_BUILD_TIME="\"pasd_heure\""
#enable io stream in the STL ...
#APP_STL := gnustl_static
#APP_STL := stlport_shared
LOCAL_CFLAGS := -D__PLATFORM__Android \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=3 \
-DEWOL_DEBUG_LEVEL=3 \
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
-DPACKAGE_NAME="\"com.example.EwolActivity.app\""
LOCAL_SRC_FILES := \
../Sources/demo.cpp \
../Sources/Main.cpp \
../Sources/base/guiAndroid.cpp \
../Sources/tinyXML/tinyxml.cpp \

View File

@ -17,7 +17,9 @@ import android.view.MotionEvent;
*
*/
class EwolGLSurfaceView extends GLSurfaceView {
private static native void nativeApplicationInit();
private static native void nativePause();
private static native void nativeApplicationUnInit();
private static native void nativeEventInputMotion(int pointerID, float x, float y);
private static native void nativeEventInputState(int pointerID, boolean isDown);
private static native void nativeEventUnknow(int eventID);
@ -26,6 +28,7 @@ class EwolGLSurfaceView extends GLSurfaceView {
super(context);
mRenderer = new EwolRenderer();
setRenderer(mRenderer);
nativeApplicationInit();
}
private boolean InputDown1 = false;