[DEV] replay simulation is now availlable and multiple backend
This commit is contained in:
parent
b1033f884e
commit
65a35a8ead
29
gale/context/Android/Context.hpp
Normal file
29
gale/context/Android/Context.hpp
Normal 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
|
||||
|
@ -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[]) :
|
||||
m_application(_application),
|
||||
m_imulationActive(false),
|
||||
m_simulationActive(false),
|
||||
m_simulationFile("gale.gsim"),
|
||||
//m_objectManager(*this),
|
||||
m_previousDisplayTime(),
|
||||
@ -207,10 +207,10 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
||||
m_displayFps=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()) );
|
||||
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-mode=") == true) {
|
||||
m_imulationActive = true;
|
||||
} else if (m_commandLine.get(iii) == "--gale-simulation-stop") {
|
||||
|
||||
} else if (m_commandLine.get(iii) == "--gale-simulation-record") {
|
||||
m_simulationActive = true;
|
||||
} 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
|
||||
} else if (m_commandLine.get(iii) == "--gale-disable-opengl") {
|
||||
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(" --gale-simulation-file=XXX.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(" Mode of the simulation");
|
||||
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");
|
||||
GALE_PRINT(" --gale-simulation-record");
|
||||
GALE_PRINT(" Record the IO in the simulation file");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
GALE_PRINT(" --gale-disable-opengl");
|
||||
GALE_PRINT(" Disable openGL access (availlable in SIMULATION mode)");
|
||||
#endif
|
||||
GALE_PRINT(" --gale-fps");
|
||||
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(" Display this help");
|
||||
GALE_PRINT(" example:");
|
||||
@ -255,10 +276,16 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
||||
|
||||
GALE_INFO("GALE v:" << gale::getVersion());
|
||||
// request the init of the application in the main context of openGL ...
|
||||
if (m_imulationActive == true) {
|
||||
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":INIT");
|
||||
m_simulationFile.filePuts("\n");
|
||||
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(":INIT");
|
||||
m_simulationFile.filePuts("\n");
|
||||
}
|
||||
}
|
||||
m_msgSystem.post([](gale::Context& _context){
|
||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||
@ -279,10 +306,6 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
||||
#else
|
||||
forceOrientation(gale::orientation::screenAuto);
|
||||
#endif
|
||||
if (m_imulationActive == true) {
|
||||
// in simulation case:
|
||||
m_simulationFile.fileOpenWrite();
|
||||
}
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
GALE_INFO(" == > Gale system init (END)");
|
||||
@ -321,14 +344,14 @@ gale::Context::~Context() {
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
GALE_INFO(" == > Gale system Un-Init (END)");
|
||||
if (m_imulationActive == true) {
|
||||
if (m_simulationActive == true) {
|
||||
// in simulation case:
|
||||
m_simulationFile.fileClose();
|
||||
}
|
||||
}
|
||||
|
||||
void gale::Context::requestUpdateSize() {
|
||||
if (m_imulationActive == true) {
|
||||
if (m_simulationActive == true) {
|
||||
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
|
||||
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 ...
|
||||
gale::Dimension::setPixelWindowsSize(_size);
|
||||
if (m_imulationActive == true) {
|
||||
if (m_simulationActive == true) {
|
||||
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":RESIZE:");
|
||||
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,
|
||||
int32_t _pointerID,
|
||||
const vec2& _pos) {
|
||||
if (m_imulationActive == true) {
|
||||
if (m_simulationActive == true) {
|
||||
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":INPUT:");
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (m_imulationActive == true) {
|
||||
if (m_simulationActive == true) {
|
||||
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":KEYBOARD:");
|
||||
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() {
|
||||
if (m_imulationActive == true) {
|
||||
if (m_simulationActive == true) {
|
||||
m_simulationFile.filePuts(etk::to_string(echrono::Steady::now()));
|
||||
m_simulationFile.filePuts(":VIEW:false\n");
|
||||
}
|
||||
@ -482,7 +505,7 @@ void gale::Context::OS_Hide() {
|
||||
}
|
||||
|
||||
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(":VIEW:true\n");
|
||||
}
|
||||
@ -503,7 +526,7 @@ void gale::Context::OS_Show() {
|
||||
|
||||
|
||||
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(":CLIPBOARD_ARRIVE:");
|
||||
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) {
|
||||
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();
|
||||
echrono::Steady currentTime = echrono::Steady::now();
|
||||
// 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 ...");
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -60,9 +60,9 @@ namespace gale {
|
||||
* @note this un-lock the main mutex
|
||||
*/
|
||||
void unLockContext();
|
||||
private:
|
||||
protected:
|
||||
// simulation area:
|
||||
bool m_imulationActive;
|
||||
bool m_simulationActive;
|
||||
etk::FSNode m_simulationFile;
|
||||
private:
|
||||
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
|
||||
*/
|
||||
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.
|
||||
|
@ -32,3 +32,25 @@ namespace IOs {
|
||||
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
|
||||
|
||||
|
@ -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[]);
|
||||
}
|
||||
}
|
||||
}
|
@ -260,6 +260,10 @@ class GLUTInterface : public gale::Context {
|
||||
m_cursorEventPos);
|
||||
}
|
||||
}
|
||||
int32_t run() {
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
GLUTInterface* g_interface = nullptr;
|
||||
@ -287,12 +291,17 @@ static void gale_glut_mouse_pasive(int _x, int _y) {
|
||||
g_interface->mousePasive(vec2(_x, _y));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main of the program
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
|
||||
|
||||
|
||||
#include <gale/context/SDL/Context.hpp>
|
||||
|
||||
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__
|
||||
// include GL stuff, to check that we can compile hybrid 2d/GL apps
|
||||
extern void glBegin(int mode);
|
||||
@ -302,12 +311,7 @@ int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
glBindBuffer(0, 0);
|
||||
}
|
||||
#endif
|
||||
etk::init(_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;
|
||||
}
|
||||
ememory::SharedPtr<gale::Context> out; ememory::makeShared<X11Interface>(_application, _argc, _argv);
|
||||
|
||||
/* Initialize the window */
|
||||
glutInit(&_argc, (char**)_argv);
|
||||
@ -325,11 +329,5 @@ int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
glutMotionFunc(gale_glut_mouse_pasive);
|
||||
GALE_DEBUG("7987984654654\n");
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
int32_t retValue = 0;
|
||||
|
||||
delete(g_interface);
|
||||
g_interface = nullptr;
|
||||
return retValue;
|
||||
return out;
|
||||
}
|
||||
|
@ -625,23 +625,13 @@ static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARA
|
||||
return galeWindowsContext->WndProcReal(_hWnd, _message, _wParam, _lParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
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();
|
||||
delete(localInterface);
|
||||
localInterface = nullptr;
|
||||
GALE_INFO("END APPLICATION");
|
||||
return retValue;
|
||||
#include <gale/context/Windows/Context.hpp>
|
||||
|
||||
bool gale::context::windows::isBackendPresent() {
|
||||
// TODO : Do it better...
|
||||
return true;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<gale::Context> gale::context::windows::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
return ememory::makeShared<WindowsContext>(_application, _argc, _argv);
|
||||
}
|
||||
|
26
gale/context/Windows/Context.hpp
Normal file
26
gale/context/Windows/Context.hpp
Normal 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[]);
|
||||
}
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@
|
||||
#define GUI_LOCK() XLockDisplay(m_display)
|
||||
#define GUI_UNLOCK() XUnlockDisplay(m_display)
|
||||
*/
|
||||
bool hasDisplay = false;
|
||||
static bool hasDisplay = false;
|
||||
//#define DEBUG_X11_EVENT
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
#define X11_DEBUG GALE_DEBUG
|
||||
@ -1484,21 +1484,13 @@ class X11Interface : public gale::Context {
|
||||
}
|
||||
};
|
||||
|
||||
#include <gale/context/X11/Context.hpp>
|
||||
|
||||
/**
|
||||
* @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);
|
||||
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);
|
||||
interface = nullptr;
|
||||
return retValue;
|
||||
bool gale::context::x11::isBackendPresent() {
|
||||
// TODO : Do it better...
|
||||
return true;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<gale::Context> gale::context::x11::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
return ememory::makeShared<X11Interface>(_application, _argc, _argv);
|
||||
}
|
||||
|
26
gale/context/X11/Context.hpp
Normal file
26
gale/context/X11/Context.hpp
Normal 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[]);
|
||||
}
|
||||
}
|
||||
}
|
@ -48,6 +48,16 @@ namespace etk {
|
||||
template<> std::string to_string<enum gale::context::clipBoard::clipboardListe>(const enum gale::context::clipBoard::clipboardListe& _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() {
|
||||
|
225
gale/context/simulation/Context.cpp
Normal file
225
gale/context/simulation/Context.cpp
Normal 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);
|
||||
}
|
26
gale/context/simulation/Context.hpp
Normal file
26
gale/context/simulation/Context.hpp
Normal 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[]);
|
||||
}
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ extern "C" {
|
||||
|
||||
#include <gale/renderer/openGL/openGL-include.hpp>
|
||||
|
||||
bool hasDisplay = false;
|
||||
static bool hasDisplay = false;
|
||||
#define DEBUG_WAYLAND_EVENT
|
||||
#ifdef DEBUG_WAYLAND_EVENT
|
||||
#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[]) {
|
||||
etk::init(_argc, _argv);
|
||||
WAYLANDInterface* interface = new WAYLANDInterface(_application, _argc, _argv);
|
||||
if (interface == nullptr) {
|
||||
GALE_CRITICAL("Can not create the WAYLAND interface ... MEMORY allocation error");
|
||||
return -2;
|
||||
}
|
||||
int32_t retValue = interface->run();
|
||||
delete(interface);
|
||||
interface = nullptr;
|
||||
return retValue;
|
||||
#include <gale/context/wayland/Context.hpp>
|
||||
|
||||
bool gale::context::wayland::isBackendPresent() {
|
||||
// TODO : Do it better...
|
||||
return true;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<gale::Context> gale::context::wayland::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
return ememory::makeShared<WAYLANDInterface>(_application, _argc, _argv);
|
||||
}
|
||||
|
||||
|
||||
|
26
gale/context/wayland/Context.hpp
Normal file
26
gale/context/wayland/Context.hpp
Normal 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[]);
|
||||
}
|
||||
}
|
||||
}
|
@ -262,4 +262,32 @@ namespace etk {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
@ -64,5 +64,15 @@ namespace etk {
|
||||
template<> std::string to_string<enum gale::key::keyboard>(const enum gale::key::keyboard& _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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,5 +35,14 @@ namespace etk {
|
||||
template<> std::string to_string<enum gale::key::status>(const enum gale::key::status& _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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,4 +24,14 @@ namespace etk {
|
||||
template<> std::string to_string<enum gale::key::type>(const enum gale::key::type& _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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
/**
|
||||
* @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() {
|
||||
l_programId = -1;
|
||||
l_textureflags = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glFlush();
|
||||
checkGlError("glFlush", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
OPENGL_INFO("========================" );
|
||||
@ -206,25 +206,25 @@ void gale::openGL::swap() {
|
||||
}
|
||||
|
||||
void gale::openGL::setViewPort(const ivec2& _start, const ivec2& _stop) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
OPENGL_INFO("setViewport " << _start << " " << _stop);
|
||||
glViewport(_start.x(), _start.y(), _stop.x(), _stop.y());
|
||||
CHECK_GL_ERROR("glViewport", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gale::openGL::setViewPort(const vec2& _start, const vec2& _stop) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
OPENGL_INFO("setViewport " << _start << " " << _stop);
|
||||
glViewport(_start.x(), _start.y(), _stop.x(), _stop.y());
|
||||
CHECK_GL_ERROR("glViewport", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -243,18 +243,18 @@ static int32_t basicFlagClearCount = sizeof(basicFlagClear) / sizeof(struct corr
|
||||
|
||||
|
||||
void gale::openGL::clearColor(const etk::Color<float>& _color) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClearColor(_color.r(), _color.g(), _color.b(), _color.a());
|
||||
CHECK_GL_ERROR("glClearColor", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gale::openGL::clearDepth(float _value) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
#if !((defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs)))
|
||||
@ -265,17 +265,17 @@ void gale::openGL::clearDepth(float _value) {
|
||||
glClearDepthf(_value);
|
||||
CHECK_GL_ERROR("glClearDepthf", __LINE__);
|
||||
#endif
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void gale::openGL::clearStencil(int32_t _value) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClearStencil(_value);
|
||||
CHECK_GL_ERROR("glClearStencil", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -287,12 +287,12 @@ void gale::openGL::clear(uint32_t _flags) {
|
||||
field |= basicFlagClear[iii].OGlFlag;
|
||||
}
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClear(field);
|
||||
CHECK_GL_ERROR("glClear", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -474,7 +474,7 @@ void gale::openGL::reset() {
|
||||
void gale::openGL::enable(enum gale::openGL::flag _flagID) {
|
||||
//GALE_INFO("Enable : " <GALE_ERROR< _flagID);
|
||||
#ifdef DIRECT_MODE
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
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__);
|
||||
}
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
# else
|
||||
@ -498,12 +498,12 @@ void gale::openGL::disable(enum gale::openGL::flag _flagID) {
|
||||
#ifdef DIRECT_MODE
|
||||
for (int32_t iii=0; iii<basicFlagCount ; iii++) {
|
||||
if (basicFlag[iii].curentFlag == (uint32_t)_flagID) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDisable(basicFlag[iii].OGlFlag);
|
||||
CHECK_GL_ERROR("glDisable", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -529,22 +529,22 @@ void gale::openGL::updateAllFlags() {
|
||||
uint32_t CurrentFlag = basicFlag[iii].curentFlag;
|
||||
if ( (l_flagsMustBeSet&CurrentFlag)!=(l_flagsCurrent&CurrentFlag) ) {
|
||||
if ( (l_flagsMustBeSet&CurrentFlag) != 0) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glEnable(basicFlag[iii].OGlFlag);
|
||||
CHECK_GL_ERROR("glEnable", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
OPENGL_INFO(" enable : " << (enum openGL::flag)basicFlag[iii].curentFlag);
|
||||
} else {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDisable(basicFlag[iii].OGlFlag);
|
||||
CHECK_GL_ERROR("glDisable", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
OPENGL_INFO(" disable : " << (enum openGL::flag)basicFlag[iii].curentFlag);
|
||||
@ -557,12 +557,12 @@ void gale::openGL::updateAllFlags() {
|
||||
|
||||
void gale::openGL::activeTexture(uint32_t _flagID) {
|
||||
if (l_programId >= 0) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glActiveTexture(_flagID);
|
||||
CHECK_GL_ERROR("glActiveTexture", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
@ -600,12 +600,12 @@ const uint32_t convertRenderMode[] = {
|
||||
void gale::openGL::drawArrays(enum gale::openGL::renderMode _mode, int32_t _first, int32_t _count) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDrawArrays(convertRenderMode[uint32_t(_mode)], _first, _count);
|
||||
CHECK_GL_ERROR("glDrawArrays", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#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) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
//GALE_DEBUG("Request draw of " << indices.size() << "elements");
|
||||
glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_INT, &_indices[0]);
|
||||
CHECK_GL_ERROR("glDrawElements", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#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) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]);
|
||||
CHECK_GL_ERROR("glDrawElements", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#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) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDrawElements(convertRenderMode[uint32_t(_mode)], _indices.size(), GL_UNSIGNED_BYTE, &_indices[0]);
|
||||
CHECK_GL_ERROR("glDrawElements", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -666,40 +666,40 @@ void gale::openGL::useProgram(int32_t _id) {
|
||||
}
|
||||
if (l_programId != _id) {
|
||||
l_programId = _id;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glUseProgram(l_programId);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
if (_id == -1) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glUseProgram(0);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
l_programId = _id;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glUseProgram(_id);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
CHECK_GL_ERROR("glUseProgram", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -714,12 +714,17 @@ bool gale::openGL::genBuffers(std::vector<uint32_t>& _buffers) {
|
||||
return true;
|
||||
}
|
||||
OPENGL_INFO("Create N=" << _buffers.size() << " Buffer");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glGenBuffers(_buffers.size(), &_buffers[0]);
|
||||
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
|
||||
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");
|
||||
return true;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDeleteBuffers(_buffers.size(), &_buffers[0]);
|
||||
CHECK_GL_ERROR("glDeleteBuffers", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
for (auto &it : _buffers) {
|
||||
@ -752,12 +757,12 @@ bool gale::openGL::deleteBuffers(std::vector<uint32_t>& _buffers) {
|
||||
}
|
||||
|
||||
bool gale::openGL::bindBuffer(uint32_t _bufferId) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _bufferId);
|
||||
CHECK_GL_ERROR("glBindBuffer", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
@ -770,24 +775,24 @@ static GLenum convertUsage[] = {
|
||||
};
|
||||
|
||||
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) {
|
||||
#endif
|
||||
glBufferData(GL_ARRAY_BUFFER, _size, _data, convertUsage[uint32_t(_usage)]);
|
||||
CHECK_GL_ERROR("glBufferData", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gale::openGL::unbindBuffer() {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
CHECK_GL_ERROR("glBindBuffer(0)", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
@ -805,25 +810,25 @@ int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) {
|
||||
GLuint shader = 0;
|
||||
if (_type == gale::openGL::shader::type::vertex) {
|
||||
GALE_VERBOSE("create shader: VERTEX");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
shader = glCreateShader(GL_VERTEX_SHADER);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
} else {
|
||||
static int32_t count = 0;
|
||||
static int32_t count = 1;
|
||||
shader = count++;
|
||||
}
|
||||
#endif
|
||||
} else if (_type == gale::openGL::shader::type::fragment) {
|
||||
GALE_VERBOSE("create shader: FRAGMENT");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
} else {
|
||||
static int32_t count = 0;
|
||||
static int32_t count = 1;
|
||||
shader = count++;
|
||||
}
|
||||
#endif
|
||||
@ -834,11 +839,11 @@ int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) {
|
||||
GALE_VERBOSE("create shader: ... (done)");
|
||||
if (shader == 0) {
|
||||
GALE_ERROR("glCreateShader return error ...");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
checkGlError("glCreateShader");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
@ -850,12 +855,12 @@ void gale::openGL::shader::remove(int64_t& _shader) {
|
||||
if (_shader < 0) {
|
||||
return;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDeleteShader(GLuint(_shader));
|
||||
CHECK_GL_ERROR("glDeleteShader", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
_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) {
|
||||
const char* data = &_data[0];
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
@ -893,7 +898,7 @@ bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) {
|
||||
|
||||
int64_t gale::openGL::program::create() {
|
||||
GLuint program = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
program = glCreateProgram();
|
||||
@ -902,7 +907,7 @@ int64_t gale::openGL::program::create() {
|
||||
CHECK_GL_ERROR("glCreateProgram", __LINE__);
|
||||
return -1;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
} else {
|
||||
static uint32_t iii=0;
|
||||
program = iii++;
|
||||
@ -916,12 +921,12 @@ void gale::openGL::program::remove(int64_t& _prog) {
|
||||
if (_prog < 0) {
|
||||
return;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDeleteProgram(GLuint(_prog));
|
||||
CHECK_GL_ERROR("glDeleteProgram", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
_prog = -1;
|
||||
@ -936,12 +941,12 @@ bool gale::openGL::program::attach(int64_t _prog, int64_t _shader) {
|
||||
GALE_ERROR("wrong shader ID");
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glAttachShader(GLuint(_prog), GLuint(_shader));
|
||||
CHECK_GL_ERROR("glAttachShader", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
@ -951,7 +956,7 @@ bool gale::openGL::program::compile(int64_t _prog) {
|
||||
GALE_ERROR("wrong program ID");
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glLinkProgram(GLuint(_prog));
|
||||
@ -987,7 +992,7 @@ bool gale::openGL::program::compile(int64_t _prog) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
@ -1003,7 +1008,7 @@ int32_t gale::openGL::program::getAttributeLocation(int64_t _prog, const std::st
|
||||
return -1;
|
||||
}
|
||||
GLint val = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
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__);
|
||||
GALE_WARNING("glGetAttribLocation(\"" << _name << "\") = " << val);
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return val;
|
||||
@ -1027,7 +1032,7 @@ int32_t gale::openGL::program::getUniformLocation(int64_t _prog, const std::stri
|
||||
return -1;
|
||||
}
|
||||
GLint val = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
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__);
|
||||
GALE_WARNING("glGetUniformLocation(\"" << _name << "\") = " << val);
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
return val;
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
namespace gale {
|
||||
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)
|
||||
* This generate a non access on the openGL IO, and all function work corectly.
|
||||
|
@ -64,11 +64,21 @@ def configure(target, my_module):
|
||||
if "Web" in target.get_type():
|
||||
my_module.add_src_file('gale/context/SDL/Context.cpp')
|
||||
elif "Linux" in target.get_type():
|
||||
# TODO : Do it better ...
|
||||
if False:
|
||||
my_module.add_src_file('gale/context/X11/Context.cpp')
|
||||
else:
|
||||
my_module.add_src_file('gale/context/wayland/Context.cpp')
|
||||
|
||||
my_module.add_optionnal_depend(
|
||||
'X11',
|
||||
["c++", "-DGALE_BUILD_X11"],
|
||||
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 ...
|
||||
my_module.add_optionnal_depend('egami', ["c++", "-DGALE_BUILD_EGAMI"])
|
||||
elif "Windows" in target.get_type():
|
||||
@ -104,6 +114,15 @@ def configure(target, my_module):
|
||||
])
|
||||
else:
|
||||
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:
|
||||
my_module.add_src_file([
|
||||
'gale/key/keyboard.cpp',
|
||||
@ -161,15 +180,12 @@ def configure(target, my_module):
|
||||
"SDL"
|
||||
])
|
||||
elif "Linux" in target.get_type():
|
||||
if False:
|
||||
my_module.add_depend("X11")
|
||||
else:
|
||||
my_module.add_depend([
|
||||
'wayland',
|
||||
'egl',
|
||||
'gles2',
|
||||
'xkbcommon'
|
||||
])
|
||||
# TODO : This is specific at wayland ==> check How we can add it better
|
||||
my_module.add_depend([
|
||||
'egl',
|
||||
'gles2',
|
||||
'xkbcommon'
|
||||
])
|
||||
elif "Android" in target.get_type():
|
||||
my_module.add_depend(["SDK", "jvm-basics"])
|
||||
# add tre creator of the basic java class ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user