diff --git a/Sources/libagg b/Sources/libagg index b6ae353b..18e51a5e 160000 --- a/Sources/libagg +++ b/Sources/libagg @@ -1 +1 @@ -Subproject commit b6ae353bdfe68963de4652babaf8d4d24b1026d3 +Subproject commit 18e51a5e97561222fd352db77cca65928c69e517 diff --git a/Sources/libewol/ewol/game/SceneElement.cpp b/Sources/libewol/ewol/game/SceneElement.cpp index 6eebf69e..2eb8ff2d 100644 --- a/Sources/libewol/ewol/game/SceneElement.cpp +++ b/Sources/libewol/ewol/game/SceneElement.cpp @@ -51,9 +51,10 @@ ewol::SceneElement::SceneElement(void) } retreviveElement = 0; allocatedElements = 0; - if (false == ewol::resource::Keep(background) ) { + + background = new ewol::OObject2DTextured(1024,1024); + if (NULL == background ) { EWOL_ERROR("error to keep the scene background"); - background = NULL; } } @@ -92,7 +93,8 @@ ewol::SceneElement::~SceneElement(void) } animated.Clear(); if (NULL != background) { - ewol::resource::Release(background); + delete background; + background = NULL; } } diff --git a/Sources/libewol/ewol/game/SceneElement.h b/Sources/libewol/ewol/game/SceneElement.h index f3f06df3..5b4ac19e 100644 --- a/Sources/libewol/ewol/game/SceneElement.h +++ b/Sources/libewol/ewol/game/SceneElement.h @@ -55,11 +55,11 @@ namespace ewol { int32_t numberOfGroup; //!< curent scene number of group etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy - ewol::Texture* background; //!< background element - etk::Vector animated; //!< element that must be display the second - etk::Vector listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group - etk::Vector listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free - etk::Vector listCreatorElement; //!< list of all creatable elements + ewol::OObject2DTextured* background; //!< background element + etk::Vector animated; //!< element that must be display the second + etk::Vector listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group + etk::Vector listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free + etk::Vector listCreatorElement; //!< list of all creatable elements int16_t GetUniqueId(void) { int16_t iddd = m_id; m_id++; return iddd; }; void RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString); void RmElement(int16_t group, int16_t posInList); @@ -94,7 +94,7 @@ namespace ewol { void AddEarrerDestroy(uint32_t uId); void RmEarrerDestroy(uint32_t uId); void SendEventRemove(uint32_t uId); - ewol::Texture* GetBackground(void) { return background; }; + ewol::OObject2DTextured* GetBackground(void) { return background; }; }; }; diff --git a/Sources/libewol/ewol/oObject/2DTextured.cpp b/Sources/libewol/ewol/oObject/2DTextured.cpp index a6ee547f..a20ee60a 100644 --- a/Sources/libewol/ewol/oObject/2DTextured.cpp +++ b/Sources/libewol/ewol/oObject/2DTextured.cpp @@ -33,9 +33,37 @@ ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX, float sizeY) { EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\""); - if (false == ewol::resource::Keep(textureName, m_resource, Vector2D(sizeX,sizeY)) ) { + ewol::TextureFile* resourceFile = NULL; + if (false == ewol::resource::Keep(textureName, resourceFile, Vector2D(sizeX,sizeY)) ) { EWOL_CRITICAL("can not get a resource Texture"); } + m_resource = resourceFile; + #ifdef __VIDEO__OPENGL_ES_2 + etk::UString tmpString("textured.prog"); + // get the shader resource : + m_GLPosition = 0; + if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { + m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); + m_GLColor = m_GLprogram->GetAttribute("EW_color"); + m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); + m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); + m_GLtexID = m_GLprogram->GetUniform("EW_texID"); + } + #endif +} + +ewol::OObject2DTextured::OObject2DTextured( float sizeX, float sizeY) +{ + if (false == ewol::resource::Keep(m_resource) ) { + EWOL_CRITICAL("can not get a resource Texture"); + } + if (NULL!=m_resource) { + m_resource->SetImageSize(Vector2D(sizeX,sizeY)); + draw::Image& tmpImage = m_resource->Get(); + tmpImage.SetFillColor(draw::color::black); + tmpImage.Clear(); + m_resource->Flush(); + } #ifdef __VIDEO__OPENGL_ES_2 etk::UString tmpString("textured.prog"); // get the shader resource : diff --git a/Sources/libewol/ewol/oObject/2DTextured.h b/Sources/libewol/ewol/oObject/2DTextured.h index d0ea18d6..588f1f8b 100644 --- a/Sources/libewol/ewol/oObject/2DTextured.h +++ b/Sources/libewol/ewol/oObject/2DTextured.h @@ -33,6 +33,7 @@ namespace ewol { { public: OObject2DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1); + OObject2DTextured(float sizeX=-1, float sizeY=-1); virtual ~OObject2DTextured(void); public: virtual void Draw(void); @@ -48,7 +49,7 @@ namespace ewol { int32_t m_GLtexture; int32_t m_GLtexID; #endif - ewol::TextureFile* m_resource; //!< texture resources + ewol::Texture* m_resource; //!< texture resources etk::Vector > m_coord; //!< internal coord of the object etk::Vector m_coordTex; //!< internal texture coordinate for every point #ifdef __VIDEO__OPENGL_ES_2 @@ -56,6 +57,21 @@ namespace ewol { #else etk::Vector m_coordColor; //!< internal color of the different point #endif + public: + draw::Image* GetImage(void) + { + if (NULL == m_resource) { + return NULL; + } + draw::Image& tmpImage = m_resource->Get(); + return &tmpImage; + }; + void Flush(void) + { + if (NULL != m_resource) { + m_resource->Flush(); + } + } }; }; diff --git a/Sources/libewol/ewol/texture/Texture.cpp b/Sources/libewol/ewol/texture/Texture.cpp index 77bea46b..a9525ad8 100644 --- a/Sources/libewol/ewol/texture/Texture.cpp +++ b/Sources/libewol/ewol/texture/Texture.cpp @@ -130,4 +130,3 @@ void ewol::Texture::SetImageSize(Vector2D newSize) m_data.Resize(newSize); } - diff --git a/Sources/libewol/ewol/widget/Scene.cpp b/Sources/libewol/ewol/widget/Scene.cpp index 31e14757..20189d1d 100644 --- a/Sources/libewol/ewol/widget/Scene.cpp +++ b/Sources/libewol/ewol/widget/Scene.cpp @@ -90,6 +90,9 @@ void ewol::Scene::OnDraw(DrawProperty& displayProp) //EWOL_ERROR(" On draw : " << m_currentDrawId); // draw background : // TODO : ... + if (NULL != m_sceneElement.background) { + m_sceneElement.background->Draw(); + } //background // draw elements for (int32_t iii=0; iii