[DEV] replay simulation is now availlable and multiple backend

This commit is contained in:
Edouard DUPIN 2017-01-25 22:44:53 +01:00
parent b1033f884e
commit 65a35a8ead
22 changed files with 982 additions and 186 deletions

View File

@ -0,0 +1,29 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#if 0
namespace gale {
namespace context {
namespace Android {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}
#endif

View File

@ -172,7 +172,7 @@ void gale::Context::setArchiveDir(int _mode, const char* _str, const char* _appl
gale::Context::Context(gale::Application* _application, int32_t _argc, const char* _argv[]) : gale::Context::Context(gale::Application* _application, int32_t _argc, const char* _argv[]) :
m_application(_application), m_application(_application),
m_imulationActive(false), m_simulationActive(false),
m_simulationFile("gale.gsim"), m_simulationFile("gale.gsim"),
//m_objectManager(*this), //m_objectManager(*this),
m_previousDisplayTime(), m_previousDisplayTime(),
@ -207,10 +207,10 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
m_displayFps=true; m_displayFps=true;
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-file=") == true) { } else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-file=") == true) {
m_simulationFile.setName(std::string(m_commandLine.get(iii).begin()+23, m_commandLine.get(iii).end()) ); m_simulationFile.setName(std::string(m_commandLine.get(iii).begin()+23, m_commandLine.get(iii).end()) );
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-mode=") == true) { } else if (m_commandLine.get(iii) == "--gale-simulation-record") {
m_imulationActive = true; m_simulationActive = true;
} else if (m_commandLine.get(iii) == "--gale-simulation-stop") { } else if (etk::start_with(m_commandLine.get(iii), "--gale-backend=") == true) {
// nothing to do ==> parse in the buttom of the current file ...
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
} else if (m_commandLine.get(iii) == "--gale-disable-opengl") { } else if (m_commandLine.get(iii) == "--gale-disable-opengl") {
gale::openGL::startSimulationMode(); gale::openGL::startSimulationMode();
@ -222,18 +222,39 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
GALE_PRINT(" " << etk::getApplicationName() << " [options]"); GALE_PRINT(" " << etk::getApplicationName() << " [options]");
GALE_PRINT(" --gale-simulation-file=XXX.gsim"); GALE_PRINT(" --gale-simulation-file=XXX.gsim");
GALE_PRINT(" Enable the simulation mode of the gale IO, parameter: file (default:simulation gale.gsim)"); GALE_PRINT(" Enable the simulation mode of the gale IO, parameter: file (default:simulation gale.gsim)");
GALE_PRINT(" --gale-simulation-mode=XXX"); GALE_PRINT(" --gale-simulation-record");
GALE_PRINT(" Mode of the simulation"); GALE_PRINT(" Record the IO in the simulation file");
GALE_PRINT(" - record Record all input of the playing element (default)");
GALE_PRINT(" - play Play all the sequence write in the simulation file");
GALE_PRINT(" --gale-simulation-stop");
GALE_PRINT(" Stop at the end of the simulation");
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
GALE_PRINT(" --gale-disable-opengl"); GALE_PRINT(" --gale-disable-opengl");
GALE_PRINT(" Disable openGL access (availlable in SIMULATION mode)"); GALE_PRINT(" Disable openGL access (availlable in SIMULATION mode)");
#endif #endif
GALE_PRINT(" --gale-fps"); GALE_PRINT(" --gale-fps");
GALE_PRINT(" Display the current fps of the display"); GALE_PRINT(" Display the current fps of the display");
#if defined(__TARGET_OS__Linux)
GALE_PRINT(" --gale-backend=XXX");
GALE_PRINT(" 'X11' For X11 backend (default)");
GALE_PRINT(" 'wayland' For wayland backend");
#ifdef GALE_BUILD_SIMULATION
GALE_PRINT(" 'simulation' For simulation backend");
#endif
GALE_PRINT(" can be set with environement variable 'export EWOL_BACKEND=xxx'");
#endif
#if defined(__TARGET_OS__Windows)
GALE_PRINT(" --gale-backend=XXX");
GALE_PRINT(" 'windows' For windows backend (default)");
#ifdef GALE_BUILD_SIMULATION
GALE_PRINT(" 'simulation' For simulation backend");
#endif
GALE_PRINT(" can be set with environement variable 'export EWOL_BACKEND=xxx'");
#endif
#if defined(__TARGET_OS__MacOs)
GALE_PRINT(" --gale-backend=XXX");
GALE_PRINT(" 'macos' For MacOs backend (default)");
#ifdef GALE_BUILD_SIMULATION
GALE_PRINT(" 'simulation' For simulation backend");
#endif
GALE_PRINT(" can be set with environement variable 'export EWOL_BACKEND=xxx'");
#endif
GALE_PRINT(" -h/--help"); GALE_PRINT(" -h/--help");
GALE_PRINT(" Display this help"); GALE_PRINT(" Display this help");
GALE_PRINT(" example:"); GALE_PRINT(" example:");
@ -255,11 +276,17 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
GALE_INFO("GALE v:" << gale::getVersion()); GALE_INFO("GALE v:" << gale::getVersion());
// request the init of the application in the main context of openGL ... // request the init of the application in the main context of openGL ...
if (m_imulationActive == true) { if (m_simulationActive == true) {
// in simulation case:
if (m_simulationFile.fileOpenWrite() == false) {
GALE_CRITICAL("Can not create Simulation file : " << m_simulationFile);
m_simulationActive = false;
} else {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":INIT"); m_simulationFile.filePuts(":INIT");
m_simulationFile.filePuts("\n"); m_simulationFile.filePuts("\n");
} }
}
m_msgSystem.post([](gale::Context& _context){ m_msgSystem.post([](gale::Context& _context){
ememory::SharedPtr<gale::Application> appl = _context.getApplication(); ememory::SharedPtr<gale::Application> appl = _context.getApplication();
if (appl == nullptr) { if (appl == nullptr) {
@ -279,10 +306,6 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
#else #else
forceOrientation(gale::orientation::screenAuto); forceOrientation(gale::orientation::screenAuto);
#endif #endif
if (m_imulationActive == true) {
// in simulation case:
m_simulationFile.fileOpenWrite();
}
// release the curent interface : // release the curent interface :
unLockContext(); unLockContext();
GALE_INFO(" == > Gale system init (END)"); GALE_INFO(" == > Gale system init (END)");
@ -321,14 +344,14 @@ gale::Context::~Context() {
// release the curent interface : // release the curent interface :
unLockContext(); unLockContext();
GALE_INFO(" == > Gale system Un-Init (END)"); GALE_INFO(" == > Gale system Un-Init (END)");
if (m_imulationActive == true) { if (m_simulationActive == true) {
// in simulation case: // in simulation case:
m_simulationFile.fileClose(); m_simulationFile.fileClose();
} }
} }
void gale::Context::requestUpdateSize() { void gale::Context::requestUpdateSize() {
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":RECALCULATE_SIZE\n"); m_simulationFile.filePuts(":RECALCULATE_SIZE\n");
} }
@ -345,7 +368,7 @@ void gale::Context::OS_Resize(const vec2& _size) {
} }
// TODO : Better in the thread ... ==> but generate some init error ... // TODO : Better in the thread ... ==> but generate some init error ...
gale::Dimension::setPixelWindowsSize(_size); gale::Dimension::setPixelWindowsSize(_size);
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":RESIZE:"); m_simulationFile.filePuts(":RESIZE:");
m_simulationFile.filePuts(etk::to_string(_size)); m_simulationFile.filePuts(etk::to_string(_size));
@ -398,7 +421,7 @@ void gale::Context::OS_SetInput(enum gale::key::type _type,
enum gale::key::status _status, enum gale::key::status _status,
int32_t _pointerID, int32_t _pointerID,
const vec2& _pos) { const vec2& _pos) {
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":INPUT:"); m_simulationFile.filePuts(":INPUT:");
m_simulationFile.filePuts(etk::to_string(_type)); m_simulationFile.filePuts(etk::to_string(_type));
@ -435,7 +458,7 @@ void gale::Context::OS_setKeyboard(const gale::key::Special& _special,
_state = gale::key::status::upRepeate; _state = gale::key::status::upRepeate;
} }
} }
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":KEYBOARD:"); m_simulationFile.filePuts(":KEYBOARD:");
m_simulationFile.filePuts(etk::to_string(_special)); m_simulationFile.filePuts(etk::to_string(_special));
@ -461,7 +484,7 @@ void gale::Context::OS_setKeyboard(const gale::key::Special& _special,
} }
void gale::Context::OS_Hide() { void gale::Context::OS_Hide() {
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":VIEW:false\n"); m_simulationFile.filePuts(":VIEW:false\n");
} }
@ -482,7 +505,7 @@ void gale::Context::OS_Hide() {
} }
void gale::Context::OS_Show() { void gale::Context::OS_Show() {
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":VIEW:true\n"); m_simulationFile.filePuts(":VIEW:true\n");
} }
@ -503,7 +526,7 @@ void gale::Context::OS_Show() {
void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID) { void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID) {
if (m_imulationActive == true) { if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now())); m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":CLIPBOARD_ARRIVE:"); m_simulationFile.filePuts(":CLIPBOARD_ARRIVE:");
m_simulationFile.filePuts(etk::to_string(_clipboardID)); m_simulationFile.filePuts(etk::to_string(_clipboardID));
@ -528,6 +551,12 @@ void gale::Context::clipBoardSet(enum gale::context::clipBoard::clipboardListe _
} }
bool gale::Context::OS_Draw(bool _displayEveryTime) { bool gale::Context::OS_Draw(bool _displayEveryTime) {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
m_simulationFile.filePuts(":DRAW:");
m_simulationFile.filePuts(etk::to_string(_displayEveryTime));
m_simulationFile.filePuts("\n");
}
gale::openGL::threadHasContext(); gale::openGL::threadHasContext();
echrono::Steady currentTime = echrono::Steady::now(); echrono::Steady currentTime = echrono::Steady::now();
// this is to prevent the multiple display at the a high frequency ... // this is to prevent the multiple display at the a high frequency ...
@ -746,3 +775,298 @@ void gale::Context::keyboardHide() {
GALE_INFO("keyboardHide: NOT implemented ..."); GALE_INFO("keyboardHide: NOT implemented ...");
} }
// for IOs and Android, this is embended system ==> it is too complex tro wrap it ...
#if !defined(__TARGET_OS__Android) \
&& !defined(__TARGET_OS__IOs)
#if defined(__TARGET_OS__Linux)
#ifdef GALE_BUILD_X11
#include <gale/context/X11/Context.hpp>
#endif
#ifdef GALE_BUILD_WAYLAND
#include <gale/context/wayland/Context.hpp>
#endif
#elif defined(__TARGET_OS__Windows)
#include <gale/context/Windows/Context.hpp>
#elif defined(__TARGET_OS__Web)
#include <gale/context/SDL/Context.hpp>
#elif defined(__TARGET_OS__Android)
//#include <gale/context/Android/Context.hpp>
#elif defined(__TARGET_OS__IOs)
//#include <gale/context/IOs/Context.hpp>
#elif defined(__TARGET_OS__MacOs)
#include <gale/context/MacOs/Context.hpp>
#endif
#ifdef GALE_BUILD_SIMULATION
#include <gale/context/simulation/Context.hpp>
#endif
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
ememory::SharedPtr<gale::Context> context;
std::string request = "";
// get the environement variable:
char * basicEnv = getenv("EWOL_BACKEND");
if (nullptr != basicEnv) {
std::string tmpVal = basicEnv;
//TODO : Check if it leak ...
#if defined(__TARGET_OS__Linux)
if (false) { }
#ifdef GALE_BUILD_X11
else if (tmpVal == "X11") {
request = tmpVal;
}
#endif
#ifdef GALE_BUILD_WAYLAND
else if (tmpVal == "wayland") {
request = tmpVal;
}
#endif
#ifdef GALE_BUILD_SIMULATION
else if (tmpVal == "simulation") {
request = tmpVal;
}
#endif
else {
GALE_ERROR("Unsupported environement variable : '" << tmpVal << "' only: ["
#ifdef GALE_BUILD_X11
<< "X11"
#endif
#ifdef GALE_BUILD_WAYLAND
<< ",wayland"
#endif
#ifdef GALE_BUILD_SIMULATION
<< ",simulation"
#endif
<< "]");
}
#elif defined(__TARGET_OS__Windows)
if ( tmpVal != "windows"
#ifdef GALE_BUILD_SIMULATION
|| tmpVal != "simulation"
#endif
) {
GALE_ERROR("Unsupported environement variable : '" << tmpVal << "' only: [windows,"
#ifdef GALE_BUILD_SIMULATION
<< ",simulation"
#endif
<< "]");
} else {
request = tmpVal;
}
#elif defined(__TARGET_OS__MacOs)
if ( tmpVal != "macos"
#ifdef GALE_BUILD_SIMULATION
|| tmpVal != "simulation"
#endif
) {
GALE_ERROR("Unsupported environement variable : '" << tmpVal << "' only: [macos,"
#ifdef GALE_BUILD_SIMULATION
<< ",simulation"
#endif
<< "]");
} else {
request = tmpVal;
}
#else
GALE_ERROR("Unsupported environement variable 'EWOL_BACKEND' in this mode");
#endif
}
for(int32_t iii=0; iii<_argc; ++iii) {
if (etk::start_with(_argv[iii], "--gale-backend=") == true) {
std::string tmpVal = &(_argv[iii][15]);
#if defined(__TARGET_OS__Linux)
if (false) { }
#ifdef GALE_BUILD_X11
else if (tmpVal == "X11") {
request = tmpVal;
}
#endif
#ifdef GALE_BUILD_WAYLAND
else if (tmpVal == "wayland") {
request = tmpVal;
}
#endif
#ifdef GALE_BUILD_SIMULATION
else if (tmpVal == "simulation") {
request = tmpVal;
}
#endif
else {
GALE_ERROR("Unsupported environement variable : '" << tmpVal << "' only: ["
#ifdef GALE_BUILD_X11
<< "X11"
#endif
#ifdef GALE_BUILD_WAYLAND
<< ",wayland"
#endif
#ifdef GALE_BUILD_SIMULATION
<< ",simulation"
#endif
<< "]");
}
#elif defined(__TARGET_OS__Windows)
if ( tmpVal != "windows"
#ifdef GALE_BUILD_SIMULATION
|| tmpVal != "simulation"
#endif
) {
GALE_ERROR("Unsupported command line input --gale-backend='" << tmpVal << "' only: [windows,"
#ifdef GALE_BUILD_SIMULATION
<< ",simulation"
#endif
<< "]");
} else {
request = tmpVal;
}
#elif defined(__TARGET_OS__MacOs)
if ( tmpVal != "macos"
#ifdef GALE_BUILD_SIMULATION
|| tmpVal != "simulation"
#endif
) {
GALE_ERROR("Unsupported command line input --gale-backend='" << tmpVal << "' only: [macos,"
#ifdef GALE_BUILD_SIMULATION
<< ",simulation"
#endif
<< "]");
} else {
request = tmpVal;
}
#else
GALE_ERROR("Unsupported environement variable 'EWOL_BACKEND' in this mode");
#endif
}
}
#if defined(__TARGET_OS__Linux)
if (request == "") {
if (false) {}
#ifdef GALE_BUILD_X11
else if (gale::context::x11::isBackendPresent() == true) {
context = gale::context::x11::createInstance(_application, _argc, _argv);
}
#endif
#ifdef GALE_BUILD_WAYLAND
else if (gale::context::wayland::isBackendPresent() == true) {
context = gale::context::wayland::createInstance(_application, _argc, _argv);
}
#endif
#ifdef GALE_BUILD_SIMULATION
else if (gale::context::simulation::isBackendPresent() == true) {
context = gale::context::simulation::createInstance(_application, _argc, _argv);
}
#endif
else {
GALE_CRITICAL("Have no backend to generate display ...");
}
}
#ifdef GALE_BUILD_X11
else if (request == "X11") {
if (gale::context::x11::isBackendPresent() == true) {
context = gale::context::x11::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'X11' is not present");
}
}
#endif
#ifdef GALE_BUILD_WAYLAND
else if (request == "wayland") {
if (gale::context::wayland::isBackendPresent() == true) {
context = gale::context::wayland::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'wayland' is not present");
}
#endif
#ifdef GALE_BUILD_SIMULATION
} else if (request == "simulation") {
if (gale::context::simulation::isBackendPresent() == true) {
context = gale::context::simulation::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'simulation' is not present");
}
#endif
} else {
GALE_CRITICAL("Must not appear");
}
#elif defined(__TARGET_OS__Windows)
if (request == "") {
if (gale::context::windows::isBackendPresent() == true) {
context = gale::context::windows::createInstance(_application, _argc, _argv);
}
#ifdef GALE_BUILD_SIMULATION
else if (gale::context::simulation::isBackendPresent() == true) {
context = gale::context::simulation::createInstance(_application, _argc, _argv);
}
#endif
else {
GALE_CRITICAL("Have no backend to generate display ...");
}
} else if (request == "windows") {
if (gale::context::windows::isBackendPresent() == true) {
context = gale::context::windows::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'windows' is not present");
}
}
#ifdef GALE_BUILD_SIMULATION
else if (request == "simulation") {
if (gale::context::simulation::isBackendPresent() == true) {
context = gale::context::simulation::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'simulation' is not present");
}
#endif
} else {
GALE_CRITICAL("Must not appear");
}
#elif defined(__TARGET_OS__Web)
context = gale::context::web::createInstance(_application, _argc, _argv);
#elif defined(__TARGET_OS__Android)
context = gale::context::andoid::createInstance(_application, _argc, _argv);
#elif defined(__TARGET_OS__IOs)
context = gale::context::ios::createInstance(_application, _argc, _argv);
#elif defined(__TARGET_OS__MacOs)
if (request == "") {
if (gale::context::macos::isBackendPresent() == true) {
context = gale::context::macos::createInstance(_application, _argc, _argv);
}
#ifdef GALE_BUILD_SIMULATION
else if (gale::context::simulation::isBackendPresent() == true) {
context = gale::context::simulation::createInstance(_application, _argc, _argv);
}
#endif
else {
GALE_CRITICAL("Have no backend to generate display ...");
}
} else if (request == "macos") {
if (gale::context::macos::isBackendPresent() == true) {
context = gale::context::macos::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'macos' is not present");
}
#ifdef GALE_BUILD_SIMULATION
} else if (request == "simulation") {
if (gale::context::simulation::isBackendPresent() == true) {
context = gale::context::simulation::createInstance(_application, _argc, _argv);
} else {
GALE_CRITICAL("Backend 'simulation' is not present");
}
#endif
} else {
GALE_CRITICAL("Must not appear");
}
#endif
if (context == nullptr) {
GALE_ERROR("Can not allocate the interface of the GUI ...");
return -1;
}
return context->run();
}
#endif

