Android first version is now ok ==> must review event and insit uninit system for android

This commit is contained in:
Edouard Dupin 2011-12-04 13:34:24 +01:00
parent aa3e79f8d1
commit 278fc2712f
16 changed files with 333 additions and 216 deletions

View File

@ -311,7 +311,7 @@ clean:
@echo ' CLEANING : $(F_VIOLET)$(OUTPUT_NAME)$(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
ifeq ($(PLATFORM), Android)
rm -r bin libs gen obj
rm -rf bin libs gen obj
else
@echo Remove Folder : $(OBJECT_DIR)
@rm -rf $(OBJECT_DIR)

View File

@ -87,13 +87,13 @@ class Plop :public ewol::Windows
};
};
static Plop * myWindowsExample = NULL;
/**
* @brief main input fonction
* @brief main application function Initialisation
*/
int main(int argc, char *argv[])
void APP_Init(int argc, char *argv[])
{
ewol::Init(argc, argv);
ewol::ChangeSize(800, 600);
/*
if (true == ewol::AddFont("dataTest/TextMonospace.ebt", true, true, true) ) {
@ -103,23 +103,18 @@ int main(int argc, char *argv[])
ewol::SetFontFolder("Font");
ewol::SetDefaultFont("freefont/FreeMono", 14);
ewol::theme::LoadDefault("dataTest/exemple.eol");
//ewol::theme::LoadDefault("dataTest/exemple.eol");
//exit(0);
Plop * myWindowsExample = new Plop();
myWindowsExample = new Plop();
// create the specific windows
ewol::DisplayWindows(myWindowsExample);
ewol::Run();
ewol::DisplayWindows(NULL);
delete(myWindowsExample);
ewol::UnInit();
return 0;
}
/**
* @brief main application function Un-Initialisation
*/
void APP_UnInit(void)
{
delete(myWindowsExample);
}

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* @file guiAndroid.h
* @file gui.h
* @brief Gui abstraction layer (header)
* @author Edouard DUPIN
* @date 20/10/2011
@ -44,6 +44,8 @@ namespace guiAbstraction
bool IsPressedInput(int32_t inputID);
};
//!< must be define in CPP by the application ...
void APP_Init(int argc, char *argv[]);
void APP_UnInit(void);
#endif

View File

@ -33,8 +33,10 @@
#include <ewol/Debug.h>
#include <etk/String.h>
#include <ewol/WidgetManager.h>
#include <base/guiAndroid.h>
#include <base/gui.h>
#include <ewol/ewol.h>
#include <importgl.h>
#include <app.h>
@ -50,9 +52,10 @@ static long sTimeOffset = 0;
static int sTimeOffsetInit = 0;
static long sTimeStopped = 0;
static int32_t currentWidth = 320;
static int32_t currentHeight = 480;
static etkFloat_t m_width = 320;
static etkFloat_t m_height = 480;
ewol::Windows* m_uniqueWindows = NULL;
static long _getTime(void)
{
@ -61,6 +64,9 @@ static long _getTime(void)
return (long)(now.tv_sec*1000 + now.tv_usec/1000);
}
void Draw(void);
extern "C"
{
@ -68,7 +74,8 @@ extern "C"
void Java_com_example_ewolAbstraction_EwolRenderer_nativeInit( JNIEnv* env )
{
EWOL_INFO("Init : Start All Application");
appInit();
ewol::Init(0, NULL);
APP_Init(0, NULL);
gAppAlive = 1;
sDemoStopped = 0;
sTimeOffsetInit = 0;
@ -77,16 +84,24 @@ extern "C"
void Java_com_example_ewolAbstraction_EwolRenderer_nativeResize( JNIEnv* env, jobject thiz, jint w, jint h )
{
currentWidth = w;
currentHeight = h;
m_width = w;
m_height = h;
EWOL_INFO("Resize w=" << w << " h=" << h);
if (NULL != m_uniqueWindows) {
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
}
}
/* Call to finalize the graphics state */
void Java_com_example_ewolAbstraction_EwolRenderer_nativeDone( JNIEnv* env )
{
EWOL_INFO("Renderer : Close All Application");
appDeinit();
// 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
@ -111,7 +126,13 @@ extern "C"
{
EWOL_INFO("Event : Input Motion ID=" << pointerID << " x=" << x << " y=" << y);
if (0 == pointerID) {
appMove(x,y);
//appMove(x,y);
if(NULL != m_uniqueWindows) {
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);
}
}
}
@ -148,7 +169,7 @@ extern "C"
}
}
appRender(curTime, currentWidth, currentHeight);
Draw();
}
}
@ -156,6 +177,121 @@ extern "C"
static void Setwindow(ewol::Windows* newWindows)
{
m_uniqueWindows = newWindows;
if (NULL != m_uniqueWindows) {
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
}
}
static etkFloat_t gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
static etkFloat_t 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 Draw(void)
{
//EWOL_DEBUG("redraw (" << m_width << "," << m_height << ")");
if(NULL == m_uniqueWindows) {
// set the size of the open GL system
glViewport(0,0,m_width,m_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(-m_width/2, m_width/2, m_height/2, -m_height/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-m_width/2, -m_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, oglTypeFloat_t, 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, oglTypeFloat_t, 0, gTriangleVertices );
glDrawArrays( GL_TRIANGLES, 0, 3);
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND);
} else {
m_uniqueWindows->SysDraw();
}
glFlush();
}
@ -182,13 +318,7 @@ void guiAbstraction::Init(int32_t argc, char *argv[])
void guiAbstraction::Run(void)
{
if (true == guiAbstractionIsInit) {
EWOL_INFO("Start Running");
//myX11Access->Run();
EWOL_INFO("Stop Running");
} else {
EWOL_CRITICAL("Can not Run X11 ==> not init ... ");
}
EWOL_INFO("Noting to run in android mode ...");
}
void guiAbstraction::Stop(void)
@ -203,7 +333,7 @@ void guiAbstraction::Stop(void)
void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newOne)
{
if (true == guiAbstractionIsInit) {
//myX11Access->Setwindow(newOne);
Setwindow(newOne);
} else {
EWOL_CRITICAL("Can not set Windows X11 ==> not init ... ");
}
@ -277,3 +407,43 @@ bool guiAbstraction::IsPressedInput(int32_t inputID)
return false;
//}
}
// never had main in android ...
/*
int main(int argc, char *argv[])
{
return -1;
}
*/
void glOrtho(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal)
{
GLfloat myMatrix[4*4];
int iii;
for(iii=0; iii<4*4 ; iii++) {
myMatrix[iii] = 0;
}
myMatrix[0] = 2.0 / (right - left);
myMatrix[5] = 2.0 / (top - bottom);
myMatrix[10] = -2.0 / (farVal - nearVal);
#if 1
myMatrix[3] = -1*(right + left) / (right - left);
myMatrix[7] = -1*(top + bottom) / (top - bottom);
myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
#else
// test if matrix is not corectly instanciate ...
myMatrix[12] = -1*(right + left) / (right - left);
myMatrix[13] = -1*(top + bottom) / (top - bottom);
myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal);
#endif
myMatrix[15] = 1;
glLoadMatrixf(myMatrix);
}

