[DEV] continue removing STL
This commit is contained in:
parent
dd88360740
commit
5df959666e
@ -8,23 +8,9 @@
|
||||
|
||||
#include <gale/context/Context.hpp>
|
||||
|
||||
#if defined(__TARGET_OS__Android)
|
||||
void* gale::Thread::threadCallback(void* _userData) {
|
||||
gale::Thread* threadHandle = static_cast<gale::Thread*>(_userData);
|
||||
if (threadHandle != nullptr) {
|
||||
threadHandle->threadCall();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
gale::Thread::Thread() :
|
||||
m_state(state::stop),
|
||||
#if !defined(__TARGET_OS__Android)
|
||||
m_thread(nullptr),
|
||||
#endif
|
||||
m_context(nullptr) {
|
||||
m_context(0) {
|
||||
GALE_INFO("Create new Thread");
|
||||
}
|
||||
|
||||
@ -39,16 +25,11 @@ void gale::Thread::start() {
|
||||
GALE_DEBUG("Allocate ethread::Thread [START]");
|
||||
m_state = state::starting;
|
||||
m_context = &gale::getContext();
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_create(&m_thread, nullptr, &gale::Thread::threadCallback, this);
|
||||
#else
|
||||
m_thread = ememory::makeShared<ethread::Thread>(&gale::Thread::threadCall, this);
|
||||
if (m_thread == nullptr) {
|
||||
GALE_ERROR("Can not create thread ...");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
//m_thread->detach();
|
||||
m_thread = ememory::makeShared<ethread::Thread>([=](){this->threadCall();}, "galeThread");
|
||||
if (m_thread == nullptr) {
|
||||
GALE_ERROR("Can not create thread ...");
|
||||
return;
|
||||
}
|
||||
GALE_DEBUG("Allocate ethread::Thread [Set priority]");
|
||||
// set priority
|
||||
|
||||
@ -72,22 +53,13 @@ void gale::Thread::stop() {
|
||||
|| m_state == state::starting) {
|
||||
// requesting a stop ...
|
||||
GALE_INFO("wait Thread stopping");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
ethread::sleepMilliSeconds((100));
|
||||
}
|
||||
GALE_DEBUG("stop ethread::Thread [START]");
|
||||
#if defined(__TARGET_OS__Android)
|
||||
void* ret = nullptr;
|
||||
int val = pthread_join(m_thread, &ret);
|
||||
#else
|
||||
m_thread->join();
|
||||
#endif
|
||||
m_thread->join();
|
||||
//gale::contextUnRegisterThread(m_thread);
|
||||
GALE_DEBUG("stop ethread::Thread [delete]");
|
||||
#if defined(__TARGET_OS__Android)
|
||||
|
||||
#else
|
||||
m_thread.reset();
|
||||
#endif
|
||||
m_thread.reset();
|
||||
GALE_DEBUG("stop ethread::Thread [set state]");
|
||||
m_state = state::stop;
|
||||
GALE_INFO("stop ethread::Thread [STOP]");
|
||||
@ -103,7 +75,7 @@ void gale::Thread::threadCall() {
|
||||
while (m_state != state::stopping) {
|
||||
if (m_state == state::starting) {
|
||||
GALE_DEBUG("run ethread::Thread [NOTHING to do]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
ethread::sleepMilliSeconds((1));
|
||||
continue;
|
||||
}
|
||||
if (m_name != "") {
|
||||
|
@ -9,11 +9,7 @@
|
||||
#include <ethread/tools.hpp>
|
||||
#include <gale/context/Context.hpp>
|
||||
|
||||
#if defined(__TARGET_OS__Android)
|
||||
#include <pthread.h>
|
||||
#else
|
||||
#include <ethread/Thread.hpp>
|
||||
#endif
|
||||
#include <ethread/Thread.hpp>
|
||||
|
||||
namespace gale {
|
||||
/**
|
||||
@ -39,11 +35,7 @@ namespace gale {
|
||||
*/
|
||||
enum gale::Thread::state getState();
|
||||
private:
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_t m_thread; //!< Current handle on the thread
|
||||
#else
|
||||
ememory::SharedPtr<ethread::Thread> m_thread; //!< Current handle on the thread
|
||||
#endif
|
||||
ememory::SharedPtr<ethread::Thread> m_thread; //!< Current handle on the thread
|
||||
gale::Context* m_context; //!< Copy of the gale context (permit to get current gale interface)
|
||||
public:
|
||||
/**
|
||||
@ -72,9 +64,6 @@ namespace gale {
|
||||
*/
|
||||
void setName(etk::String m_name);
|
||||
private:
|
||||
#if defined(__TARGET_OS__Android)
|
||||
static void* threadCallback(void* _userData);
|
||||
#endif
|
||||
/**
|
||||
* @brief Internal periodic call of the thead
|
||||
*/
|
||||
|
@ -7,7 +7,9 @@
|
||||
#include <jni.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <cstdint>
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
}
|
||||
#include <pthread.h>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <gale/debug.hpp>
|
||||
@ -502,7 +504,7 @@ extern "C" {
|
||||
jint _mode,
|
||||
jstring _myString,
|
||||
jstring _applicationName) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -535,7 +537,7 @@ extern "C" {
|
||||
jclass _classBase,
|
||||
jobject _objCallback,
|
||||
int _typeApplication) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Creating GALE context **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -565,7 +567,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
void Java_org_gale_Gale_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** remove JVM Pointer **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -583,7 +585,7 @@ extern "C" {
|
||||
s_listInstance[_id]=nullptr;
|
||||
}
|
||||
void Java_org_gale_Gale_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG(" == > Touch Event");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
@ -596,7 +598,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
void Java_org_gale_Gale_EWonCreate(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on Create **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -612,7 +614,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
void Java_org_gale_Gale_EWonStart(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on Start **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -627,7 +629,7 @@ extern "C" {
|
||||
//SendSystemMessage(" testmessages ... ");
|
||||
}
|
||||
void Java_org_gale_Gale_EWonReStart(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on Re-Start **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -641,7 +643,7 @@ extern "C" {
|
||||
s_listInstance[_id]->ANDROID_reStart();
|
||||
}
|
||||
void Java_org_gale_Gale_EWonResume(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on resume **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -655,7 +657,7 @@ extern "C" {
|
||||
s_listInstance[_id]->OS_Resume();
|
||||
}
|
||||
void Java_org_gale_Gale_EWonPause(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on pause **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -671,7 +673,7 @@ extern "C" {
|
||||
s_listInstance[_id]->OS_Suspend();
|
||||
}
|
||||
void Java_org_gale_Gale_EWonStop(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on Stop **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -685,7 +687,7 @@ extern "C" {
|
||||
s_listInstance[_id]->OS_Stop();
|
||||
}
|
||||
void Java_org_gale_Gale_EWonDestroy(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG("*******************************************");
|
||||
GALE_DEBUG("** Activity on Destroy **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
@ -711,7 +713,7 @@ extern "C" {
|
||||
jint _pointerID,
|
||||
jfloat _x,
|
||||
jfloat _y) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -732,7 +734,7 @@ extern "C" {
|
||||
jboolean _isDown,
|
||||
jfloat _x,
|
||||
jfloat _y) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr ) {
|
||||
@ -752,7 +754,7 @@ extern "C" {
|
||||
jint _pointerID,
|
||||
jfloat _x,
|
||||
jfloat _y) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -773,7 +775,7 @@ extern "C" {
|
||||
jboolean _isDown,
|
||||
jfloat _x,
|
||||
jfloat _y) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -791,7 +793,7 @@ extern "C" {
|
||||
jobject _thiz,
|
||||
jint _id,
|
||||
jint _pointerID) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -807,7 +809,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jint _type,
|
||||
jboolean _isdown) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -824,7 +826,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jint _uniChar,
|
||||
jboolean _isdown) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -841,7 +843,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jfloat _ratioX,
|
||||
jfloat _ratioY) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -859,7 +861,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jint _keyVal,
|
||||
jboolean _isdown) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
@ -903,7 +905,7 @@ extern "C" {
|
||||
void Java_org_gale_Gale_EWrenderInit(JNIEnv* _env,
|
||||
jobject _thiz,
|
||||
jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_VERBOSE("Java_org_gale_Gale_EWrenderInit [BEGIN]");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
@ -920,7 +922,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jint _w,
|
||||
jint _h) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_VERBOSE("Java_org_gale_Gale_EWrenderResize [BEGIN]");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
@ -937,7 +939,7 @@ extern "C" {
|
||||
void Java_org_gale_Gale_EWrenderDraw(JNIEnv* _env,
|
||||
jobject _thiz,
|
||||
jint _id) {
|
||||
std::unique_lock<ethread::Mutex> lock(g_interfaceMutex);
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_VERBOSE("Java_org_gale_Gale_EWrenderDraw [BEGIN]");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|
@ -37,23 +37,23 @@ static ethread::Mutex& mutexInterface() {
|
||||
|
||||
|
||||
static ethread::Mutex g_lockContextMap;
|
||||
static etk::Map<ethread::Thread::id, gale::Context*>& getContextList() {
|
||||
static etk::Map<ethread::Thread::id, gale::Context*> g_val;
|
||||
static etk::Map<uint64_t, gale::Context*>& getContextList() {
|
||||
static etk::Map<uint64_t, gale::Context*> g_val;
|
||||
return g_val;
|
||||
}
|
||||
|
||||
static gale::Context* lastContextSet = nullptr;
|
||||
|
||||
gale::Context& gale::getContext() {
|
||||
etk::Map<ethread::Thread::id, gale::Context*>& list = getContextList();
|
||||
etk::Map<uint64_t, gale::Context*>& list = getContextList();
|
||||
g_lockContextMap.lock();
|
||||
etk::Map<ethread::Thread::id, gale::Context*>::Iterator it = list.find(std::this_thread::get_id());
|
||||
etk::Map<uint64_t, gale::Context*>::Iterator it = list.find(ethread::getId());
|
||||
gale::Context* out = nullptr;
|
||||
if (it != list.end()) {
|
||||
out = it->second;
|
||||
}
|
||||
|
||||
g_lockContextMap.unlock();
|
||||
g_lockContextMap.unLock();
|
||||
if (out == nullptr) {
|
||||
for (auto &it2 : list) {
|
||||
if (out == nullptr) {
|
||||
@ -85,14 +85,14 @@ gale::Context& gale::getContext() {
|
||||
}
|
||||
|
||||
void gale::setContext(gale::Context* _context) {
|
||||
etk::Map<ethread::Thread::id, gale::Context*>& list = getContextList();
|
||||
//GALE_ERROR("Set context : " << std::this_thread::get_id() << " context pointer : " << uint64_t(_context));
|
||||
etk::Map<uint64_t, gale::Context*>& list = getContextList();
|
||||
//GALE_ERROR("Set context : " << ethread::getId() << " context pointer : " << uint64_t(_context));
|
||||
g_lockContextMap.lock();
|
||||
if (_context != nullptr) {
|
||||
lastContextSet = _context;
|
||||
}
|
||||
list.set(std::this_thread::get_id(), _context);
|
||||
g_lockContextMap.unlock();
|
||||
list.set(ethread::getId(), _context);
|
||||
g_lockContextMap.unLock();
|
||||
}
|
||||
|
||||
void gale::contextRegisterThread(ethread::Thread* _thread) {
|
||||
@ -100,24 +100,24 @@ void gale::contextRegisterThread(ethread::Thread* _thread) {
|
||||
return;
|
||||
}
|
||||
gale::Context* context = &gale::getContext();
|
||||
etk::Map<ethread::Thread::id, gale::Context*>& list = getContextList();
|
||||
etk::Map<uint64_t, gale::Context*>& list = getContextList();
|
||||
//GALE_ERROR("REGISTER Thread : " << _thread->get_id() << " context pointer : " << uint64_t(context));
|
||||
g_lockContextMap.lock();
|
||||
list.set(_thread->get_id(), context);
|
||||
g_lockContextMap.unlock();
|
||||
list.set(_thread->getId(), context);
|
||||
g_lockContextMap.unLock();
|
||||
}
|
||||
|
||||
void gale::contextUnRegisterThread(ethread::Thread* _thread) {
|
||||
if (_thread == nullptr) {
|
||||
return;
|
||||
}
|
||||
etk::Map<ethread::Thread::id, gale::Context*>& list = getContextList();
|
||||
etk::Map<uint64_t, gale::Context*>& list = getContextList();
|
||||
g_lockContextMap.lock();
|
||||
etk::Map<ethread::Thread::id, gale::Context*>::Iterator it = list.find(_thread->get_id());
|
||||
etk::Map<uint64_t, gale::Context*>::Iterator it = list.find(_thread->getId());
|
||||
if (it != list.end()) {
|
||||
list.erase(it);
|
||||
}
|
||||
g_lockContextMap.unlock();
|
||||
g_lockContextMap.unLock();
|
||||
}
|
||||
|
||||
void gale::Context::setInitImage(const etk::String& _fileName) {
|
||||
@ -141,7 +141,7 @@ void gale::Context::lockContext() {
|
||||
*/
|
||||
void gale::Context::unLockContext() {
|
||||
setContext(nullptr);
|
||||
mutexInterface().unlock();
|
||||
mutexInterface().unLock();
|
||||
}
|
||||
|
||||
void gale::Context::processEvents() {
|
||||
@ -151,7 +151,7 @@ void gale::Context::processEvents() {
|
||||
nbEvent++;
|
||||
etk::Function<void(gale::Context& _context)> func;
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.wait(func);
|
||||
}
|
||||
if (func == nullptr) {
|
||||
@ -193,10 +193,10 @@ namespace gale {
|
||||
public:
|
||||
PeriodicThread(gale::Context* _context):
|
||||
m_context(_context) {
|
||||
setName("GaleThread 2");
|
||||
setName("Galethread 2");
|
||||
}
|
||||
bool onThreadCall() override {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
ethread::sleepMilliSeconds((10));
|
||||
#if 0
|
||||
m_context->lockContext();
|
||||
#else
|
||||
@ -210,7 +210,7 @@ namespace gale {
|
||||
#if 0
|
||||
m_context->unLockContext();
|
||||
#else
|
||||
mutexInterface().unlock();
|
||||
mutexInterface().unLock();
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -370,13 +370,13 @@ void gale::Context::start2ndThreadProcessing() {
|
||||
// set the curent interface:
|
||||
lockContext();
|
||||
m_periodicThread->start();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
ethread::sleepMilliSeconds((1));
|
||||
// release the curent interface:
|
||||
unLockContext();
|
||||
}
|
||||
|
||||
void gale::Context::postAction(etk::Function<void(gale::Context& _context)> _action) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post(_action);
|
||||
}
|
||||
|
||||
@ -421,7 +421,7 @@ void gale::Context::requestUpdateSize() {
|
||||
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":RECALCULATE_SIZE\n");
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([](gale::Context& _context){
|
||||
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
||||
_context.forceRedrawAll();
|
||||
@ -440,7 +440,7 @@ void gale::Context::OS_Resize(const vec2& _size) {
|
||||
m_simulationFile.filePuts(etk::toString(_size));
|
||||
m_simulationFile.filePuts("\n");
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([_size](gale::Context& _context){
|
||||
GALE_DEBUG("Receive MSG : THREAD_RESIZE : " << _context.m_windowsSize << " ==> " << _size);
|
||||
_context.m_windowsSize = _size;
|
||||
@ -462,7 +462,7 @@ void gale::Context::OS_Move(const vec2& _pos) {
|
||||
if (m_windowsPos == _pos) {
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([_pos](gale::Context& _context){
|
||||
GALE_DEBUG("Receive MSG : THREAD_MOVE : " << _context.m_windowsPos << " ==> " << _pos);
|
||||
_context.m_windowsPos = _pos;
|
||||
@ -499,7 +499,7 @@ void gale::Context::OS_SetInput(enum gale::key::type _type,
|
||||
m_simulationFile.filePuts(etk::toString(_pos));
|
||||
m_simulationFile.filePuts("\n");
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([_type, _status, _pointerID, _pos](gale::Context& _context){
|
||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||
if (appl == nullptr) {
|
||||
@ -536,7 +536,7 @@ void gale::Context::OS_setKeyboard(const gale::key::Special& _special,
|
||||
m_simulationFile.filePuts(etk::toString(uint64_t(_char)));
|
||||
m_simulationFile.filePuts("\n");
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([_special, _type, _state, _char](gale::Context& _context){
|
||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||
if (appl == nullptr) {
|
||||
@ -554,7 +554,7 @@ void gale::Context::OS_Hide() {
|
||||
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":VIEW:false\n");
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([](gale::Context& _context){
|
||||
/*
|
||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||
@ -598,7 +598,7 @@ void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardL
|
||||
m_simulationFile.filePuts(etk::toString(_clipboardID));
|
||||
m_simulationFile.filePuts("\n");
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_msgSystem.post([_clipboardID](gale::Context& _context){
|
||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||
if (appl != nullptr) {
|
||||
@ -629,7 +629,7 @@ bool gale::Context::OS_Draw(bool _displayEveryTime) {
|
||||
#if ( !defined(__TARGET_OS__Windows) \
|
||||
&& !defined(__TARGET_OS__Android))
|
||||
if(currentTime - m_previousDisplayTime < echrono::milliseconds(8)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
ethread::sleepMilliSeconds((1));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <gale/orientation.hpp>
|
||||
#include <gale/context/clipBoard.hpp>
|
||||
#include <ethread/tools.hpp>
|
||||
#include <ethread/MutexRecursive.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
|
||||
#define MAX_MANAGE_INPUT (15)
|
||||
@ -30,7 +31,7 @@ namespace gale {
|
||||
class Context {
|
||||
friend class gale::PeriodicThread;
|
||||
protected:
|
||||
std::recursive_mutex m_mutex;
|
||||
ethread::MutexRecursive m_mutex;
|
||||
ememory::SharedPtr<gale::Thread> m_periodicThread;
|
||||
private:
|
||||
ememory::SharedPtr<gale::Application> m_application; //!< Application handle
|
||||
|
@ -18,10 +18,11 @@
|
||||
#include <gale/context/IOs/Interface.h>
|
||||
#include <gale/context/IOs/Context.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
#include <sys/times.h>
|
||||
#include <mach/clock.h>
|
||||
|
@ -102,8 +102,8 @@ class MacOSInterface : public gale::Context {
|
||||
bool _isAReapeateKey) {
|
||||
OS_setKeyboard(_special, _move, (_isDown==true?gale::key::status::down:gale::key::status::up), _isAReapeateKey);
|
||||
}
|
||||
void openURL(const std::string& _url) {
|
||||
std::string req = "open " + _url;
|
||||
void openURL(const etk::String& _url) {
|
||||
etk::String req = "open " + _url;
|
||||
system(req.c_str());
|
||||
}
|
||||
void MAC_Stop() {
|
||||
@ -116,7 +116,7 @@ class MacOSInterface : public gale::Context {
|
||||
if (_clipboardID == gale::context::clipBoard::clipboardStd) {
|
||||
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
|
||||
NSString* myString = [myPasteboard stringForType:NSPasteboardTypeString];
|
||||
std::string val([myString UTF8String]);
|
||||
etk::String val([myString UTF8String]);
|
||||
gale::context::clipBoard::setSystem(_clipboardID, val);
|
||||
if (val.size() != 0) {
|
||||
OS_ClipBoardArrive(_clipboardID);
|
||||
@ -198,7 +198,7 @@ void MacOs::stopRequested() {
|
||||
interface->MAC_Stop();
|
||||
}
|
||||
/*
|
||||
void MacOs::setRedrawCallback(const std::function<void()>& _func) {
|
||||
void MacOs::setRedrawCallback(const etk::Function<void()>& _func) {
|
||||
if (interface == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -96,9 +96,8 @@ int mm_main(int _argc, const char* _argv[]) {
|
||||
}
|
||||
|
||||
int mm_run(void) {
|
||||
//MacOs::setRedrawCallback(std::bind(callbackSomeThingToDo));
|
||||
GALE_ERROR("Start to run");
|
||||
[NSApp run];
|
||||
GALE_ERROR("Start to run");
|
||||
[NSApp run];
|
||||
GALE_DEBUG("END of application");
|
||||
// return no error
|
||||
return 0;
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
static gale::key::Special guiKeyBoardMode;
|
||||
|
||||
static std::vector<std::pair<uint16_t,unichar>> g_listlasteventDown;
|
||||
static etk::Vector<etk::Pair<uint16_t,unichar>> g_listlasteventDown;
|
||||
|
||||
-(void)localKeyEvent:(NSEvent*)theEvent isDown:(bool)_isDown {
|
||||
bool thisIsAReapeateKey = false;
|
||||
@ -202,7 +202,7 @@ static std::vector<std::pair<uint16_t,unichar>> g_listlasteventDown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_listlasteventDown.push_back(std::make_pair(keycode, c));
|
||||
g_listlasteventDown.push_back(etk::makePair(keycode, c));
|
||||
}
|
||||
MacOs::setKeyboard(guiKeyBoardMode, c, _isDown, thisIsAReapeateKey);
|
||||
if (thisIsAReapeateKey == true) {
|
||||
@ -250,7 +250,7 @@ static std::vector<std::pair<uint16_t,unichar>> g_listlasteventDown;
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)theEvent {
|
||||
uint32_t bitField = [theEvent modifierFlags];
|
||||
GALE_VERBOSE("flagsChanged : " << std::hex << [theEvent modifierFlags]);
|
||||
GALE_VERBOSE("flagsChanged : " << etk::toBin([theEvent modifierFlags], 32));
|
||||
#ifdef __MAC_10_12
|
||||
[self flagsUpdate:bitField: NSEventModifierFlagCapsLock: gale::key::keyboard::capLock];
|
||||
#else
|
||||
|
@ -4,10 +4,11 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
@ -114,7 +115,7 @@ class GLUTInterface : public gale::Context {
|
||||
OS_Draw(true);
|
||||
GLUT_INFO("Draw [STOP]");
|
||||
glutSwapBuffers();
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
//ethread::sleepMilliSeconds((1000));
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************************/
|
||||
|
@ -1,390 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
|
||||
#include <gale/debug.hpp>
|
||||
#include <gale/gale.hpp>
|
||||
#include <gale/key/key.hpp>
|
||||
#include <gale/context/commandLine.hpp>
|
||||
#include <gale/resource/Manager.hpp>
|
||||
#include <gale/context/Context.hpp>
|
||||
#include <gale/Dimension.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#include "SDL/SDL_opengl.h"
|
||||
#include <emscripten.h>
|
||||
|
||||
bool hasDisplay = false;
|
||||
//#define DEBUG_SDL_EVENT
|
||||
#ifdef DEBUG_SDL_EVENT
|
||||
#define SDL_DEBUG GALE_DEBUG
|
||||
#define SDL_VERBOSE GALE_VERBOSE
|
||||
#define SDL_INFO GALE_INFO
|
||||
#define SDL_CRITICAL GALE_CRITICAL
|
||||
#else
|
||||
#define SDL_DEBUG GALE_VERBOSE
|
||||
#define SDL_VERBOSE GALE_VERBOSE
|
||||
#define SDL_INFO GALE_VERBOSE
|
||||
#define SDL_CRITICAL GALE_VERBOSE
|
||||
#endif
|
||||
|
||||
#ifdef GALE_BUILD_EGAMI
|
||||
#include <egami/egami.hpp>
|
||||
#endif
|
||||
|
||||
int result = 1;
|
||||
|
||||
static char *TouchFingerTypeToString(int type) {
|
||||
if (type == SDL_FINGERMOTION) return "SDL_FINGERMOTION";
|
||||
if (type == SDL_FINGERDOWN) return "SDL_FINGERDOWN";
|
||||
if (type == SDL_FINGERUP) return "SDL_FINGERUP";
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
int got_down = 0;
|
||||
int got_move = 0;
|
||||
int got_up = 0;
|
||||
|
||||
|
||||
void progress() {
|
||||
if (!got_down) printf("Hold down a finger to generate a touch down event.\n");
|
||||
else if (!got_move) printf("Drag a finger to generate a touch move event.\n");
|
||||
else if (!got_up) printf("Release a finger to generate a touch up event.\n");
|
||||
else
|
||||
{
|
||||
int result = 0;
|
||||
#ifdef REPORT_RESULT
|
||||
REPORT_RESULT();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void loopppp(void* arg) {
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP: {
|
||||
SDL_TouchFingerEvent *t = (SDL_TouchFingerEvent*)&event;
|
||||
printf("type: %s, timestamp: %u, touchId: %llu, fingerId: %llu, x: %f, y: %f, dx: %f, dy: %f, pressure: %f\n",
|
||||
TouchFingerTypeToString(event.type), t->timestamp, t->touchId, t->fingerId, t->x, t->y, t->dx, t->dy, t->pressure);
|
||||
|
||||
if (t->timestamp != 0 && t->x >= 0.f && t->x <= 1.f && t->y >= 0.f && t->y <= 1.f && t->pressure >= 0.f && t->pressure <= 1.f) {
|
||||
if (event.type == SDL_FINGERDOWN) { got_down = 1; progress(); }
|
||||
if (event.type == SDL_FINGERMOTION) { got_move = 1; progress(); }
|
||||
if (event.type == SDL_FINGERDOWN) { got_up = 1; progress(); }
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SDLInterface : public gale::Context {
|
||||
private:
|
||||
gale::key::Special m_guiKeyBoardMode;
|
||||
int32_t m_originX;
|
||||
int32_t m_originY;
|
||||
int32_t m_cursorEventX;
|
||||
int32_t m_cursorEventY;
|
||||
int32_t m_currentHeight;
|
||||
int32_t m_currentWidth;
|
||||
bool m_doubleBuffered;
|
||||
bool m_run;
|
||||
//forcing the position
|
||||
bool m_grabAllEvent; //!< grab mode enable...
|
||||
vec2 m_forcePos; //!< position to reset the cursor
|
||||
bool m_positionChangeRequested; //!< the position modifiquation has been requested
|
||||
vec2 m_curentGrabDelta; //!< the position in SDL will arrive by pool
|
||||
bool m_inputIsPressed[MAX_MANAGE_INPUT];
|
||||
etk::String m_uniqueWindowsName;
|
||||
enum gale::context::cursor m_currentCursor; //!< select the current cursor to display :
|
||||
char32_t m_lastKeyPressed; //!< The last element key presed...
|
||||
SDL_Surface* m_screen;
|
||||
public:
|
||||
SDLInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
|
||||
gale::Context(_application, _argc, _argv),
|
||||
m_originX(0),
|
||||
m_originY(0),
|
||||
m_cursorEventX(0),
|
||||
m_cursorEventY(0),
|
||||
m_currentHeight(450),
|
||||
m_currentWidth(600),
|
||||
m_doubleBuffered(0),
|
||||
m_run(false),
|
||||
m_grabAllEvent(false),
|
||||
m_forcePos(0,0),
|
||||
m_positionChangeRequested(false),
|
||||
m_curentGrabDelta(0,0),
|
||||
m_currentCursor(gale::context::cursor::arrow),
|
||||
m_lastKeyPressed(0),
|
||||
m_screen(nullptr) {
|
||||
SDL_INFO("SDL:INIT");
|
||||
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
m_inputIsPressed[iii] = false;
|
||||
}
|
||||
if (m_doubleBuffered) {
|
||||
//XSync(m_display,0);
|
||||
}
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new*
|
||||
m_screen = SDL_SetVideoMode(m_currentWidth, m_currentHeight, 32, SDL_OPENGL/*SDL_HWSURFACE*/);
|
||||
SDL_INFO("SDL:INIT");
|
||||
// Set the OpenGL state after creating the context with SDL_SetVideoMode
|
||||
|
||||
glClearColor( 0, 0, 0, 0 );
|
||||
SDL_INFO("SDL:INIT");
|
||||
glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline.
|
||||
|
||||
glViewport( 0, 0, 640, 480 );
|
||||
SDL_INFO("SDL:INIT");
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
SDL_INFO("SDL:INIT");
|
||||
glPushMatrix(); // just for testing
|
||||
SDL_INFO("SDL:INIT");
|
||||
glLoadIdentity();
|
||||
SDL_INFO("SDL:INIT");
|
||||
glOrtho( 0, 640, 480, 0, -1000, 1000 );
|
||||
|
||||
SDL_INFO("SDL:INIT");
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
SDL_INFO("SDL:INIT");
|
||||
glLoadIdentity();
|
||||
SDL_INFO("SDL:INIT");
|
||||
OS_Resize(vec2(m_currentWidth, m_currentHeight));
|
||||
|
||||
SDL_INFO("SDL:INIT");
|
||||
// Configure the DPI of the screen:
|
||||
{
|
||||
vec2 dpi(0,0);
|
||||
dpi.setX(75);
|
||||
dpi.setY(75);
|
||||
gale::Dimension::setPixelRatio(dpi, gale::distance::inch);
|
||||
GALE_INFO("monitor property : dpi=" << dpi << " px/inch");
|
||||
}
|
||||
m_run = true;
|
||||
}
|
||||
|
||||
~SDLInterface() {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
int32_t run() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP: {
|
||||
SDL_TouchFingerEvent *t = (SDL_TouchFingerEvent*)&event;
|
||||
SDL_INFO("type: " << TouchFingerTypeToString(event.type)
|
||||
<< ", timestamp: " << t->timestamp
|
||||
<< ", touchId: " << t->touchId
|
||||
<< ", fingerId: " << t->fingerId
|
||||
<< ", pos=" << vec2(t->x, t->y)
|
||||
<< ", delta Pos=" << vec2(t->dx, t->dy)
|
||||
<< ", pressure: " << t->pressure);
|
||||
if (t->timestamp != 0 && t->x >= 0.f && t->x <= 1.f && t->y >= 0.f && t->y <= 1.f && t->pressure >= 0.f && t->pressure <= 1.f) {
|
||||
if (event.type == SDL_FINGERDOWN) {
|
||||
got_down = 1; progress();
|
||||
}
|
||||
if (event.type == SDL_FINGERMOTION) {
|
||||
got_move = 1; progress();
|
||||
}
|
||||
if (event.type == SDL_FINGERDOWN) {
|
||||
got_up = 1; progress();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_LockSurface(m_screen);
|
||||
}
|
||||
/*
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
*/
|
||||
if (true) {
|
||||
for (int yyy = 0; yyy < m_currentWidth; yyy++) {
|
||||
for (int xxx = 0; xxx < m_currentHeight; xxx++) {
|
||||
#ifdef TEST_SDL_LOCK_OPTS
|
||||
// Alpha behaves like in the browser, so write proper opaque pixels.
|
||||
int alpha = 255;
|
||||
#else
|
||||
// To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting
|
||||
// data (and testing that it does get discarded)
|
||||
int alpha = (yyy+xxx) % 255;
|
||||
#endif
|
||||
*((Uint32*)m_screen->pixels + yyy * m_currentWidth + xxx) = SDL_MapRGBA(m_screen->format, yyy, xxx, (Uint32)(255.0f * float(yyy)/float(m_currentHeight)), alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_UnlockSurface(m_screen);
|
||||
}
|
||||
SDL_INFO("Draw [START]");
|
||||
OS_Draw(true);
|
||||
SDL_INFO("Draw [STOP]");
|
||||
SDL_Flip(m_screen);
|
||||
|
||||
return 0;
|
||||
|
||||
// main cycle
|
||||
//while(m_run == true) {
|
||||
SDL_Event evt;
|
||||
if ( SDL_PollEvent(&evt) != 0
|
||||
&& evt.type == SDL_QUIT) {
|
||||
m_run = false;
|
||||
return -1;
|
||||
}
|
||||
if(m_run == true) {
|
||||
if ( m_doubleBuffered == true
|
||||
&& hasDisplay == true) {
|
||||
// TODO : SWAP ....
|
||||
}
|
||||
//hasDisplay = OS_Draw(true);
|
||||
//SDL_LockSurface(m_screen);
|
||||
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
//SDL_LockSurface(m_screen);
|
||||
}
|
||||
if (false) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
for (int j = 0; j < 256; j++) {
|
||||
#ifdef TEST_SDL_LOCK_OPTS
|
||||
// Alpha behaves like in the browser, so write proper opaque pixels.
|
||||
int alpha = 255;
|
||||
#else
|
||||
// To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting
|
||||
// data (and testing that it does get discarded)
|
||||
int alpha = (i+j) % 255;
|
||||
#endif
|
||||
*((Uint32*)m_screen->pixels + i * 256 + j) = SDL_MapRGBA(m_screen->format, i, j, 255-i, alpha);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
OS_Draw(true);
|
||||
}
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
//SDL_UnlockSurface(m_screen);
|
||||
}
|
||||
SDL_Flip(m_screen);
|
||||
//SDL_UnlockSurface(m_screen);
|
||||
//SDL_Delay(33);
|
||||
}
|
||||
//}
|
||||
/*
|
||||
// main cycle
|
||||
while(m_run == true) {
|
||||
SDL_Event evt;
|
||||
if ( SDL_PollEvent(&evt) != 0
|
||||
&& evt.type == SDL_QUIT) {
|
||||
m_run = false;
|
||||
continue;
|
||||
}
|
||||
if(m_run == true) {
|
||||
if ( m_doubleBuffered == true
|
||||
&& hasDisplay == true) {
|
||||
// TODO : SWAP ....
|
||||
}
|
||||
//hasDisplay = OS_Draw(true);
|
||||
//SDL_LockSurface(m_screen);
|
||||
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_LockSurface(m_screen);
|
||||
}
|
||||
for (int i = 0; i < 256; i++) {
|
||||
for (int j = 0; j < 256; j++) {
|
||||
#ifdef TEST_SDL_LOCK_OPTS
|
||||
// Alpha behaves like in the browser, so write proper opaque pixels.
|
||||
int alpha = 255;
|
||||
#else
|
||||
// To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting
|
||||
// data (and testing that it does get discarded)
|
||||
int alpha = (i+j) % 255;
|
||||
#endif
|
||||
*((Uint32*)m_screen->pixels + i * 256 + j) = SDL_MapRGBA(m_screen->format, i, j, 255-i, alpha);
|
||||
}
|
||||
}
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_UnlockSurface(m_screen);
|
||||
}
|
||||
SDL_Flip(m_screen);
|
||||
//SDL_UnlockSurface(m_screen);
|
||||
SDL_Delay(33);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************************/
|
||||
virtual void stop() {
|
||||
SDL_INFO("SDL-API: Stop");
|
||||
m_run = false;
|
||||
}
|
||||
};
|
||||
|
||||
static void loop(void* _arg) {
|
||||
SDLInterface* interface = (SDLInterface*)_arg;
|
||||
if (interface != nullptr) {
|
||||
interface->run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Main of the program
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
printf("lklklklklk\n");
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// include GL stuff, to check that we can compile hybrid 2d/GL apps
|
||||
extern void glBegin(int mode);
|
||||
extern void glBindBuffer(int target, int buffer);
|
||||
if (_argc == 9876) {
|
||||
glBegin(0);
|
||||
glBindBuffer(0, 0);
|
||||
}
|
||||
#endif
|
||||
printf("22222222\n");
|
||||
etk::init(_argc, _argv);
|
||||
printf("33333333\n");
|
||||
SDLInterface* interface = new SDLInterface(_application, _argc, _argv);
|
||||
if (interface == nullptr) {
|
||||
GALE_CRITICAL("Can not create the SDL interface ... MEMORY allocation error");
|
||||
return -2;
|
||||
}
|
||||
printf("444444\n");
|
||||
emscripten_set_main_loop_arg(loop, interface, 0, 0);
|
||||
int32_t retValue = interface->run();
|
||||
printf("55555\n");
|
||||
delete(interface);
|
||||
printf("666666\n");
|
||||
interface = nullptr;
|
||||
return retValue;
|
||||
}
|
@ -1,349 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
|
||||
#include <gale/debug.hpp>
|
||||
#include <gale/gale.hpp>
|
||||
#include <gale/key/key.hpp>
|
||||
#include <gale/context/commandLine.hpp>
|
||||
#include <gale/resource/Manager.hpp>
|
||||
#include <gale/context/Context.hpp>
|
||||
#include <gale/Dimension.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
//#include <SDL/SDL_opengl.h>
|
||||
#include <SDL/SDL_opengles2.h>
|
||||
#include <emscripten.h>
|
||||
|
||||
bool hasDisplay = false;
|
||||
//#define DEBUG_SDL_EVENT
|
||||
#ifdef DEBUG_SDL_EVENT
|
||||
#define SDL_DEBUG GALE_DEBUG
|
||||
#define SDL_VERBOSE GALE_VERBOSE
|
||||
#define SDL_INFO GALE_INFO
|
||||
#define SDL_CRITICAL GALE_CRITICAL
|
||||
#else
|
||||
#define SDL_DEBUG GALE_VERBOSE
|
||||
#define SDL_VERBOSE GALE_VERBOSE
|
||||
#define SDL_INFO GALE_VERBOSE
|
||||
#define SDL_CRITICAL GALE_VERBOSE
|
||||
#endif
|
||||
|
||||
#ifdef GALE_BUILD_EGAMI
|
||||
#include <egami/egami.hpp>
|
||||
#endif
|
||||
|
||||
int result = 1;
|
||||
|
||||
static char *TouchFingerTypeToString(int type) {
|
||||
if (type == SDL_FINGERMOTION) return "SDL_FINGERMOTION";
|
||||
if (type == SDL_FINGERDOWN) return "SDL_FINGERDOWN";
|
||||
if (type == SDL_FINGERUP) return "SDL_FINGERUP";
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
int got_down = 0;
|
||||
int got_move = 0;
|
||||
int got_up = 0;
|
||||
|
||||
|
||||
void progress() {
|
||||
if (!got_down) printf("Hold down a finger to generate a touch down event.\n");
|
||||
else if (!got_move) printf("Drag a finger to generate a touch move event.\n");
|
||||
else if (!got_up) printf("Release a finger to generate a touch up event.\n");
|
||||
else
|
||||
{
|
||||
int result = 0;
|
||||
#ifdef REPORT_RESULT
|
||||
REPORT_RESULT();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void loopppp(void* arg) {
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP: {
|
||||
SDL_TouchFingerEvent *t = (SDL_TouchFingerEvent*)&event;
|
||||
printf("type: %s, timestamp: %u, touchId: %llu, fingerId: %llu, x: %f, y: %f, dx: %f, dy: %f, pressure: %f\n",
|
||||
TouchFingerTypeToString(event.type), t->timestamp, t->touchId, t->fingerId, t->x, t->y, t->dx, t->dy, t->pressure);
|
||||
|
||||
if (t->timestamp != 0 && t->x >= 0.f && t->x <= 1.f && t->y >= 0.f && t->y <= 1.f && t->pressure >= 0.f && t->pressure <= 1.f) {
|
||||
if (event.type == SDL_FINGERDOWN) { got_down = 1; progress(); }
|
||||
if (event.type == SDL_FINGERMOTION) { got_move = 1; progress(); }
|
||||
if (event.type == SDL_FINGERDOWN) { got_up = 1; progress(); }
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SDLInterface : public gale::Context {
|
||||
private:
|
||||
gale::key::Special m_guiKeyBoardMode;
|
||||
int32_t m_originX;
|
||||
int32_t m_originY;
|
||||
int32_t m_cursorEventX;
|
||||
int32_t m_cursorEventY;
|
||||
int32_t m_currentHeight;
|
||||
int32_t m_currentWidth;
|
||||
bool m_doubleBuffered;
|
||||
bool m_run;
|
||||
//forcing the position
|
||||
bool m_grabAllEvent; //!< grab mode enable...
|
||||
vec2 m_forcePos; //!< position to reset the cursor
|
||||
bool m_positionChangeRequested; //!< the position modifiquation has been requested
|
||||
vec2 m_curentGrabDelta; //!< the position in SDL will arrive by pool
|
||||
bool m_inputIsPressed[MAX_MANAGE_INPUT];
|
||||
etk::String m_uniqueWindowsName;
|
||||
enum gale::context::cursor m_currentCursor; //!< select the current cursor to display :
|
||||
char32_t m_lastKeyPressed; //!< The last element key presed...
|
||||
SDL_Window* m_screen;
|
||||
//SDL_Surface* m_screen;
|
||||
SDL_GLContext m_context;
|
||||
public:
|
||||
SDLInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
|
||||
gale::Context(_application, _argc, _argv),
|
||||
m_originX(0),
|
||||
m_originY(0),
|
||||
m_cursorEventX(0),
|
||||
m_cursorEventY(0),
|
||||
m_currentHeight(450),
|
||||
m_currentWidth(600),
|
||||
m_doubleBuffered(0),
|
||||
m_run(false),
|
||||
m_grabAllEvent(false),
|
||||
m_forcePos(0,0),
|
||||
m_positionChangeRequested(false),
|
||||
m_curentGrabDelta(0,0),
|
||||
m_currentCursor(gale::context::cursor::arrow),
|
||||
m_lastKeyPressed(0),
|
||||
m_screen(nullptr) {
|
||||
SDL_INFO("SDL:INIT");
|
||||
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
m_inputIsPressed[iii] = false;
|
||||
}
|
||||
if (m_doubleBuffered) {
|
||||
//XSync(m_display,0);
|
||||
}
|
||||
SDL_INFO("SDL:INIT");
|
||||
if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
|
||||
printf("Unable to initialize SDL: %s\n", SDL_GetError());
|
||||
exit(-1);
|
||||
}
|
||||
SDL_INFO("SDL:INIT");
|
||||
|
||||
m_screen = SDL_CreateWindow("sdl_gl_read", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_currentWidth, m_currentHeight, SDL_WINDOW_OPENGL);
|
||||
|
||||
SDL_INFO("SDL:INIT");
|
||||
if (!m_screen) {
|
||||
printf("Unable to create window: %s\n", SDL_GetError());
|
||||
exit(-1);
|
||||
}
|
||||
SDL_INFO("SDL:INIT");
|
||||
m_context = SDL_GL_CreateContext(m_screen);
|
||||
SDL_INFO("SDL:INIT");
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new*
|
||||
/*
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
m_screen = SDL_SetVideoMode(m_currentWidth, m_currentHeight, 32, SDL_OPENGL/*SDL_HWSURFACE* /);
|
||||
*/
|
||||
SDL_INFO("SDL:INIT");
|
||||
OS_Resize(vec2(m_currentWidth, m_currentHeight));
|
||||
|
||||
// Configure the DPI of the screen:
|
||||
{
|
||||
vec2 dpi(0,0);
|
||||
dpi.setX(75);
|
||||
dpi.setY(75);
|
||||
gale::Dimension::setPixelRatio(dpi, gale::distance::inch);
|
||||
GALE_INFO("monitor property : dpi=" << dpi << " px/inch");
|
||||
}
|
||||
m_run = true;
|
||||
}
|
||||
|
||||
~SDLInterface() {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
int32_t run() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP: {
|
||||
SDL_TouchFingerEvent *t = (SDL_TouchFingerEvent*)&event;
|
||||
SDL_INFO("type: " << TouchFingerTypeToString(event.type)
|
||||
<< ", timestamp: " << t->timestamp
|
||||
<< ", touchId: " << t->touchId
|
||||
<< ", fingerId: " << t->fingerId
|
||||
<< ", pos=" << vec2(t->x, t->y)
|
||||
<< ", delta Pos=" << vec2(t->dx, t->dy)
|
||||
<< ", pressure: " << t->pressure);
|
||||
if (t->timestamp != 0 && t->x >= 0.f && t->x <= 1.f && t->y >= 0.f && t->y <= 1.f && t->pressure >= 0.f && t->pressure <= 1.f) {
|
||||
if (event.type == SDL_FINGERDOWN) {
|
||||
got_down = 1; progress();
|
||||
}
|
||||
if (event.type == SDL_FINGERMOTION) {
|
||||
got_move = 1; progress();
|
||||
}
|
||||
if (event.type == SDL_FINGERDOWN) {
|
||||
got_up = 1; progress();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_LockSurface(m_screen);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
*/
|
||||
/*
|
||||
if (true) {
|
||||
for (int yyy = 0; yyy < m_currentWidth; yyy++) {
|
||||
for (int xxx = 0; xxx < m_currentHeight; xxx++) {
|
||||
#ifdef TEST_SDL_LOCK_OPTS
|
||||
// Alpha behaves like in the browser, so write proper opaque pixels.
|
||||
int alpha = 255;
|
||||
#else
|
||||
// To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting
|
||||
// data (and testing that it does get discarded)
|
||||
int alpha = (yyy+xxx) % 255;
|
||||
#endif
|
||||
*((Uint32*)m_screen->pixels + yyy * m_currentWidth + xxx) = SDL_MapRGBA(m_screen->format, yyy, xxx, (Uint32)(255.0f * float(yyy)/float(m_currentHeight)), alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_UnlockSurface(m_screen);
|
||||
}
|
||||
*/
|
||||
SDL_INFO("Draw [START]");
|
||||
OS_Draw(true);
|
||||
SDL_INFO("Draw [STOP]");
|
||||
//SDL_Flip(m_screen);
|
||||
|
||||
return 0;
|
||||
|
||||
/*
|
||||
// main cycle
|
||||
while(m_run == true) {
|
||||
SDL_Event evt;
|
||||
if ( SDL_PollEvent(&evt) != 0
|
||||
&& evt.type == SDL_QUIT) {
|
||||
m_run = false;
|
||||
continue;
|
||||
}
|
||||
if(m_run == true) {
|
||||
if ( m_doubleBuffered == true
|
||||
&& hasDisplay == true) {
|
||||
// TODO : SWAP ....
|
||||
}
|
||||
//hasDisplay = OS_Draw(true);
|
||||
//SDL_LockSurface(m_screen);
|
||||
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_LockSurface(m_screen);
|
||||
}
|
||||
for (int i = 0; i < 256; i++) {
|
||||
for (int j = 0; j < 256; j++) {
|
||||
#ifdef TEST_SDL_LOCK_OPTS
|
||||
// Alpha behaves like in the browser, so write proper opaque pixels.
|
||||
int alpha = 255;
|
||||
#else
|
||||
// To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting
|
||||
// data (and testing that it does get discarded)
|
||||
int alpha = (i+j) % 255;
|
||||
#endif
|
||||
*((Uint32*)m_screen->pixels + i * 256 + j) = SDL_MapRGBA(m_screen->format, i, j, 255-i, alpha);
|
||||
}
|
||||
}
|
||||
if (SDL_MUSTLOCK(m_screen)) {
|
||||
SDL_UnlockSurface(m_screen);
|
||||
}
|
||||
SDL_Flip(m_screen);
|
||||
//SDL_UnlockSurface(m_screen);
|
||||
SDL_Delay(33);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************************/
|
||||
virtual void stop() {
|
||||
SDL_INFO("SDL-API: Stop");
|
||||
m_run = false;
|
||||
}
|
||||
};
|
||||
|
||||
static void loop(void* _arg) {
|
||||
SDLInterface* interface = (SDLInterface*)_arg;
|
||||
if (interface != nullptr) {
|
||||
interface->run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Main of the program
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
printf("lklklklklk\n");
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// include GL stuff, to check that we can compile hybrid 2d/GL apps
|
||||
extern void glBegin(int mode);
|
||||
extern void glBindBuffer(int target, int buffer);
|
||||
if (_argc == 9876) {
|
||||
glBegin(0);
|
||||
glBindBuffer(0, 0);
|
||||
}
|
||||
#endif
|
||||
printf("22222222\n");
|
||||
etk::init(_argc, _argv);
|
||||
printf("33333333\n");
|
||||
SDLInterface* interface = new SDLInterface(_application, _argc, _argv);
|
||||
if (interface == nullptr) {
|
||||
GALE_CRITICAL("Can not create the SDL interface ... MEMORY allocation error");
|
||||
return -2;
|
||||
}
|
||||
printf("444444\n");
|
||||
emscripten_set_main_loop_arg(loop, interface, 0, 0);
|
||||
int32_t retValue = interface->run();
|
||||
printf("55555\n");
|
||||
delete(interface);
|
||||
printf("666666\n");
|
||||
interface = nullptr;
|
||||
return retValue;
|
||||
}
|
@ -4,10 +4,11 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
|
@ -36,11 +36,11 @@
|
||||
#include <gale/renderer/eSystem.hpp>
|
||||
#include <gale/openGL/openGL.hpp>
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
}
|
||||
#include <directfb.h>
|
||||
#include <directfbgl.h>
|
||||
|
||||
|
@ -4,9 +4,11 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
|
@ -11,11 +11,12 @@
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
}
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <gale/context/commandLine.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <gale/Dimension.hpp>
|
||||
#include <chrono>
|
||||
|
||||
#ifndef GALE_VERSION
|
||||
#define GALE_VERSION "0.0.0"
|
||||
|
@ -280,7 +280,7 @@ namespace etk {
|
||||
}
|
||||
template <> bool from_string<gale::key::Special>(gale::key::Special& _variableRet, const etk::String& _value) {
|
||||
gale::key::Special out;
|
||||
etk::Vector<etk::String> listElem = etk::split(_value, "|");
|
||||
etk::Vector<etk::String> listElem = _value.split('|');
|
||||
for (auto &it : listElem) {
|
||||
if (it == "CAPS") {
|
||||
out.setCapsLock(true);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <gale/renderer/openGL/openGL.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <etk/Pair.hpp>
|
||||
//#define DIRECT_MODE
|
||||
#include <gale/renderer/openGL/openGL-include.hpp>
|
||||
#include <ethread/tools.hpp>
|
||||
@ -81,45 +82,45 @@ void gale::openGL::lock() {
|
||||
}
|
||||
|
||||
void gale::openGL::unLock() {
|
||||
mutexOpenGl().unlock();
|
||||
mutexOpenGl().unLock();
|
||||
}
|
||||
|
||||
static etk::Vector<ethread::Thread::id>& getContextList() {
|
||||
static etk::Vector<ethread::Thread::id> g_val;
|
||||
static etk::Vector<uint64_t>& getContextList() {
|
||||
static etk::Vector<uint64_t> g_val;
|
||||
return g_val;
|
||||
}
|
||||
|
||||
bool gale::openGL::hasContext() {
|
||||
bool ret = false;
|
||||
mutexOpenGl().lock();
|
||||
auto it = std::find(getContextList().begin(), getContextList().end(), std::this_thread::get_id());
|
||||
auto it = etk::find(getContextList().begin(), getContextList().end(), ethread::getId());
|
||||
if (it != getContextList().end()) {
|
||||
ret = true;
|
||||
}
|
||||
mutexOpenGl().unlock();
|
||||
mutexOpenGl().unLock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void gale::openGL::threadHasContext() {
|
||||
mutexOpenGl().lock();
|
||||
auto it = std::find(getContextList().begin(), getContextList().end(), std::this_thread::get_id());
|
||||
auto it = etk::find(getContextList().begin(), getContextList().end(), ethread::getId());
|
||||
if (it != getContextList().end()) {
|
||||
GALE_ERROR("set openGL context associate with threadID a second time ... ");
|
||||
} else {
|
||||
getContextList().pushBack(std::this_thread::get_id());
|
||||
getContextList().pushBack(ethread::getId());
|
||||
}
|
||||
mutexOpenGl().unlock();
|
||||
mutexOpenGl().unLock();
|
||||
}
|
||||
|
||||
void gale::openGL::threadHasNoMoreContext() {
|
||||
mutexOpenGl().lock();
|
||||
auto it = std::find(getContextList().begin(), getContextList().end(), std::this_thread::get_id());
|
||||
auto it = etk::find(getContextList().begin(), getContextList().end(), ethread::getId());
|
||||
if (it != getContextList().end()) {
|
||||
getContextList().erase(it);
|
||||
} else {
|
||||
GALE_ERROR("rm openGL context associate with threadID that is not registered.");
|
||||
}
|
||||
mutexOpenGl().unlock();
|
||||
mutexOpenGl().unLock();
|
||||
}
|
||||
|
||||
void gale::openGL::setBasicMatrix(const mat4& _newOne) {
|
||||
|
@ -20,7 +20,7 @@ gale::resource::Manager::Manager() :
|
||||
}
|
||||
|
||||
gale::resource::Manager::~Manager() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
bool hasError = false;
|
||||
if (m_resourceListToUpdate.size()!=0) {
|
||||
GALE_ERROR("Must not have anymore resources to update !!!");
|
||||
@ -37,7 +37,7 @@ gale::resource::Manager::~Manager() {
|
||||
}
|
||||
|
||||
void gale::resource::Manager::unInit() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
display();
|
||||
m_resourceListToUpdate.clear();
|
||||
// remove all resources ...
|
||||
@ -58,7 +58,7 @@ void gale::resource::Manager::unInit() {
|
||||
void gale::resource::Manager::display() {
|
||||
GALE_INFO("Resources loaded : ");
|
||||
// remove all resources ...
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
for (auto &it : m_resourceList) {
|
||||
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
|
||||
if (tmpRessource != nullptr) {
|
||||
@ -74,7 +74,7 @@ void gale::resource::Manager::display() {
|
||||
void gale::resource::Manager::reLoadResources() {
|
||||
GALE_INFO("------------- Resources re-loaded -------------");
|
||||
// remove all resources ...
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_resourceList.size() != 0) {
|
||||
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
|
||||
GALE_INFO(" Reload level : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
|
||||
@ -96,7 +96,7 @@ void gale::resource::Manager::reLoadResources() {
|
||||
|
||||
void gale::resource::Manager::update(const ememory::SharedPtr<gale::Resource>& _object) {
|
||||
// chek if not added before
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
for (auto &it : m_resourceListToUpdate) {
|
||||
if ( it != nullptr
|
||||
&& it == _object) {
|
||||
@ -118,9 +118,9 @@ void gale::resource::Manager::updateContext() {
|
||||
if (m_contextHasBeenRemoved == true) {
|
||||
// need to update all ...
|
||||
m_contextHasBeenRemoved = false;
|
||||
std::list<ememory::WeakPtr<gale::Resource>> resourceList;
|
||||
etk::Vector<ememory::WeakPtr<gale::Resource>> resourceList;
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// Clean the update list
|
||||
m_resourceListToUpdate.clear();
|
||||
resourceList = m_resourceList;
|
||||
@ -135,7 +135,7 @@ void gale::resource::Manager::updateContext() {
|
||||
//GALE_DEBUG("Update context named : " << l_resourceList[iii]->getName());
|
||||
if (tmpRessource->updateContext() == false) {
|
||||
// Lock error ==> postponned
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_resourceListToUpdate.pushBack(tmpRessource);
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ void gale::resource::Manager::updateContext() {
|
||||
} else {
|
||||
etk::Vector<ememory::SharedPtr<gale::Resource>> resourceListToUpdate;
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
resourceListToUpdate = m_resourceListToUpdate;
|
||||
// Clean the update list
|
||||
m_resourceListToUpdate.clear();
|
||||
@ -157,7 +157,7 @@ void gale::resource::Manager::updateContext() {
|
||||
if ( it != nullptr
|
||||
&& jjj == it->getResourceLevel()) {
|
||||
if (it->updateContext() == false) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// Lock error ==> postponned
|
||||
m_resourceListToUpdate.pushBack(it);
|
||||
}
|
||||
@ -170,7 +170,7 @@ void gale::resource::Manager::updateContext() {
|
||||
|
||||
// in this case, it is really too late ...
|
||||
void gale::resource::Manager::contextHasBeenDestroyed() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
for (auto &it : m_resourceList) {
|
||||
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
|
||||
if (tmpRessource != nullptr) {
|
||||
@ -188,7 +188,7 @@ void gale::resource::Manager::applicationExiting() {
|
||||
|
||||
// internal generic keeper ...
|
||||
ememory::SharedPtr<gale::Resource> gale::resource::Manager::localKeep(const etk::String& _filename) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
GALE_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources");
|
||||
for (auto &it : m_resourceList) {
|
||||
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
|
||||
@ -203,7 +203,7 @@ ememory::SharedPtr<gale::Resource> gale::resource::Manager::localKeep(const etk:
|
||||
|
||||
// internal generic keeper ...
|
||||
void gale::resource::Manager::localAdd(const ememory::SharedPtr<gale::Resource>& _object) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
//Add ... find empty slot
|
||||
for (auto &it : m_resourceList) {
|
||||
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
|
||||
@ -218,7 +218,7 @@ void gale::resource::Manager::localAdd(const ememory::SharedPtr<gale::Resource>&
|
||||
|
||||
// in case of error ...
|
||||
void gale::resource::Manager::cleanInternalRemoved() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
//GALE_INFO("remove object in Manager");
|
||||
updateContext();
|
||||
for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) {
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <ethread/MutexRecursive.hpp>
|
||||
#include <gale/debug.hpp>
|
||||
#include <gale/resource/Resource.hpp>
|
||||
|
||||
@ -15,11 +15,11 @@ namespace gale {
|
||||
namespace resource {
|
||||
class Manager{
|
||||
private:
|
||||
std::list<ememory::WeakPtr<gale::Resource>> m_resourceList;
|
||||
etk::Vector<ememory::WeakPtr<gale::Resource>> m_resourceList;
|
||||
etk::Vector<ememory::SharedPtr<gale::Resource>> m_resourceListToUpdate;
|
||||
bool m_contextHasBeenRemoved;
|
||||
bool m_exiting;
|
||||
std::recursive_mutex m_mutex;
|
||||
ethread::MutexRecursive m_mutex;
|
||||
public:
|
||||
/**
|
||||
* @brief initialize the internal variable
|
||||
|
@ -27,7 +27,7 @@ gale::resource::Program::Program() :
|
||||
|
||||
void gale::resource::Program::init(const etk::String& _filename) {
|
||||
gale::Resource::init(_filename);
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
GALE_DEBUG("OGL : load PROGRAM '" << m_name << "'");
|
||||
// load data from file "all the time ..."
|
||||
|
||||
@ -162,7 +162,7 @@ static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
|
||||
|
||||
|
||||
bool gale::resource::Program::checkIdValidity(int32_t _idElem) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if ( _idElem < 0
|
||||
|| (size_t)_idElem > m_elementList.size()) {
|
||||
return false;
|
||||
@ -171,7 +171,7 @@ bool gale::resource::Program::checkIdValidity(int32_t _idElem) {
|
||||
}
|
||||
|
||||
int32_t gale::resource::Program::getAttribute(etk::String _elementName) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// check if it exist previously :
|
||||
for(size_t iii=0; iii<m_elementList.size(); iii++) {
|
||||
if (m_elementList[iii].m_name == _elementName) {
|
||||
@ -204,7 +204,7 @@ int32_t gale::resource::Program::getAttribute(etk::String _elementName) {
|
||||
}
|
||||
|
||||
int32_t gale::resource::Program::getUniform(etk::String _elementName) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// check if it exist previously :
|
||||
for(size_t iii=0; iii<m_elementList.size(); iii++) {
|
||||
if (m_elementList[iii].m_name == _elementName) {
|
||||
@ -237,8 +237,8 @@ int32_t gale::resource::Program::getUniform(etk::String _elementName) {
|
||||
}
|
||||
|
||||
bool gale::resource::Program::updateContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
||||
if (lock.try_lock() == false) {
|
||||
ethread::RecursiveLock lock(m_mutex, true);
|
||||
if (lock.tryLock() == false) {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
@ -302,7 +302,7 @@ bool gale::resource::Program::updateContext() {
|
||||
}
|
||||
|
||||
void gale::resource::Program::removeContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == true) {
|
||||
gale::openGL::program::remove(m_program);
|
||||
m_program = 0;
|
||||
@ -315,7 +315,7 @@ void gale::resource::Program::removeContext() {
|
||||
}
|
||||
|
||||
void gale::resource::Program::removeContextToLate() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_exist = false;
|
||||
m_program = 0;
|
||||
}
|
||||
@ -365,7 +365,7 @@ void gale::resource::Program::sendAttribute(int32_t _idElem,
|
||||
int32_t _nbElement,
|
||||
const void* _pointer,
|
||||
int32_t _jumpBetweenSample) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -394,7 +394,7 @@ void gale::resource::Program::sendAttributePointer(int32_t _idElem,
|
||||
int32_t _index,
|
||||
int32_t _jumpBetweenSample,
|
||||
int32_t _offset) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -434,7 +434,7 @@ void gale::resource::Program::sendAttributePointer(int32_t _idElem,
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void gale::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -461,7 +461,7 @@ void gale::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void gale::resource::Program::uniform1f(int32_t _idElem, float _value1) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -476,7 +476,7 @@ void gale::resource::Program::uniform1f(int32_t _idElem, float _value1) {
|
||||
checkGlError("glUniform1f", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -491,7 +491,7 @@ void gale::resource::Program::uniform2f(int32_t _idElem, float _value1, float _
|
||||
checkGlError("glUniform2f", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -506,7 +506,7 @@ void gale::resource::Program::uniform3f(int32_t _idElem, float _value1, float _v
|
||||
checkGlError("glUniform3f", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -524,7 +524,7 @@ void gale::resource::Program::uniform4f(int32_t _idElem, float _value1, float _v
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void gale::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -539,7 +539,7 @@ void gale::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) {
|
||||
checkGlError("glUniform1i", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -554,7 +554,7 @@ void gale::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_
|
||||
checkGlError("glUniform2i", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -569,7 +569,7 @@ void gale::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_
|
||||
checkGlError("glUniform3i", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -588,7 +588,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) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -612,7 +612,7 @@ void gale::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, co
|
||||
checkGlError("glUniform1fv", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -636,7 +636,7 @@ void gale::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, co
|
||||
checkGlError("glUniform2fv", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -661,7 +661,7 @@ void gale::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, co
|
||||
checkGlError("glUniform3fv", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -689,7 +689,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) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -713,7 +713,7 @@ void gale::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, co
|
||||
checkGlError("glUniform1iv", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -737,7 +737,7 @@ void gale::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, co
|
||||
checkGlError("glUniform2iv", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -761,7 +761,7 @@ void gale::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, co
|
||||
checkGlError("glUniform3iv", __LINE__, _idElem);
|
||||
}
|
||||
void gale::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -805,7 +805,7 @@ void gale::resource::Program::use() {
|
||||
|
||||
|
||||
void gale::resource::Program::setTexture0(int32_t _idElem, int64_t _textureOpenGlID) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -832,7 +832,7 @@ void gale::resource::Program::setTexture0(int32_t _idElem, int64_t _textureOpenG
|
||||
}
|
||||
|
||||
void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenGlID) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
@ -861,7 +861,7 @@ void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenG
|
||||
|
||||
void gale::resource::Program::unUse() {
|
||||
GALE_VERBOSE("Will UN-use program : " << m_program);
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == false) {
|
||||
return;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <ethread/MutexRecursive.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <gale/debug.hpp>
|
||||
@ -19,7 +20,7 @@
|
||||
GALE_ERROR("Factory resource error"); \
|
||||
return nullptr; \
|
||||
} \
|
||||
resource->init(std::forward<GALE_TYPE>(_all)... ); \
|
||||
resource->init(etk::forward<GALE_TYPE>(_all)... ); \
|
||||
if (resource->resourceHasBeenCorectlyInit() == false) { \
|
||||
GALE_CRITICAL("resource Is not correctly init : " << #className ); \
|
||||
} \
|
||||
@ -47,7 +48,7 @@
|
||||
GALE_ERROR("allocation error of a resource : " << _name); \
|
||||
return nullptr; \
|
||||
} \
|
||||
resource->init(_name, std::forward<GALE_TYPE>(_all)... ); \
|
||||
resource->init(_name, etk::forward<GALE_TYPE>(_all)... ); \
|
||||
if (resource->resourceHasBeenCorectlyInit() == false) { \
|
||||
GALE_CRITICAL("resource Is not correctly init : " << #className ); \
|
||||
} \
|
||||
@ -74,7 +75,7 @@
|
||||
GALE_ERROR("allocation error of a resource : " << uniqueName); \
|
||||
return nullptr; \
|
||||
} \
|
||||
resource->init(uniqueName, std::forward<GALE_TYPE>(_all)... ); \
|
||||
resource->init(uniqueName, etk::forward<GALE_TYPE>(_all)... ); \
|
||||
if (resource->resourceHasBeenCorectlyInit() == false) { \
|
||||
GALE_CRITICAL("resource Is not correctly init : " << #className ); \
|
||||
} \
|
||||
@ -97,7 +98,7 @@ namespace gale {
|
||||
*/
|
||||
class Resource : public ememory::EnableSharedFromThis<gale::Resource> {
|
||||
protected:
|
||||
mutable std::recursive_mutex m_mutex;
|
||||
mutable ethread::MutexRecursive m_mutex;
|
||||
protected:
|
||||
/**
|
||||
* @brief generic protected contructor (use factory to create this class)
|
||||
|
@ -23,7 +23,7 @@ gale::resource::Shader::Shader() :
|
||||
}
|
||||
|
||||
void gale::resource::Shader::init(const etk::String& _filename) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
gale::Resource::init(_filename);
|
||||
GALE_DEBUG("OGL : load SHADER '" << _filename << "'");
|
||||
// load data from file "all the time ..."
|
||||
@ -40,15 +40,15 @@ void gale::resource::Shader::init(const etk::String& _filename) {
|
||||
}
|
||||
|
||||
gale::resource::Shader::~Shader() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_fileData.clear();
|
||||
gale::openGL::shader::remove(m_shader);
|
||||
m_exist = false;
|
||||
}
|
||||
|
||||
bool gale::resource::Shader::updateContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
||||
if (lock.try_lock() == false) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (lock.tryLock() == false) {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
@ -83,7 +83,7 @@ bool gale::resource::Shader::updateContext() {
|
||||
}
|
||||
|
||||
void gale::resource::Shader::removeContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (true == m_exist) {
|
||||
gale::openGL::shader::remove(m_shader);
|
||||
m_exist = false;
|
||||
@ -91,13 +91,13 @@ void gale::resource::Shader::removeContext() {
|
||||
}
|
||||
|
||||
void gale::resource::Shader::removeContextToLate() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_exist = false;
|
||||
m_shader = 0;
|
||||
}
|
||||
|
||||
void gale::resource::Shader::reload() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
etk::FSNode file(m_name);
|
||||
if (false == file.exist()) {
|
||||
GALE_CRITICAL("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'");
|
||||
|
@ -51,8 +51,8 @@ gale::resource::Texture::~Texture() {
|
||||
}
|
||||
|
||||
bool gale::resource::Texture::updateContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
||||
if (lock.try_lock() == false) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (lock.tryLock() == false) {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
@ -88,7 +88,7 @@ bool gale::resource::Texture::updateContext() {
|
||||
}
|
||||
|
||||
void gale::resource::Texture::removeContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (true == m_loaded) {
|
||||
// Request remove texture ...
|
||||
GALE_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
|
||||
@ -98,13 +98,13 @@ void gale::resource::Texture::removeContext() {
|
||||
}
|
||||
|
||||
void gale::resource::Texture::removeContextToLate() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_loaded = false;
|
||||
m_texId=0;
|
||||
}
|
||||
|
||||
void gale::resource::Texture::flush() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// request to the manager to be call at the next update ...
|
||||
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
||||
}
|
||||
@ -113,7 +113,7 @@ void gale::resource::Texture::setTexture(const ememory::SharedPtr<etk::Vector<ch
|
||||
const ivec2& _size,
|
||||
enum gale::resource::Texture::dataType _dataType,
|
||||
enum gale::resource::Texture::color _dataColorSpace) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_data = _data;
|
||||
m_size = _size;
|
||||
m_endPointSize = _size;
|
||||
|
@ -49,8 +49,8 @@ void gale::resource::VirtualBufferObject::retreiveData() {
|
||||
|
||||
bool gale::resource::VirtualBufferObject::updateContext() {
|
||||
GALE_VERBOSE(" Start: [" << getId() << "] '" << getName() << "' (size=" << m_buffer[0].size() << ")");
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
||||
if (lock.try_lock() == false) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (lock.tryLock() == false) {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
@ -76,7 +76,7 @@ bool gale::resource::VirtualBufferObject::updateContext() {
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::removeContext() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_exist == true) {
|
||||
gale::openGL::deleteBuffers(m_vbo);
|
||||
m_exist = false;
|
||||
@ -84,7 +84,7 @@ void gale::resource::VirtualBufferObject::removeContext() {
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::removeContextToLate() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_exist = false;
|
||||
for (size_t iii=0; iii<m_vbo.size(); iii++) {
|
||||
m_vbo[iii] = 0;
|
||||
@ -92,20 +92,20 @@ void gale::resource::VirtualBufferObject::removeContextToLate() {
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::reload() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
removeContext();
|
||||
updateContext();
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::flush() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// request to the manager to be call at the next update ...
|
||||
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
||||
GALE_VERBOSE("Request flush of VBO: [" << getId() << "] '" << getName() << "'");
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 3;
|
||||
} else if (m_vboSizeDataOffset[_id] != 3) {
|
||||
@ -119,7 +119,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3&
|
||||
}
|
||||
|
||||
vec3 gale::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID) const {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if ((size_t)_elementID*3 > m_buffer[_id].size()) {
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
@ -129,16 +129,16 @@ vec3 gale::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _
|
||||
}
|
||||
|
||||
int32_t gale::resource::VirtualBufferObject::bufferSize(int32_t _id) const {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
return m_buffer[_id].size()/m_vboSizeDataOffset[_id];
|
||||
}
|
||||
int32_t gale::resource::VirtualBufferObject::getElementSize(int32_t _id) const {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
return m_vboSizeDataOffset[_id];
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 2;
|
||||
} else if (m_vboSizeDataOffset[_id] != 2) {
|
||||
@ -151,7 +151,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2&
|
||||
}
|
||||
|
||||
vec2 gale::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID) const {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if ((size_t)_elementID*2 > m_buffer[_id].size()) {
|
||||
return vec2(0,0);
|
||||
}
|
||||
@ -160,7 +160,7 @@ vec2 gale::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const float& _data) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 1;
|
||||
} else if (m_vboSizeDataOffset[_id] != 1) {
|
||||
@ -172,7 +172,7 @@ void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const float&
|
||||
}
|
||||
|
||||
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 4;
|
||||
} else if (m_vboSizeDataOffset[_id] != 4) {
|
||||
@ -187,7 +187,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) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 3;
|
||||
} else if (m_vboSizeDataOffset[_id] != 3) {
|
||||
@ -201,7 +201,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) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 2;
|
||||
} else if (m_vboSizeDataOffset[_id] != 2) {
|
||||
@ -214,7 +214,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) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 1;
|
||||
} else if (m_vboSizeDataOffset[_id] != 1) {
|
||||
|
@ -172,7 +172,7 @@ def configure(target, my_module):
|
||||
my_module.add_path(".")
|
||||
|
||||
my_module.add_flag('c++', [
|
||||
"-DGALE_VERSION=\"\\\"" + tools.version_toString(my_module.get_pkg("VERSION")) + "\\\"\""
|
||||
"-DGALE_VERSION=\"\\\"" + tools.version_to_string(my_module.get_pkg("VERSION")) + "\\\"\""
|
||||
])
|
||||
|
||||
if "Web" in target.get_type():
|
||||
@ -401,7 +401,7 @@ def tool_generate_main_java_class(target, module, package_name):
|
||||
debug.warning("Missing application 'VERSION_CODE' ==> set it at '0' (this can creata an NON update on android play store)")
|
||||
module.set_pkg("VERSION_CODE", "0")
|
||||
tmpFile.write( ' android:versionCode="' + str(module.get_pkg("VERSION_CODE")) + '" \n')
|
||||
tmpFile.write( ' android:versionName="'+tools.version_toString(module.get_pkg("VERSION"))+'"> \n')
|
||||
tmpFile.write( ' android:versionName="'+tools.version_to_string(module.get_pkg("VERSION"))+'"> \n')
|
||||
tmpFile.write( ' <uses-feature android:glEsVersion="0x00030000" android:required="true" />\n')
|
||||
tmpFile.write( ' <uses-sdk android:minSdkVersion="' + str(target.board_id) + '" \n')
|
||||
tmpFile.write( ' android:targetSdkVersion="' + str(target.board_id) + '" /> \n')
|
||||
|
Loading…
Reference in New Issue
Block a user