View File

@ -60,9 +60,9 @@ namespace gale {
* @note this un-lock the main mutex * @note this un-lock the main mutex
*/ */
void unLockContext(); void unLockContext();
private: protected:
// simulation area: // simulation area:
bool m_imulationActive; bool m_simulationActive;
etk::FSNode m_simulationFile; etk::FSNode m_simulationFile;
private: private:
echrono::Steady m_previousDisplayTime; // this is to limit framerate ... in case... echrono::Steady m_previousDisplayTime; // this is to limit framerate ... in case...
@ -289,6 +289,12 @@ namespace gale {
* @param[in] _fileName Name of the image to load * @param[in] _fileName Name of the image to load
*/ */
void setInitImage(const std::string& _fileName); void setInitImage(const std::string& _fileName);
/**
* @brief Internal API to run the processing of the event loop ...
* @return The Exit value of the program
* @note INTERNAL API
*/
virtual int32_t run() = 0;
}; };
/** /**
* @brief From everyware in the program, we can get the context inteface. * @brief From everyware in the program, we can get the context inteface.

View File

@ -32,3 +32,25 @@ namespace IOs {
void suspend(); void suspend();
} }
#if 0
namespace gale {
namespace context {
namespace ios {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}
#endif

View File

@ -25,3 +25,23 @@ namespace MacOs {
*/ */
} }
namespace gale {
namespace context {
namespace macos {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -260,6 +260,10 @@ class GLUTInterface : public gale::Context {
m_cursorEventPos); m_cursorEventPos);
} }
} }
int32_t run() {
glutMainLoop();
return 0;
}
}; };
GLUTInterface* g_interface = nullptr; GLUTInterface* g_interface = nullptr;
@ -287,12 +291,17 @@ static void gale_glut_mouse_pasive(int _x, int _y) {
g_interface->mousePasive(vec2(_x, _y)); g_interface->mousePasive(vec2(_x, _y));
} }
/**
* @brief Main of the program
* @param std IO
* @return std IO #include <gale/context/SDL/Context.hpp>
*/
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) { bool gale::context::sdl::isBackendPresent() {
// TODO : Do it better...
return true;
}
ememory::SharedPtr<gale::Context> gale::context::sdl::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
// include GL stuff, to check that we can compile hybrid 2d/GL apps // include GL stuff, to check that we can compile hybrid 2d/GL apps
extern void glBegin(int mode); extern void glBegin(int mode);
@ -302,12 +311,7 @@ int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
glBindBuffer(0, 0); glBindBuffer(0, 0);
} }
#endif #endif
etk::init(_argc, _argv); ememory::SharedPtr<gale::Context> out; ememory::makeShared<X11Interface>(_application, _argc, _argv);
g_interface = new GLUTInterface(_application, _argc, _argv);
if (g_interface == nullptr) {
GALE_CRITICAL("Can not create the GLUT interface ... MEMORY allocation error");
return -2;
}
/* Initialize the window */ /* Initialize the window */
glutInit(&_argc, (char**)_argv); glutInit(&_argc, (char**)_argv);
@ -325,11 +329,5 @@ int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
glutMotionFunc(gale_glut_mouse_pasive); glutMotionFunc(gale_glut_mouse_pasive);
GALE_DEBUG("7987984654654\n"); GALE_DEBUG("7987984654654\n");
glutMainLoop(); return out;
int32_t retValue = 0;
delete(g_interface);
g_interface = nullptr;
return retValue;
} }

