[DEV] update of external of elog and ethread

This commit is contained in:
Edouard DUPIN 2016-03-08 21:29:34 +01:00
parent 3aafd851dc
commit dd58d4e668
18 changed files with 119 additions and 115 deletions

@ -38,29 +38,29 @@ gale::Thread::~Thread() {
void gale::Thread::start() { void gale::Thread::start() {
if (m_state == state_stop) { if (m_state == state_stop) {
GALE_DEBUG("Allocate std11::thread [START]"); GALE_DEBUG("Allocate std::thread [START]");
m_state = state_starting; m_state = state_starting;
m_context = &gale::getContext(); m_context = &gale::getContext();
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
pthread_create(&m_thread, nullptr, &gale::Thread::threadCallback, this); pthread_create(&m_thread, nullptr, &gale::Thread::threadCallback, this);
#else #else
m_thread = std11::make_shared<std11::thread>(&gale::Thread::threadCall, this); m_thread = std::make_shared<std::thread>(&gale::Thread::threadCall, this);
if (m_thread == nullptr) { if (m_thread == nullptr) {
GALE_ERROR("Can not create thread ..."); GALE_ERROR("Can not create thread ...");
return; return;
} }
#endif #endif
//m_thread->detach(); //m_thread->detach();
GALE_DEBUG("Allocate std11::thread [Set priority]"); GALE_DEBUG("Allocate std::thread [Set priority]");
// set priority // set priority
GALE_DEBUG("Allocate std11::thread [Register context]"); GALE_DEBUG("Allocate std::thread [Register context]");
// set association with the gale context ... // set association with the gale context ...
//gale::contextRegisterThread(m_thread); //gale::contextRegisterThread(m_thread);
GALE_DEBUG("Allocate std11::thread [set State]"); GALE_DEBUG("Allocate std::thread [set State]");
m_state = state_running; m_state = state_running;
GALE_DEBUG("Allocate std11::thread [STOP]"); GALE_DEBUG("Allocate std::thread [STOP]");
} }
} }
@ -74,7 +74,7 @@ void gale::Thread::stop() {
GALE_INFO("wait Thread stopping"); GALE_INFO("wait Thread stopping");
std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::this_thread::sleep_for(std::chrono::milliseconds(500));
} }
GALE_DEBUG("stop std11::thread [START]"); GALE_DEBUG("stop std::thread [START]");
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
void* ret = nullptr; void* ret = nullptr;
int val = pthread_join(m_thread, &ret); int val = pthread_join(m_thread, &ret);
@ -82,15 +82,15 @@ void gale::Thread::stop() {
m_thread->join(); m_thread->join();
#endif #endif
//gale::contextUnRegisterThread(m_thread); //gale::contextUnRegisterThread(m_thread);
GALE_DEBUG("stop std11::thread [delete]"); GALE_DEBUG("stop std::thread [delete]");
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
#else #else
m_thread.reset(); m_thread.reset();
#endif #endif
GALE_DEBUG("stop std11::thread [set state]"); GALE_DEBUG("stop std::thread [set state]");
m_state = state_stop; m_state = state_stop;
GALE_DEBUG("stop std11::thread [STOP]"); GALE_DEBUG("stop std::thread [STOP]");
} }
void gale::Thread::threadCall() { void gale::Thread::threadCall() {
@ -98,12 +98,12 @@ void gale::Thread::threadCall() {
gale::setContext(m_context); gale::setContext(m_context);
while (m_state != state_stopping) { while (m_state != state_stopping) {
if (m_state == state_starting) { if (m_state == state_starting) {
GALE_DEBUG("run std11::thread [NOTHING to do]"); GALE_DEBUG("run std::thread [NOTHING to do]");
usleep(1000); usleep(1000);
continue; continue;
} }
if (onThreadCall() == true) { if (onThreadCall() == true) {
GALE_DEBUG("run std11::thread [AUTO STOP]"); GALE_DEBUG("run std::thread [AUTO STOP]");
m_state = state_stopping; m_state = state_stopping;
return; return;
} }

@ -8,7 +8,7 @@
#pragma once #pragma once
#include <etk/types.h> #include <etk/types.h>
#include <etk/thread/tools.h> #include <ethread/tools.h>
#include <gale/context/Context.h> #include <gale/context/Context.h>
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
@ -34,7 +34,7 @@ namespace gale {
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
pthread_t m_thread; pthread_t m_thread;
#else #else
std11::shared_ptr<std11::thread> m_thread; std::shared_ptr<std::thread> m_thread;
#endif #endif
gale::Context* m_context; gale::Context* m_context;
public: public:

@ -13,7 +13,7 @@
#include <etk/tool.h> #include <etk/tool.h>
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#include <etk/thread/tools.h> #include <ethread/tools.h>
#include <mutex> #include <mutex>
#include <gale/gale.h> #include <gale/gale.h>
@ -39,16 +39,16 @@ static std::mutex& mutexInterface() {
} }
static std11::mutex g_lockContextMap; static std::mutex g_lockContextMap;
static std::map<std11::thread::id, gale::Context*>& getContextList() { static std::map<std::thread::id, gale::Context*>& getContextList() {
static std::map<std11::thread::id, gale::Context*> g_val; static std::map<std::thread::id, gale::Context*> g_val;
return g_val; return g_val;
} }
gale::Context& gale::getContext() { gale::Context& gale::getContext() {
std::map<std11::thread::id, gale::Context*>& list = getContextList(); std::map<std::thread::id, gale::Context*>& list = getContextList();
g_lockContextMap.lock(); g_lockContextMap.lock();
std::map<std11::thread::id, gale::Context*>::iterator it = list.find(std11::this_thread::get_id()); std::map<std::thread::id, gale::Context*>::iterator it = list.find(std::this_thread::get_id());
gale::Context* out = nullptr; gale::Context* out = nullptr;
if (it != list.end()) { if (it != list.end()) {
out = it->second; out = it->second;
@ -64,42 +64,42 @@ gale::Context& gale::getContext() {
} }
void gale::setContext(gale::Context* _context) { void gale::setContext(gale::Context* _context) {
std::map<std11::thread::id, gale::Context*>& list = getContextList(); std::map<std::thread::id, gale::Context*>& list = getContextList();
//GALE_ERROR("Set context : " << std11::this_thread::get_id() << " context pointer : " << uint64_t(_context)); //GALE_ERROR("Set context : " << std::this_thread::get_id() << " context pointer : " << uint64_t(_context));
g_lockContextMap.lock(); g_lockContextMap.lock();
std::map<std11::thread::id, gale::Context*>::iterator it = list.find(std11::this_thread::get_id()); std::map<std::thread::id, gale::Context*>::iterator it = list.find(std::this_thread::get_id());
if (it == list.end()) { if (it == list.end()) {
list.insert(std::pair<std11::thread::id, gale::Context*>(std11::this_thread::get_id(), _context)); list.insert(std::pair<std::thread::id, gale::Context*>(std::this_thread::get_id(), _context));
} else { } else {
it->second = _context; it->second = _context;
} }
g_lockContextMap.unlock(); g_lockContextMap.unlock();
} }
void gale::contextRegisterThread(std11::thread* _thread) { void gale::contextRegisterThread(std::thread* _thread) {
if (_thread == nullptr) { if (_thread == nullptr) {
return; return;
} }
gale::Context* context = &gale::getContext(); gale::Context* context = &gale::getContext();
std::map<std11::thread::id, gale::Context*>& list = getContextList(); std::map<std::thread::id, gale::Context*>& list = getContextList();
//GALE_ERROR("REGISTER Thread : " << _thread->get_id() << " context pointer : " << uint64_t(context)); //GALE_ERROR("REGISTER Thread : " << _thread->get_id() << " context pointer : " << uint64_t(context));
g_lockContextMap.lock(); g_lockContextMap.lock();
std::map<std11::thread::id, gale::Context*>::iterator it = list.find(_thread->get_id()); std::map<std::thread::id, gale::Context*>::iterator it = list.find(_thread->get_id());
if (it == list.end()) { if (it == list.end()) {
list.insert(std::pair<std11::thread::id, gale::Context*>(_thread->get_id(), context)); list.insert(std::pair<std::thread::id, gale::Context*>(_thread->get_id(), context));
} else { } else {
it->second = context; it->second = context;
} }
g_lockContextMap.unlock(); g_lockContextMap.unlock();
} }
void gale::contextUnRegisterThread(std11::thread* _thread) { void gale::contextUnRegisterThread(std::thread* _thread) {
if (_thread == nullptr) { if (_thread == nullptr) {
return; return;
} }
std::map<std11::thread::id, gale::Context*>& list = getContextList(); std::map<std::thread::id, gale::Context*>& list = getContextList();
g_lockContextMap.lock(); g_lockContextMap.lock();
std::map<std11::thread::id, gale::Context*>::iterator it = list.find(_thread->get_id()); std::map<std::thread::id, gale::Context*>::iterator it = list.find(_thread->get_id());
if (it != list.end()) { if (it != list.end()) {
list.erase(it); list.erase(it);
} }
@ -204,7 +204,7 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
m_FpsFlush( "Flush ", false), m_FpsFlush( "Flush ", false),
m_windowsSize(320,480) { m_windowsSize(320,480) {
// set a basic // set a basic
etk::thread::setName("galeThread"); ethread::setName("galeThread");
if (m_application == nullptr) { if (m_application == nullptr) {
GALE_CRITICAL("Can not start context with no Application ==> rtfm ..."); GALE_CRITICAL("Can not start context with no Application ==> rtfm ...");
} }

@ -21,7 +21,7 @@
#include <memory> #include <memory>
#include <gale/orientation.h> #include <gale/orientation.h>
#include <gale/context/clipBoard.h> #include <gale/context/clipBoard.h>
#include <etk/thread/tools.h> #include <ethread/tools.h>
#define MAX_MANAGE_INPUT (15) #define MAX_MANAGE_INPUT (15)
@ -308,11 +308,11 @@ namespace gale {
* @brief When a new thread is created, it is needed to register it in the gale context interface to permit to get the context associated on it ... * @brief When a new thread is created, it is needed to register it in the gale context interface to permit to get the context associated on it ...
* @param[in] _thread generic C++11 thread handle * @param[in] _thread generic C++11 thread handle
*/ */
void contextRegisterThread(std11::thread* _thread); void contextRegisterThread(std::thread* _thread);
/** /**
* @brief Remove an associated thread * @brief Remove an associated thread
* @param[in] _thread generic C++11 thread handle * @param[in] _thread generic C++11 thread handle
*/ */
void contextUnRegisterThread(std11::thread* _thread); void contextUnRegisterThread(std::thread* _thread);
} }

@ -9,6 +9,6 @@
#include <gale/debug.h> #include <gale/debug.h>
int32_t gale::getLogId() { int32_t gale::getLogId() {
static int32_t g_val = etk::log::registerInstance("gale"); static int32_t g_val = elog::registerInstance("gale");
return g_val; return g_val;
} }

@ -7,12 +7,12 @@
*/ */
#pragma once #pragma once
#include <etk/log.h> #include <elog/log.h>
namespace gale { namespace gale {
int32_t getLogId(); int32_t getLogId();
}; };
#define GALE_BASE(info,data) TK_LOG_BASE(gale::getLogId(),info,data) #define GALE_BASE(info,data) ELOG_BASE(gale::getLogId(),info,data)
#define GALE_PRINT(data) GALE_BASE(-1, data) #define GALE_PRINT(data) GALE_BASE(-1, data)
#define GALE_CRITICAL(data) GALE_BASE(1, data) #define GALE_CRITICAL(data) GALE_BASE(1, data)

@ -7,6 +7,7 @@
*/ */
#include <gale/key/Special.h> #include <gale/key/Special.h>
#include <etk/stdTools.h>
#define GALE_FLAG_KEY_CAPS_LOCK 0x00000001 #define GALE_FLAG_KEY_CAPS_LOCK 0x00000001
#define GALE_FLAG_KEY_SHIFT 0x00000002 #define GALE_FLAG_KEY_SHIFT 0x00000002

@ -7,6 +7,7 @@
*/ */
#include <gale/key/keyboard.h> #include <gale/key/keyboard.h>
#include <etk/stdTools.h>
static const char* keyboardDescriptionString[] = { static const char* keyboardDescriptionString[] = {
"keyboard_unknow", "keyboard_unknow",

@ -7,6 +7,7 @@
*/ */
#include <gale/key/status.h> #include <gale/key/status.h>
#include <etk/stdTools.h>
static const char* statusDescriptionString[] = { static const char* statusDescriptionString[] = {
"status_unknow", "status_unknow",

@ -7,6 +7,7 @@
*/ */
#include <gale/key/type.h> #include <gale/key/type.h>
#include <etk/stdTools.h>
static const char* typeDescriptionString[] = { static const char* typeDescriptionString[] = {

@ -13,7 +13,7 @@
#include <mutex> #include <mutex>
//#define DIRECT_MODE //#define DIRECT_MODE
#include <gale/renderer/openGL/openGL-include.h> #include <gale/renderer/openGL/openGL-include.h>
#include <etk/thread/tools.h> #include <ethread/tools.h>
#define CHECK_ERROR_OPENGL #define CHECK_ERROR_OPENGL
@ -84,15 +84,15 @@ void gale::openGL::unLock() {
mutexOpenGl().unlock(); mutexOpenGl().unlock();
} }
static std::vector<std11::thread::id>& getContextList() { static std::vector<std::thread::id>& getContextList() {
static std::vector<std11::thread::id> g_val; static std::vector<std::thread::id> g_val;
return g_val; return g_val;
} }
bool gale::openGL::hasContext() { bool gale::openGL::hasContext() {
bool ret = false; bool ret = false;
mutexOpenGl().lock(); mutexOpenGl().lock();
auto it = std::find(getContextList().begin(), getContextList().end(), std11::this_thread::get_id()); auto it = std::find(getContextList().begin(), getContextList().end(), std::this_thread::get_id());
if (it != getContextList().end()) { if (it != getContextList().end()) {
ret = true; ret = true;
} }
@ -102,18 +102,18 @@ bool gale::openGL::hasContext() {
void gale::openGL::threadHasContext() { void gale::openGL::threadHasContext() {
mutexOpenGl().lock(); mutexOpenGl().lock();
auto it = std::find(getContextList().begin(), getContextList().end(), std11::this_thread::get_id()); auto it = std::find(getContextList().begin(), getContextList().end(), std::this_thread::get_id());
if (it != getContextList().end()) { if (it != getContextList().end()) {
GALE_ERROR("set openGL context associate with threadID a second time ... "); GALE_ERROR("set openGL context associate with threadID a second time ... ");
} else { } else {
getContextList().push_back(std11::this_thread::get_id()); getContextList().push_back(std::this_thread::get_id());
} }
mutexOpenGl().unlock(); mutexOpenGl().unlock();
} }
void gale::openGL::threadHasNoMoreContext() { void gale::openGL::threadHasNoMoreContext() {
mutexOpenGl().lock(); mutexOpenGl().lock();
auto it = std::find(getContextList().begin(), getContextList().end(), std11::this_thread::get_id()); auto it = std::find(getContextList().begin(), getContextList().end(), std::this_thread::get_id());
if (it != getContextList().end()) { if (it != getContextList().end()) {
getContextList().erase(it); getContextList().erase(it);
} else { } else {

@ -21,7 +21,7 @@ gale::resource::Manager::Manager() :
} }
gale::resource::Manager::~Manager() { gale::resource::Manager::~Manager() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
bool hasError = false; bool hasError = false;
if (m_resourceListToUpdate.size()!=0) { if (m_resourceListToUpdate.size()!=0) {
GALE_ERROR("Must not have anymore resources to update !!!"); GALE_ERROR("Must not have anymore resources to update !!!");
@ -38,7 +38,7 @@ gale::resource::Manager::~Manager() {
} }
void gale::resource::Manager::unInit() { void gale::resource::Manager::unInit() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
display(); display();
m_resourceListToUpdate.clear(); m_resourceListToUpdate.clear();
// remove all resources ... // remove all resources ...
@ -59,7 +59,7 @@ void gale::resource::Manager::unInit() {
void gale::resource::Manager::display() { void gale::resource::Manager::display() {
GALE_INFO("Resources loaded : "); GALE_INFO("Resources loaded : ");
// remove all resources ... // remove all resources ...
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
for (auto &it : m_resourceList) { for (auto &it : m_resourceList) {
std::shared_ptr<gale::Resource> tmpRessource = it.lock(); std::shared_ptr<gale::Resource> tmpRessource = it.lock();
if (tmpRessource != nullptr) { if (tmpRessource != nullptr) {
@ -75,7 +75,7 @@ void gale::resource::Manager::display() {
void gale::resource::Manager::reLoadResources() { void gale::resource::Manager::reLoadResources() {
GALE_INFO("------------- Resources re-loaded -------------"); GALE_INFO("------------- Resources re-loaded -------------");
// remove all resources ... // remove all resources ...
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_resourceList.size() != 0) { if (m_resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) { for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
GALE_INFO(" Reload level : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1)); GALE_INFO(" Reload level : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
@ -97,7 +97,7 @@ void gale::resource::Manager::reLoadResources() {
void gale::resource::Manager::update(const std::shared_ptr<gale::Resource>& _object) { void gale::resource::Manager::update(const std::shared_ptr<gale::Resource>& _object) {
// chek if not added before // chek if not added before
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
for (auto &it : m_resourceListToUpdate) { for (auto &it : m_resourceListToUpdate) {
if ( it != nullptr if ( it != nullptr
&& it == _object) { && it == _object) {
@ -117,7 +117,7 @@ void gale::resource::Manager::updateContext() {
m_contextHasBeenRemoved = false; m_contextHasBeenRemoved = false;
std::list<std::weak_ptr<gale::Resource>> resourceList; std::list<std::weak_ptr<gale::Resource>> resourceList;
{ {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// Clean the update list // Clean the update list
m_resourceListToUpdate.clear(); m_resourceListToUpdate.clear();
resourceList = m_resourceList; resourceList = m_resourceList;
@ -132,7 +132,7 @@ void gale::resource::Manager::updateContext() {
//GALE_DEBUG("Update context named : " << l_resourceList[iii]->getName()); //GALE_DEBUG("Update context named : " << l_resourceList[iii]->getName());
if (tmpRessource->updateContext() == false) { if (tmpRessource->updateContext() == false) {
// Lock error ==> postponned // Lock error ==> postponned
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_resourceListToUpdate.push_back(tmpRessource); m_resourceListToUpdate.push_back(tmpRessource);
} }
} }
@ -142,7 +142,7 @@ void gale::resource::Manager::updateContext() {
} else { } else {
std::vector<std::shared_ptr<gale::Resource>> resourceListToUpdate; std::vector<std::shared_ptr<gale::Resource>> resourceListToUpdate;
{ {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
resourceListToUpdate = m_resourceListToUpdate; resourceListToUpdate = m_resourceListToUpdate;
// Clean the update list // Clean the update list
m_resourceListToUpdate.clear(); m_resourceListToUpdate.clear();
@ -154,7 +154,7 @@ void gale::resource::Manager::updateContext() {
if ( it != nullptr if ( it != nullptr
&& jjj == it->getResourceLevel()) { && jjj == it->getResourceLevel()) {
if (it->updateContext() == false) { if (it->updateContext() == false) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// Lock error ==> postponned // Lock error ==> postponned
m_resourceListToUpdate.push_back(it); m_resourceListToUpdate.push_back(it);
} }
@ -167,7 +167,7 @@ void gale::resource::Manager::updateContext() {
// in this case, it is really too late ... // in this case, it is really too late ...
void gale::resource::Manager::contextHasBeenDestroyed() { void gale::resource::Manager::contextHasBeenDestroyed() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
for (auto &it : m_resourceList) { for (auto &it : m_resourceList) {
std::shared_ptr<gale::Resource> tmpRessource = it.lock(); std::shared_ptr<gale::Resource> tmpRessource = it.lock();
if (tmpRessource != nullptr) { if (tmpRessource != nullptr) {
@ -180,7 +180,7 @@ void gale::resource::Manager::contextHasBeenDestroyed() {
// internal generic keeper ... // internal generic keeper ...
std::shared_ptr<gale::Resource> gale::resource::Manager::localKeep(const std::string& _filename) { std::shared_ptr<gale::Resource> gale::resource::Manager::localKeep(const std::string& _filename) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
GALE_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources"); GALE_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources");
for (auto &it : m_resourceList) { for (auto &it : m_resourceList) {
std::shared_ptr<gale::Resource> tmpRessource = it.lock(); std::shared_ptr<gale::Resource> tmpRessource = it.lock();
@ -195,7 +195,7 @@ std::shared_ptr<gale::Resource> gale::resource::Manager::localKeep(const std::st
// internal generic keeper ... // internal generic keeper ...
void gale::resource::Manager::localAdd(const std::shared_ptr<gale::Resource>& _object) { void gale::resource::Manager::localAdd(const std::shared_ptr<gale::Resource>& _object) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
//Add ... find empty slot //Add ... find empty slot
for (auto &it : m_resourceList) { for (auto &it : m_resourceList) {
std::shared_ptr<gale::Resource> tmpRessource = it.lock(); std::shared_ptr<gale::Resource> tmpRessource = it.lock();
@ -210,7 +210,7 @@ void gale::resource::Manager::localAdd(const std::shared_ptr<gale::Resource>& _o
// in case of error ... // in case of error ...
void gale::resource::Manager::cleanInternalRemoved() { void gale::resource::Manager::cleanInternalRemoved() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
//GALE_INFO("remove object in Manager"); //GALE_INFO("remove object in Manager");
updateContext(); updateContext();
for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) { for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) {

@ -20,7 +20,7 @@ namespace gale {
std::list<std::weak_ptr<gale::Resource>> m_resourceList; std::list<std::weak_ptr<gale::Resource>> m_resourceList;
std::vector<std::shared_ptr<gale::Resource>> m_resourceListToUpdate; std::vector<std::shared_ptr<gale::Resource>> m_resourceListToUpdate;
bool m_contextHasBeenRemoved; bool m_contextHasBeenRemoved;
std11::recursive_mutex m_mutex; std::recursive_mutex m_mutex;
public: public:
/** /**
* @brief initialize the internal variable * @brief initialize the internal variable

@ -32,7 +32,7 @@ gale::resource::Program::Program() :
void gale::resource::Program::init(const std::string& _filename) { void gale::resource::Program::init(const std::string& _filename) {
gale::Resource::init(_filename); gale::Resource::init(_filename);
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
GALE_DEBUG("OGL : load PROGRAM '" << m_name << "'"); GALE_DEBUG("OGL : load PROGRAM '" << m_name << "'");
// load data from file "all the time ..." // load data from file "all the time ..."
@ -167,7 +167,7 @@ static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
bool gale::resource::Program::checkIdValidity(int32_t _idElem) { bool gale::resource::Program::checkIdValidity(int32_t _idElem) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if ( _idElem < 0 if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) { || (size_t)_idElem > m_elementList.size()) {
return false; return false;
@ -176,7 +176,7 @@ bool gale::resource::Program::checkIdValidity(int32_t _idElem) {
} }
int32_t gale::resource::Program::getAttribute(std::string _elementName) { int32_t gale::resource::Program::getAttribute(std::string _elementName) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// check if it exist previously : // check if it exist previously :
for(size_t iii=0; iii<m_elementList.size(); iii++) { for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) { if (m_elementList[iii].m_name == _elementName) {
@ -209,7 +209,7 @@ int32_t gale::resource::Program::getAttribute(std::string _elementName) {
} }
int32_t gale::resource::Program::getUniform(std::string _elementName) { int32_t gale::resource::Program::getUniform(std::string _elementName) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// check if it exist previously : // check if it exist previously :
for(size_t iii=0; iii<m_elementList.size(); iii++) { for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) { if (m_elementList[iii].m_name == _elementName) {
@ -242,7 +242,7 @@ int32_t gale::resource::Program::getUniform(std::string _elementName) {
} }
bool gale::resource::Program::updateContext() { bool gale::resource::Program::updateContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex, std11::defer_lock); std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
if (lock.try_lock() == false) { if (lock.try_lock() == false) {
//Lock error ==> try later ... //Lock error ==> try later ...
return false; return false;
@ -307,7 +307,7 @@ bool gale::resource::Program::updateContext() {
} }
void gale::resource::Program::removeContext() { void gale::resource::Program::removeContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == true) { if (m_exist == true) {
gale::openGL::program::remove(m_program); gale::openGL::program::remove(m_program);
m_program = 0; m_program = 0;
@ -320,7 +320,7 @@ void gale::resource::Program::removeContext() {
} }
void gale::resource::Program::removeContextToLate() { void gale::resource::Program::removeContextToLate() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_exist = false; m_exist = false;
m_program = 0; m_program = 0;
} }
@ -370,7 +370,7 @@ void gale::resource::Program::sendAttribute(int32_t _idElem,
int32_t _nbElement, int32_t _nbElement,
const void* _pointer, const void* _pointer,
int32_t _jumpBetweenSample) { int32_t _jumpBetweenSample) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -399,7 +399,7 @@ void gale::resource::Program::sendAttributePointer(int32_t _idElem,
int32_t _index, int32_t _index,
int32_t _jumpBetweenSample, int32_t _jumpBetweenSample,
int32_t _offset) { int32_t _offset) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -437,7 +437,7 @@ void gale::resource::Program::sendAttributePointer(int32_t _idElem,
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose) { void gale::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -463,7 +463,7 @@ void gale::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1f(int32_t _idElem, float _value1) { void gale::resource::Program::uniform1f(int32_t _idElem, float _value1) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -478,7 +478,7 @@ void gale::resource::Program::uniform1f(int32_t _idElem, float _value1) {
checkGlError("glUniform1f", __LINE__, _idElem); checkGlError("glUniform1f", __LINE__, _idElem);
} }
void gale::resource::Program::uniform2f(int32_t _idElem, float _value1, float _value2) { void gale::resource::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -493,7 +493,7 @@ void gale::resource::Program::uniform2f(int32_t _idElem, float _value1, float _
checkGlError("glUniform2f", __LINE__, _idElem); checkGlError("glUniform2f", __LINE__, _idElem);
} }
void gale::resource::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) { void gale::resource::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -508,7 +508,7 @@ void gale::resource::Program::uniform3f(int32_t _idElem, float _value1, float _v
checkGlError("glUniform3f", __LINE__, _idElem); checkGlError("glUniform3f", __LINE__, _idElem);
} }
void gale::resource::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) { void gale::resource::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -526,7 +526,7 @@ void gale::resource::Program::uniform4f(int32_t _idElem, float _value1, float _v
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) { void gale::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -541,7 +541,7 @@ void gale::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) {
checkGlError("glUniform1i", __LINE__, _idElem); checkGlError("glUniform1i", __LINE__, _idElem);
} }
void gale::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) { void gale::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -556,7 +556,7 @@ void gale::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_
checkGlError("glUniform2i", __LINE__, _idElem); checkGlError("glUniform2i", __LINE__, _idElem);
} }
void gale::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) { void gale::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -571,7 +571,7 @@ void gale::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_
checkGlError("glUniform3i", __LINE__, _idElem); checkGlError("glUniform3i", __LINE__, _idElem);
} }
void gale::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) { void gale::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -590,7 +590,7 @@ void gale::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void gale::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -613,7 +613,7 @@ void gale::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, co
checkGlError("glUniform1fv", __LINE__, _idElem); checkGlError("glUniform1fv", __LINE__, _idElem);
} }
void gale::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void gale::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -636,7 +636,7 @@ void gale::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, co
checkGlError("glUniform2fv", __LINE__, _idElem); checkGlError("glUniform2fv", __LINE__, _idElem);
} }
void gale::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void gale::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -660,7 +660,7 @@ void gale::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, co
checkGlError("glUniform3fv", __LINE__, _idElem); checkGlError("glUniform3fv", __LINE__, _idElem);
} }
void gale::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void gale::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -687,7 +687,7 @@ void gale::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, co
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void gale::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -710,7 +710,7 @@ void gale::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, co
checkGlError("glUniform1iv", __LINE__, _idElem); checkGlError("glUniform1iv", __LINE__, _idElem);
} }
void gale::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void gale::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -733,7 +733,7 @@ void gale::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, co
checkGlError("glUniform2iv", __LINE__, _idElem); checkGlError("glUniform2iv", __LINE__, _idElem);
} }
void gale::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void gale::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -756,7 +756,7 @@ void gale::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, co
checkGlError("glUniform3iv", __LINE__, _idElem); checkGlError("glUniform3iv", __LINE__, _idElem);
} }
void gale::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void gale::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -798,7 +798,7 @@ void gale::resource::Program::use() {
void gale::resource::Program::setTexture0(int32_t _idElem, int64_t _textureOpenGlID) { void gale::resource::Program::setTexture0(int32_t _idElem, int64_t _textureOpenGlID) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -824,7 +824,7 @@ void gale::resource::Program::setTexture0(int32_t _idElem, int64_t _textureOpenG
} }
void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenGlID) { void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenGlID) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }
@ -852,7 +852,7 @@ void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenG
void gale::resource::Program::unUse() { void gale::resource::Program::unUse() {
//GALE_WARNING("Will use program : " << m_program); //GALE_WARNING("Will use program : " << m_program);
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_exist == false) { if (m_exist == false) {
return; return;
} }

@ -101,7 +101,7 @@ namespace gale {
*/ */
class Resource : public std::enable_shared_from_this<gale::Resource> { class Resource : public std::enable_shared_from_this<gale::Resource> {
protected: protected:
std11::recursive_mutex m_mutex; std::recursive_mutex m_mutex;
protected: protected:
/** /**
* @brief generic protected contructor (use factory to create this class) * @brief generic protected contructor (use factory to create this class)

@ -28,7 +28,7 @@ gale::resource::Shader::Shader() :
} }
void gale::resource::Shader::init(const std::string& _filename) { void gale::resource::Shader::init(const std::string& _filename) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
gale::Resource::init(_filename); gale::Resource::init(_filename);
GALE_DEBUG("OGL : load SHADER \"" << _filename << "\""); GALE_DEBUG("OGL : load SHADER \"" << _filename << "\"");
// load data from file "all the time ..." // load data from file "all the time ..."
@ -45,14 +45,14 @@ void gale::resource::Shader::init(const std::string& _filename) {
} }
gale::resource::Shader::~Shader() { gale::resource::Shader::~Shader() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_fileData.clear(); m_fileData.clear();
gale::openGL::shader::remove(m_shader); gale::openGL::shader::remove(m_shader);
m_exist = false; m_exist = false;
} }
bool gale::resource::Shader::updateContext() { bool gale::resource::Shader::updateContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex, std11::defer_lock); std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
if (lock.try_lock() == false) { if (lock.try_lock() == false) {
//Lock error ==> try later ... //Lock error ==> try later ...
return false; return false;
@ -88,7 +88,7 @@ bool gale::resource::Shader::updateContext() {
} }
void gale::resource::Shader::removeContext() { void gale::resource::Shader::removeContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (true == m_exist) { if (true == m_exist) {
gale::openGL::shader::remove(m_shader); gale::openGL::shader::remove(m_shader);
m_exist = false; m_exist = false;
@ -96,13 +96,13 @@ void gale::resource::Shader::removeContext() {
} }
void gale::resource::Shader::removeContextToLate() { void gale::resource::Shader::removeContextToLate() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_exist = false; m_exist = false;
m_shader = 0; m_shader = 0;
} }
void gale::resource::Shader::reload() { void gale::resource::Shader::reload() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
etk::FSNode file(m_name); etk::FSNode file(m_name);
if (false == file.exist()) { if (false == file.exist()) {
GALE_CRITICAL("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'"); GALE_CRITICAL("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'");

@ -57,7 +57,7 @@ gale::resource::Texture::~Texture() {
} }
bool gale::resource::Texture::updateContext() { bool gale::resource::Texture::updateContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex, std11::defer_lock); std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
if (lock.try_lock() == false) { if (lock.try_lock() == false) {
//Lock error ==> try later ... //Lock error ==> try later ...
return false; return false;
@ -94,7 +94,7 @@ bool gale::resource::Texture::updateContext() {
} }
void gale::resource::Texture::removeContext() { void gale::resource::Texture::removeContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (true == m_loaded) { if (true == m_loaded) {
// Request remove texture ... // Request remove texture ...
GALE_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); GALE_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
@ -104,13 +104,13 @@ void gale::resource::Texture::removeContext() {
} }
void gale::resource::Texture::removeContextToLate() { void gale::resource::Texture::removeContextToLate() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_loaded = false; m_loaded = false;
m_texId=0; m_texId=0;
} }
void gale::resource::Texture::flush() { void gale::resource::Texture::flush() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this())); getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this()));
} }
@ -119,7 +119,7 @@ void gale::resource::Texture::setTexture(const std::shared_ptr<std::vector<char>
const ivec2& _size, const ivec2& _size,
enum gale::resource::Texture::dataType _dataType, enum gale::resource::Texture::dataType _dataType,
enum gale::resource::Texture::color _dataColorSpace) { enum gale::resource::Texture::color _dataColorSpace) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_data = _data; m_data = _data;
m_size = _size; m_size = _size;
m_endPointSize = _size; m_endPointSize = _size;

@ -39,7 +39,7 @@ void gale::resource::VirtualBufferObject::retreiveData() {
} }
bool gale::resource::VirtualBufferObject::updateContext() { bool gale::resource::VirtualBufferObject::updateContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex, std11::defer_lock); std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
if (lock.try_lock() == false) { if (lock.try_lock() == false) {
//Lock error ==> try later ... //Lock error ==> try later ...
return false; return false;
@ -65,7 +65,7 @@ bool gale::resource::VirtualBufferObject::updateContext() {
} }
void gale::resource::VirtualBufferObject::removeContext() { void gale::resource::VirtualBufferObject::removeContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (true == m_exist) { if (true == m_exist) {
gale::openGL::deleteBuffers(m_vbo); gale::openGL::deleteBuffers(m_vbo);
m_exist = false; m_exist = false;
@ -73,7 +73,7 @@ void gale::resource::VirtualBufferObject::removeContext() {
} }
void gale::resource::VirtualBufferObject::removeContextToLate() { void gale::resource::VirtualBufferObject::removeContextToLate() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_exist = false; m_exist = false;
for (size_t iii=0; iii<m_vbo.size(); iii++) { for (size_t iii=0; iii<m_vbo.size(); iii++) {
m_vbo[iii] = 0; m_vbo[iii] = 0;
@ -81,19 +81,19 @@ void gale::resource::VirtualBufferObject::removeContextToLate() {
} }
void gale::resource::VirtualBufferObject::reload() { void gale::resource::VirtualBufferObject::reload() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
removeContext(); removeContext();
updateContext(); updateContext();
} }
void gale::resource::VirtualBufferObject::flush() { void gale::resource::VirtualBufferObject::flush() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this())); getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this()));
} }
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) { void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_vboSizeDataOffset[_id] == -1) { if (m_vboSizeDataOffset[_id] == -1) {
m_vboSizeDataOffset[_id] = 3; m_vboSizeDataOffset[_id] = 3;
} else if (m_vboSizeDataOffset[_id] != 3) { } else if (m_vboSizeDataOffset[_id] != 3) {
@ -107,7 +107,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3&
} }
vec3 gale::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID) { vec3 gale::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if ((size_t)_elementID*3 > m_buffer[_id].size()) { if ((size_t)_elementID*3 > m_buffer[_id].size()) {
return vec3(0,0,0); return vec3(0,0,0);
} }
@ -117,16 +117,16 @@ vec3 gale::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _
} }
int32_t gale::resource::VirtualBufferObject::bufferSize(int32_t _id) { int32_t gale::resource::VirtualBufferObject::bufferSize(int32_t _id) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
return m_buffer[_id].size()/m_vboSizeDataOffset[_id]; return m_buffer[_id].size()/m_vboSizeDataOffset[_id];
} }
int32_t gale::resource::VirtualBufferObject::getElementSize(int32_t _id) { int32_t gale::resource::VirtualBufferObject::getElementSize(int32_t _id) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
return m_vboSizeDataOffset[_id]; return m_vboSizeDataOffset[_id];
} }
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) { void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_vboSizeDataOffset[_id] == -1) { if (m_vboSizeDataOffset[_id] == -1) {
m_vboSizeDataOffset[_id] = 2; m_vboSizeDataOffset[_id] = 2;
} else if (m_vboSizeDataOffset[_id] != 2) { } else if (m_vboSizeDataOffset[_id] != 2) {
@ -139,7 +139,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2&
} }
vec2 gale::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID) { vec2 gale::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if ((size_t)_elementID*2 > m_buffer[_id].size()) { if ((size_t)_elementID*2 > m_buffer[_id].size()) {
return vec2(0,0); return vec2(0,0);
} }
@ -149,7 +149,7 @@ vec2 gale::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data) { void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_vboSizeDataOffset[_id] == -1) { if (m_vboSizeDataOffset[_id] == -1) {
m_vboSizeDataOffset[_id] = 4; m_vboSizeDataOffset[_id] = 4;
} else if (m_vboSizeDataOffset[_id] != 4) { } else if (m_vboSizeDataOffset[_id] != 4) {
@ -164,7 +164,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::C
} }
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,3>& _data) { void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,3>& _data) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_vboSizeDataOffset[_id] == -1) { if (m_vboSizeDataOffset[_id] == -1) {
m_vboSizeDataOffset[_id] = 3; m_vboSizeDataOffset[_id] = 3;
} else if (m_vboSizeDataOffset[_id] != 3) { } else if (m_vboSizeDataOffset[_id] != 3) {
@ -178,7 +178,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::C
} }
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,2>& _data) { void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,2>& _data) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_vboSizeDataOffset[_id] == -1) { if (m_vboSizeDataOffset[_id] == -1) {
m_vboSizeDataOffset[_id] = 2; m_vboSizeDataOffset[_id] = 2;
} else if (m_vboSizeDataOffset[_id] != 2) { } else if (m_vboSizeDataOffset[_id] != 2) {
@ -191,7 +191,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::C
} }
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,1>& _data) { void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,1>& _data) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (m_vboSizeDataOffset[_id] == -1) { if (m_vboSizeDataOffset[_id] == -1) {
m_vboSizeDataOffset[_id] = 1; m_vboSizeDataOffset[_id] = 1;
} else if (m_vboSizeDataOffset[_id] != 1) { } else if (m_vboSizeDataOffset[_id] != 1) {