Android first application working...
This commit is contained in:
parent
8d7a9bedfa
commit
0dc3241a72
@ -42,6 +42,7 @@ namespace guiAbstraction
|
|||||||
void StartResizeSystem(void);
|
void StartResizeSystem(void);
|
||||||
void StartMoveSystem(void);
|
void StartMoveSystem(void);
|
||||||
bool IsPressedInput(int32_t inputID);
|
bool IsPressedInput(int32_t inputID);
|
||||||
|
void ForceRedrawAll(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
//!< must be define in CPP by the application ...
|
//!< must be define in CPP by the application ...
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <ewol/ewol.h>
|
#include <ewol/ewol.h>
|
||||||
|
|
||||||
#include <importgl.h>
|
#include <importgl.h>
|
||||||
|
#include <ewol/Texture.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "AndroidJNI"
|
#define __class__ "AndroidJNI"
|
||||||
@ -74,6 +75,7 @@ extern "C"
|
|||||||
gAppAlive = 1;
|
gAppAlive = 1;
|
||||||
sDemoStopped = 0;
|
sDemoStopped = 0;
|
||||||
sTimeOffsetInit = 0;
|
sTimeOffsetInit = 0;
|
||||||
|
ewol::TextureOGLContext(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +84,8 @@ extern "C"
|
|||||||
m_width = w;
|
m_width = w;
|
||||||
m_height = h;
|
m_height = h;
|
||||||
EWOL_INFO("Resize w=" << w << " h=" << h);
|
EWOL_INFO("Resize w=" << w << " h=" << h);
|
||||||
|
ewol::TextureOGLContext(false);
|
||||||
|
ewol::TextureOGLContext(true);
|
||||||
if (NULL != m_uniqueWindows) {
|
if (NULL != m_uniqueWindows) {
|
||||||
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
|
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
|
||||||
}
|
}
|
||||||
@ -91,6 +95,7 @@ extern "C"
|
|||||||
void Java_com_example_ewolAbstraction_EwolRenderer_nativeDone( JNIEnv* env )
|
void Java_com_example_ewolAbstraction_EwolRenderer_nativeDone( JNIEnv* env )
|
||||||
{
|
{
|
||||||
EWOL_INFO("Renderer : Close All Application");
|
EWOL_INFO("Renderer : Close All Application");
|
||||||
|
ewol::TextureOGLContext(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is called to indicate to the render loop that it should
|
/* This is called to indicate to the render loop that it should
|
||||||
@ -205,7 +210,7 @@ extern "C"
|
|||||||
curTime = 0;
|
curTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,6 +450,13 @@ bool guiAbstraction::IsPressedInput(int32_t inputID)
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void guiAbstraction::ForceRedrawAll(void)
|
||||||
|
{
|
||||||
|
if (NULL != m_uniqueWindows) {
|
||||||
|
m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// never had main in android ...
|
// never had main in android ...
|
||||||
/*
|
/*
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <ewol/WidgetManager.h>
|
#include <ewol/WidgetManager.h>
|
||||||
#include <base/gui.h>
|
#include <base/gui.h>
|
||||||
|
|
||||||
|
#include <ewol/Texture.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -342,11 +344,14 @@ namespace guiAbstraction {
|
|||||||
EWOL_INFO("XF86 DRI NOT available\n");
|
EWOL_INFO("XF86 DRI NOT available\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
//ewol::TextureOGLContext(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(void)
|
void Draw(void)
|
||||||
{
|
{
|
||||||
|
// TODO : set this otherwise
|
||||||
|
ewol::TextureOGLContext(true);
|
||||||
//EWOL_DEBUG("redraw (" << m_width << "," << m_height << ")");
|
//EWOL_DEBUG("redraw (" << m_width << "," << m_height << ")");
|
||||||
if(NULL == m_uniqueWindows) {
|
if(NULL == m_uniqueWindows) {
|
||||||
//EWOL_DEBUG("Has No Windows set...");
|
//EWOL_DEBUG("Has No Windows set...");
|
||||||
|
@ -203,7 +203,7 @@ namespace ewol
|
|||||||
};
|
};
|
||||||
uint32_t GetOglId(void)
|
uint32_t GetOglId(void)
|
||||||
{
|
{
|
||||||
return m_textureId;
|
return GetTextureGLID(m_textureId);
|
||||||
};
|
};
|
||||||
int32_t GetHeight(void)
|
int32_t GetHeight(void)
|
||||||
{
|
{
|
||||||
@ -286,6 +286,8 @@ int32_t ewol::LoadFont(etk::String fontName, int32_t size)
|
|||||||
return s_listLoadedFonts.Size()-1;
|
return s_listLoadedFonts.Size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ewol::UnloadFont(int32_t id)
|
void ewol::UnloadFont(int32_t id)
|
||||||
{
|
{
|
||||||
EWOL_TODO("I do not think it was a good idea... will be done later");
|
EWOL_TODO("I do not think it was a good idea... will be done later");
|
||||||
@ -308,6 +310,7 @@ void ewol::DrawText(int32_t fontID,
|
|||||||
etk::VectorType<UTF8Element_ts> & listOfElement = s_listLoadedFonts[fontID]->GetRefOnElement();
|
etk::VectorType<UTF8Element_ts> & listOfElement = s_listLoadedFonts[fontID]->GetRefOnElement();
|
||||||
|
|
||||||
fontTextureId = s_listLoadedFonts[fontID]->GetOglId();
|
fontTextureId = s_listLoadedFonts[fontID]->GetOglId();
|
||||||
|
EWOL_DEBUG("**************** plop " << fontTextureId);
|
||||||
int32_t size = s_listLoadedFonts[fontID]->GetHeight();
|
int32_t size = s_listLoadedFonts[fontID]->GetHeight();
|
||||||
|
|
||||||
etkFloat_t posDrawX = drawPosition.x;
|
etkFloat_t posDrawX = drawPosition.x;
|
||||||
@ -375,6 +378,7 @@ void ewol::DrawText(int32_t fontID,
|
|||||||
char * tmpVal = (char*)utf8String;
|
char * tmpVal = (char*)utf8String;
|
||||||
|
|
||||||
fontTextureId = s_listLoadedFonts[fontID]->GetOglId();
|
fontTextureId = s_listLoadedFonts[fontID]->GetOglId();
|
||||||
|
EWOL_DEBUG("**************** plop2 " << fontTextureId);
|
||||||
int32_t size = s_listLoadedFonts[fontID]->GetHeight();
|
int32_t size = s_listLoadedFonts[fontID]->GetHeight();
|
||||||
|
|
||||||
etkFloat_t posDrawX = drawPosition.x;
|
etkFloat_t posDrawX = drawPosition.x;
|
||||||
@ -400,29 +404,81 @@ void ewol::DrawText(int32_t fontID,
|
|||||||
etkFloat_t sizeWidth = listOfElement[charIndex].width;
|
etkFloat_t sizeWidth = listOfElement[charIndex].width;
|
||||||
// 0x01 == 0x20 == ' ';
|
// 0x01 == 0x20 == ' ';
|
||||||
if (tmpChar != 0x01) {
|
if (tmpChar != 0x01) {
|
||||||
// set texture coordonates :
|
#if !defined(__PLATFORM__Android)
|
||||||
coordTex.PushBack(listOfElement[charIndex].posStart);
|
// set texture coordonates :
|
||||||
texCoord_ts tmpTex;
|
coordTex.PushBack(listOfElement[charIndex].posStart);
|
||||||
tmpTex.u = listOfElement[charIndex].posStop.u;
|
texCoord_ts tmpTex;
|
||||||
tmpTex.v = listOfElement[charIndex].posStart.v;
|
tmpTex.u = listOfElement[charIndex].posStop.u;
|
||||||
coordTex.PushBack(tmpTex);
|
tmpTex.v = listOfElement[charIndex].posStart.v;
|
||||||
coordTex.PushBack(listOfElement[charIndex].posStop);
|
coordTex.PushBack(tmpTex);
|
||||||
tmpTex.u = listOfElement[charIndex].posStart.u;
|
coordTex.PushBack(listOfElement[charIndex].posStop);
|
||||||
tmpTex.v = listOfElement[charIndex].posStop.v;
|
tmpTex.u = listOfElement[charIndex].posStart.u;
|
||||||
coordTex.PushBack(tmpTex);
|
tmpTex.v = listOfElement[charIndex].posStop.v;
|
||||||
// set display positions :
|
coordTex.PushBack(tmpTex);
|
||||||
/*int32_t xxxx = posDrawX;
|
// set display positions :
|
||||||
int32_t yyyy = drawPosition.y;*/
|
/*int32_t xxxx = posDrawX;
|
||||||
coord2D_ts tmpCoord;
|
int32_t yyyy = drawPosition.y;*/
|
||||||
tmpCoord.x = posDrawX;
|
coord2D_ts tmpCoord;
|
||||||
tmpCoord.y = drawPosition.y;
|
tmpCoord.x = posDrawX;
|
||||||
coord.PushBack(tmpCoord);
|
tmpCoord.y = drawPosition.y;
|
||||||
tmpCoord.x = posDrawX + sizeWidth;
|
coord.PushBack(tmpCoord);
|
||||||
coord.PushBack(tmpCoord);
|
tmpCoord.x = posDrawX + sizeWidth;
|
||||||
tmpCoord.y = drawPosition.y + size;
|
coord.PushBack(tmpCoord);
|
||||||
coord.PushBack(tmpCoord);
|
tmpCoord.y = drawPosition.y + size;
|
||||||
tmpCoord.x = posDrawX;
|
coord.PushBack(tmpCoord);
|
||||||
coord.PushBack(tmpCoord);
|
tmpCoord.x = posDrawX;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
#else
|
||||||
|
// NOTE : Android does not support the Quads elements ...
|
||||||
|
/* Step 1 :
|
||||||
|
* ********
|
||||||
|
* ******
|
||||||
|
* ****
|
||||||
|
* **
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(listOfElement[charIndex].posStart);
|
||||||
|
texCoord_ts tmpTex;
|
||||||
|
tmpTex.u = listOfElement[charIndex].posStop.u;
|
||||||
|
tmpTex.v = listOfElement[charIndex].posStart.v;
|
||||||
|
coordTex.PushBack(tmpTex);
|
||||||
|
coordTex.PushBack(listOfElement[charIndex].posStop);
|
||||||
|
// set display positions :
|
||||||
|
coord2D_ts tmpCoord;
|
||||||
|
tmpCoord.x = posDrawX;
|
||||||
|
tmpCoord.y = drawPosition.y;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
tmpCoord.x = posDrawX + sizeWidth;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
tmpCoord.y = drawPosition.y + size;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
|
||||||
|
/* Step 2 :
|
||||||
|
*
|
||||||
|
* **
|
||||||
|
* ****
|
||||||
|
* ******
|
||||||
|
* ********
|
||||||
|
*/
|
||||||
|
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(listOfElement[charIndex].posStart);
|
||||||
|
coordTex.PushBack(listOfElement[charIndex].posStop);
|
||||||
|
tmpTex.u = listOfElement[charIndex].posStart.u;
|
||||||
|
tmpTex.v = listOfElement[charIndex].posStop.v;
|
||||||
|
coordTex.PushBack(tmpTex);
|
||||||
|
|
||||||
|
// set display positions :
|
||||||
|
tmpCoord.x = posDrawX;
|
||||||
|
tmpCoord.y = drawPosition.y;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
tmpCoord.x = posDrawX + sizeWidth;
|
||||||
|
tmpCoord.y = drawPosition.y + size;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
tmpCoord.x = posDrawX;
|
||||||
|
coord.PushBack(tmpCoord);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
posDrawX += sizeWidth;
|
posDrawX += sizeWidth;
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,6 @@ void ewol::OObject2DText::Draw(void)
|
|||||||
//EWOL_WARNING("Nothink to draw...");
|
//EWOL_WARNING("Nothink to draw...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO : Android does not support GL_QUADS ...
|
|
||||||
#if !defined(__PLATFORM__Android)
|
|
||||||
glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha);
|
glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_FontTextureId);
|
glBindTexture(GL_TEXTURE_2D, m_FontTextureId);
|
||||||
@ -71,12 +69,16 @@ void ewol::OObject2DText::Draw(void)
|
|||||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||||
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );
|
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );
|
||||||
glTexCoordPointer( 2, oglTypeFloat_t, 0, &m_coordTex[0] );
|
glTexCoordPointer( 2, oglTypeFloat_t, 0, &m_coordTex[0] );
|
||||||
glDrawArrays( GL_QUADS, 0, m_coord.Size());
|
#if !defined(__PLATFORM__Android)
|
||||||
|
glDrawArrays( GL_QUADS, 0, m_coord.Size());
|
||||||
|
#else
|
||||||
|
// NOTE : Android does not support the Quads elements ...
|
||||||
|
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||||
|
#endif
|
||||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
||||||
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
||||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::OObject2DText::Text(etkFloat_t x, etkFloat_t y, const char* utf8String)
|
void ewol::OObject2DText::Text(etkFloat_t x, etkFloat_t y, const char* utf8String)
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <ewol/Texture.h>
|
#include <ewol/Texture.h>
|
||||||
#include <importgl.h>
|
#include <importgl.h>
|
||||||
|
#include <ewol/ewol.h>
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -314,14 +315,63 @@ class LoadedTexture
|
|||||||
int32_t m_nbTimeLoaded;
|
int32_t m_nbTimeLoaded;
|
||||||
int32_t m_imageSize; // must be x=y ...
|
int32_t m_imageSize; // must be x=y ...
|
||||||
uint32_t m_openGlTextureID;
|
uint32_t m_openGlTextureID;
|
||||||
|
Bitmap* m_imageData;
|
||||||
|
bool m_loaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
etk::VectorType<LoadedTexture*> listLoadedTexture;
|
etk::VectorType<LoadedTexture*> listLoadedTexture;
|
||||||
|
|
||||||
|
static bool OGLContextLoaded=false;
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol"
|
#define __class__ "ewol"
|
||||||
|
|
||||||
|
void ewol::TextureOGLContext(bool enable)
|
||||||
|
{
|
||||||
|
if (OGLContextLoaded != enable) {
|
||||||
|
OGLContextLoaded = enable;
|
||||||
|
if (true == OGLContextLoaded) {
|
||||||
|
EWOL_WARNING("POST loading the Texture");
|
||||||
|
for (int32_t iii=0; iii < listLoadedTexture.Size(); iii++) {
|
||||||
|
GLuint textureid;
|
||||||
|
glGenTextures(1, &textureid);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, textureid);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
//--- mode nearest
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
//#ifdef __PLATFORM__X11
|
||||||
|
//--- Mode linear
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
//#endif
|
||||||
|
EWOL_WARNING("Set in OpenGl texture =" << listLoadedTexture[iii]->m_imageData->Width()
|
||||||
|
<< "px different of height=" << listLoadedTexture[iii]->m_imageData->Height()
|
||||||
|
<< "px in file:" << listLoadedTexture[iii]->m_filename << " in id OGL : " << textureid);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||||
|
listLoadedTexture[iii]->m_imageData->Width(),
|
||||||
|
listLoadedTexture[iii]->m_imageData->Height(),
|
||||||
|
0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||||
|
listLoadedTexture[iii]->m_imageData->Data());
|
||||||
|
listLoadedTexture[iii]->m_openGlTextureID = textureid;
|
||||||
|
listLoadedTexture[iii]->m_loaded = true;
|
||||||
|
}
|
||||||
|
ewol::ForceRedrawAll();
|
||||||
|
} else {
|
||||||
|
for (int32_t iii=0; iii < listLoadedTexture.Size(); iii++) {
|
||||||
|
EWOL_DEBUG("unlink openGL texture ID=" << iii << " file:" << listLoadedTexture[iii]->m_filename);
|
||||||
|
glDeleteTextures(1,&listLoadedTexture[iii]->m_openGlTextureID);
|
||||||
|
listLoadedTexture[iii]->m_loaded = false;
|
||||||
|
listLoadedTexture[iii]->m_openGlTextureID = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t ewol::LoadTexture(etk::File fileName)
|
int32_t ewol::LoadTexture(etk::File fileName)
|
||||||
{
|
{
|
||||||
if (listLoadedTexture.Size()!=0) {
|
if (listLoadedTexture.Size()!=0) {
|
||||||
@ -338,39 +388,47 @@ int32_t ewol::LoadTexture(etk::File fileName)
|
|||||||
EWOL_ERROR("File does not Exist ... " << fileName);
|
EWOL_ERROR("File does not Exist ... " << fileName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Bitmap myBitmap(fileName);
|
Bitmap * myBitmap = new Bitmap(fileName);
|
||||||
myBitmap.Display();
|
myBitmap->Display();
|
||||||
if (myBitmap.LoadOK() == true) {
|
if (myBitmap->LoadOK() == true) {
|
||||||
if (myBitmap.Width()!= myBitmap.Height()) {
|
if (myBitmap->Width()!= myBitmap->Height()) {
|
||||||
EWOL_ERROR("Texture can not have Width=" << myBitmap.Width() << "px different of height=" << myBitmap.Height() << "px in file:" << fileName);
|
EWOL_ERROR("Texture can not have Width=" << myBitmap->Width() << "px different of height=" << myBitmap->Height() << "px in file:" << fileName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
GLuint textureid;
|
|
||||||
glGenTextures(1, &textureid);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textureid);
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
//--- mode nearest
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
//--- Mode linear
|
|
||||||
|
|
||||||
#ifdef __PLATFORM__X11
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
#endif
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myBitmap.Width(), myBitmap.Height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, myBitmap.Data());
|
|
||||||
LoadedTexture *tmpTex = new LoadedTexture();
|
LoadedTexture *tmpTex = new LoadedTexture();
|
||||||
|
int32_t outTextureID = -1;
|
||||||
|
GLuint textureid = 0;
|
||||||
if (NULL != tmpTex) {
|
if (NULL != tmpTex) {
|
||||||
tmpTex->m_filename = fileName;
|
tmpTex->m_filename = fileName;
|
||||||
tmpTex->m_nbTimeLoaded = 1;
|
tmpTex->m_nbTimeLoaded = 1;
|
||||||
tmpTex->m_imageSize = myBitmap.Width();
|
tmpTex->m_imageSize = myBitmap->Width();
|
||||||
tmpTex->m_openGlTextureID = textureid;
|
tmpTex->m_openGlTextureID = -1;
|
||||||
|
tmpTex->m_imageData = myBitmap;
|
||||||
|
tmpTex->m_loaded = false;
|
||||||
|
if (true == OGLContextLoaded) {
|
||||||
|
glGenTextures(1, &textureid);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, textureid);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
//--- mode nearest
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
//#ifdef __PLATFORM__X11
|
||||||
|
//--- Mode linear
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
//#endif
|
||||||
|
EWOL_WARNING("Set in OpenGl texture =" << myBitmap->Width() << "px different of height=" << myBitmap->Height() << "px in file:" << fileName << " in id OGL : " <<textureid);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myBitmap->Width(), myBitmap->Height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, myBitmap->Data());
|
||||||
|
tmpTex->m_openGlTextureID = textureid;
|
||||||
|
tmpTex->m_loaded = true;
|
||||||
|
}
|
||||||
listLoadedTexture.PushBack(tmpTex);
|
listLoadedTexture.PushBack(tmpTex);
|
||||||
|
outTextureID = listLoadedTexture.Size()-1;
|
||||||
} else {
|
} else {
|
||||||
EWOL_ERROR("Allocation ERROR... ");
|
EWOL_ERROR("Allocation ERROR... ");
|
||||||
}
|
}
|
||||||
return textureid;
|
return outTextureID;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -382,22 +440,30 @@ int32_t ewol::LoadTexture(etk::File fileName)
|
|||||||
|
|
||||||
void ewol::UnLoadTexture(uint32_t textureID)
|
void ewol::UnLoadTexture(uint32_t textureID)
|
||||||
{
|
{
|
||||||
for (int32_t iii=0; iii<listLoadedTexture.Size(); iii++) {
|
if (textureID>=0 && textureID<listLoadedTexture.Size()) {
|
||||||
if (listLoadedTexture[iii]->m_openGlTextureID == textureID) {
|
listLoadedTexture[textureID]->m_nbTimeLoaded--;
|
||||||
listLoadedTexture[iii]->m_nbTimeLoaded--;
|
if (0 == listLoadedTexture[textureID]->m_nbTimeLoaded) {
|
||||||
if (0 == listLoadedTexture[iii]->m_nbTimeLoaded) {
|
EWOL_DEBUG("Remove openGL texture ID=" << textureID << " file:" << listLoadedTexture[textureID]->m_filename);
|
||||||
EWOL_DEBUG("Remove openGL texture ID=" << textureID << " file:" << listLoadedTexture[iii]->m_filename);
|
if (true == listLoadedTexture[textureID]->m_loaded) {
|
||||||
glDeleteTextures(1,&listLoadedTexture[iii]->m_openGlTextureID);
|
glDeleteTextures(1,&listLoadedTexture[textureID]->m_openGlTextureID);
|
||||||
delete(listLoadedTexture[iii]);
|
|
||||||
listLoadedTexture[iii] = NULL;
|
|
||||||
listLoadedTexture.Erase(iii);
|
|
||||||
}
|
}
|
||||||
return;
|
delete(listLoadedTexture[textureID]);
|
||||||
|
listLoadedTexture[textureID] = NULL;
|
||||||
|
listLoadedTexture.Erase(textureID);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
EWOL_CRITICAL("Can not find TextureId=" << (int)textureID << " in the list of texture loaded...==> to remove it ...");
|
EWOL_CRITICAL("Can not find TextureId=" << (int)textureID << " in the list of texture loaded...==> to remove it ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ewol::GetTextureGLID(uint32_t textureID)
|
||||||
|
{
|
||||||
|
if (textureID>=0 && textureID<listLoadedTexture.Size()) {
|
||||||
|
return listLoadedTexture[textureID]->m_openGlTextureID;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ewol::GetTextureSize(uint32_t textureID)
|
int32_t ewol::GetTextureSize(uint32_t textureID)
|
||||||
{
|
{
|
||||||
|
@ -39,9 +39,11 @@ namespace ewol
|
|||||||
int32_t GetSize(uint32_t textureID);
|
int32_t GetSize(uint32_t textureID);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
int32_t LoadTexture(etk::File fileName);
|
int32_t LoadTexture(etk::File fileName);
|
||||||
void UnLoadTexture(uint32_t textureID);
|
void UnLoadTexture(uint32_t textureID);
|
||||||
int32_t GetTextureSize(uint32_t textureID);
|
int32_t GetTextureSize(uint32_t textureID);
|
||||||
|
uint32_t GetTextureGLID(uint32_t textureID);
|
||||||
|
void TextureOGLContext(bool enable);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -111,3 +111,8 @@ bool ewol::IsPressedInput(int32_t inputID)
|
|||||||
return guiAbstraction::IsPressedInput(inputID);
|
return guiAbstraction::IsPressedInput(inputID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::ForceRedrawAll(void)
|
||||||
|
{
|
||||||
|
guiAbstraction::ForceRedrawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ namespace ewol {
|
|||||||
void StartResizeSystem(void);
|
void StartResizeSystem(void);
|
||||||
void StartMoveSystem(void);
|
void StartMoveSystem(void);
|
||||||
bool IsPressedInput(int32_t inputID);
|
bool IsPressedInput(int32_t inputID);
|
||||||
|
void ForceRedrawAll(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user