View File

@ -625,23 +625,13 @@ static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARA
return galeWindowsContext->WndProcReal(_hWnd, _message, _wParam, _lParam); return galeWindowsContext->WndProcReal(_hWnd, _message, _wParam, _lParam);
} }
/** #include <gale/context/Windows/Context.hpp>
* @brief Main of the program
* @param std IO bool gale::context::windows::isBackendPresent() {
* @return std IO // TODO : Do it better...
*/ return true;
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
WindowsContext* localInterface = new WindowsContext(_application, _argc, _argv);
if (localInterface == nullptr) {
GALE_CRITICAL("Can not create the 'Windows' interface ... MEMORY allocation error");
return -2;
} }
int32_t retValue = localInterface->run(); ememory::SharedPtr<gale::Context> gale::context::windows::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
delete(localInterface); return ememory::makeShared<WindowsContext>(_application, _argc, _argv);
localInterface = nullptr;
GALE_INFO("END APPLICATION");
return retValue;
} }

View File

@ -0,0 +1,26 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace windows {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -45,7 +45,7 @@
#define GUI_LOCK() XLockDisplay(m_display) #define GUI_LOCK() XLockDisplay(m_display)
#define GUI_UNLOCK() XUnlockDisplay(m_display) #define GUI_UNLOCK() XUnlockDisplay(m_display)
*/ */
bool hasDisplay = false; static bool hasDisplay = false;
//#define DEBUG_X11_EVENT //#define DEBUG_X11_EVENT
#ifdef DEBUG_X11_EVENT #ifdef DEBUG_X11_EVENT
#define X11_DEBUG GALE_DEBUG #define X11_DEBUG GALE_DEBUG
@ -1484,21 +1484,13 @@ class X11Interface : public gale::Context {
} }
}; };
#include <gale/context/X11/Context.hpp>
/** bool gale::context::x11::isBackendPresent() {
* @brief Main of the program // TODO : Do it better...
* @param std IO return true;
* @return std IO
*/
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
X11Interface* interface = new X11Interface(_application, _argc, _argv);
if (interface == nullptr) {
GALE_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2;
} }
int32_t retValue = interface->run();
delete(interface); ememory::SharedPtr<gale::Context> gale::context::x11::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
interface = nullptr; return ememory::makeShared<X11Interface>(_application, _argc, _argv);
return retValue;
} }

