[DEV] display an image background on the scene
This commit is contained in:
parent
f5c65e0fb6
commit
cd39ae1512
@ -1 +1 @@
|
|||||||
Subproject commit b6ae353bdfe68963de4652babaf8d4d24b1026d3
|
Subproject commit 18e51a5e97561222fd352db77cca65928c69e517
|
@ -51,9 +51,10 @@ ewol::SceneElement::SceneElement(void)
|
|||||||
}
|
}
|
||||||
retreviveElement = 0;
|
retreviveElement = 0;
|
||||||
allocatedElements = 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");
|
EWOL_ERROR("error to keep the scene background");
|
||||||
background = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +93,8 @@ ewol::SceneElement::~SceneElement(void)
|
|||||||
}
|
}
|
||||||
animated.Clear();
|
animated.Clear();
|
||||||
if (NULL != background) {
|
if (NULL != background) {
|
||||||
ewol::resource::Release(background);
|
delete background;
|
||||||
|
background = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +55,11 @@ namespace ewol {
|
|||||||
int32_t numberOfGroup; //!< curent scene number of group
|
int32_t numberOfGroup; //!< curent scene number of group
|
||||||
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
|
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
|
||||||
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
|
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
|
||||||
ewol::Texture* background; //!< background element
|
ewol::OObject2DTextured* background; //!< background element
|
||||||
etk::Vector<ewol::Sprite*> animated; //!< element that must be display the second
|
etk::Vector<ewol::Sprite*> animated; //!< element that must be display the second
|
||||||
etk::Vector<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group
|
etk::Vector<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group
|
||||||
etk::Vector<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free
|
etk::Vector<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free
|
||||||
etk::Vector<listRegisteElement*> listCreatorElement; //!< list of all creatable elements
|
etk::Vector<listRegisteElement*> listCreatorElement; //!< list of all creatable elements
|
||||||
int16_t GetUniqueId(void) { int16_t iddd = m_id; m_id++; return iddd; };
|
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 RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString);
|
||||||
void RmElement(int16_t group, int16_t posInList);
|
void RmElement(int16_t group, int16_t posInList);
|
||||||
@ -94,7 +94,7 @@ namespace ewol {
|
|||||||
void AddEarrerDestroy(uint32_t uId);
|
void AddEarrerDestroy(uint32_t uId);
|
||||||
void RmEarrerDestroy(uint32_t uId);
|
void RmEarrerDestroy(uint32_t uId);
|
||||||
void SendEventRemove(uint32_t uId);
|
void SendEventRemove(uint32_t uId);
|
||||||
ewol::Texture* GetBackground(void) { return background; };
|
ewol::OObject2DTextured* GetBackground(void) { return background; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,9 +33,37 @@
|
|||||||
ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX, float sizeY)
|
ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX, float sizeY)
|
||||||
{
|
{
|
||||||
EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\"");
|
EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\"");
|
||||||
if (false == ewol::resource::Keep(textureName, m_resource, Vector2D<int32_t>(sizeX,sizeY)) ) {
|
ewol::TextureFile* resourceFile = NULL;
|
||||||
|
if (false == ewol::resource::Keep(textureName, resourceFile, Vector2D<int32_t>(sizeX,sizeY)) ) {
|
||||||
EWOL_CRITICAL("can not get a resource Texture");
|
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<int32_t>(sizeX,sizeY));
|
||||||
|
draw::Image& tmpImage = m_resource->Get();
|
||||||
|
tmpImage.SetFillColor(draw::color::black);
|
||||||
|
tmpImage.Clear();
|
||||||
|
m_resource->Flush();
|
||||||
|
}
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
etk::UString tmpString("textured.prog");
|
etk::UString tmpString("textured.prog");
|
||||||
// get the shader resource :
|
// get the shader resource :
|
||||||
|
@ -33,6 +33,7 @@ namespace ewol {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OObject2DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1);
|
OObject2DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1);
|
||||||
|
OObject2DTextured(float sizeX=-1, float sizeY=-1);
|
||||||
virtual ~OObject2DTextured(void);
|
virtual ~OObject2DTextured(void);
|
||||||
public:
|
public:
|
||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
@ -48,7 +49,7 @@ namespace ewol {
|
|||||||
int32_t m_GLtexture;
|
int32_t m_GLtexture;
|
||||||
int32_t m_GLtexID;
|
int32_t m_GLtexID;
|
||||||
#endif
|
#endif
|
||||||
ewol::TextureFile* m_resource; //!< texture resources
|
ewol::Texture* m_resource; //!< texture resources
|
||||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
@ -56,6 +57,21 @@ namespace ewol {
|
|||||||
#else
|
#else
|
||||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||||
#endif
|
#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();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,4 +130,3 @@ void ewol::Texture::SetImageSize(Vector2D<int32_t> newSize)
|
|||||||
m_data.Resize(newSize);
|
m_data.Resize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +90,9 @@ void ewol::Scene::OnDraw(DrawProperty& displayProp)
|
|||||||
//EWOL_ERROR(" On draw : " << m_currentDrawId);
|
//EWOL_ERROR(" On draw : " << m_currentDrawId);
|
||||||
// draw background :
|
// draw background :
|
||||||
// TODO : ...
|
// TODO : ...
|
||||||
|
if (NULL != m_sceneElement.background) {
|
||||||
|
m_sceneElement.background->Draw();
|
||||||
|
}
|
||||||
//background
|
//background
|
||||||
// draw elements
|
// draw elements
|
||||||
for (int32_t iii=0; iii<m_sceneElement.animated.Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.animated.Size(); iii++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user