[DEV] start rework of the message system and start think of simulation mode
This commit is contained in:
parent
170589f606
commit
5c5a3d7dee
@ -79,26 +79,7 @@ void gale::Context::unLockContext() {
|
||||
|
||||
namespace gale {
|
||||
class eSystemMessage {
|
||||
public:
|
||||
enum theadMessage {
|
||||
msgNone,
|
||||
msgInit,
|
||||
msgRecalculateSize,
|
||||
msgResize,
|
||||
msgHide,
|
||||
msgShow,
|
||||
|
||||
msgInputMotion,
|
||||
msgInputState,
|
||||
|
||||
msgKeyboardKey,
|
||||
msgKeyboardMove,
|
||||
|
||||
msgClipboardArrive
|
||||
};
|
||||
public :
|
||||
// specify the message type
|
||||
enum theadMessage TypeMessage;
|
||||
// can not set a union ...
|
||||
enum gale::context::clipBoard::clipboardListe clipboardID;
|
||||
// InputId
|
||||
@ -114,7 +95,6 @@ namespace gale {
|
||||
gale::key::Special keyboardSpecial;
|
||||
|
||||
eSystemMessage() :
|
||||
TypeMessage(msgNone),
|
||||
clipboardID(gale::context::clipBoard::clipboardStd),
|
||||
inputType(gale::key::type_unknow),
|
||||
inputId(-1),
|
||||
@ -158,62 +138,6 @@ void gale::Context::processEvents() {
|
||||
m_msgSystem.wait(data);
|
||||
//GALE_DEBUG("EVENT");
|
||||
switch (data->TypeMessage) {
|
||||
case eSystemMessage::msgInit:
|
||||
// this is due to the openGL context
|
||||
/*bool returnVal = */
|
||||
m_application->onCreate(*this);
|
||||
m_application->onStart(*this);
|
||||
m_application->onResume(*this);
|
||||
break;
|
||||
case eSystemMessage::msgRecalculateSize:
|
||||
forceRedrawAll();
|
||||
break;
|
||||
case eSystemMessage::msgResize:
|
||||
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
||||
m_windowsSize = data->dimention;
|
||||
gale::Dimension::setPixelWindowsSize(m_windowsSize);
|
||||
forceRedrawAll();
|
||||
break;
|
||||
case eSystemMessage::msgInputMotion:
|
||||
//GALE_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
|
||||
if (m_application == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_application->onPointer(data->inputType,
|
||||
data->inputId,
|
||||
data->dimention,
|
||||
gale::key::status_move);
|
||||
break;
|
||||
case eSystemMessage::msgInputState:
|
||||
//GALE_DEBUG("Receive MSG : THREAD_INPUT_STATE");
|
||||
if (m_application == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_application->onPointer(data->inputType,
|
||||
data->inputId,
|
||||
data->dimention,
|
||||
(data->stateIsDown==true?gale::key::status_down:gale::key::status_up));
|
||||
break;
|
||||
case eSystemMessage::msgKeyboardKey:
|
||||
case eSystemMessage::msgKeyboardMove:
|
||||
//GALE_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
|
||||
if (m_application == nullptr) {
|
||||
return;
|
||||
} else {
|
||||
gale::key::status state = data->stateIsDown==true?gale::key::status_down:gale::key::status_up;
|
||||
if (data->repeateKey == true) {
|
||||
if (state == gale::key::status_down) {
|
||||
state = gale::key::status_downRepeate;
|
||||
} else {
|
||||
state = gale::key::status_upRepeate;
|
||||
}
|
||||
}
|
||||
m_application->onKeyboard(data->keyboardSpecial,
|
||||
data->keyboardMove,
|
||||
data->keyboardChar,
|
||||
state);
|
||||
}
|
||||
break;
|
||||
case eSystemMessage::msgClipboardArrive:
|
||||
{
|
||||
std::shared_ptr<gale::Application> appl = m_application;
|
||||
@ -222,19 +146,6 @@ void gale::Context::processEvents() {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eSystemMessage::msgHide:
|
||||
GALE_DEBUG("Receive MSG : msgHide");
|
||||
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
|
||||
//gui_uniqueWindows->SysOnHide();
|
||||
break;
|
||||
case eSystemMessage::msgShow:
|
||||
GALE_DEBUG("Receive MSG : msgShow");
|
||||
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
|
||||
//gui_uniqueWindows->SysOnShow();
|
||||
break;
|
||||
default:
|
||||
GALE_DEBUG("Receive MSG : UNKNOW");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -296,19 +207,49 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
||||
etk::theme::setNameDefault("GUI", "shape/square/");
|
||||
etk::theme::setNameDefault("COLOR", "color/black/");
|
||||
// parse the debug level:
|
||||
for(int32_t iii = 0; iii < m_commandLine.size() ; ++iii) {
|
||||
for(int32_t iii=0; iii<m_commandLine.size(); ++iii) {
|
||||
if (m_commandLine.get(iii) == "--gale-fps") {
|
||||
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-mode=") == true) {
|
||||
|
||||
} else if (m_commandLine.get(iii) == "--gale-simulation-stop") {
|
||||
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
} else if (m_commandLine.get(iii) == "--gale-disable-opengl") {
|
||||
gale::openGL::startSimulationMode();
|
||||
#endif
|
||||
} else if ( m_commandLine.get(iii) == "-h"
|
||||
|| m_commandLine.get(iii) == "--help") {
|
||||
|| m_commandLine.get(iii) == "--help"
|
||||
|| etk::start_with(m_commandLine.get(iii), "--gale") == true) {
|
||||
GALE_PRINT("gale - help : ");
|
||||
GALE_PRINT(" " << etk::getApplicationName() << " [options]");
|
||||
GALE_PRINT(" --gale-fps: Display the current fps of the display");
|
||||
GALE_PRINT(" -h/--help: Display this help");
|
||||
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");
|
||||
#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");
|
||||
GALE_PRINT(" -h/--help");
|
||||
GALE_PRINT(" Display this help");
|
||||
GALE_PRINT(" example:");
|
||||
GALE_PRINT(" " << etk::getApplicationName() << " --gale-fps");
|
||||
// this is a global help system does not remove it
|
||||
continue;
|
||||
if (etk::start_with(m_commandLine.get(iii), "--gale") == true) {
|
||||
GALE_ERROR("gale unknow element in parameter: '" << m_commandLine.get(iii) << "'");
|
||||
// remove parameter ...
|
||||
} else {
|
||||
// this is a global help system does not remove it
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@ -322,15 +263,7 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
||||
// TODO : remove this ...
|
||||
etk::initDefaultFolder("galeApplNoName");
|
||||
// request the init of the application in the main context of openGL ...
|
||||
{
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
} else {
|
||||
data->TypeMessage = eSystemMessage::msgInit;
|
||||
m_msgSystem.post(data);
|
||||
}
|
||||
}
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionInit>());
|
||||
// force a recalculation
|
||||
requestUpdateSize();
|
||||
#if defined(__GALE_ANDROID_ORIENTATION_LANDSCAPE__)
|
||||
@ -375,26 +308,13 @@ gale::Context::~Context() {
|
||||
}
|
||||
|
||||
void gale::Context::requestUpdateSize() {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgRecalculateSize;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionRecalculateSize>());
|
||||
}
|
||||
|
||||
void gale::Context::OS_Resize(const vec2& _size) {
|
||||
// TODO : Better in the thread ... == > but generate some init error ...
|
||||
gale::Dimension::setPixelWindowsSize(_size);
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgResize;
|
||||
data->dimention = _size;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionResize>(_size));
|
||||
}
|
||||
void gale::Context::OS_Move(const vec2& _pos) {
|
||||
/*
|
||||
@ -407,112 +327,74 @@ void gale::Context::OS_Move(const vec2& _pos) {
|
||||
}
|
||||
|
||||
void gale::Context::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgInputMotion;
|
||||
data->inputType = gale::key::type_finger;
|
||||
data->inputId = _pointerID;
|
||||
data->dimention = _pos;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionInput>(gale::key::type_finger,
|
||||
gale::key::status_move,
|
||||
_pointerID,
|
||||
_pos));
|
||||
}
|
||||
|
||||
void gale::Context::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgInputState;
|
||||
data->inputType = gale::key::type_finger;
|
||||
data->inputId = _pointerID;
|
||||
data->stateIsDown = _isDown;
|
||||
data->dimention = _pos;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionInput>(gale::key::type_finger,
|
||||
(_isDown==true?gale::key::status_down:gale::key::status_up),
|
||||
_pointerID,
|
||||
_pos));
|
||||
}
|
||||
|
||||
void gale::Context::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgInputMotion;
|
||||
data->inputType = gale::key::type_mouse;
|
||||
data->inputId = _pointerID;
|
||||
data->dimention = _pos;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionInput>(gale::key::type_mouse,
|
||||
gale::key::status_move,
|
||||
_pointerID,
|
||||
_pos));
|
||||
}
|
||||
|
||||
void gale::Context::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgInputState;
|
||||
data->inputType = gale::key::type_mouse;
|
||||
data->inputId = _pointerID;
|
||||
data->stateIsDown = _isDown;
|
||||
data->dimention = _pos;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionInput>(gale::key::type_mouse,
|
||||
(_isDown==true?gale::key::status_down:gale::key::status_up),
|
||||
_pointerID,
|
||||
_pos));
|
||||
}
|
||||
|
||||
void gale::Context::OS_SetKeyboard(gale::key::Special& _special,
|
||||
char32_t _myChar,
|
||||
bool _isDown,
|
||||
bool _isARepeateKey) {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
enum gale::key::status state = _isDown==true?gale::key::status_down:gale::key::status_up;
|
||||
if (_isARepeateKey == true) {
|
||||
if (state == gale::key::status_down) {
|
||||
state = gale::key::status_downRepeate;
|
||||
} else {
|
||||
state = gale::key::status_upRepeate;
|
||||
}
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgKeyboardKey;
|
||||
data->stateIsDown = _isDown;
|
||||
data->keyboardMove = gale::key::keyboard_char;
|
||||
data->keyboardChar = _myChar;
|
||||
data->keyboardSpecial = _special;
|
||||
data->repeateKey = _isARepeateKey;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionKeyboard>(_special
|
||||
gale::key::keyboard_char,
|
||||
state,
|
||||
_myChar));
|
||||
}
|
||||
|
||||
void gale::Context::OS_SetKeyboardMove(gale::key::Special& _special,
|
||||
enum gale::key::keyboard _move,
|
||||
bool _isDown,
|
||||
bool _isARepeateKey) {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
enum gale::key::keyboard _move,
|
||||
bool _isDown,
|
||||
bool _isARepeateKey) {
|
||||
gale::key::status state = _isDown==true?gale::key::status_down:gale::key::status_up;
|
||||
if (_isARepeateKey == true) {
|
||||
if (state == gale::key::status_down) {
|
||||
state = gale::key::status_downRepeate;
|
||||
} else {
|
||||
state = gale::key::status_upRepeate;
|
||||
}
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgKeyboardMove;
|
||||
data->stateIsDown = _isDown;
|
||||
data->keyboardMove = _move;
|
||||
data->keyboardSpecial = _special;
|
||||
data->repeateKey = _isARepeateKey;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionKeyboard>(_special
|
||||
_move,
|
||||
state));
|
||||
}
|
||||
|
||||
void gale::Context::OS_Hide() {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgHide;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionView>(false));
|
||||
}
|
||||
|
||||
void gale::Context::OS_Show() {
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocationerror of message");
|
||||
return;
|
||||
}
|
||||
data->TypeMessage = eSystemMessage::msgShow;
|
||||
m_msgSystem.post(data);
|
||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionView>(true));
|
||||
}
|
||||
|
||||
|
||||
|
119
gale/context/LoopAction.cpp
Normal file
119
gale/context/LoopAction.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
etk::Hash<std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> >& getList() {
|
||||
static etk::Hash<std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> > list;
|
||||
return list;
|
||||
}
|
||||
|
||||
std::shared_ptr<gale::context::LoopAction> gale::context::createAction(const std::string& _lineToParse) {
|
||||
// TODO: parse line ...
|
||||
std::string _name = "lkjlkjlkjlk";
|
||||
std::string nameLower = etk::tolower(_name);
|
||||
if (getList().exist(nameLower) == true) {
|
||||
std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> func = getList()[nameLower];
|
||||
if (func != nullptr) {
|
||||
return func(_lineToParse);
|
||||
}
|
||||
}
|
||||
GALE_WARNING("try to create an UnExistant widget : " << nameLower);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void gale::context::addFactory(const std::string& _type, const std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)>& _func) {
|
||||
if (_func == nullptr) {
|
||||
return;
|
||||
}
|
||||
//Keep name in lower case :
|
||||
std::string nameLower = etk::tolower(_name);
|
||||
if (true == getList().exist(nameLower)) {
|
||||
GALE_WARNING("Replace Creator of a loop action : " << nameLower);
|
||||
getList()[nameLower] = _func;
|
||||
return;
|
||||
}
|
||||
GALE_INFO("Add Creator of a specify loop action : " << nameLower);
|
||||
getList().add(nameLower, _func);
|
||||
}
|
||||
|
||||
gale::context::LoopAction::LoopAction() {
|
||||
m_timestamp = gale::getTime();
|
||||
}
|
||||
|
||||
gale::context::LoopAction::~LoopAction() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void gale::context::LoopActionInit::doAction(gale::Context& _context) {
|
||||
// this is due to the openGL context
|
||||
if (_context.m_application == nullptr) {
|
||||
return;
|
||||
}
|
||||
_context.m_application->onCreate(*this);
|
||||
_context.m_application->onStart(*this);
|
||||
_context.m_application->onResume(*this);
|
||||
}
|
||||
|
||||
gale::context::LoopActionResize::LoopActionResize(const vec2& _size) :
|
||||
m_size(_size) {
|
||||
|
||||
}
|
||||
|
||||
void gale::context::LoopActionResize::doAction(gale::Context& _context) {
|
||||
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
||||
_context.m_windowsSize = m_size;
|
||||
gale::Dimension::setPixelWindowsSize(_context.m_windowsSize);
|
||||
_context.forceRedrawAll();
|
||||
}
|
||||
|
||||
void gale::context::LoopActionRecalculateSize::doAction(gale::Context& _context) {
|
||||
_context.forceRedrawAll();
|
||||
}
|
||||
|
||||
gale::context::LoopActionInput::LoopActionInput(enum gale::key::type _type,
|
||||
enum gale::key::status _status,
|
||||
int32_t _pointerID,
|
||||
const vec2& _pos) :
|
||||
m_type(_type),
|
||||
m_status(_status),
|
||||
m_pointerID(_pointerID),
|
||||
m_pos(_pos) {
|
||||
|
||||
}
|
||||
|
||||
void gale::context::LoopActionInput::doAction(gale::Context& _context) {
|
||||
if (_context.m_application == nullptr) {
|
||||
return;
|
||||
}
|
||||
_context.m_application->onPointer(m_type,
|
||||
m_pointerID,
|
||||
m_pos,
|
||||
m_status);
|
||||
}
|
||||
|
||||
gale::context::LoopActionKeyboard::LoopActionKeyboard(const gale::key::Special& _special,
|
||||
enum gale::key::keyboard _type,
|
||||
enum gale::key::status _state,
|
||||
char32_t _char) :
|
||||
m_special(_special),
|
||||
m_type(_type),
|
||||
m_state(_state),
|
||||
m_char(_char) {
|
||||
|
||||
}
|
||||
|
||||
void gale::context::LoopActionKeyboard::doAction(gale::Context& _context) {
|
||||
if (_context.m_application == nullptr) {
|
||||
return;
|
||||
}
|
||||
_context.m_application->onKeyboard(m_special,
|
||||
m_type,
|
||||
m_char,
|
||||
m_state);
|
||||
}
|
86
gale/context/LoopAction.h
Normal file
86
gale/context/LoopAction.h
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GALE_CONTEXT_LOOP_ACTION_H__
|
||||
#define __GALE_CONTEXT_LOOP_ACTION_H__
|
||||
|
||||
#include <etk/os/Fifo.h>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/gale.h>
|
||||
#include <gale/key/key.h>
|
||||
#include <memory>
|
||||
m_timestamp
|
||||
#define MAX_MANAGE_INPUT (15)
|
||||
|
||||
namespace gale {
|
||||
namespace context {
|
||||
/**
|
||||
* @brief Create action from the simulation string line
|
||||
* @param[in] _lineToParse Simulation string line
|
||||
* @return Created action.
|
||||
*/
|
||||
std::shared_ptr<LoopAction> createAction(const std::string& _lineToParse);
|
||||
|
||||
/**
|
||||
* @brief Add a factory to create an event from a specific type
|
||||
* @param[in] _type Type of the action
|
||||
* @param[in] _func function to call to create
|
||||
* @return Created action.
|
||||
*/
|
||||
void addFactory(const std::string& _type, const std::function<std::shared_ptr<LoopAction>(const std::string&)>& _func);
|
||||
|
||||
class LoopAction : public std::enable_shared_from_this<LoopAction> {
|
||||
protected:
|
||||
int64_t m_timestamp; //!< time of the signal is emit (used for simulation)
|
||||
public:
|
||||
LoopAction();
|
||||
virtual ~LoopAction();
|
||||
virtual void doAction(gale::Context& _context) = 0;
|
||||
virtual std::string createString() { return "" };
|
||||
}
|
||||
class LoopActionInit : public LoopAction {
|
||||
public:
|
||||
LoopActionInit() {};
|
||||
virtual void doAction(gale::Context& _context);
|
||||
}
|
||||
class LoopActionResize : public LoopAction {
|
||||
protected:
|
||||
vec2 m_size;
|
||||
public:
|
||||
LoopActionResize(const vec2& _size);
|
||||
virtual void doAction(gale::Context& _context);
|
||||
}
|
||||
class LoopActionRecalculateSize : public LoopAction {
|
||||
public:
|
||||
LoopActionRecalculateSize() {};
|
||||
virtual void doAction(gale::Context& _context);
|
||||
}
|
||||
class LoopActionInput : public LoopAction {
|
||||
private:
|
||||
enum gale::key::type m_type;
|
||||
enum gale::key::status m_statusm
|
||||
int32_t m_pointerID;
|
||||
const vec2& m_pos;
|
||||
public:
|
||||
LoopActionInput(enum gale::key::type _type, enum gale::key::status _status, int32_t _pointerID, const vec2& _pos);
|
||||
virtual void doAction(gale::Context& _context);
|
||||
}
|
||||
class LoopActionKeyboard : public LoopAction {
|
||||
private:
|
||||
gale::key::Special m_special;
|
||||
enum gale::key::keyboard m_type;
|
||||
enum gale::key::status m_state;
|
||||
char32_t m_char;
|
||||
public:
|
||||
LoopActionKeyboard(const gale::key::Special& _special, enum gale::key::keyboard _type, enum gale::key::status _state, char32_t _char=u32char::Null);
|
||||
virtual void doAction(gale::Context& _context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
0
gale/context/Simulator.cpp
Normal file
0
gale/context/Simulator.cpp
Normal file
0
gale/context/Simulator.h
Normal file
0
gale/context/Simulator.h
Normal file
@ -37,6 +37,18 @@ static void checkGlError(const char* _op, int32_t _localLine) {
|
||||
//#define OPENGL_INFO(data) GALE_INFO(data)
|
||||
|
||||
|
||||
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
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)
|
||||
* This generate a non access on the openGL IO, and all function work corectly.
|
||||
*/
|
||||
void gale::openGL::startSimulationMode() {
|
||||
s_simulationMode = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief get the draw mutex (gale render).
|
||||
* @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time.
|
||||
@ -137,7 +149,13 @@ void gale::openGL::finish() {
|
||||
void gale::openGL::flush() {
|
||||
l_programId = -1;
|
||||
l_textureflags = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glFlush();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
OPENGL_INFO("========================" );
|
||||
OPENGL_INFO("== FLUSH OPEN GL ==" );
|
||||
OPENGL_INFO("========================");
|
||||
@ -148,11 +166,23 @@ void gale::openGL::swap() {
|
||||
}
|
||||
|
||||
void gale::openGL::setViewPort(const ivec2& _start, const ivec2& _stop) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glViewport(_start.x(), _start.y(), _stop.x(), _stop.y());
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gale::openGL::setViewPort(const vec2& _start, const vec2& _stop) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glViewport(_start.x(), _start.y(), _stop.x(), _stop.y());
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -169,14 +199,32 @@ static int32_t basicFlagClearCount = sizeof(basicFlagClear) / sizeof(struct corr
|
||||
|
||||
|
||||
void gale::openGL::clearColor(const etk::Color<float>& _color) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClearColor(_color.r(), _color.g(), _color.b(), _color.a());
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gale::openGL::clearDepth(float _value) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClearDepth(_value);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void gale::openGL::clearStencil(int32_t _value) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClearStencil(_value);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gale::openGL::clear(uint32_t _flags) {
|
||||
@ -186,7 +234,13 @@ void gale::openGL::clear(uint32_t _flags) {
|
||||
field |= basicFlagClear[iii].OGlFlag;
|
||||
}
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glClear(field);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::ostream& gale::operator <<(std::ostream& _os, const enum openGL::flag& _obj) {
|
||||
@ -366,11 +420,17 @@ void gale::openGL::reset() {
|
||||
void gale::openGL::enable(enum gale::openGL::flag _flagID) {
|
||||
//GALE_INFO("Enable : " <GALE_ERROR< _flagID);
|
||||
#ifdef DIRECT_MODE
|
||||
for (int32_t iii=0; iii<basicFlagCount ; iii++) {
|
||||
if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
|
||||
glEnable(basicFlag[iii].OGlFlag);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
for (int32_t iii=0; iii<basicFlagCount ; iii++) {
|
||||
if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
|
||||
glEnable(basicFlag[iii].OGlFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
# else
|
||||
//GALE_DEBUG("Enable FLAGS = " << l_flagsMustBeSet);
|
||||
l_flagsMustBeSet |= (uint32_t)_flagID;
|
||||
@ -381,11 +441,17 @@ void gale::openGL::enable(enum gale::openGL::flag _flagID) {
|
||||
void gale::openGL::disable(enum gale::openGL::flag _flagID) {
|
||||
//GALE_INFO("Disable : " << _flagID);
|
||||
#ifdef DIRECT_MODE
|
||||
for (int32_t iii=0; iii<basicFlagCount ; iii++) {
|
||||
if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
|
||||
glDisable(basicFlag[iii].OGlFlag);
|
||||
for (int32_t iii=0; iii<basicFlagCount ; iii++) {
|
||||
if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDisable(basicFlag[iii].OGlFlag);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
# else
|
||||
//GALE_DEBUG("Disable FLAGS = " << l_flagsMustBeSet);
|
||||
l_flagsMustBeSet &= ~((uint32_t)_flagID);
|
||||
@ -407,10 +473,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
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glEnable(basicFlag[iii].OGlFlag);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
OPENGL_INFO(" enable : " << (enum openGL::flag)basicFlag[iii].curentFlag);
|
||||
} else {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDisable(basicFlag[iii].OGlFlag);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
OPENGL_INFO(" disable : " << (enum openGL::flag)basicFlag[iii].curentFlag);
|
||||
}
|
||||
}
|
||||
@ -421,7 +499,13 @@ void gale::openGL::updateAllFlags() {
|
||||
|
||||
void gale::openGL::activeTexture(uint32_t _flagID) {
|
||||
if (l_programId >= 0) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glActiveTexture(_flagID);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,29 +537,53 @@ 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
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDrawArrays(convertRenderMode[_mode], _first, _count);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void gale::openGL::drawElements(enum renderMode _mode, const std::vector<uint32_t>& _indices) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
//GALE_DEBUG("Request draw of " << indices.size() << "elements");
|
||||
glDrawElements(convertRenderMode[_mode], _indices.size(), GL_UNSIGNED_INT, &_indices[0]);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void gale::openGL::drawElements16(enum renderMode _mode, const std::vector<uint16_t>& _indices) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDrawElements(convertRenderMode[_mode], _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void gale::openGL::drawElements8(enum renderMode _mode, const std::vector<uint8_t>& _indices) {
|
||||
if (l_programId >= 0) {
|
||||
updateAllFlags();
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDrawElements(convertRenderMode[_mode], _indices.size(), GL_UNSIGNED_BYTE, &_indices[0]);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,14 +599,32 @@ void gale::openGL::useProgram(int32_t _id) {
|
||||
}
|
||||
if (l_programId != _id) {
|
||||
l_programId = _id;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glUseProgram(l_programId);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
if (-1 == _id) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glUseProgram(0);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
l_programId = _id;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glUseProgram(_id);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -512,8 +638,14 @@ bool gale::openGL::genBuffers(std::vector<uint32_t>& _buffers) {
|
||||
return true;
|
||||
}
|
||||
OPENGL_INFO("Create N=" << _buffers.size() << " Buffer");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glGenBuffers(_buffers.size(), &_buffers[0]);
|
||||
checkGlError("glGenBuffers", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
bool hasError = false;
|
||||
for (size_t iii=0; iii<_buffers.size(); iii++) {
|
||||
if (_buffers[iii] == 0) {
|
||||
@ -529,8 +661,14 @@ 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
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDeleteBuffers(_buffers.size(), &_buffers[0]);
|
||||
checkGlError("glDeleteBuffers", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
for (auto &it : _buffers) {
|
||||
it = 0;
|
||||
}
|
||||
@ -538,8 +676,14 @@ bool gale::openGL::deleteBuffers(std::vector<uint32_t>& _buffers) {
|
||||
}
|
||||
|
||||
bool gale::openGL::bindBuffer(uint32_t _bufferId) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _bufferId);
|
||||
checkGlError("glBindBuffer", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -550,14 +694,26 @@ static GLenum convertUsage[] = {
|
||||
};
|
||||
|
||||
bool gale::openGL::bufferData(size_t _size, const void* _data, enum gale::openGL::usage _usage) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glBufferData(GL_ARRAY_BUFFER, _size, _data, convertUsage[_usage]);
|
||||
checkGlError("glBufferData", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gale::openGL::unbindBuffer() {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
checkGlError("glBindBuffer(0)", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -572,16 +728,40 @@ static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
|
||||
int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) {
|
||||
GLuint shader = 0;
|
||||
if (_type == gale::openGL::shader::type_vertex) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
shader = glCreateShader(GL_VERTEX_SHADER);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
} else {
|
||||
static int32_t count = 0;
|
||||
shader = count++;
|
||||
}
|
||||
#endif
|
||||
} else if (_type == gale::openGL::shader::type_fragment) {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
} else {
|
||||
static int32_t count = 0;
|
||||
shader = count++;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
GALE_ERROR("create shader with wrong type ...");
|
||||
return -1;
|
||||
}
|
||||
if (shader == 0) {
|
||||
GALE_ERROR("glCreateShader return error ...");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
checkGlError("glCreateShader");
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
return int64_t(shader);
|
||||
@ -591,12 +771,21 @@ void gale::openGL::shader::remove(int64_t& _shader) {
|
||||
if (_shader < 0) {
|
||||
return;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDeleteShader(GLuint(_shader));
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
_shader = -1;
|
||||
}
|
||||
|
||||
bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) {
|
||||
const char* data = &_data[0];
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glShaderSource(GLuint(_shader), 1, (const char**)&data, nullptr);
|
||||
glCompileShader(GLuint(_shader));
|
||||
GLint compiled = 0;
|
||||
@ -612,17 +801,30 @@ bool gale::openGL::shader::compile(int64_t _shader, const std::string& _data) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int64_t gale::openGL::program::create() {
|
||||
GLuint program = glCreateProgram();
|
||||
GLuint program = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
program = glCreateProgram();
|
||||
if (program == 0) {
|
||||
GALE_ERROR("program creation return error ...");
|
||||
checkGlError("glCreateProgram", __LINE__);
|
||||
return -1;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
} else {
|
||||
static uint32_t iii=0;
|
||||
program = iii++;
|
||||
}
|
||||
#endif
|
||||
GALE_DEBUG("Create program with oglID=" << program);
|
||||
return int64_t(program);
|
||||
}
|
||||
@ -631,8 +833,14 @@ void gale::openGL::program::remove(int64_t& _prog) {
|
||||
if (_prog < 0) {
|
||||
return;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glDeleteProgram(GLuint(_prog));
|
||||
checkGlError("glDeleteProgram", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
_prog = -1;
|
||||
}
|
||||
|
||||
@ -645,8 +853,14 @@ bool gale::openGL::program::attach(int64_t _prog, int64_t _shader) {
|
||||
GALE_ERROR("wrong shader ID");
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glAttachShader(GLuint(_prog), GLuint(_shader));
|
||||
checkGlError("glAttachShader", __LINE__);
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
bool gale::openGL::program::compile(int64_t _prog) {
|
||||
@ -654,6 +868,9 @@ bool gale::openGL::program::compile(int64_t _prog) {
|
||||
GALE_ERROR("wrong program ID");
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
glLinkProgram(GLuint(_prog));
|
||||
checkGlError("glLinkProgram", __LINE__);
|
||||
GLint linkStatus = GL_FALSE;
|
||||
@ -687,6 +904,9 @@ bool gale::openGL::program::compile(int64_t _prog) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -699,11 +919,18 @@ int32_t gale::openGL::program::getAttributeLocation(int64_t _prog, const std::st
|
||||
GALE_ERROR("wrong name of attribure");
|
||||
return -1;
|
||||
}
|
||||
GLint val = glGetAttribLocation(GLuint(_prog), _name.c_str());
|
||||
GLint val = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
val = glGetAttribLocation(GLuint(_prog), _name.c_str());
|
||||
if (val < 0) {
|
||||
checkGlError("glGetAttribLocation", __LINE__);
|
||||
GALE_WARNING("glGetAttribLocation(\"" << _name << "\") = " << val);
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -716,11 +943,18 @@ int32_t gale::openGL::program::getUniformLocation(int64_t _prog, const std::stri
|
||||
GALE_ERROR("wrong name of uniform");
|
||||
return -1;
|
||||
}
|
||||
GLint val = 0;
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
GLint val = glGetUniformLocation(GLuint(_prog), _name.c_str());
|
||||
if (val < 0) {
|
||||
checkGlError("glGetUniformLocation", __LINE__);
|
||||
GALE_WARNING("glGetUniformLocation(\"" << _name << "\") = " << val);
|
||||
}
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
}
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,13 @@
|
||||
|
||||
namespace gale {
|
||||
namespace openGL {
|
||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
void startSimulationMode();
|
||||
#endif
|
||||
/**
|
||||
* @brief Lock the openGL context for one user only == > better to keep flags and other things ...
|
||||
*/
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user