View File

@ -0,0 +1,26 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace x11 {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -48,6 +48,16 @@ namespace etk {
template<> std::string to_string<enum gale::context::clipBoard::clipboardListe>(const enum gale::context::clipBoard::clipboardListe& _obj) { template<> std::string to_string<enum gale::context::clipBoard::clipboardListe>(const enum gale::context::clipBoard::clipboardListe& _obj) {
return clipboardDescriptionString[int32_t(_obj)]; return clipboardDescriptionString[int32_t(_obj)];
} }
template <> bool from_string<enum gale::context::clipBoard::clipboardListe>(enum gale::context::clipBoard::clipboardListe& _variableRet, const std::string& _value) {
for (size_t iii=0; iii< sizeof(clipboardDescriptionString); ++iii) {
if (clipboardDescriptionString[iii] == _value) {
_variableRet = (enum gale::context::clipBoard::clipboardListe)iii;
return true;
}
}
return false;
}
} }
void gale::context::clipBoard::init() { void gale::context::clipBoard::init() {

View File

@ -0,0 +1,225 @@
/** @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 <gale/renderer/openGL/openGL.hpp>
#include <gale/renderer/openGL/openGL-include.hpp>
static std::vector<std::string> localSplit(const std::string& _input) {
std::vector<std::string> out;
char lastValue = '\0';
std::string tmpInput;
for(auto &it : _input) {
if ( lastValue == ':'
&& it == ':') {
tmpInput += "::";
lastValue = '\0';
continue;
} else if (lastValue == ':') {
out.push_back(tmpInput);
tmpInput = "";
tmpInput += it;
} else if (it == ':') {
// nothing to do ...
} else {
tmpInput += it;
}
lastValue = it;
}
if (tmpInput!="") {
out.push_back(tmpInput);
}
return out;
}
class SimulationInterface : public gale::Context {
private:
gale::key::Special m_guiKeyBoardMode;
bool m_run;
public:
SimulationInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv) {
GALE_INFO("SIMU:INIT");
m_run = true;
}
~SimulationInterface() {
// TODO : ...
}
int32_t run() {
// Try to open the file of simulation:
if (m_simulationFile.fileOpenRead() == false) {
GALE_ERROR("can not open the simulation file");
return -1;
}
std::string action;
// main cycle
while(m_run == true) {
bool lineIsOk = m_simulationFile.fileGets(action);
if (lineIsOk == false) {
// reach end of simulation file;
return 0;
}
if (action.size() == 0) {
continue;
}
GALE_VERBOSE("SIM-EVENT : '" << action << "'");
std::vector<std::string> pads = localSplit(action);
GALE_DEBUG(" " << pads);
// The first is the time ...
if (pads.size() < 2) {
GALE_ERROR("Simu: Can not parse: '" << action << "'");
continue;
}
uint64_t time = etk::string_to_uint64_t(pads[0]);
std::string localAction = pads[1];
if (localAction == "INIT") {
// nothing to do ...
} else if (localAction == "RECALCULATE_SIZE") {
//requestUpdateSize();
} else if (localAction == "RESIZE") {
// vec2
OS_Resize(vec2(pads[2]));
} else if (localAction == "INPUT") {
// string type
// string status
// int32_t pointerID
// vec2 pos
enum gale::key::type type;
etk::from_string(type, pads[2]);
enum gale::key::status status;
etk::from_string(status, pads[3]);
int32_t pointerID = etk::string_to_int32_t(pads[4]);
vec2 pos(pads[5]);
OS_SetInput(type, status, pointerID, pos);
} else if (localAction == "KEYBOARD") {
// string special
// string type
// int32_t state
// vec2 value
gale::key::Special special;
etk::from_string(special, pads[2]);
enum gale::key::keyboard type;
etk::from_string(type, pads[3]);
enum gale::key::status status;
etk::from_string(status, pads[4]);
char32_t valChar = etk::string_to_uint64_t(pads[5]);
OS_setKeyboard(special, type, status, false, valChar);
} else if (localAction == "VIEW") {
// bool ==> hide, show ...
if (etk::string_to_bool(pads[2]) == true) {
OS_Show();
} else {
OS_Hide();
}
} else if (localAction == "CLIPBOARD_ARRIVE") {
// int32_t clipboard ID
enum gale::context::clipBoard::clipboardListe clipboardId;
etk::from_string(clipboardId, pads[2]);
OS_ClipBoardArrive(clipboardId);
} else if (localAction == "DRAW") {
// bool ==> display every time ...
OS_Draw(etk::string_to_bool(pads[2]));
} else {
GALE_ERROR("unknow event : '" << localAction << "'");
}
}
m_simulationFile.fileClose();
return 0;
}
/****************************************************************************************/
virtual void stop() {
GALE_INFO("SIMU-API: Stop");
m_run = false;
}
/****************************************************************************************/
virtual void setSize(const vec2& _size) {
GALE_INFO("SIMU-API: changeSize=" << _size);
}
/****************************************************************************************/
void setFullScreen(bool _status) {
GALE_INFO("SIMU-API: changeFullscreen=" << _status);
}
/****************************************************************************************/
virtual void grabKeyboardEvents(bool _status) {
}
/****************************************************************************************/
virtual void setWindowsDecoration(bool _status) {
GALE_INFO("SIMU-API: setWindows Decoration :" << _status);
};
/****************************************************************************************/
virtual void setPos(const vec2& _pos) {
GALE_INFO("SIMU-API: changePos=" << _pos);
}
/****************************************************************************************/
virtual void setCursor(enum gale::context::cursor _newCursor) {
GALE_INFO("SIMU-API: setCursor=" << _newCursor);
}
/****************************************************************************************/
void grabPointerEvents(bool _status, const vec2& _forcedPosition) {
GALE_DEBUG("SIMU-API: Grab Events");
}
/****************************************************************************************/
void setIcon(const std::string& _inputFile) {
GALE_DEBUG("SIMU set icon " << _inputFile);
}
/****************************************************************************************/
void setTitle(const std::string& _title) {
GALE_INFO("SIMU: set Title " << _title);
}
void openURL(const std::string& _url) {
GALE_INFO("SIMU: open URL " << _url);
}
/****************************************************************************************/
void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
GALE_INFO("SIMU: clipBoardGet " << _clipboardID);
}
/****************************************************************************************/
void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
GALE_INFO("SIMU: clipBoardSet " << _clipboardID);
}
};
#include <gale/context/simulation/Context.hpp>
bool gale::context::simulation::isBackendPresent() {
// TODO : Do it better...
return true;
}
ememory::SharedPtr<gale::Context> gale::context::simulation::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
// Disable openGL:
gale::openGL::startSimulationMode();
return ememory::makeShared<SimulationInterface>(_application, _argc, _argv);
}

