[DEV] update ewol to gale (basic work step 2)

This commit is contained in:
Edouard DUPIN 2015-08-11 22:38:34 +02:00
parent 4325aaecf2
commit 6560b59eab
13 changed files with 80 additions and 122 deletions

View File

@ -63,7 +63,7 @@ void ewol::compositing::Area::draw(bool _disableDepthTest) {
m_GLprogram->use(); m_GLprogram->use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
// TextureID // TextureID
m_GLprogram->setTexture0(m_GLtexID, m_resource->getId()); m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId());
// position : // position :
m_GLprogram->sendAttribute(m_GLPosition, m_coord); m_GLprogram->sendAttribute(m_GLPosition, m_coord);
// Texture : // Texture :

View File

@ -84,12 +84,12 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) {
if (m_distanceFieldMode == true) { if (m_distanceFieldMode == true) {
EWOL_ERROR("FONT type error Request distance field and display normal ..."); EWOL_ERROR("FONT type error Request distance field and display normal ...");
} }
m_GLprogram->setTexture0(m_GLtexID, m_resource->getId()); m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId());
} else { } else {
if (m_distanceFieldMode == false) { if (m_distanceFieldMode == false) {
EWOL_ERROR("FONT type error Request normal and display distance field ..."); EWOL_ERROR("FONT type error Request normal and display distance field ...");
} }
m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getId()); m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getRendererId());
} }
// position : // position :
m_GLprogram->sendAttribute(m_GLPosition, m_coord); m_GLprogram->sendAttribute(m_GLPosition, m_coord);

View File

@ -199,7 +199,7 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
} }
if (nullptr!=m_resourceTexture) { if (nullptr!=m_resourceTexture) {
// TextureID // TextureID
m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getId()); m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getRendererId());
} }
// Request the draw of the elements : // Request the draw of the elements :
//gale::openGL::drawArrays(gale::openGL::render_triangle, 0, SHAPER_NB_MAX_VERTEX); //gale::openGL::drawArrays(gale::openGL::render_triangle, 0, SHAPER_NB_MAX_VERTEX);

View File

@ -53,7 +53,7 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en
m_GLprogram->use(); m_GLprogram->use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
// Texture : // Texture :
m_GLprogram->setTexture0(m_GLtexID, m_font->getId()); m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x());
// position : // position :
@ -92,7 +92,7 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) {
m_GLprogram->use(); m_GLprogram->use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
// Texture : // Texture :
m_GLprogram->setTexture0(m_GLtexID, m_font->getId()); m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x());
// position : // position :

View File

@ -64,7 +64,7 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
m_GLprogram->use(); m_GLprogram->use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
// Texture : // Texture :
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId()); m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x());
m_GLprogram->sendAttribute(m_GLPosition, m_coord); m_GLprogram->sendAttribute(m_GLPosition, m_coord);
@ -102,7 +102,7 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
m_GLprogram->use(); m_GLprogram->use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
// Texture : // Texture :
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId()); m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x());
m_GLprogram->sendAttribute(m_GLPosition, m_coord); m_GLprogram->sendAttribute(m_GLPosition, m_coord);

View File