View File

@ -1,40 +0,0 @@
/**
*******************************************************************************
* @file guiDoubleBuffer.h
* @brief Gui abstraction layer (header)
* @author Edouard DUPIN
* @date 20/10/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.
*
*******************************************************************************
*/
#ifndef __GUI_ABSTRACTION_H__
#define __GUI_ABSTRACTION_H__
#include <etk/Types.h>
namespace guiAbstraction
{
void Init(int32_t argc, char *argv[]);
void Run(void);
void UnInit(void);
};
#endif

View File

@ -1,39 +0,0 @@
/**
*******************************************************************************
* @file guiIPhone.h
* @brief Gui abstraction layer (header)
* @author Edouard DUPIN
* @date 20/10/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.
*
*******************************************************************************
*/
#ifndef __GUI_ABSTRACTION_H__
#define __GUI_ABSTRACTION_H__
#include <etk/Types.h>
namespace guiAbstraction
{
void Init(int32_t argc, char *argv[]);
void Run(void);
void UnInit(void);
};
#endif

View File

@ -26,7 +26,7 @@
#include <ewol/Debug.h>
#include <etk/String.h>
#include <ewol/WidgetManager.h>
#include <base/guiX11.h>
#include <base/gui.h>
#include <unistd.h>
#include <stdlib.h>
@ -876,3 +876,27 @@ bool guiAbstraction::IsPressedInput(int32_t inputID)
}
}
#include <ewol/ewol.h>
int main(int argc, char *argv[])
{
// init Ewol
ewol::Init(argc, argv);
// Init Application ...
APP_Init(argc, argv);
// Start Ewol diwplay while
ewol::Run();
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// uninit Ewol
ewol::UnInit();
return 0;
}

View File

@ -1,49 +0,0 @@
/**
*******************************************************************************
* @file guiX11.h
* @brief Gui abstraction layer (header)
* @author Edouard DUPIN
* @date 20/10/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.
*
*******************************************************************************
*/
#ifndef __GUI_ABSTRACTION_H__
#define __GUI_ABSTRACTION_H__
#include <etk/Types.h>
#include <ewol/Windows.h>
namespace guiAbstraction
{
void Init(int32_t argc, char *argv[]);
void Run(void);
void Stop(void);
void UnInit(void);
void SetDisplayOnWindows(ewol::Windows * newOne);
void ChangeSize(int32_t w, int32_t h);
void ChangePos(int32_t x, int32_t y);
void GetAbsPos(int32_t & x, int32_t & y);
void StartResizeSystem(void);
void StartMoveSystem(void);
bool IsPressedInput(int32_t inputID);
};
#endif

View File