View File

@ -0,0 +1,26 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace simulation {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -53,7 +53,7 @@ extern "C" {
#include <gale/renderer/openGL/openGL-include.hpp> #include <gale/renderer/openGL/openGL-include.hpp>
bool hasDisplay = false; static bool hasDisplay = false;
#define DEBUG_WAYLAND_EVENT #define DEBUG_WAYLAND_EVENT
#ifdef DEBUG_WAYLAND_EVENT #ifdef DEBUG_WAYLAND_EVENT
#define WAYLAND_DEBUG GALE_DEBUG #define WAYLAND_DEBUG GALE_DEBUG
@ -1842,17 +1842,15 @@ static void data_source_cancelled(void* _data, struct wl_data_source* _wl_data_s
} }
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) { #include <gale/context/wayland/Context.hpp>
etk::init(_argc, _argv);
WAYLANDInterface* interface = new WAYLANDInterface(_application, _argc, _argv); bool gale::context::wayland::isBackendPresent() {
if (interface == nullptr) { // TODO : Do it better...
GALE_CRITICAL("Can not create the WAYLAND interface ... MEMORY allocation error"); return true;
return -2;
} }
int32_t retValue = interface->run();
delete(interface); ememory::SharedPtr<gale::Context> gale::context::wayland::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
interface = nullptr; return ememory::makeShared<WAYLANDInterface>(_application, _argc, _argv);
return retValue;
} }

View File

@ -0,0 +1,26 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace wayland {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -262,4 +262,32 @@ namespace etk {
} }
return out; return out;
} }
template <> bool from_string<gale::key::Special>(gale::key::Special& _variableRet, const std::string& _value) {
gale::key::Special out;
std::vector<std::string> listElem = etk::split(_value, "|");
for (auto &it : listElem) {
if (it == "CAPS") {
out.setCapsLock(true);
} else if (it == "SHIFT") {
out.setShift(true);
} else if (it == "CTRL") {
out.setCtrl(true);
} else if (it == "META") {
out.setMeta(true);
} else if (it == "ALT") {
out.setAlt(true);
} else if (it == "ALTGR") {
out.setAltGr(true);
} else if (it == "NUM_LOCK") {
out.setNumLock(true);
} else if (it == "INSERT") {
out.setInsert(true);
} else {
GALE_ERROR("unknow element '" << it << "'");
return false;
}
}
_variableRet = out;
return true;
}
} }

View File

@ -64,5 +64,15 @@ namespace etk {
template<> std::string to_string<enum gale::key::keyboard>(const enum gale::key::keyboard& _obj) { template<> std::string to_string<enum gale::key::keyboard>(const enum gale::key::keyboard& _obj) {
return keyboardDescriptionString[int32_t(_obj)]; return keyboardDescriptionString[int32_t(_obj)];
} }
template <> bool from_string<enum gale::key::keyboard>(enum gale::key::keyboard& _variableRet, const std::string& _value) {
for (size_t iii=0; iii< sizeof(keyboardDescriptionString); ++iii) {
if (keyboardDescriptionString[iii] == _value) {
_variableRet = (enum gale::key::keyboard)iii;
return true;
}
}
return false;
}
} }

View File

@ -35,5 +35,14 @@ namespace etk {
template<> std::string to_string<enum gale::key::status>(const enum gale::key::status& _obj) { template<> std::string to_string<enum gale::key::status>(const enum gale::key::status& _obj) {
return statusDescriptionString[int32_t(_obj)]; return statusDescriptionString[int32_t(_obj)];
} }
}
template <> bool from_string<enum gale::key::status>(enum gale::key::status& _variableRet, const std::string& _value) {
for (size_t iii=0; iii< sizeof(statusDescriptionString); ++iii) {
if (statusDescriptionString[iii] == _value) {
_variableRet = (enum gale::key::status)iii;
return true;
}
}
return false;
}
}

View File

@ -24,4 +24,14 @@ namespace etk {
template<> std::string to_string<enum gale::key::type>(const enum gale::key::type& _obj) { template<> std::string to_string<enum gale::key::type>(const enum gale::key::type& _obj) {
return typeDescriptionString[int32_t(_obj)]; return typeDescriptionString[int32_t(_obj)];
} }
template <> bool from_string<enum gale::key::type>(enum gale::key::type& _variableRet, const std::string& _value) {
for (size_t iii=0; iii< sizeof(typeDescriptionString); ++iii) {
if (typeDescriptionString[iii] == _value) {
_variableRet = (enum gale::key::type)iii;
return true;
}
}
return false;
}
} }

View File

