From bd0c899654ec6579b40e38d4dc57df52072c6c37 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 25 Jun 2017 15:01:32 +0200 Subject: [PATCH] [DEV] add an api to set texture in compsiting::Image ==> need to rework this API --- ewol/compositing/Image.cpp | 21 +++++++++++++++++++-- ewol/compositing/Image.hpp | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ewol/compositing/Image.cpp b/ewol/compositing/Image.cpp index 54c8d9ea..18ea306c 100644 --- a/ewol/compositing/Image.cpp +++ b/ewol/compositing/Image.cpp @@ -75,7 +75,8 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) { return; } if ( m_resource == nullptr - && m_resourceDF == nullptr) { + && m_resourceDF == nullptr + && m_resourceImage == nullptr) { // this is a normale case ... the user can choice to have no image ... return; } @@ -94,7 +95,9 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) { m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // TextureID - if (m_resource != nullptr) { + if (m_resourceImage != nullptr) { + m_GLprogram->setTexture0(m_GLtexID, m_resourceImage->getRendererId()); + } else if (m_resource != nullptr) { if (m_distanceFieldMode == true) { EWOL_ERROR("FONT type error Request distance field and display normal ..."); } @@ -274,10 +277,12 @@ void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2 } ememory::SharedPtr resource = m_resource; ememory::SharedPtr resourceDF = m_resourceDF; + ememory::SharedPtr resourceTex = m_resourceImage; m_filename = _newFile; m_requestSize = _size; m_resource.reset(); m_resourceDF.reset(); + m_resourceImage.reset(); ivec2 tmpSize(_size.x(),_size.y()); // note that no image can be loaded... if (_newFile != "") { @@ -304,8 +309,20 @@ void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2 EWOL_WARNING("Retrive previous resource (DF)"); m_resourceDF = resourceDF; } + if (resourceTex != nullptr) { + EWOL_WARNING("Retrive previous resource (image)"); + m_resourceImage = resourceTex; + } } } +void ewol::compositing::Image::setSource(egami::Image _image) { + clear(); + m_filename = "direct image BUFFER"; + m_requestSize = _image.getSize(); + m_resourceImage = ewol::resource::Texture::create(); + m_resourceImage->get() = _image; + m_resourceImage->flush(); +} bool ewol::compositing::Image::hasSources() { return m_resource != nullptr diff --git a/ewol/compositing/Image.hpp b/ewol/compositing/Image.hpp index da294f9a..cccf9027 100644 --- a/ewol/compositing/Image.hpp +++ b/ewol/compositing/Image.hpp @@ -36,6 +36,7 @@ namespace ewol { private: bool m_distanceFieldMode; //!< select distance field mode ememory::SharedPtr m_resource; //!< texture resources + ememory::SharedPtr m_resourceImage; //!< texture resources ememory::SharedPtr m_resourceDF; //!< texture resources static const int32_t m_vboIdCoord; static const int32_t m_vboIdCoordTex; @@ -162,6 +163,7 @@ namespace ewol { setSource(_newFile, vec2(_size,_size)); }; void setSource(const std::string& _newFile, const vec2& _size); + void setSource(egami::Image _image); /** * @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * @return the validity od the resources.