@ -41,32 +41,7 @@ void glOrtho(GLfloat left,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal)
{
GLfloat myMatrix[4*4];
int iii;
for(iii=0; iii<4*4 ; iii++) {
myMatrix[iii] = 0;
}
myMatrix[0] = 2.0 / (right - left);
myMatrix[5] = 2.0 / (top - bottom);
myMatrix[10] = -2.0 / (farVal - nearVal);
#if 1
myMatrix[3] = -1*(right + left) / (right - left);
myMatrix[7] = -1*(top + bottom) / (top - bottom);
myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
#else
// test if matrix is not corectly instanciate ...
myMatrix[12] = -1*(right + left) / (right - left);
myMatrix[13] = -1*(top + bottom) / (top - bottom);
myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal);
#endif
myMatrix[15] = 1;
glLoadMatrixf(myMatrix);
}
GLfloat farVal);

View File

@ -29,6 +29,14 @@
#include <cstdio>
#include <typeinfo>
#if defined(__PLATFORM__Android)
# include <string.h>
# 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__))
#endif
namespace etk{
class CEndl{};
class CHex{};
@ -36,12 +44,75 @@ namespace etk{
private:
bool hex;
public:
#if defined(__PLATFORM__Android)
private:
char m_tmpChar[2048];
public:
CCout(){
hex=false;
memset(m_tmpChar, 0, 2048*sizeof(char));
};
~CCout() { };
CCout& operator << (int t) {
char tmp[256];
sprintf(tmp,"%d", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (unsigned int t) {
char tmp[256];
sprintf(tmp, "%d", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (long t) {
char tmp[256];
sprintf(tmp, "%ld", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (double t) {
char tmp[256];
sprintf(tmp, "%f", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (float t) {
char tmp[256];
sprintf(tmp, "%f", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (char * t) {
char tmp[256];
sprintf(tmp, "%s", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (const char * t) {
char tmp[256];
sprintf(tmp, "%s", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (char t) {
char tmp[256];
sprintf(tmp, "%c", t);
strcat(m_tmpChar, tmp);
return *this;
}
CCout& operator << (etk::CEndl t) {
strcat(m_tmpChar, "\n");
LOGI("%s", m_tmpChar);
memset(m_tmpChar, 0, 2048*sizeof(char));
return *this;
}
#else
CCout(){
hex=false;
};
~CCout() { };
CCout& operator << (int t) {
printf("%d", t);
return *this;
@ -78,6 +149,7 @@ namespace etk{
printf("\n");
return *this;
}
#endif
};
extern etk::CCout cout;
extern etk::CEndl endl;

View File

@ -58,7 +58,8 @@ ewol::OObject2DText::~OObject2DText(void)
void ewol::OObject2DText::Draw(void)
{
if (m_coord.Size()<=0) {
EWOL_WARNING("Nothink to draw...");
// TODO : a remètre ...
//EWOL_WARNING("Nothink to draw...");
return;
}
// TODO : Android does not support GL_QUADS ...

View File

@ -68,6 +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 << ")");
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,6 +134,24 @@ 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);
@ -149,13 +167,13 @@ void ewol::Windows::SysDraw(void)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, -m_size.y, -5);
#endif
//http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html
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);
GenDraw();
glDisable(GL_BLEND);

View File

@ -28,21 +28,7 @@
#include <ewol/WidgetManager.h>
#include <ewol/themeManager.h>
#if defined(__PLATFORM__X11)
#include <base/guiX11.h>
#elif defined(__PLATFORM__DoubleBuffer)
#include <base/guiDoubleBuffer.h>
#elif defined(__PLATFORM__Android)
#include <base/guiAndroid.h>
#elif defined(__PLATFORM__AndroidTablet)
#include <base/guiAndroidTablet.h>
#elif defined(__PLATFORM__IPhone)
#include <base/guiIPhone.h>
#elif defined(__PLATFORM__IPad)
#include <base/guiIPad.h>
#else
#error you need to specify a platform ...
#endif
#include <base/gui.h>
#undef __class__
#define __class__ "ewol"

View File

@ -137,11 +137,11 @@ void ewol::Test::OnRegenerateDisplay(void)
AddOObject(tmpOObjects, "BouttonDecoration");
tmpOObjects = new ewol::OObject2DColored;
//tmpOObjects = new ewol::OObject2DColored;
ewol::theme::Generate(0, 0, *tmpOObjects, 50, 50, m_size.x*0.75, m_size.y*0.75);
//ewol::theme::Generate(0, 0, *tmpOObjects, 50, 50, m_size.x*0.75, m_size.y*0.75);
AddOObject(tmpOObjects, "themeObject");
//AddOObject(tmpOObjects, "themeObject");

View File

@ -8,7 +8,7 @@ LOCAL_MODULE := ewolabstraction
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../Sources
LOCAL_CFLAGS := -D__PLATFORM__Android -Wno-write-strings
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
@ -16,6 +16,7 @@ LOCAL_CFLAGS := -D__PLATFORM__Android -Wno-write-strings
LOCAL_SRC_FILES := \
../Sources/demo.cpp \
../Sources/Main.cpp \
../Sources/base/guiAndroid.cpp \
../Sources/tinyXML/tinyxml.cpp \
../Sources/tinyXML/tinyxmlparser.cpp \