@ -39,7 +39,7 @@ static void checkGlError(const char* _op, int32_t _localLine) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
bool s_simulationMode = false; bool s_simulationMode = false;
/** /**
* @brief Start the simulation mode of Open GL (can be usebull when no HW is availlable for testing System like buildfarm (eg: travis-ci) * @brief Start the simulation mode of Open GL (can be usebull when no HW is availlable for testing System like buildfarm (eg: travis-ci)
@ -188,12 +188,12 @@ void gale::openGL::finish() {
void gale::openGL::flush() { void gale::openGL::flush() {
l_programId = -1; l_programId = -1;
l_textureflags = 0; l_textureflags = 0;
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glFlush(); glFlush();
checkGlError("glFlush", __LINE__); checkGlError("glFlush", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
OPENGL_INFO("========================" ); OPENGL_INFO("========================" );
@ -206,25 +206,25 @@ void gale::openGL::swap() {
} }
void gale::openGL::setViewPort(const ivec2& _start, const ivec2& _stop) { void gale::openGL::setViewPort(const ivec2& _start, const ivec2& _stop) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
OPENGL_INFO("setViewport " << _start << " " << _stop); OPENGL_INFO("setViewport " << _start << " " << _stop);
glViewport(_start.x(), _start.y(), _stop.x(), _stop.y()); glViewport(_start.x(), _start.y(), _stop.x(), _stop.y());
CHECK_GL_ERROR("glViewport", __LINE__); CHECK_GL_ERROR("glViewport", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
void gale::openGL::setViewPort(const vec2& _start, const vec2& _stop) { void gale::openGL::setViewPort(const vec2& _start, const vec2& _stop) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
OPENGL_INFO("setViewport " << _start << " " << _stop); OPENGL_INFO("setViewport " << _start << " " << _stop);
glViewport(_start.x(), _start.y(), _stop.x(), _stop.y()); glViewport(_start.x(), _start.y(), _stop.x(), _stop.y());
CHECK_GL_ERROR("glViewport", __LINE__); CHECK_GL_ERROR("glViewport", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -243,18 +243,18 @@ static int32_t basicFlagClearCount = sizeof(basicFlagClear) / sizeof(struct corr
void gale::openGL::clearColor(const etk::Color<float>& _color) { void gale::openGL::clearColor(const etk::Color<float>& _color) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glClearColor(_color.r(), _color.g(), _color.b(), _color.a()); glClearColor(_color.r(), _color.g(), _color.b(), _color.a());
CHECK_GL_ERROR("glClearColor", __LINE__); CHECK_GL_ERROR("glClearColor", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
void gale::openGL::clearDepth(float _value) { void gale::openGL::clearDepth(float _value) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
#if !((defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs))) #if !((defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs)))
@ -265,17 +265,17 @@ void gale::openGL::clearDepth(float _value) {
glClearDepthf(_value); glClearDepthf(_value);
CHECK_GL_ERROR("glClearDepthf", __LINE__); CHECK_GL_ERROR("glClearDepthf", __LINE__);
#endif #endif
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
void gale::openGL::clearStencil(int32_t _value) { void gale::openGL::clearStencil(int32_t _value) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glClearStencil(_value); glClearStencil(_value);
CHECK_GL_ERROR("glClearStencil", __LINE__); CHECK_GL_ERROR("glClearStencil", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -287,12 +287,12 @@ void gale::openGL::clear(uint32_t _flags) {
field |= basicFlagClear[iii].OGlFlag; field |= basicFlagClear[iii].OGlFlag;
} }
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glClear(field); glClear(field);
CHECK_GL_ERROR("glClear", __LINE__); CHECK_GL_ERROR("glClear", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -474,7 +474,7 @@ void gale::openGL::reset() {
void gale::openGL::enable(enum gale::openGL::flag _flagID) { void gale::openGL::enable(enum gale::openGL::flag _flagID) {
//GALE_INFO("Enable : " <GALE_ERROR< _flagID); //GALE_INFO("Enable : " <GALE_ERROR< _flagID);
#ifdef DIRECT_MODE #ifdef DIRECT_MODE
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
for (int32_t iii=0; iii<basicFlagCount ; iii++) { for (int32_t iii=0; iii<basicFlagCount ; iii++) {
@ -483,7 +483,7 @@ void gale::openGL::enable(enum gale::openGL::flag _flagID) {
CHECK_GL_ERROR("glEnable", __LINE__); CHECK_GL_ERROR("glEnable", __LINE__);
} }
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
# else # else
@ -498,12 +498,12 @@ void gale::openGL::disable(enum gale::openGL::flag _flagID) {
#ifdef DIRECT_MODE #ifdef DIRECT_MODE
for (int32_t iii=0; iii<basicFlagCount ; iii++) { for (int32_t iii=0; iii<basicFlagCount ; iii++) {
if (basicFlag[iii].curentFlag == (uint32_t)_flagID) { if (basicFlag[iii].curentFlag == (uint32_t)_flagID) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDisable(basicFlag[iii].OGlFlag); glDisable(basicFlag[iii].OGlFlag);
CHECK_GL_ERROR("glDisable", __LINE__); CHECK_GL_ERROR("glDisable", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -529,22 +529,22 @@ void gale::openGL::updateAllFlags() {
uint32_t CurrentFlag = basicFlag[iii].curentFlag; uint32_t CurrentFlag = basicFlag[iii].curentFlag;
if ( (l_flagsMustBeSet&CurrentFlag)!=(l_flagsCurrent&CurrentFlag) ) { if ( (l_flagsMustBeSet&CurrentFlag)!=(l_flagsCurrent&CurrentFlag) ) {
if ( (l_flagsMustBeSet&CurrentFlag) != 0) { if ( (l_flagsMustBeSet&CurrentFlag) != 0) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glEnable(basicFlag[iii].OGlFlag); glEnable(basicFlag[iii].OGlFlag);
CHECK_GL_ERROR("glEnable", __LINE__); CHECK_GL_ERROR("glEnable", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
OPENGL_INFO(" enable : " << (enum openGL::flag)basicFlag[iii].curentFlag); OPENGL_INFO(" enable : " << (enum openGL::flag)basicFlag[iii].curentFlag);
} else { } else {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDisable(basicFlag[iii].OGlFlag); glDisable(basicFlag[iii].OGlFlag);
CHECK_GL_ERROR("glDisable", __LINE__); CHECK_GL_ERROR("glDisable", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
OPENGL_INFO(" disable : " << (enum openGL::flag)basicFlag[iii].curentFlag); OPENGL_INFO(" disable : " << (enum openGL::flag)basicFlag[iii].curentFlag);
@ -557,12 +557,12 @@ void gale::openGL::updateAllFlags() {
void gale::openGL::activeTexture(uint32_t _flagID) { void gale::openGL::activeTexture(uint32_t _flagID) {
if (l_programId >= 0) { if (l_programId >= 0) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glActiveTexture(_flagID); glActiveTexture(_flagID);
CHECK_GL_ERROR("glActiveTexture", __LINE__); CHECK_GL_ERROR("glActiveTexture", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} else { } else {
@ -600,12 +600,12 @@ const uint32_t convertRenderMode[] = {
void gale::openGL::drawArrays(enum gale::openGL::renderMode _mode, int32_t _first, int32_t _count) { void gale::openGL::drawArrays(enum gale::openGL::renderMode _mode, int32_t _first, int32_t _count) {
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDrawArrays(convertRenderMode[uint32_t(_mode)], _first, _count); glDrawArrays(convertRenderMode[uint32_t(_mode)], _first, _count);
CHECK_GL_ERROR("glDrawArrays", __LINE__); CHECK_GL_ERROR("glDrawArrays", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -614,13 +614,13 @@ void gale::openGL::drawArrays(enum gale::openGL::renderMode _mode, int32_t _firs
void gale::openGL::drawElements(enum renderMode _mode, const std::vector<uint32_t>& _indices) { void gale::openGL::drawElements(enum renderMode _mode, const std::vector<uint32_t>& _indices) {
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
//GALE_DEBUG("Request draw of " << indices.size() << "elements"); //GALE_DEBUG("Request draw of " << indices.size() << "elements");
glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_INT, &_indices[0]); glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_INT, &_indices[0]);
CHECK_GL_ERROR("glDrawElements", __LINE__); CHECK_GL_ERROR("glDrawElements", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -629,12 +629,12 @@ void gale::openGL::drawElements(enum renderMode _mode, const std::vector<uint32_
void gale::openGL::drawElements16(enum renderMode _mode, const std::vector<uint16_t>& _indices) { void gale::openGL::drawElements16(enum renderMode _mode, const std::vector<uint16_t>& _indices) {
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]); glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]);
CHECK_GL_ERROR("glDrawElements", __LINE__); CHECK_GL_ERROR("glDrawElements", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -643,12 +643,12 @@ void gale::openGL::drawElements16(enum renderMode _mode, const std::vector<uint1
void gale::openGL::drawElements8(enum renderMode _mode, const std::vector<uint8_t>& _indices) { void gale::openGL::drawElements8(enum renderMode _mode, const std::vector<uint8_t>& _indices) {
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_BYTE, &_indices[0]); glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_BYTE, &_indices[0]);
CHECK_GL_ERROR("glDrawElements", __LINE__); CHECK_GL_ERROR("glDrawElements", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
@ -666,40 +666,40 @@ void gale::openGL::useProgram(int32_t _id) {
} }
if (l_programId != _id) { if (l_programId != _id) {
l_programId = _id; l_programId = _id;
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glUseProgram(l_programId); glUseProgram(l_programId);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
#else #else
if (_id == -1) { if (_id == -1) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glUseProgram(0); glUseProgram(0);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} else { } else {
l_programId = _id; l_programId = _id;
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glUseProgram(_id); glUseProgram(_id);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
} }
#endif #endif
#if 1 #if 1
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
CHECK_GL_ERROR("glUseProgram", __LINE__); CHECK_GL_ERROR("glUseProgram", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
#endif #endif
@ -714,12 +714,17 @@ bool gale::openGL::genBuffers(std::vector<uint32_t>& _buffers) {
return true; return true;
} }
OPENGL_INFO("Create N=" << _buffers.size() << " Buffer"); OPENGL_INFO("Create N=" << _buffers.size() << " Buffer");
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glGenBuffers(_buffers.size(), &_buffers[0]); glGenBuffers(_buffers.size(), &_buffers[0]);
CHECK_GL_ERROR("glGenBuffers", __LINE__); CHECK_GL_ERROR("glGenBuffers", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} else {
static int32_t count = 1;
for (auto &it : _buffers) {
it = count++;
}
} }
#endif #endif
bool hasError = false; bool hasError = false;
@ -737,12 +742,12 @@ bool gale::openGL::deleteBuffers(std::vector<uint32_t>& _buffers) {
GALE_WARNING("try to delete vector buffer with size 0"); GALE_WARNING("try to delete vector buffer with size 0");
return true; return true;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDeleteBuffers(_buffers.size(), &_buffers[0]); glDeleteBuffers(_buffers.size(), &_buffers[0]);
CHECK_GL_ERROR("glDeleteBuffers", __LINE__); CHECK_GL_ERROR("glDeleteBuffers", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
for (auto &it : _buffers) { for (auto &it : _buffers) {
@ -752,12 +757,12 @@ bool gale::openGL::deleteBuffers(std::vector<uint32_t>& _buffers) {
} }
bool gale::openGL::bindBuffer(uint32_t _bufferId) { bool gale::openGL::bindBuffer(uint32_t _bufferId) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glBindBuffer(GL_ARRAY_BUFFER, _bufferId); glBindBuffer(GL_ARRAY_BUFFER, _bufferId);
CHECK_GL_ERROR("glBindBuffer", __LINE__); CHECK_GL_ERROR("glBindBuffer", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return true; return true;
@ -770,24 +775,24 @@ static GLenum convertUsage[] = {
}; };
bool gale::openGL::bufferData(size_t _size, const void* _data, enum gale::openGL::usage _usage) { bool gale::openGL::bufferData(size_t _size, const void* _data, enum gale::openGL::usage _usage) {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glBufferData(GL_ARRAY_BUFFER, _size, _data, convertUsage[uint32_t(_usage)]); glBufferData(GL_ARRAY_BUFFER, _size, _data, convertUsage[uint32_t(_usage)]);
CHECK_GL_ERROR("glBufferData", __LINE__); CHECK_GL_ERROR("glBufferData", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return true; return true;
} }
bool gale::openGL::unbindBuffer() { bool gale::openGL::unbindBuffer() {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
CHECK_GL_ERROR("glBindBuffer(0)", __LINE__); CHECK_GL_ERROR("glBindBuffer(0)", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return true; return true;
@ -805,25 +810,25 @@ int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) {
GLuint shader = 0; GLuint shader = 0;
if (_type == gale::openGL::shader::type::vertex) { if (_type == gale::openGL::shader::type::vertex) {
GALE_VERBOSE("create shader: VERTEX"); GALE_VERBOSE("create shader: VERTEX");
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
shader = glCreateShader(GL_VERTEX_SHADER); shader = glCreateShader(GL_VERTEX_SHADER);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} else { } else {
static int32_t count = 0; static int32_t count = 1;
shader = count++; shader = count++;
} }
#endif #endif
} else if (_type == gale::openGL::shader::type::fragment) { } else if (_type == gale::openGL::shader::type::fragment) {
GALE_VERBOSE("create shader: FRAGMENT"); GALE_VERBOSE("create shader: FRAGMENT");
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
shader = glCreateShader(GL_FRAGMENT_SHADER); shader = glCreateShader(GL_FRAGMENT_SHADER);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} else { } else {
static int32_t count = 0; static int32_t count = 1;
shader = count++; shader = count++;
} }
#endif #endif
@ -834,11 +839,11 @@ int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) {
GALE_VERBOSE("create shader: ... (done)"); GALE_VERBOSE("create shader: ... (done)");
if (shader == 0) { if (shader == 0) {
GALE_ERROR("glCreateShader return error ..."); GALE_ERROR("glCreateShader return error ...");
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
checkGlError("glCreateShader"); checkGlError("glCreateShader");
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return -1; return -1;
@ -850,12 +855,12 @@ void gale::openGL::shader::remove(int64_t& _shader) {
if (_shader < 0) { if (_shader < 0) {
return; return;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDeleteShader(GLuint(_shader)); glDeleteShader(GLuint(_shader));
CHECK_GL_ERROR("glDeleteShader", __LINE__); CHECK_GL_ERROR("glDeleteShader", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
_shader = -1; _shader = -1;
@ -863,7 +868,7 @@ void gale::openGL::shader::remove(int64_t& _shader) {
bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) { bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) {
const char* data = &_data[0]; const char* data = &_data[0];
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glShaderSource(GLuint(_shader), 1, (const char**)&data, nullptr); glShaderSource(GLuint(_shader), 1, (const char**)&data, nullptr);
@ -884,7 +889,7 @@ bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) {
} }
return false; return false;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return true; return true;
@ -893,7 +898,7 @@ bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) {
int64_t gale::openGL::program::create() { int64_t gale::openGL::program::create() {
GLuint program = 0; GLuint program = 0;
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
program = glCreateProgram(); program = glCreateProgram();
@ -902,7 +907,7 @@ int64_t gale::openGL::program::create() {
CHECK_GL_ERROR("glCreateProgram", __LINE__); CHECK_GL_ERROR("glCreateProgram", __LINE__);
return -1; return -1;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} else { } else {
static uint32_t iii=0; static uint32_t iii=0;
program = iii++; program = iii++;
@ -916,12 +921,12 @@ void gale::openGL::program::remove(int64_t& _prog) {
if (_prog < 0) { if (_prog < 0) {
return; return;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glDeleteProgram(GLuint(_prog)); glDeleteProgram(GLuint(_prog));
CHECK_GL_ERROR("glDeleteProgram", __LINE__); CHECK_GL_ERROR("glDeleteProgram", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
_prog = -1; _prog = -1;
@ -936,12 +941,12 @@ bool gale::openGL::program::attach(int64_t _prog, int64_t _shader) {
GALE_ERROR("wrong shader ID"); GALE_ERROR("wrong shader ID");
return false; return false;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glAttachShader(GLuint(_prog), GLuint(_shader)); glAttachShader(GLuint(_prog), GLuint(_shader));
CHECK_GL_ERROR("glAttachShader", __LINE__); CHECK_GL_ERROR("glAttachShader", __LINE__);
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return true; return true;
@ -951,7 +956,7 @@ bool gale::openGL::program::compile(int64_t _prog) {
GALE_ERROR("wrong program ID"); GALE_ERROR("wrong program ID");
return false; return false;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
glLinkProgram(GLuint(_prog)); glLinkProgram(GLuint(_prog));
@ -987,7 +992,7 @@ bool gale::openGL::program::compile(int64_t _prog) {
} }
return false; return false;
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return true; return true;
@ -1003,7 +1008,7 @@ int32_t gale::openGL::program::getAttributeLocation(int64_t _prog, const std::st
return -1; return -1;
} }
GLint val = 0; GLint val = 0;
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
val = glGetAttribLocation(GLuint(_prog), _name.c_str()); val = glGetAttribLocation(GLuint(_prog), _name.c_str());
@ -1011,7 +1016,7 @@ int32_t gale::openGL::program::getAttributeLocation(int64_t _prog, const std::st
CHECK_GL_ERROR("glGetAttribLocation", __LINE__); CHECK_GL_ERROR("glGetAttribLocation", __LINE__);
GALE_WARNING("glGetAttribLocation(\"" << _name << "\") = " << val); GALE_WARNING("glGetAttribLocation(\"" << _name << "\") = " << val);
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return val; return val;
@ -1027,7 +1032,7 @@ int32_t gale::openGL::program::getUniformLocation(int64_t _prog, const std::stri
return -1; return -1;
} }
GLint val = 0; GLint val = 0;
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
if (s_simulationMode == false) { if (s_simulationMode == false) {
#endif #endif
val = glGetUniformLocation(GLuint(_prog), _name.c_str()); val = glGetUniformLocation(GLuint(_prog), _name.c_str());
@ -1041,7 +1046,7 @@ int32_t gale::openGL::program::getUniformLocation(int64_t _prog, const std::stri
CHECK_GL_ERROR("glGetUniformLocation", __LINE__); CHECK_GL_ERROR("glGetUniformLocation", __LINE__);
GALE_WARNING("glGetUniformLocation(\"" << _name << "\") = " << val); GALE_WARNING("glGetUniformLocation(\"" << _name << "\") = " << val);
} }
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
} }
#endif #endif
return val; return val;

View File

@ -13,7 +13,7 @@
namespace gale { namespace gale {
namespace openGL { namespace openGL {
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE #ifdef GALE_BUILD_SIMULATION
/** /**
* @brief Start the simulation mode of Open GL (can be usebull when no HW is availlable for testing System like buildfarm (eg: travis-ci) * @brief Start the simulation mode of Open GL (can be usebull when no HW is availlable for testing System like buildfarm (eg: travis-ci)
* This generate a non access on the openGL IO, and all function work corectly. * This generate a non access on the openGL IO, and all function work corectly.

View File

@ -64,11 +64,21 @@ def configure(target, my_module):
if "Web" in target.get_type(): if "Web" in target.get_type():
my_module.add_src_file('gale/context/SDL/Context.cpp') my_module.add_src_file('gale/context/SDL/Context.cpp')
elif "Linux" in target.get_type(): elif "Linux" in target.get_type():
# TODO : Do it better ...
if False: my_module.add_optionnal_depend(
my_module.add_src_file('gale/context/X11/Context.cpp') 'X11',
else: ["c++", "-DGALE_BUILD_X11"],
my_module.add_src_file('gale/context/wayland/Context.cpp') src_file=[
'gale/context/X11/Context.cpp',
]
)
my_module.add_optionnal_depend(
'wayland',
["c++", "-DGALE_BUILD_WAYLAND"],
src_file=[
'gale/context/wayland/Context.cpp',
]
)
# check if egami is present in the worktree: this is for the icon parsing ... # check if egami is present in the worktree: this is for the icon parsing ...
my_module.add_optionnal_depend('egami', ["c++", "-DGALE_BUILD_EGAMI"]) my_module.add_optionnal_depend('egami', ["c++", "-DGALE_BUILD_EGAMI"])
elif "Windows" in target.get_type(): elif "Windows" in target.get_type():
@ -104,6 +114,15 @@ def configure(target, my_module):
]) ])
else: else:
debug.error("unknow mode...") debug.error("unknow mode...")
if "Linux" in target.get_type() \
or "Windows" in target.get_type() \
or "MacOs" in target.get_type():
# only in debug we add simulation:
if target.get_mode() == "debug":
my_module.add_flag('c++', "-DGALE_BUILD_SIMULATION")
my_module.add_src_file('gale/context/simulation/Context.cpp')
# Key properties: # Key properties:
my_module.add_src_file([ my_module.add_src_file([
'gale/key/keyboard.cpp', 'gale/key/keyboard.cpp',
@ -161,11 +180,8 @@ def configure(target, my_module):
"SDL" "SDL"
]) ])
elif "Linux" in target.get_type(): elif "Linux" in target.get_type():
if False: # TODO : This is specific at wayland ==> check How we can add it better
my_module.add_depend("X11")
else:
my_module.add_depend([ my_module.add_depend([
'wayland',
'egl', 'egl',
'gles2', 'gles2',
'xkbcommon' 'xkbcommon'