@ -33,51 +33,18 @@
#include <ewol/context/Context.h> #include <ewol/context/Context.h>
/**
* @brief get the main ewol mutex (event or periodic call mutex).
* @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time.
* @return the main inteface Mutex
*/
static std::mutex& mutexInterface() {
static std::mutex s_interfaceMutex;
return s_interfaceMutex;
}
static ewol::Context* l_curentInterface=nullptr; static ewol::Context* l_curentInterface=nullptr;
ewol::Context& ewol::getContext() { ewol::Context& ewol::getContext() {
#if DEBUG_LEVEL > 2 gale::Context& context = gale::getContext();
if(nullptr == l_curentInterface){ std::shared_ptr<gale::Application> appl = context.getApplication();
EWOL_CRITICAL("[CRITICAL] try acces at an empty interface"); if (appl == nullptr) {
} EWOL_CRITICAL("[CRITICAL] try acces at an empty GALE application (can not get Context)");
#endif // ???
return *l_curentInterface; }
return *(std::static_pointer_cast<ewol::Context>(appl));
} }
/**
* @brief set the curent interface.
* @note this lock the main mutex
*/
void ewol::Context::lockContext() {
mutexInterface().lock();
l_curentInterface = this;
}
/**
* @brief set the curent interface at nullptr.
* @note this un-lock the main mutex
*/
void ewol::Context::unLockContext() {
l_curentInterface = nullptr;
mutexInterface().unlock();
}
void ewol::Context::setInitImage(const std::string& _fileName) { void ewol::Context::setInitImage(const std::string& _fileName) {
//m_initDisplayImageName = _fileName; //m_initDisplayImageName = _fileName;
} }
@ -100,7 +67,6 @@ void ewol::Context::inputEventUnGrabPointer() {
void ewol::Context::onCreate(gale::Context& _context) { void ewol::Context::onCreate(gale::Context& _context) {
lockContext();
EWOL_INFO(" == > Ewol system init (BEGIN)"); EWOL_INFO(" == > Ewol system init (BEGIN)");
// Add basic ewol translation: // Add basic ewol translation:
ewol::translate::addPath("ewol", "DATA:translate/ewol/"); ewol::translate::addPath("ewol", "DATA:translate/ewol/");
@ -140,34 +106,27 @@ void ewol::Context::onCreate(gale::Context& _context) {
#endif #endif
*/ */
EWOL_INFO(" == > Ewol system init (END)"); EWOL_INFO(" == > Ewol system init (END)");
unLockContext();
} }
void ewol::Context::onStart(gale::Context& _context) { void ewol::Context::onStart(gale::Context& _context) {
lockContext();
if (m_application == nullptr) { if (m_application == nullptr) {
// TODO : Request exit of the application .... with error ... // TODO : Request exit of the application .... with error ...
unLockContext();
return; return;
} }
for (int32_t iii=0; iii<m_application->getNbStepInit(); ++iii) { for (int32_t iii=0; iii<m_application->getNbStepInit(); ++iii) {
m_application->init(*this, iii); m_application->init(*this, iii);
} }
unLockContext();
} }
void ewol::Context::onResume(gale::Context& _context) { void ewol::Context::onResume(gale::Context& _context) {
lockContext();
unLockContext();
} }
void ewol::Context::onRegenerateDisplay(gale::Context& _context) { void ewol::Context::onRegenerateDisplay(gale::Context& _context) {
lockContext();
EWOL_INFO("REGENERATE_DISPLAY"); EWOL_INFO("REGENERATE_DISPLAY");
// check if the user selected a windows // check if the user selected a windows
if (m_windowsCurrent == nullptr) { if (m_windowsCurrent == nullptr) {
EWOL_INFO("No windows ..."); EWOL_INFO("No windows ...");
unLockContext();
return; return;
} }
// Redraw all needed elements // Redraw all needed elements
@ -176,11 +135,9 @@ void ewol::Context::onRegenerateDisplay(gale::Context& _context) {
markDrawingIsNeeded(); markDrawingIsNeeded();
} }
//markDrawingIsNeeded(); //markDrawingIsNeeded();
unLockContext();
} }
void ewol::Context::onDraw(gale::Context& _context) { void ewol::Context::onDraw(gale::Context& _context) {
lockContext();
EWOL_INFO("DRAW"); EWOL_INFO("DRAW");
// clean internal data... // clean internal data...
m_objectManager.cleanInternalRemoved(); m_objectManager.cleanInternalRemoved();
@ -189,22 +146,16 @@ void ewol::Context::onDraw(gale::Context& _context) {
return; return;
} }
m_windowsCurrent->sysDraw(); m_windowsCurrent->sysDraw();
unLockContext();
} }
void ewol::Context::onPause(gale::Context& _context) { void ewol::Context::onPause(gale::Context& _context) {
lockContext();
unLockContext();
} }
void ewol::Context::onStop(gale::Context& _context) { void ewol::Context::onStop(gale::Context& _context) {
lockContext();
m_application->unInit(*this); m_application->unInit(*this);
unLockContext();
} }
void ewol::Context::onDestroy(gale::Context& _context) { void ewol::Context::onDestroy(gale::Context& _context) {
lockContext();
EWOL_INFO(" == > Ewol system Un-Init (BEGIN)"); EWOL_INFO(" == > Ewol system Un-Init (BEGIN)");
// Remove current windows // Remove current windows
m_windowsCurrent.reset(); m_windowsCurrent.reset();
@ -221,14 +172,12 @@ void ewol::Context::onDestroy(gale::Context& _context) {
// now All must be removed !!! // now All must be removed !!!
m_objectManager.unInit(); m_objectManager.unInit();
EWOL_INFO(" == > Ewol system Un-Init (END)"); EWOL_INFO(" == > Ewol system Un-Init (END)");
unLockContext();
} }
void ewol::Context::onPointer(enum gale::key::type _type, void ewol::Context::onPointer(enum gale::key::type _type,
int32_t _pointerID, int32_t _pointerID,
const vec2& _pos, const vec2& _pos,
gale::key::status _state) { gale::key::status _state) {
lockContext();
switch (_state) { switch (_state) {
case gale::key::status_move: case gale::key::status_move:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION"); //EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
@ -247,18 +196,15 @@ void ewol::Context::onPointer(enum gale::key::type _type,
EWOL_DEBUG("Unknow state : " << _state); EWOL_DEBUG("Unknow state : " << _state);
break; break;
} }
unLockContext();
} }
void ewol::Context::onKeyboard(gale::key::Special& _special, void ewol::Context::onKeyboard(gale::key::Special& _special,
enum gale::key::keyboard _type, enum gale::key::keyboard _type,
char32_t _value, char32_t _value,
gale::key::status _state) { gale::key::status _state) {
lockContext();
// store the keyboard special key status for mouse event... // store the keyboard special key status for mouse event...
m_input.setLastKeyboardSpecial(_special); m_input.setLastKeyboardSpecial(_special);
if (m_windowsCurrent == nullptr) { if (m_windowsCurrent == nullptr) {
// No windows ... // No windows ...
unLockContext();
return; return;
} }
bool repeate = (_state == gale::key::status_downRepeate); bool repeate = (_state == gale::key::status_downRepeate);
@ -269,14 +215,12 @@ void ewol::Context::onKeyboard(gale::key::Special& _special,
_type, _type,
isDown) == true) { isDown) == true) {
// Keep a shortcut ... // Keep a shortcut ...
unLockContext();
return; return;
} }
// get the current focused Widget : // get the current focused Widget :
std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet(); std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
// no Widget ... // no Widget ...
unLockContext();
return; return;
} }
// check if the widget allow repeating key events. // check if the widget allow repeating key events.
@ -314,7 +258,6 @@ void ewol::Context::onKeyboard(gale::key::Special& _special,
EWOL_DEBUG("remove Repeate key ..."); EWOL_DEBUG("remove Repeate key ...");
} }
} }
unLockContext();
} }
/* /*
@ -328,12 +271,10 @@ void ewol::Context::processEvents() {
*/ */
void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) { void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) {
lockContext();
std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet(); std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != nullptr) { if (tmpWidget != nullptr) {
tmpWidget->onEventClipboard(_clipboardId); tmpWidget->onEventClipboard(_clipboardId);
} }
unLockContext();
} }
@ -367,7 +308,6 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
//! Event management section ... //! Event management section ...
{ {
// set the curent interface : // set the curent interface :
lockContext();
processEvents(); processEvents();
if (m_initStepId < m_application->getNbStepInit()) { if (m_initStepId < m_application->getNbStepInit()) {
ewol::eSystemMessage *data = new ewol::eSystemMessage(); ewol::eSystemMessage *data = new ewol::eSystemMessage();
@ -388,7 +328,6 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
//! bool needRedraw = ewol::widgetManager::isDrawingNeeded(); //! bool needRedraw = ewol::widgetManager::isDrawingNeeded();
needRedraw = m_widgetManager.isDrawingNeeded(); needRedraw = m_widgetManager.isDrawingNeeded();
// release the curent interface : // release the curent interface :
unLockContext();
} }
bool hasDisplayDone = false; bool hasDisplayDone = false;
//! drawing section : //! drawing section :
@ -437,7 +376,6 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
} }
{ {
// set the curent interface : // set the curent interface :
lockContext();
// release open GL Context // release open GL Context
gale::openGL::lock(); gale::openGL::lock();
// while The Gui is drawing in OpenGl, we do some not realTime things // while The Gui is drawing in OpenGl, we do some not realTime things
@ -447,7 +385,6 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
m_objectManager.cleanInternalRemoved(); m_objectManager.cleanInternalRemoved();
m_resourceManager.cleanInternalRemoved(); m_resourceManager.cleanInternalRemoved();
// release the curent interface : // release the curent interface :
unLockContext();
} }
return hasDisplayDone; return hasDisplayDone;
} }
@ -473,40 +410,40 @@ void ewol::Context::setWindows(const std::shared_ptr<ewol::widget::Windows>& _wi
std::shared_ptr<ewol::widget::Windows> ewol::Context::getWindows() { std::shared_ptr<ewol::widget::Windows> ewol::Context::getWindows() {
return m_windowsCurrent; return m_windowsCurrent;
}; };
void ewol::Context::onResize(const ivec2& _size) {
EWOL_ERROR("Resize: " << _size);
forceRedrawAll();
}
void ewol::Context::forceRedrawAll() { void ewol::Context::forceRedrawAll() {
if (m_windowsCurrent == nullptr) { if (m_windowsCurrent == nullptr) {
return; return;
} }
// TODO: m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y())); ivec2 size = getSize();
m_windowsCurrent->calculateSize(vec2(size.x(), size.y()));
} }
/* /*
void ewol::Context::OS_Stop() { void ewol::Context::OS_Stop() {
// set the curent interface : // set the curent interface :
lockContext();
EWOL_INFO("OS_Stop..."); EWOL_INFO("OS_Stop...");
if (m_windowsCurrent != nullptr) { if (m_windowsCurrent != nullptr) {
m_windowsCurrent->sysOnKill(); m_windowsCurrent->sysOnKill();
} }
// release the curent interface : // release the curent interface :
unLockContext();
} }
void ewol::Context::OS_Suspend() { void ewol::Context::OS_Suspend() {
// set the curent interface : // set the curent interface :
lockContext();
EWOL_INFO("OS_Suspend..."); EWOL_INFO("OS_Suspend...");
m_previousDisplayTime = -1; m_previousDisplayTime = -1;
if (m_windowsCurrent != nullptr) { if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateSuspend(); m_windowsCurrent->onStateSuspend();
} }
// release the curent interface : // release the curent interface :
unLockContext();
} }
void ewol::Context::OS_Resume() { void ewol::Context::OS_Resume() {
// set the curent interface : // set the curent interface :
lockContext();
EWOL_INFO("OS_Resume..."); EWOL_INFO("OS_Resume...");
m_previousDisplayTime = ewol::getTime(); m_previousDisplayTime = ewol::getTime();
m_objectManager.timeCallResume(m_previousDisplayTime); m_objectManager.timeCallResume(m_previousDisplayTime);
@ -514,28 +451,23 @@ void ewol::Context::OS_Resume() {
m_windowsCurrent->onStateResume(); m_windowsCurrent->onStateResume();
} }
// release the curent interface : // release the curent interface :
unLockContext();
} }
void ewol::Context::OS_Foreground() { void ewol::Context::OS_Foreground() {
// set the curent interface : // set the curent interface :
lockContext();
EWOL_INFO("OS_Foreground..."); EWOL_INFO("OS_Foreground...");
if (m_windowsCurrent != nullptr) { if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateForeground(); m_windowsCurrent->onStateForeground();
} }
// release the curent interface : // release the curent interface :
unLockContext();
} }
void ewol::Context::OS_Background() { void ewol::Context::OS_Background() {
// set the curent interface : // set the curent interface :
lockContext();
EWOL_INFO("OS_Background..."); EWOL_INFO("OS_Background...");
if (m_windowsCurrent != nullptr) { if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateBackground(); m_windowsCurrent->onStateBackground();
} }
// release the curent interface : // release the curent interface :
unLockContext();
} }
*/ */

View File

@ -65,18 +65,6 @@ namespace ewol {
virtual ~Context(); virtual ~Context();
private: private:
ewol::context::InputManager m_input; ewol::context::InputManager m_input;
protected:
/**
* @brief set the curent interface.
* @note this lock the main mutex
*/
void lockContext();
/**
* @brief set the curent interface at nullptr.
* @note this un-lock the main mutex
*/
void unLockContext();
public: // herited function: public: // herited function:
virtual void onCreate(gale::Context& _context); virtual void onCreate(gale::Context& _context);
virtual void onStart(gale::Context& _context); virtual void onStart(gale::Context& _context);
@ -140,6 +128,8 @@ namespace ewol {
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute * @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/ */
void inputEventUnGrabPointer(); void inputEventUnGrabPointer();
// herited function:
virtual void onResize(const ivec2& _size);
#if 0 #if 0
/** /**
* @brief Inform the Gui that we want to have a copy of the clipboard * @brief Inform the Gui that we want to have a copy of the clipboard

View File

@ -145,15 +145,16 @@ bool ewol::Object::parameterSetOnWidgetNamed(const std::string& _objectName, con
return object->parameterSet(_config, _value); return object->parameterSet(_config, _value);
} }
ewol::object::Manager& ewol::Object::getObjectManager() const { ewol::object::Manager& ewol::Object::getObjectManager() {
ewol::object::Manager& tmp = ewol::getContext().getEObjectManager(); ewol::object::Manager& tmp = ewol::getContext().getEObjectManager();
return tmp; return tmp;
} }
ewol::Context& ewol::Object::getContext() const { ewol::Context& ewol::Object::getContext() {
return ewol::getContext(); return ewol::getContext();
} }
std::shared_ptr<ewol::Object> ewol::Object::getObjectNamed(const std::string& _objectName) const {
std::shared_ptr<ewol::Object> ewol::Object::getObjectNamed(const std::string& _objectName) {
return getObjectManager().getObjectNamed(_objectName); return getObjectManager().getObjectNamed(_objectName);
} }
@ -171,4 +172,5 @@ bool ewol::parameterSetOnObjectNamed(const std::string& _objectName, const std::
return false; return false;
} }
return object->parameterSet(_config, _value); return object->parameterSet(_config, _value);
} }

View File

@ -45,6 +45,32 @@ namespace ewol {
return object; \ return object; \
} }
#define DECLARE_SINGLE_FACTORY(className,uniqueName) \
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
std::shared_ptr<className> object; \
std::shared_ptr<ewol::Object> object2 = getObjectNamed(uniqueName); \
if (object2 != nullptr) { \
object = std::dynamic_pointer_cast<className>(object2); \
if (object == nullptr) { \
GALE_CRITICAL("Request object element: '" << uniqueName << "' With the wrong type (dynamic cast error)"); \
return nullptr; \
} \
} \
if (object != nullptr) { \
return object; \
} \
object = std::shared_ptr<className>(new className()); \
if (object == nullptr) { \
EWOL_ERROR("Factory error"); \
return nullptr; \
} \
object->init(uniqueName, std::forward<T>(all)... ); \
if (object->objectHasBeenCorectlyInit() == false) { \
EWOL_CRITICAL("Object is not correctly init : " << #className ); \
} \
return object; \
}
namespace ewol { namespace ewol {
/** /**
* @brief Basic message classes for ewol system * @brief Basic message classes for ewol system
@ -181,12 +207,12 @@ namespace ewol {
* @breif get the current Object manager. * @breif get the current Object manager.
* @return the requested object manager. * @return the requested object manager.
*/ */
ewol::object::Manager& getObjectManager() const; static ewol::object::Manager& getObjectManager();
/** /**
* @brief get the curent the system inteface. * @brief get the curent the system inteface.
* @return current reference on the instance. * @return current reference on the instance.
*/ */
ewol::Context& getContext() const; static ewol::Context& getContext();
private: private:
bool m_isResource; //!< enable this when you want to declare this element is auto-remove bool m_isResource; //!< enable this when you want to declare this element is auto-remove
public: public:
@ -210,7 +236,7 @@ namespace ewol {
* @param[in] _name Name of the object * @param[in] _name Name of the object
* @return the requested object or nullptr * @return the requested object or nullptr
*/ */
std::shared_ptr<ewol::Object> getObjectNamed(const std::string& _objectName) const; static std::shared_ptr<ewol::Object> getObjectNamed(const std::string& _objectName);
/** /**
* @brief Retrive an object with his name (in the global list) * @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object * @param[in] _name Name of the object

View File

@ -41,22 +41,24 @@ void ewol::resource::Texture::init() {
gale::Resource::init(); gale::Resource::init();
} }
ewol::resource::Texture::Texture() { ewol::resource::Texture::Texture() :
m_texId(0),
m_endPointSize(1,1),
m_loaded(false) {
addResourceType("ewol::compositing::Texture"); addResourceType("ewol::compositing::Texture");
m_loaded = false;
m_texId = 0;
m_endPointSize.setValue(1.0,1.0);
} }
ewol::resource::Texture::~Texture() { ewol::resource::Texture::~Texture() {
removeContext(); removeContext();
} }
#include <egami/wrapperBMP.h>
void ewol::resource::Texture::updateContext() { void ewol::resource::Texture::updateContext() {
if (false == m_loaded) { if (false == m_loaded) {
// Request a new texture at openGl : // Request a new texture at openGl :
glGenTextures(1, &m_texId); glGenTextures(1, &m_texId);
} }
EWOL_ERROR("plop : load the image:" << m_name);
// in all case we set the texture properties : // in all case we set the texture properties :
// TODO : check error ??? // TODO : check error ???
glBindTexture(GL_TEXTURE_2D, m_texId); glBindTexture(GL_TEXTURE_2D, m_texId);
@ -70,6 +72,7 @@ void ewol::resource::Texture::updateContext() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" <<m_texId); EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" <<m_texId);
//egami::storeBMP("~/bbb_image.bmp", m_data);
glTexImage2D(GL_TEXTURE_2D, // Target glTexImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
GL_RGBA, // Format internal GL_RGBA, // Format internal

View File

@ -16,8 +16,9 @@
namespace ewol { namespace ewol {
namespace resource { namespace resource {
class Texture : public gale::resource::Texture { class Texture : public gale::Resource {
protected: protected:
uint32_t m_texId; //!< openGl textureID.
// openGl Context propoerties : // openGl Context propoerties :
egami::Image m_data; egami::Image m_data;
// some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0 // some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0
@ -44,6 +45,12 @@ namespace ewol {
void updateContext(); void updateContext();
void removeContext(); void removeContext();
void removeContextToLate(); void removeContextToLate();
const ivec2& getOpenGlSize() const {
return m_data.getSize();
};
uint32_t getRendererId() const {
return m_texId;
};
}; };
}; };
}; };

View File

@ -73,7 +73,7 @@ std::shared_ptr<ewol::Widget> ewol::widget::Windows::getWidgetAtPos(const vec2&
} }
void ewol::widget::Windows::sysDraw() { void ewol::widget::Windows::sysDraw() {
//EWOL_DEBUG("Drow on " << m_size); EWOL_DEBUG("Drow on " << m_size);
// set the size of the open GL system // set the size of the open GL system
gale::openGL::setViewPort(vec2(0,0), m_size); gale::openGL::setViewPort(vec2(0,0), m_size);
gale::openGL::disable(gale::openGL::flag_dither); gale::openGL::disable(gale::openGL::flag_dither);
@ -121,18 +121,17 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) {
#ifdef TEST_PERFO_WINDOWS #ifdef TEST_PERFO_WINDOWS
int64_t ___startTime0 = ewol::getTime(); int64_t ___startTime0 = ewol::getTime();
#endif #endif
// clear the screen with transparency ... // clear the screen with transparency ...
etk::Color<float> colorBg(0.5, 0.5, 0.5, 0.5); etk::Color<float> colorBg(0.5, 0.5, 0.5, 0.5);
if (m_colorProperty != nullptr) { if (m_colorProperty != nullptr) {
colorBg = m_colorProperty->get(m_colorBg); colorBg = m_colorProperty->get(m_colorBg);
} }
glClearColor(colorBg.r(), colorBg.g(), colorBg.b(), colorBg.a()); gale::openGL::clearColor(colorBg);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gale::openGL::clear( gale::openGL::clearFlag_colorBuffer
| gale::openGL::clearFlag_depthBuffer);
#ifdef TEST_PERFO_WINDOWS #ifdef TEST_PERFO_WINDOWS
float ___localTime0 = (float)(ewol::getTime() - ___startTime0) / 1000.0f; float ___localTime0 = (float)(ewol::getTime() - ___startTime0) / 1000.0f;
EWOL_ERROR(" Windows000 : " << ___localTime0 << "ms "); EWOL_ERROR(" Windows000 : " << ___localTime0 << "ms ");
int64_t ___startTime1 = ewol::getTime(); int64_t ___startTime1 = ewol::getTime();
#endif #endif
//EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId); //EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId);
@ -144,7 +143,6 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) {
#ifdef TEST_PERFO_WINDOWS #ifdef TEST_PERFO_WINDOWS
float ___localTime1 = (float)(ewol::getTime() - ___startTime1) / 1000.0f; float ___localTime1 = (float)(ewol::getTime() - ___startTime1) / 1000.0f;
EWOL_ERROR(" Windows111 : " << ___localTime1 << "ms "); EWOL_ERROR(" Windows111 : " << ___localTime1 << "ms ");
int64_t ___startTime2 = ewol::getTime(); int64_t ___startTime2 = ewol::getTime();
#endif #endif
// second display the pop-up // second display the pop-up

View File

@ -19,12 +19,12 @@ appl::Windows::Windows() {
} }
void appl::Windows::init() { void appl::Windows::init() {
ewol::widget::Windows::init(); ewol::widget::Windows::init();
setTitle("example 001_HelloWord"); setTitle("example 001_HelloWorld");
std::shared_ptr<ewol::widget::Label> tmpWidget = ewol::widget::Label::create(); std::shared_ptr<ewol::widget::Label> tmpWidget = ewol::widget::Label::create();
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
APPL_ERROR("Can not allocate widget ==> display might be in error"); APPL_ERROR("Can not allocate widget ==> display might be in error");
} else { } else {
tmpWidget->setLabel("Hello <font color=\"blue\">Word</font>"); tmpWidget->setLabel("Hello <font color=\"blue\">World</font>");
tmpWidget->setExpand(bvec2(true,true)); tmpWidget->setExpand(bvec2(true,true));
setSubWidget(tmpWidget); setSubWidget(tmpWidget);
} }