Compare commits

...

5 Commits

23 changed files with 541 additions and 294 deletions

View File

@ -35,6 +35,12 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants {
m_galeNative = _galeInstance;
/*
List of the Android API :
Android 9.0 28 Pie
Android 8.0 - 8.1 26 Oreo
Android 7.0 - 7.1.2 24 Nougat
Android 6.0 - 6.0.1 23 Marshmallow
Android 5.0 - 5.1.1 21 LOLIPOP
Android 4.4 - 4.4.4 19 KIT-KAT
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH

View File

@ -131,13 +131,13 @@ etk::String gale::Application::getTitle() {
return m_title;
}
void gale::Application::setIcon(const etk::String& _iconFile) {
void gale::Application::setIcon(const etk::Uri& _iconFile) {
m_iconName = _iconFile;
gale::Context& context = gale::getContext();
context.setIcon(m_iconName);
}
etk::String gale::Application::getIcon() {
const etk::Uri& gale::Application::getIcon() {
return m_iconName;
}

View File

@ -7,6 +7,7 @@
#include <ememory/memory.hpp>
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <etk/math/Vector2D.hpp>
#include <gale/orientation.hpp>
#include <gale/key/status.hpp>
@ -158,18 +159,18 @@ namespace gale {
*/
virtual etk::String getTitle();
private:
etk::String m_iconName;
etk::Uri m_iconName;
public:
/**
* @brief set the Icon of the application.
* @param[in] _iconFile File name icon (.bmp/.png).
*/
virtual void setIcon(const etk::String& _iconFile);
virtual void setIcon(const etk::Uri& _iconFile);
/**
* @brief Get the current filename of the application.
* @return Filename of the icon.
*/
virtual etk::String getIcon();
virtual const etk::Uri& getIcon();
private:
enum gale::context::cursor m_cursor;
public:

View File

@ -10,7 +10,7 @@
#include <etk/etk.hpp>
#include <etk/tool.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <ethread/tools.hpp>
#include <ethread/Mutex.hpp>
@ -26,6 +26,9 @@
#include <echrono/Time.hpp>
#include <etk/typeInfo.hpp>
#include <etk/Allocator.hpp>
#include <etk/uri/provider/ProviderFile.hpp>
#include <etk/theme/theme.hpp>
ETK_DECLARE_TYPE(gale::Context);
/**
@ -165,18 +168,19 @@ void gale::Context::setArchiveDir(int _mode, const char* _str, const char* _appl
switch(_mode) {
case 0:
GALE_DEBUG("Directory APK : path=" << _str);
etk::setBaseFolderData(_str, _applName);
etk::uri::provider::add("DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(_str));
break;
case 1:
GALE_DEBUG("Directory mode=FILE path=" << _str);
etk::setBaseFolderDataUser(_str);
etk::uri::provider::add("USER_DATA", ememory::makeShared<etk::uri::provider::ProviderFile>(_str));
break;
case 2:
GALE_DEBUG("Directory mode=CACHE path=" << _str);
etk::setBaseFolderCache(_str);
etk::uri::provider::add("CACHE", ememory::makeShared<etk::uri::provider::ProviderFile>(_str));
break;
case 3:
GALE_DEBUG("Directory mode=EXTERNAL_CACHE path=" << _str);
etk::uri::provider::add("EXTERNAL_CACHE", ememory::makeShared<etk::uri::provider::ProviderFile>(_str));
break;
default:
GALE_DEBUG("Directory mode=???? path=" << _str);
@ -216,13 +220,10 @@ namespace gale {
};
}
gale::Context::Context(gale::Application* _application, int32_t _argc, const char* _argv[]) :
m_application(_application),
m_simulationActive(false),
m_simulationFile("gale.gsim"),
m_simulationUri(etk::Path("gale.gsim")),
//m_objectManager(*this),
m_previousDisplayTime(),
// TODO : m_input(*this),
@ -253,12 +254,13 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
// By default we set 2 themes (1 color and 1 shape ...) :
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) {
if (m_commandLine.get(iii) == "--gale-fps") {
m_displayFps=true;
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-file=") == true) {
m_simulationFile.setName(etk::String(m_commandLine.get(iii).begin()+23, m_commandLine.get(iii).end()) );
m_simulationUri = etk::Path(etk::String(m_commandLine.get(iii).begin()+23, m_commandLine.get(iii).end()) );
} else if (m_commandLine.get(iii) == "--gale-simulation-record") {
m_simulationActive = true;
} else if (etk::start_with(m_commandLine.get(iii), "--gale-backend=") == true) {
@ -330,13 +332,17 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
// request the init of the application in the main context of openGL ...
if (m_simulationActive == true) {
// in simulation case:
if (m_simulationFile.fileOpenWrite() == false) {
GALE_CRITICAL("Can not create Simulation file : " << m_simulationFile);
m_simulationFile = etk::uri::get(m_simulationUri);
if (m_simulationFile == null) {
GALE_CRITICAL("Can not create Simulation file : " << m_simulationUri);
}
if (m_simulationFile->open(etk::io::OpenMode::Write) == false) {
GALE_CRITICAL("Can not create Simulation file : " << m_simulationUri);
m_simulationActive = false;
} else {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":INIT");
m_simulationFile.filePuts("\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":INIT");
m_simulationFile->puts("\n");
}
}
#if defined(__GALE_ANDROID_ORIENTATION_LANDSCAPE__)
@ -411,14 +417,14 @@ gale::Context::~Context() {
GALE_INFO(" == > Gale system Un-Init (END)");
if (m_simulationActive == true) {
// in simulation case:
m_simulationFile.fileClose();
m_simulationFile->close();
}
}
void gale::Context::requestUpdateSize() {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":RECALCULATE_SIZE\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":RECALCULATE_SIZE\n");
}
ethread::RecursiveLock lock(m_mutex);
m_msgSystem.post([](gale::Context& _context){
@ -434,10 +440,10 @@ void gale::Context::OS_Resize(const vec2& _size) {
// TODO : Better in the thread ... ==> but generate some init error ...
gale::Dimension::setPixelWindowsSize(_size);
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":RESIZE:");
m_simulationFile.filePuts(etk::toString(_size));
m_simulationFile.filePuts("\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":RESIZE:");
m_simulationFile->puts(etk::toString(_size));
m_simulationFile->puts("\n");
}
ethread::RecursiveLock lock(m_mutex);
m_msgSystem.post([_size](gale::Context& _context){
@ -487,16 +493,16 @@ void gale::Context::OS_SetInput(enum gale::key::type _type,
int32_t _pointerID,
const vec2& _pos) {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":INPUT:");
m_simulationFile.filePuts(etk::toString(_type));
m_simulationFile.filePuts(":");
m_simulationFile.filePuts(etk::toString(_status));
m_simulationFile.filePuts(":");
m_simulationFile.filePuts(etk::toString(_pointerID));
m_simulationFile.filePuts(":");
m_simulationFile.filePuts(etk::toString(_pos));
m_simulationFile.filePuts("\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":INPUT:");
m_simulationFile->puts(etk::toString(_type));
m_simulationFile->puts(":");
m_simulationFile->puts(etk::toString(_status));
m_simulationFile->puts(":");
m_simulationFile->puts(etk::toString(_pointerID));
m_simulationFile->puts(":");
m_simulationFile->puts(etk::toString(_pos));
m_simulationFile->puts("\n");
}
ethread::RecursiveLock lock(m_mutex);
m_msgSystem.post([_type, _status, _pointerID, _pos](gale::Context& _context){
@ -524,16 +530,16 @@ void gale::Context::OS_setKeyboard(const gale::key::Special& _special,
}
}
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":KEYBOARD:");
m_simulationFile.filePuts(etk::toString(_special));
m_simulationFile.filePuts(":");
m_simulationFile.filePuts(etk::toString(_type));
m_simulationFile.filePuts(":");
m_simulationFile.filePuts(etk::toString(_state));
m_simulationFile.filePuts(":");
m_simulationFile.filePuts(etk::toString(uint64_t(_char)));
m_simulationFile.filePuts("\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":KEYBOARD:");
m_simulationFile->puts(etk::toString(_special));
m_simulationFile->puts(":");
m_simulationFile->puts(etk::toString(_type));
m_simulationFile->puts(":");
m_simulationFile->puts(etk::toString(_state));
m_simulationFile->puts(":");
m_simulationFile->puts(etk::toString(uint64_t(_char)));
m_simulationFile->puts("\n");
}
ethread::RecursiveLock lock(m_mutex);
m_msgSystem.post([_special, _type, _state, _char](gale::Context& _context){
@ -550,8 +556,8 @@ void gale::Context::OS_setKeyboard(const gale::key::Special& _special,
void gale::Context::OS_Hide() {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":VIEW:false\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":VIEW:false\n");
}
ethread::RecursiveLock lock(m_mutex);
m_msgSystem.post([](gale::Context& _context){
@ -571,8 +577,8 @@ void gale::Context::OS_Hide() {
void gale::Context::OS_Show() {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":VIEW:true\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":VIEW:true\n");
}
m_msgSystem.post([](gale::Context& _context){
/*
@ -592,10 +598,10 @@ void gale::Context::OS_Show() {
void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID) {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":CLIPBOARD_ARRIVE:");
m_simulationFile.filePuts(etk::toString(_clipboardID));
m_simulationFile.filePuts("\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":CLIPBOARD_ARRIVE:");
m_simulationFile->puts(etk::toString(_clipboardID));
m_simulationFile->puts("\n");
}
ethread::RecursiveLock lock(m_mutex);
m_msgSystem.post([_clipboardID](gale::Context& _context){
@ -617,10 +623,10 @@ void gale::Context::clipBoardSet(enum gale::context::clipBoard::clipboardListe _
bool gale::Context::OS_Draw(bool _displayEveryTime) {
if (m_simulationActive == true) {
m_simulationFile.filePuts(etk::toString(echrono::Steady::now()));
m_simulationFile.filePuts(":DRAW:");
m_simulationFile.filePuts(etk::toString(_displayEveryTime));
m_simulationFile.filePuts("\n");
m_simulationFile->puts(etk::toString(echrono::Steady::now()));
m_simulationFile->puts(":DRAW:");
m_simulationFile->puts(etk::toString(_displayEveryTime));
m_simulationFile->puts("\n");
}
{
static int32_t countMemeCheck = 0;

View File

@ -6,7 +6,7 @@
#pragma once
#include <etk/os/Fifo.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key/key.hpp>
@ -73,7 +73,8 @@ namespace gale {
protected:
// simulation area:
bool m_simulationActive;
etk::FSNode m_simulationFile;
etk::Uri m_simulationUri;
ememory::SharedPtr<etk::io::Interface> m_simulationFile;
private:
echrono::Steady m_previousDisplayTime; // this is to limit framerate ... in case...
etk::Fifo<etk::Function<void(gale::Context& _context)> > m_msgSystem;
@ -262,7 +263,7 @@ namespace gale {
* @brief set the Icon of the program
* @param[in] _inputFile new filename icon of the curent program.
*/
virtual void setIcon(const etk::String& _inputFile) { };
virtual void setIcon(const etk::Uri& _inputFile) { };
/**
* @brief Enable or Disable the decoration on the Windows (availlable only on Desktop)
* @param[in] _status "true" to enable decoration / false otherwise

View File

@ -10,7 +10,7 @@
#include <gale/key/key.hpp>
#include <gale/context/commandLine.hpp>
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/context/Context.hpp>

View File

@ -11,7 +11,7 @@
#include <gale/context/commandLine.hpp>
#include <gale/context/clipBoard.hpp>
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/context/Context.hpp>

View File

@ -11,7 +11,7 @@ extern "C" {
}
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <etk/tool.hpp>
#include <gale/debug.hpp>

View File

@ -7,7 +7,7 @@
#include <gale/gale.hpp>
#include <gale/Dimension.hpp>
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <etk/math/Vector2D.hpp>
#include <etk/math/Vector3D.hpp>

View File

@ -11,7 +11,7 @@ extern "C" {
}
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <etk/tool.hpp>
#include <gale/debug.hpp>
@ -1269,7 +1269,7 @@ class X11Interface : public gale::Context {
return true;
}
/****************************************************************************************/
void setIcon(const etk::String& _inputFile) {
void setIcon(const etk::Uri& _inputFile) {
X11_FUNC();
#if defined(GALE_BUILD_EGAMI) \
&& !defined(__TARGET_OS__Web)

View File

@ -11,7 +11,7 @@ extern "C" {
}
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <etk/tool.hpp>
#include <gale/debug.hpp>
@ -75,15 +75,17 @@ class SimulationInterface : public gale::Context {
}
int32_t run() {
m_simulationFile = etk::uri::get(m_simulationUri);
// Try to open the file of simulation:
if (m_simulationFile.fileOpenRead() == false) {
if ( m_simulationFile == null
|| m_simulationFile->open(etk::io::OpenMode::Read) == false) {
GALE_ERROR("can not open the simulation file");
return -1;
}
etk::String action;
// main cycle
while(m_run == true) {
bool lineIsOk = m_simulationFile.fileGets(action);
bool lineIsOk = m_simulationFile->gets(action);
if (lineIsOk == false) {
// reach end of simulation file;
return 0;
@ -156,7 +158,7 @@ class SimulationInterface : public gale::Context {
GALE_ERROR("unknow event : '" << localAction << "'");
}
}
m_simulationFile.fileClose();
m_simulationFile->close();
return 0;
}
/****************************************************************************************/

View File

@ -18,7 +18,7 @@ extern "C" {
#include <errno.h>
}
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <etk/tool.hpp>
#include <gale/debug.hpp>
@ -52,6 +52,14 @@ extern "C" {
#include <poll.h>
}
#define XDG_INTERFACE 1
#ifdef XDG_INTERFACE
extern "C" {
#include <xdg-shell-client-protocol.h>
}
#endif
#include <gale/renderer/openGL/openGL-include.hpp>
static bool hasDisplay = false;
@ -101,6 +109,7 @@ static void configure_callback(void* _data, struct wl_callback* _callback, uint3
static struct wl_callback_listener configure_callback_listener = {
configure_callback,
};
#if O
static void handle_ping(void* _data, struct wl_shell_surface* _shellSurface, uint32_t _serial);
static void handle_configure(void* _data, struct wl_shell_surface* _shellSurface, uint32_t _edges, int32_t _width, int32_t _height);
static void handle_popup_done(void* _data, struct wl_shell_surface* _shellSurface);
@ -109,6 +118,22 @@ static const struct wl_shell_surface_listener shell_surface_listener = {
handle_configure,
handle_popup_done
};
#else
static void handle_ping(void* _data, struct xdg_wm_base* _wdgWmBase, uint32_t _serial);
static const struct xdg_wm_base_listener wm_base_listener = {
handle_ping,
};
static void xdg_surface_handle_configure(void* _data, struct xdg_surface* _xdgSurface, uint32_t _serial);
static const struct xdg_surface_listener xdg_surface_listener = {
xdg_surface_handle_configure,
};
static void xdg_toplevel_handle_configure(void* _data, struct xdg_toplevel* _xdgToplevel, int32_t _width, int32_t _height, struct wl_array* _states);
static void xdg_toplevel_handle_close(void* _data, struct xdg_toplevel* _xdgToplevel);
static const struct xdg_toplevel_listener xdg_toplevel_listener = {
xdg_toplevel_handle_configure,
xdg_toplevel_handle_close,
};
#endif
static void keyboard_handle_keymap(void* _data, struct wl_keyboard* _keyboard, uint32_t _format, int _fd, uint32_t _size);
static void keyboard_handle_enter(void* _data, struct wl_keyboard* _keyboard, uint32_t _serial, struct wl_surface* _surface, struct wl_array* _keys);
static void keyboard_handle_leave(void* _data, struct wl_keyboard* _keyboard, uint32_t _serial, struct wl_surface* _surface);
@ -215,90 +240,60 @@ static const struct wl_data_source_listener data_source_listener = {
class WAYLANDInterface : public gale::Context {
private:
gale::key::Special m_guiKeyBoardMode;
ivec2 m_size;
ivec2 m_size = ivec2(800,600);
bool m_inputIsPressed[MAX_MANAGE_INPUT];
etk::String m_uniqueWindowsName;
bool m_run;
bool m_fullscreen;
bool m_configured;
bool m_opaque;
enum gale::context::cursor m_cursorCurrent; //!< curent cursor
vec2 m_cursorCurrentPosition;
char32_t m_lastKeyPressed;
bool m_run = false;
bool m_fullscreen = false;
bool m_configured = false;
bool m_opaque = false;
enum gale::context::cursor m_cursorCurrent = gale::context::cursor::leftArrow; //!< curent cursor
vec2 m_cursorCurrentPosition = vec2(0,0);
char32_t m_lastKeyPressed = 0;
// Wayland interface
struct wl_display* m_display;
struct wl_registry* m_registry;
struct wl_compositor* m_compositor;
struct wl_shell* m_shell;
struct wl_seat* m_seat;
struct wl_pointer* m_pointer;
struct wl_keyboard* m_keyboard;
struct wl_shm* m_shm;
struct wl_cursor_theme* m_cursorTheme;
struct wl_cursor* m_cursorDefault;
struct wl_surface* m_cursorSurface;
struct wl_egl_window *m_eglWindow;
struct wl_surface *m_surface;
struct wl_shell_surface *m_shellSurface;
struct wl_callback *m_callback;
struct wl_data_device_manager* m_dataDeviceManager;
int32_t m_dataDeviceManagerVersion;
struct wl_data_device *m_dataDevice;
int32_t m_serial; //!< Unique ID of the serial element (based on the enter time)
bool m_offerIsInside; //!< Offer request in inside the windows
bool m_offerInternalCopy; //!< The windows own th copy buffer
struct wl_data_offer* m_offerCopy;
struct wl_data_source* m_dataSource;
struct wl_display* m_display = null;
struct wl_registry* m_registry = null;
struct wl_compositor* m_compositor = null;
#if 0
struct wl_shell* m_shell = null;
struct wl_shell_surface *m_shellSurface = null;
#else
struct xdg_wm_base* m_xdgWmBase = null;
struct xdg_surface* m_xdgSurface = null;
struct xdg_toplevel* m_xdgTopLevel = null;
#endif
struct wl_seat* m_seat = null;
struct wl_pointer* m_pointer = null;
struct wl_keyboard* m_keyboard = null;
struct wl_shm* m_shm = null;
struct wl_surface *m_surface = null;
struct wl_cursor_theme* m_cursorTheme = null;
struct wl_cursor* m_cursorDefault = null;
struct wl_surface* m_cursorSurface = null;
struct wl_egl_window *m_eglWindow = null;
struct wl_callback *m_callback = null;
struct wl_data_device_manager* m_dataDeviceManager = null;
int32_t m_dataDeviceManagerVersion = 0;
struct wl_data_device *m_dataDevice = null;
int32_t m_serial = 0; //!< Unique ID of the serial element (based on the enter time)
bool m_offerIsInside = false; //!< Offer request in inside the windows
bool m_offerInternalCopy = false; //!< The windows own th copy buffer
struct wl_data_offer* m_offerCopy = null;
struct wl_data_source* m_dataSource = null;
// EGL interface:
EGLDisplay m_eglDisplay;
EGLContext m_eglContext;
EGLConfig m_eglConfig;
EGLSurface m_eglSurface;
#ifdef GALE_XKB_WRAPPER_INPUT
struct xkb_context* m_XKBContext;
struct xkb_keymap* m_XKBKeymap;
struct xkb_state* m_XKBState;
struct xkb_context* m_XKBContext = null;
struct xkb_keymap* m_XKBKeymap = null;
struct xkb_state* m_XKBState = null;
#endif
public:
WAYLANDInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv),
m_size(800,600),
m_run(false),
m_fullscreen(false),
m_configured(false),
m_opaque(false),
m_cursorCurrent(gale::context::cursor::leftArrow),
m_lastKeyPressed(0),
m_display(null),
m_registry(null),
m_compositor(null),
m_shell(null),
m_seat(null),
m_pointer(null),
m_keyboard(null),
m_shm(null),
m_cursorTheme(null),
m_cursorDefault(null),
m_cursorSurface(null),
m_eglWindow(null),
m_surface(null),
m_shellSurface(null),
m_callback(null),
m_dataDeviceManager(null),
m_dataDeviceManagerVersion(0),
m_dataDevice(null),
m_serial(0),
m_offerIsInside(false),
m_offerInternalCopy(false),
m_offerCopy(null),
m_dataSource(null)
#ifdef GALE_XKB_WRAPPER_INPUT
,m_XKBContext(null),
m_XKBKeymap(null),
m_XKBState(null)
#endif
{
gale::Context(_application, _argc, _argv) {
// in case ...
GALE_WARNING("WAYLAND: INIT [START]");
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
@ -311,23 +306,36 @@ class WAYLANDInterface : public gale::Context {
GALE_CRITICAL("Couldn't create xkb context");
}
#endif
GALE_WARNING("WAYLAND: INIT [step 1]");
m_display = wl_display_connect(null);
assert(m_display);
GALE_WARNING("WAYLAND: INIT [step 2]");
m_registry = wl_display_get_registry(m_display);
wl_registry_add_listener(m_registry, &registry_listener, this);
GALE_WARNING("WAYLAND: INIT [step 3]");
wl_display_dispatch(m_display);
wl_display_roundtrip(m_display);
initEgl(m_opaque);
GALE_WARNING("WAYLAND: INIT [step 4]");
createSurface();
GALE_WARNING("WAYLAND: INIT [step 5]");
m_cursorSurface = wl_compositor_create_surface(m_compositor);
if (m_cursorSurface == null) {
GALE_CRITICAL("Can not create surface for the windows");
}
// set the DPI for the current screen: TODO : do it with real value, for now, we use a generic dpi value (most common screen)
gale::Dimension::setPixelRatio(vec2(75,75),gale::distance::inch);
m_uniqueWindowsName = "GALE_" + etk::toString(etk::tool::irand(0, 1999999999));
GALE_INFO("Start a windows name : '" << m_uniqueWindowsName << "'");
m_run = true;
GALE_WARNING("WAYLAND: INIT [STOP]");
start2ndThreadProcessing();
@ -355,10 +363,17 @@ class WAYLANDInterface : public gale::Context {
wl_cursor_theme_destroy(m_cursorTheme);
m_cursorTheme = null;
}
#if 0
if (m_shell != null) {
wl_shell_destroy(m_shell);
m_shell = null;
}
#else
if (m_xdgWmBase != null) {
xdg_wm_base_destroy(m_xdgWmBase);
m_xdgWmBase = null;
}
#endif
if (m_compositor != null) {
wl_compositor_destroy(m_compositor);
m_compositor = null;
@ -378,7 +393,7 @@ class WAYLANDInterface : public gale::Context {
}
}
/****************************************************************************************/
int32_t run() {
int32_t run() override {
int ret = 0;
while ( m_run == true
&& ret != -1) {
@ -419,13 +434,14 @@ class WAYLANDInterface : public gale::Context {
GALE_CRITICAL("Can't initialise Bind");
return;
}
EGLint nnn;
EGLint nnn = 0;
EGLBoolean ret = eglChooseConfig(m_eglDisplay, config_attribs, &m_eglConfig, 1, &nnn);
/*
GALE_WARNING("get openGL config ret=" << ret);
#if 1
EGLint count = 0;
eglGetConfigs(m_egl_display, null, 0, &count);
eglGetConfigs(m_eglDisplay, null, 0, &count);
GALE_INFO("EGL has " << count << " configs");
EGLConfig* configs = (EGLConfig*)calloc(count, sizeof *configs);
EGLConfig* configs = (EGLConfig*)calloc(count, sizeof(EGLConfig));
GALE_INFO("Display all configs:");
for (int32_t iii=0; iii<nnn; ++iii) {
EGLint size = 0;
@ -434,7 +450,7 @@ class WAYLANDInterface : public gale::Context {
eglGetConfigAttrib(m_eglDisplay, configs[iii], EGL_RED_SIZE, &sizeRed);
GALE_INFO(" " << iii << " BufferSize=" << size << " red size=" << sizeRed);
}
*/
#endif
//assert(ret && n == 1);
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, context_attribs);
@ -451,26 +467,64 @@ class WAYLANDInterface : public gale::Context {
GALE_INFO("un-Init EGL [STOP]");
}
void createSurface() {
GALE_INFO("CRATE the SURFACE [START]");
EGLBoolean ret;
m_surface = wl_compositor_create_surface(m_compositor);
if (m_surface == null) {
GALE_CRITICAL("WAYLAND: Can not create compositor surface");
}
#if 0
if (m_shell == null) {
GALE_ERROR("Try to get a shell surface without the shekk interface ==> might crash");
}
m_shellSurface = wl_shell_get_shell_surface(m_shell, m_surface);
if (m_shellSurface == null) {
GALE_CRITICAL("WAYLAND: Can not get the shell surface");
}
wl_shell_surface_add_listener(m_shellSurface, &shell_surface_listener, this);
#else
if (m_xdgWmBase == null) {
GALE_ERROR("Try to get a shell surface without the shekk interface ==> might crash");
}
m_xdgSurface = xdg_wm_base_get_xdg_surface(m_xdgWmBase, m_surface);
if (m_xdgSurface == null) {
GALE_CRITICAL("WAYLAND: Can not get the XDG surface");
}
xdg_wm_base_add_listener(m_xdgWmBase, &wm_base_listener, this);
m_xdgTopLevel= xdg_surface_get_toplevel(m_xdgSurface);
if (m_xdgTopLevel == null) {
GALE_CRITICAL("WAYLAND: Can not get top level element");
}
xdg_surface_add_listener(m_xdgSurface, &xdg_surface_listener, this);
xdg_toplevel_add_listener(m_xdgTopLevel, &xdg_toplevel_listener, this);
#endif
m_eglWindow = wl_egl_window_create(m_surface, m_size.x(), m_size.y());
wl_surface_commit(m_surface);
wl_display_roundtrip(m_display);
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_eglWindow, null);
#if 0
wl_shell_surface_set_title(m_shellSurface, m_uniqueWindowsName.c_str());
#else
xdg_toplevel_set_title(m_xdgTopLevel, m_uniqueWindowsName.c_str());
xdg_toplevel_set_app_id(m_xdgTopLevel, m_uniqueWindowsName.c_str());
#endif
ret = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
assert(ret == EGL_TRUE);
toggleFullscreen();
GALE_INFO("CRATE the SURFACE [STOP]");
GALE_INFO("CREATE the SURFACE [STOP]");
}
void destroySurface() {
GALE_INFO("DESTROY the SURFACE [START]");
wl_egl_window_destroy(m_eglWindow);
#if 0
wl_shell_surface_destroy(m_shellSurface);
#else
xdg_surface_destroy(m_xdgSurface);
xdg_toplevel_destroy(m_xdgTopLevel);
#endif
wl_surface_destroy(m_surface);
if (m_callback) {
wl_callback_destroy(m_callback);
@ -482,10 +536,18 @@ class WAYLANDInterface : public gale::Context {
GALE_INFO("toggleFullscreen [START]");
m_configured = false;
if (m_fullscreen) {
#if 0
wl_shell_surface_set_fullscreen(m_shellSurface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, null);
#else
// TODO:
#endif
} else {
#if 0
wl_shell_surface_set_toplevel(m_shellSurface);
handleConfigure(m_shellSurface, 0, m_size);
#else
// TODO:
#endif
}
struct wl_callback *callback = wl_display_sync(m_display);
wl_callback_add_listener(callback, &configure_callback_listener, this);
@ -496,12 +558,27 @@ class WAYLANDInterface : public gale::Context {
// recorder on elements ...
void registryHandler(struct wl_registry* _registry, uint32_t _id, const char* _interface, uint32_t _version) {
GALE_DEBUG("Got a registry event for '" << _interface << "' id=" << _id);
if (strcmp(_interface, "wl_compositor") == 0) {
GALE_INFO("Got a registry event for '" << _interface << "' id=" << _id);
if (strcmp(_interface, wl_compositor_interface.name) == 0) {
GALE_INFO("Get INTERFACE " << wl_compositor_interface.name);
m_compositor = (struct wl_compositor *)wl_registry_bind(_registry, _id, &wl_compositor_interface, 1);
#if 0
} else if (strcmp(_interface, "wl_shell") == 0) {
GALE_INFO("Get INTERFACE wl_shell");
m_shell = (struct wl_shell*)wl_registry_bind(_registry, _id, &wl_shell_interface, 1);
} else if (strcmp(_interface, "wl_seat") == 0) {
if (m_shell == null) {
GALE_ERROR("Can not get the shell surfaces...");
}
#else
} else if (strcmp(_interface, xdg_wm_base_interface.name) == 0) {
GALE_INFO("Get INTERFACE" << xdg_wm_base_interface.name);
m_xdgWmBase = (struct xdg_wm_base *)wl_registry_bind(_registry, _id, &xdg_wm_base_interface, 1);
if (m_xdgWmBase == null) {
GALE_ERROR("Can not get the shell surfaces...");
}
#endif
} else if (strcmp(_interface, wl_seat_interface.name) == 0) {
GALE_INFO("Get INTERFACE " << wl_seat_interface.name);
m_seat = (struct wl_seat*)wl_registry_bind(_registry, _id, &wl_seat_interface, 1);
wl_seat_add_listener(m_seat, &seat_listener, this);
if (m_dataDeviceManager != null) {
@ -510,7 +587,8 @@ class WAYLANDInterface : public gale::Context {
m_dataSource = wl_data_device_manager_create_data_source(m_dataDeviceManager);
wl_data_source_add_listener(m_dataSource, &data_source_listener, this);
}
} else if (strcmp(_interface, "wl_shm") == 0) {
} else if (strcmp(_interface, wl_shm_interface.name) == 0) {
GALE_INFO("Get INFERFACE " << wl_shm_interface.name);
m_shm = (struct wl_shm*)wl_registry_bind(_registry, _id, &wl_shm_interface, 1);
m_cursorTheme = wl_cursor_theme_load(null, 32, m_shm);
if (m_cursorTheme != null) {
@ -519,6 +597,7 @@ class WAYLANDInterface : public gale::Context {
GALE_WARNING("Can not get the generic theme");
}
} else if (strcmp(_interface, "wl_data_device_manager") == 0) {
GALE_INFO("Get INTERFACE wl_data_device_manager");
m_dataDeviceManagerVersion = etk::min(3, int32_t(_version));
m_dataDeviceManager = (struct wl_data_device_manager*)wl_registry_bind(_registry, _id, &wl_data_device_manager_interface, m_dataDeviceManagerVersion);
} else {
@ -527,6 +606,8 @@ class WAYLANDInterface : public gale::Context {
GALE_DEBUG("registry_handle_global [STOP]");
}
void registryRemover(struct wl_registry* _registry, uint32_t _id) {
GALE_WARNING("Got a registry losing event for " << _id);
}
@ -701,6 +782,7 @@ class WAYLANDInterface : public gale::Context {
}
/****************************************************************************************/
#if 0
void handlePing(struct wl_shell_surface* _shell_surface, uint32_t _serial) {
wl_shell_surface_pong(_shell_surface, _serial);
GALE_WARNING("Ping ==> pong");
@ -719,6 +801,28 @@ class WAYLANDInterface : public gale::Context {
void handlePopupDone(struct wl_shell_surface* _shell_surface) {
GALE_WARNING("Pop-up done");
}
#else
void handlePing(struct xdg_wm_base* _wdgWmBase, uint32_t _serial) {
xdg_wm_base_pong(_wdgWmBase, _serial);
GALE_WARNING("Ping ==> pong");
}
void xdgSurfaceHandleConfigure(struct xdg_surface* _xdgSurface, uint32_t _serial) {
GALE_ERROR("configure the surface ****************************************************");
xdg_surface_ack_configure(_xdgSurface, _serial);
}
void xdgToplevelHandleConfigure(struct xdg_toplevel* _xdgToplevel, ivec2 _size, struct wl_array* _states) {
GALE_ERROR("Top Level configure configure: " << _size);
if (m_eglWindow != null) {
wl_egl_window_resize(m_eglWindow, _size.x(), _size.y(), 0, 0);
}
m_size = _size;
OS_Resize(vec2(m_size.x(), m_size.y()));
}
void xdgToplevelHandleClose(struct xdg_toplevel* _xdgToplevel) {
GALE_ERROR("Top Level CLOSE ==> requested ...");
}
#endif
/****************************************************************************************/
void keyboardKeymap(struct wl_keyboard* _keyboard, enum wl_keyboard_keymap_format _format, int _fd, uint32_t _size) {
//GALE_INFO("KEY MAP : '" << _format << "'");
@ -942,7 +1046,7 @@ class WAYLANDInterface : public gale::Context {
find = true;
switch(sym) {
case XKB_KEY_dead_circumflex: m_lastKeyPressed = '^'; break;
case XKB_KEY_dead_diaeresis: m_lastKeyPressed = '"'; break;
case XKB_KEY_dead_diaeresis: m_lastKeyPressed = '"'; break; //"
//case XKB_KEY_ISO_Level3_Shif: m_lastKeyPressed = '~'; break;
//case XKB_KEY_: m_lastKeyPressed = ''; break;
default:
@ -1179,12 +1283,12 @@ class WAYLANDInterface : public gale::Context {
}
/****************************************************************************************/
virtual void stop() {
virtual void stop() override {
WAYLAND_INFO("WAYLAND-API: Stop");
m_run = false;
}
/****************************************************************************************/
virtual void setSize(const vec2& _size) {
virtual void setSize(const vec2& _size) override {
WAYLAND_INFO("WAYLAND-API: changeSize=" << _size);
/*
m_currentHeight = _size.y();
@ -1193,14 +1297,14 @@ class WAYLANDInterface : public gale::Context {
*/
}
/****************************************************************************************/
void setFullScreen(bool _status) {
void setFullScreen(bool _status) override {
WAYLAND_INFO("WAYLAND-API: changeFullscreen=" << _status);
m_fullscreen = _status;
toggleFullscreen();
// TODO : Grab all event from keyborad
}
/****************************************************************************************/
virtual void grabKeyboardEvents(bool _status) {
virtual void grabKeyboardEvents(bool _status) override {
GALE_WARNING("grabKeyboardEvents [START]");
/*
if (_status == true) {
@ -1218,7 +1322,7 @@ class WAYLANDInterface : public gale::Context {
GALE_WARNING("grabKeyboardEvents [STOP]");
}
/****************************************************************************************/
virtual void setWindowsDecoration(bool _status) {
virtual void setWindowsDecoration(bool _status) override {
WAYLAND_INFO("WAYLAND-API: setWindows Decoration :" << _status);
/*
// Remove/set decoration
@ -1237,7 +1341,7 @@ class WAYLANDInterface : public gale::Context {
*/
};
/****************************************************************************************/
virtual void setPos(const vec2& _pos) {
virtual void setPos(const vec2& _pos) override {
WAYLAND_INFO("WAYLAND-API: changePos=" << _pos);
/*
m_windowsPos = _pos;
@ -1257,7 +1361,7 @@ class WAYLANDInterface : public gale::Context {
}
*/
/****************************************************************************************/
virtual void setCursor(enum gale::context::cursor _newCursor) {
virtual void setCursor(enum gale::context::cursor _newCursor) override {
if (m_cursorCurrent == _newCursor) {
return;
}
@ -1326,7 +1430,7 @@ class WAYLANDInterface : public gale::Context {
}
}
/****************************************************************************************/
void grabPointerEvents(bool _status, const vec2& _forcedPosition) {
void grabPointerEvents(bool _status, const vec2& _forcedPosition) override {
/*
if (_status == true) {
WAYLAND_DEBUG("WAYLAND-API: Grab Events");
@ -1375,7 +1479,7 @@ class WAYLANDInterface : public gale::Context {
*/
}
/****************************************************************************************/
void setIcon(const etk::String& _inputFile) {
void setIcon(const etk::Uri& _inputFile) override {
/*
#if defined(GALE_BUILD_EGAMI) \
&& !defined(__TARGET_OS__Web)
@ -1523,17 +1627,25 @@ class WAYLANDInterface : public gale::Context {
*/
}
/****************************************************************************************/
void setTitle(const etk::String& _title) {
void setTitle(const etk::String& _title) override {
WAYLAND_INFO("WAYLAND: set Title (START)");
m_uniqueWindowsName = _title;
#if 0
if (m_shellSurface == null) {
GALE_ERROR("WAYLAND: set Title (END) ==> missing surface pointer");
return;
}
wl_shell_surface_set_title(m_shellSurface, m_uniqueWindowsName.c_str());
#else
if (m_xdgTopLevel == null) {
GALE_ERROR("WAYLAND: set Title (END) ==> missing top-level pointer");
return;
}
xdg_toplevel_set_title(m_xdgTopLevel, m_uniqueWindowsName.c_str());
#endif
WAYLAND_INFO("WAYLAND: set Title (END)");
}
void openURL(const etk::String& _url) {
void openURL(const etk::String& _url) override {
etk::String req = "xdg-open ";
req += _url;
system(req.c_str());
@ -1594,7 +1706,7 @@ class WAYLANDInterface : public gale::Context {
return false;
}
/****************************************************************************************/
void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) override {
switch (_clipboardID) {
case gale::context::clipBoard::clipboardSelection:
OS_ClipBoardArrive(_clipboardID);
@ -1613,7 +1725,7 @@ class WAYLANDInterface : public gale::Context {
}
}
/****************************************************************************************/
void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) override {
switch (_clipboardID) {
case gale::context::clipBoard::clipboardSelection:
// Use internal middle button ...
@ -1746,6 +1858,7 @@ static void configure_callback(void* _data, struct wl_callback* _callback, uint3
interface->configureCallback(_callback, _time);
}
#if 0
static void handle_ping(void* _data, struct wl_shell_surface* _shellSurface, uint32_t _serial) {
WAYLANDInterface* interface = (WAYLANDInterface*)_data;
if (interface == null) {
@ -1771,7 +1884,42 @@ static void handle_popup_done(void* _data, struct wl_shell_surface* _shellSurfac
}
interface->handlePopupDone(_shellSurface);
}
#else
static void handle_ping(void* _data, struct xdg_wm_base* _wdgWmBase, uint32_t _serial) {
WAYLANDInterface* interface = (WAYLANDInterface*)_data;
if (interface == null) {
GALE_ERROR(" ==> null");
return;
}
interface->handlePing(_wdgWmBase, _serial);
}
static void xdg_surface_handle_configure(void* _data, struct xdg_surface* _xdgSurface, uint32_t _serial) {
WAYLANDInterface* interface = (WAYLANDInterface*)_data;
if (interface == null) {
GALE_ERROR(" ==> null");
return;
}
interface->xdgSurfaceHandleConfigure(_xdgSurface, _serial);
}
static void xdg_toplevel_handle_configure(void* _data, struct xdg_toplevel* _xdgToplevel, int32_t _width, int32_t _height, struct wl_array* _states) {
WAYLANDInterface* interface = (WAYLANDInterface*)_data;
if (interface == null) {
GALE_ERROR(" ==> null");
return;
}
interface->xdgToplevelHandleConfigure(_xdgToplevel, ivec2(_width, _height), _states);
}
static void xdg_toplevel_handle_close(void* _data, struct xdg_toplevel* _xdgToplevel) {
WAYLANDInterface* interface = (WAYLANDInterface*)_data;
if (interface == null) {
GALE_ERROR(" ==> null");
return;
}
interface->xdgToplevelHandleClose(_xdgToplevel);
}
#endif
static void keyboard_handle_keymap(void* _data, struct wl_keyboard* _keyboard, uint32_t _format, int _fd, uint32_t _size) {
WAYLANDInterface* interface = (WAYLANDInterface*)_data;
if (interface == null) {

View File

@ -8,7 +8,7 @@
#include <gale/context/Context.hpp>
#include <gale/context/commandLine.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <gale/Dimension.hpp>
#ifndef GALE_VERSION

View File

@ -40,7 +40,7 @@ namespace gale {
void display();
/**
* @brief Reload all resources from files, and send there in openGL card if needed.
* @note If file is reference at THEME:XXX:filename if the Theme change the file will reload the newOne
* @note If file is reference at THEME_XXX:///filename if the Theme change the file will reload the newOne
*/
void reLoadResources();
/**

View File

@ -8,7 +8,7 @@
#include <gale/debug.hpp>
#include <gale/resource/Program.hpp>
#include <gale/resource/Manager.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <gale/gale.hpp>
#include <gale/renderer/openGL/openGL-include.hpp>
#include <etk/typeInfo.hpp>
@ -27,48 +27,49 @@ gale::resource::Program::Program() :
m_resourceLevel = 1;
}
void gale::resource::Program::init(const etk::String& _filename) {
gale::Resource::init(_filename);
void gale::resource::Program::init(const etk::Uri& _uri) {
gale::Resource::init(_uri.get());
ethread::RecursiveLock lock(m_mutex);
GALE_DEBUG("OGL : load PROGRAM '" << m_name << "'");
GALE_DEBUG("OGL : load PROGRAM '" << _uri << "'");
// load data from file "all the time ..."
etk::FSNode file(m_name);
if (file.exist() == false) {
GALE_DEBUG("File does not Exist : \"" << file << "\" == > automatic load of framment and shader with same names... ");
etk::String tmpFilename = m_name;
// remove extention ...
tmpFilename.erase(tmpFilename.size()-4, 4);
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpFilename+"vert");
if (etk::uri::exist(_uri) == false) {
GALE_DEBUG("File does not Exist : \"" << _uri << "\" == > automatic load of framment and shader with same names... ");
etk::Uri tmpUri = _uri;
tmpUri.setPath(_uri.getPath().getExtentionRemoved() + ".vert");
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpUri.get());
if (tmpShader == null) {
GALE_ERROR("Error while getting a specific shader filename : " << tmpFilename);
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
return;
} else {
GALE_DEBUG("Add shader on program : "<< tmpFilename << "vert");
GALE_DEBUG("Add shader on program : "<< tmpUri << "vert");
m_shaderList.pushBack(tmpShader);
}
tmpShader = gale::resource::Shader::create(tmpFilename+"frag");
tmpUri.setPath(_uri.getPath().getExtentionRemoved() + ".frag");
tmpShader = gale::resource::Shader::create(tmpUri.get());
if (tmpShader == null) {
GALE_ERROR("Error while getting a specific shader filename : " << tmpFilename);
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
return;
} else {
GALE_DEBUG("Add shader on program : "<< tmpFilename << "frag");
GALE_DEBUG("Add shader on program : "<< tmpUri << "frag");
m_shaderList.pushBack(tmpShader);
}
} else {
etk::String fileExtention = file.fileGetExtention();
if (fileExtention != "prog") {
GALE_ERROR("File does not have extention \".prog\" for program but : \"" << fileExtention << "\"");
if (_uri.getPath().getExtention() != "prog") {
GALE_ERROR("File does not have extention \".prog\" for program but : \"" << _uri.getPath() << "\"");
return;
}
if (file.fileOpenRead() == false) {
GALE_ERROR("Can not open the file : \"" << file << "\"");
auto fileIO = etk::uri::get(_uri);
if ( fileIO == null
|| fileIO->open(etk::io::OpenMode::Read) == false) {
GALE_ERROR("Can not open the file : \"" << _uri << "\"");
return;
}
#define MAX_LINE_SIZE (2048)
char tmpData[MAX_LINE_SIZE];
while (file.fileGets(tmpData, MAX_LINE_SIZE) != null) {
int32_t len = strlen(tmpData);
etk::String tmpData;
GALE_DEBUG("===========================================================");
while (fileIO->gets(tmpData) != false) {
GALE_DEBUG("data: " << tmpData);
int32_t len = tmpData.size();
if( tmpData[len-1] == '\n'
|| tmpData[len-1] == '\r') {
tmpData[len-1] = '\0';
@ -82,18 +83,24 @@ void gale::resource::Program::init(const etk::String& _filename) {
continue;
}
// get it with relative position:
etk::String tmpFilename = file.getRelativeFolder() + tmpData;
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpFilename);
etk::Uri tmpUri = _uri;
tmpUri.setPath(_uri.getPath().getParent() / tmpData);
GALE_VERBOSE("base path: " << _uri);
GALE_VERBOSE("base path: " << _uri.getPath());
GALE_VERBOSE("base path: " << _uri.getPath().getParent());
GALE_VERBOSE("new path: " << _uri.getPath().getParent() / tmpData);
GALE_VERBOSE("create shader: " << tmpUri);
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpUri.get());
if (tmpShader == null) {
GALE_ERROR("Error while getting a specific shader filename : " << tmpFilename);
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
} else {
GALE_DEBUG("Add shader on program : "<< tmpFilename);
GALE_DEBUG("Add shader on program : "<< tmpUri);
m_shaderList.pushBack(tmpShader);
}
}
GALE_DEBUG("===========================================================");
// close the file:
file.fileClose();
fileIO->close();
}
if (gale::openGL::hasContext() == true) {
updateContext();

View File

@ -12,6 +12,7 @@
#include <gale/resource/Shader.hpp>
#include <gale/resource/VirtualBufferObject.hpp>
#include <etk/Color.hpp>
#include <etk/uri/uri.hpp>
namespace gale {
namespace resource {
@ -57,12 +58,12 @@ namespace gale {
protected:
/**
* @brief Contructor of an opengl Program.
* @param[in] filename Standard file name format. see @ref etk::FSNode
* @param[in] _uri Uri of the file
*/
Program();
void init(const etk::String& _filename);
void init(const etk::Uri& _uri);
public:
DECLARE_RESOURCE_NAMED_FACTORY(Program);
DECLARE_RESOURCE_URI_FACTORY(Program);
/**
* @brief Destructor, remove the current Program.
*/

View File

@ -32,6 +32,11 @@ void gale::Resource::init(const etk::String& _name) {
m_name = _name;
}
void gale::Resource::init(const etk::Uri& _uri) {
m_resourceHasBeenInit=true;
m_name = _uri.get();
}
const char * const gale::Resource::getType() {
if (m_listType.size() == 0) {
return "gale::Resource";

View File

@ -9,6 +9,7 @@
#include <ethread/MutexRecursive.hpp>
#include <ememory/memory.hpp>
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <gale/debug.hpp>
#define MAX_RESOURCE_LEVEL (5)
@ -32,7 +33,7 @@
template<typename ... GALE_TYPE> static ememory::SharedPtr<className> create(const etk::String& _name, GALE_TYPE&& ... _all ) { \
ememory::SharedPtr<className> resource; \
ememory::SharedPtr<gale::Resource> resource2; \
if (_name != "" && _name != "---") { \
if (_name.isEmpty() == false && _name != "---") { \
resource2 = getManager().localKeep(_name); \
} \
if (resource2 != null) { \
@ -56,6 +57,35 @@
return resource; \
}
#define DECLARE_RESOURCE_URI_FACTORY(className) \
template<typename ... GALE_TYPE> static ememory::SharedPtr<className> create(const etk::Uri& _uri, GALE_TYPE&& ... _all ) { \
ememory::SharedPtr<className> resource; \
ememory::SharedPtr<gale::Resource> resource2; \
etk::String name = _uri.get(); \
if (name.isEmpty() == false && name != "---") { \
resource2 = getManager().localKeep(name); \
} \
if (resource2 != null) { \
resource = ememory::dynamicPointerCast<className>(resource2); \
if (resource == null) { \
GALE_CRITICAL("Request resource file : '" << name << "' With the wrong type (dynamic cast error)"); \
return null; \
} \
return resource; \
} \
resource = ememory::SharedPtr<className>(ETK_NEW(className)); \
if (resource == null) { \
GALE_ERROR("allocation error of a resource : " << name); \
return null; \
} \
resource->init(_uri, etk::forward<GALE_TYPE>(_all)... ); \
if (resource->resourceHasBeenCorectlyInit() == false) { \
GALE_CRITICAL("resource Is not correctly init : " << #className ); \
} \
getManager().localAdd(resource); \
return resource; \
}
#define DECLARE_RESOURCE_SINGLE_FACTORY(className,uniqueName) \
template<typename ... GALE_TYPE> static ememory::SharedPtr<className> create(GALE_TYPE&& ... _all ) { \
ememory::SharedPtr<className> resource; \
@ -107,10 +137,13 @@ namespace gale {
/**
* @brief Initialisation of the class and previous classes.
* @param[in] _name Name of the resource.
* @param[in] _uri Uri of the resource.
*/
void init();
//! @previous
void init(const etk::String& _name);
//! @previous
void init(const etk::Uri& _uri);
public:
//! geenric destructor
virtual ~Resource() {

View File

@ -5,7 +5,7 @@
*/
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <gale/debug.hpp>
#include <gale/resource/Shader.hpp>
#include <gale/resource/Manager.hpp>
@ -25,18 +25,18 @@ gale::resource::Shader::Shader() :
m_resourceLevel = 0;
}
void gale::resource::Shader::init(const etk::String& _filename) {
void gale::resource::Shader::init(const etk::Uri& _uri) {
ethread::RecursiveLock lock(m_mutex);
gale::Resource::init(_filename);
GALE_DEBUG("OGL : load SHADER '" << _filename << "'");
gale::Resource::init(_uri.get());
GALE_DEBUG("OGL : load SHADER '" << _uri << "'");
// load data from file "all the time ..."
if (etk::end_with(m_name, ".frag") == true) {
if (_uri.getPath().getExtention() == "frag") {
m_type = gale::openGL::shader::type::fragment;
} else if (etk::end_with(m_name, ".vert") == true) {
} else if (_uri.getPath().getExtention() == "vert") {
m_type = gale::openGL::shader::type::vertex;
} else {
GALE_ERROR("File does not have extention \".vert\" for Vertex Shader or \".frag\" for Fragment Shader. but : \"" << m_name << "\"");
GALE_ERROR("File does not have extention \".vert\" for Vertex Shader or \".frag\" for Fragment Shader. but : \"" << _uri << "\"");
return;
}
reload();
@ -101,27 +101,14 @@ void gale::resource::Shader::removeContextToLate() {
void gale::resource::Shader::reload() {
ethread::RecursiveLock lock(m_mutex);
etk::FSNode file(m_name);
if (false == file.exist()) {
GALE_CRITICAL("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'");
etk::Uri uri = m_name;
if (etk::uri::exist(uri) == false) {
GALE_CRITICAL("File does not Exist : '" << uri << "' : path='" << uri.getPath() << "'");
return;
}
int64_t fileSize = file.fileSize();
if (0 == fileSize) {
GALE_CRITICAL("This file is empty : " << file);
return;
}
if (false == file.fileOpenRead()) {
GALE_CRITICAL("Can not open the file : " << file);
return;
}
m_fileData = file.fileReadAllString();
// close the file:
file.fileClose();
etk::uri::readAll(uri, m_fileData);
GALE_VERBOSE("load shader:\n-----------------------------------------------------------------\n" << m_fileData << "\n-----------------------------------------------------------------");
// now change the OGL context ...
if (gale::openGL::hasContext() == true) {
GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> call update context (direct)");
removeContext();

View File

@ -9,6 +9,7 @@
#include <gale/debug.hpp>
#include <gale/renderer/openGL/openGL.hpp>
#include <gale/resource/Resource.hpp>
#include <etk/uri/uri.hpp>
namespace gale {
namespace resource {
@ -28,8 +29,8 @@ namespace gale {
*/
Shader();
public:
void init(const etk::String& _filename);
DECLARE_RESOURCE_NAMED_FACTORY(Shader);
void init(const etk::Uri& _uri);
DECLARE_RESOURCE_URI_FACTORY(Shader);
/**
* @brief Destructor, remove the current Shader
*/

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.debug as debug
import realog.debug as debug
import lutin.image as image
import os
import lutin.multiprocess as lutinMultiprocess
@ -186,6 +186,7 @@ def configure(target, my_module):
'gles2',
'xkbcommon'
])
my_module.add_action(tool_generate_wayland_protocol, data={})
elif "Android" in target.get_type():
my_module.add_depend(["SDK", "jvm-basics"])
# add tre creator of the basic java class ...
@ -212,6 +213,54 @@ def configure(target, my_module):
##################################################################
##
## Wayland specific section
##
##################################################################
def tool_generate_wayland_protocol(target, module, package_name):
file_list = []
debug.warning("------------------------------------------------------------------------")
debug.warning("Generate wayland back elements... '" + str(module) + "'" )
debug.warning("------------------------------------------------------------------------")
cmd = ["pkg-config", "wayland-protocols", "--variable=pkgdatadir"]
ret = lutinMultiprocess.run_command_direct(tools.list_to_str(cmd))
if ret == False:
debug.error("Can not execute protocol extraction...")
WAYLAND_PROTOCOLS_DIR = ret
debug.warning("WAYLAND_PROTOCOLS_DIR = " + str(WAYLAND_PROTOCOLS_DIR))
cmd = ["pkg-config", "--variable=wayland_scanner", "wayland-scanner"]
ret = lutinMultiprocess.run_command_direct(tools.list_to_str(cmd))
if ret == False:
debug.error("Can not execute protocol extraction...")
WAYLAND_SCANNER = ret
debug.warning("WAYLAND_SCANNER = " + str(WAYLAND_SCANNER))
XDG_SHELL_PROTOCOL = os.path.join(WAYLAND_PROTOCOLS_DIR, "stable", "xdg-shell", "xdg-shell.xml")
debug.warning("XDG_SHELL_PROTOCOL = " + str(XDG_SHELL_PROTOCOL))
client_protocol_header = "xdg-shell-client-protocol.h"
client_protocol = "xdg-shell-protocol.c"
# create files
debug.warning("Generate file = " + client_protocol_header)
tmp_file = "/tmp/gale_wayland.tmp"
cmd = [WAYLAND_SCANNER, "client-header", XDG_SHELL_PROTOCOL, tmp_file]
ret = lutinMultiprocess.run_command_direct(tools.list_to_str(cmd))
if ret == False:
debug.error("error in generate wayland header code")
tmp_file_data = tools.file_read_data(tmp_file)
module.add_generated_header_file(tmp_file_data, client_protocol_header)
debug.warning("Generate file = " + client_protocol)
cmd = [WAYLAND_SCANNER, "private-code", XDG_SHELL_PROTOCOL, tmp_file]
ret = lutinMultiprocess.run_command_direct(tools.list_to_str(cmd))
if ret == False:
debug.error("Error in wayland generation code of private header protocole")
tmp_file_data = tools.file_read_data(tmp_file)
module.add_generated_src_file(tmp_file_data, client_protocol)
##################################################################
##
## Android specific section

View File

@ -31,7 +31,7 @@ namespace appl {
void onCreate(gale::Context& _context) override {
setSize(vec2(800, 600));
m_angle = 0.0f;
m_GLprogram = gale::resource::Program::create("DATA:basic.prog");
m_GLprogram = gale::resource::Program::create("DATA:///basic.prog");
if (m_GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");