From 15c71ebe1a7fdb23723c10f75c26085e7595ca70 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 21 Nov 2012 21:56:37 +0100 Subject: [PATCH] [DEV] Rework compleately EWOL to simplify and set it more user-frendly NO-MORE-COMPILE --- external/etk | 2 +- .../Cursor.cpp => commandLine.cpp} | 0 sources/ewol/commandLine.h | 37 + sources/ewol/compositing/Cursor.h | 24 - sources/ewol/config.cpp | 52 + sources/ewol/config.h | 52 + sources/ewol/ewol.cpp | 16 + sources/ewol/ewol.h | 150 ++- sources/ewol/font/DistantFieldFont.cpp | 464 --------- sources/ewol/font/DistantFieldFont.h | 58 -- sources/ewol/font/FontManager.cpp | 53 - sources/ewol/font/FontManager.h | 29 - sources/ewol/game/GameElementLua.cpp | 929 ------------------ sources/ewol/game/GameElementLua.h | 42 - sources/ewol/key.cpp | 184 ++++ sources/ewol/key.h | 93 ++ sources/ewol/oObject/2DColored.cpp | 601 ----------- sources/ewol/oObject/2DColored.h | 53 - sources/ewol/oObject/2DTextColored.cpp | 201 ---- sources/ewol/oObject/2DTextColored.h | 57 -- sources/ewol/oObject/2DTextShader.cpp | 224 ----- sources/ewol/oObject/2DTextShader.h | 61 -- sources/ewol/oObject/2DTextured.cpp | 170 ---- sources/ewol/oObject/2DTextured.h | 58 -- sources/ewol/oObject/3DTextured.cpp | 145 --- sources/ewol/oObject/3DTextured.h | 42 - sources/ewol/oObject/OObject.cpp | 35 - sources/ewol/oObject/OObject.h | 60 -- sources/ewol/oObject/Sprite.cpp | 109 -- sources/ewol/oObject/Sprite.h | 32 - .../ewol/{ => renderer}/ResourceManager.cpp | 0 sources/ewol/{ => renderer}/ResourceManager.h | 0 sources/ewol/{ => renderer}/audio/audio.cpp | 0 sources/ewol/{ => renderer}/audio/audio.h | 0 sources/ewol/{ => renderer}/audio/decWav.cpp | 0 sources/ewol/{ => renderer}/audio/decWav.h | 0 .../audio/interfacePortAudio.cpp | 0 .../{ => renderer}/audio/interfacePortAudio.h | 0 sources/ewol/{ => renderer}/openGL/openGL.cpp | 0 sources/ewol/{ => renderer}/openGL/openGL.h | 0 sources/ewol/{ => renderer}/os/Fps.h | 0 sources/ewol/{ => renderer}/os/eSystem.cpp | 0 sources/ewol/{ => renderer}/os/eSystem.h | 0 .../ewol/{ => renderer}/os/eSystemInput.cpp | 0 sources/ewol/{ => renderer}/os/eSystemInput.h | 0 .../{ => renderer}/os/gui.Android.base.cpp | 0 .../ewol/{ => renderer}/os/gui.Android.cpp | 0 .../ewol/{ => renderer}/os/gui.Example.cpp | 0 sources/ewol/{ => renderer}/os/gui.IOs.cpp | 0 sources/ewol/{ => renderer}/os/gui.MacOs.cpp | 0 .../ewol/{ => renderer}/os/gui.Windows.cpp | 0 sources/ewol/{ => renderer}/os/gui.X11.cpp | 23 + sources/ewol/{ => renderer}/os/gui.h | 0 .../resources/Config.cpp} | 0 .../resources/Config.h} | 0 .../resources/Font.cpp} | 0 .../resources/Font.h} | 0 .../resources}/FontFreeType.cpp | 0 .../resources}/FontFreeType.h | 0 .../resources/Image.cpp} | 0 .../resources/Image.h} | 0 .../{Mesh => renderer/resources}/Mesh.cpp | 4 +- .../ewol/{Mesh => renderer/resources}/Mesh.h | 0 .../{Mesh => renderer/resources}/MeshObj.cpp | 7 +- .../{Mesh => renderer/resources}/MeshObj.h | 0 .../resources}/Program.cpp | 132 --- .../{openGL => renderer/resources}/Program.h | 60 -- .../ewol/{ => renderer/resources}/Resource.h | 0 .../{openGL => renderer/resources}/Shader.cpp | 0 .../{openGL => renderer/resources}/Shader.h | 0 .../resources}/Texture.cpp | 0 .../{texture => renderer/resources}/Texture.h | 0 .../resources}/VirtualBufferObject.cpp | 0 .../resources}/VirtualBufferObject.h | 0 .../ewol/{ => renderer/resources}/font/Font.h | 0 .../resources}/font/GlyphProperty.h | 0 .../{ => renderer/resources}/font/Kerning.h | 0 .../resources/image/ImageBMP.cpp} | 0 .../resources/image/ImageBMP.h} | 0 .../resources/image/ImagePNG.cpp} | 9 +- .../resources/image/ImagePNG.h} | 0 .../resources/image/ImageSVG.cpp} | 0 .../resources/image/ImageSVG.h} | 0 sources/ewol/widget/Widget.cpp | 44 - sources/ewol/widget/Widget.h | 65 -- 85 files changed, 537 insertions(+), 3840 deletions(-) rename sources/ewol/{compositing/Cursor.cpp => commandLine.cpp} (100%) create mode 100644 sources/ewol/commandLine.h delete mode 100644 sources/ewol/compositing/Cursor.h create mode 100644 sources/ewol/config.cpp create mode 100644 sources/ewol/config.h delete mode 100644 sources/ewol/font/DistantFieldFont.cpp delete mode 100644 sources/ewol/font/DistantFieldFont.h delete mode 100644 sources/ewol/font/FontManager.cpp delete mode 100644 sources/ewol/font/FontManager.h delete mode 100644 sources/ewol/game/GameElementLua.cpp delete mode 100644 sources/ewol/game/GameElementLua.h create mode 100644 sources/ewol/key.cpp create mode 100644 sources/ewol/key.h delete mode 100644 sources/ewol/oObject/2DColored.cpp delete mode 100644 sources/ewol/oObject/2DColored.h delete mode 100644 sources/ewol/oObject/2DTextColored.cpp delete mode 100644 sources/ewol/oObject/2DTextColored.h delete mode 100644 sources/ewol/oObject/2DTextShader.cpp delete mode 100644 sources/ewol/oObject/2DTextShader.h delete mode 100644 sources/ewol/oObject/2DTextured.cpp delete mode 100644 sources/ewol/oObject/2DTextured.h delete mode 100644 sources/ewol/oObject/3DTextured.cpp delete mode 100644 sources/ewol/oObject/3DTextured.h delete mode 100644 sources/ewol/oObject/OObject.cpp delete mode 100644 sources/ewol/oObject/OObject.h delete mode 100644 sources/ewol/oObject/Sprite.cpp delete mode 100644 sources/ewol/oObject/Sprite.h rename sources/ewol/{ => renderer}/ResourceManager.cpp (100%) rename sources/ewol/{ => renderer}/ResourceManager.h (100%) rename sources/ewol/{ => renderer}/audio/audio.cpp (100%) rename sources/ewol/{ => renderer}/audio/audio.h (100%) rename sources/ewol/{ => renderer}/audio/decWav.cpp (100%) rename sources/ewol/{ => renderer}/audio/decWav.h (100%) rename sources/ewol/{ => renderer}/audio/interfacePortAudio.cpp (100%) rename sources/ewol/{ => renderer}/audio/interfacePortAudio.h (100%) rename sources/ewol/{ => renderer}/openGL/openGL.cpp (100%) rename sources/ewol/{ => renderer}/openGL/openGL.h (100%) rename sources/ewol/{ => renderer}/os/Fps.h (100%) rename sources/ewol/{ => renderer}/os/eSystem.cpp (100%) rename sources/ewol/{ => renderer}/os/eSystem.h (100%) rename sources/ewol/{ => renderer}/os/eSystemInput.cpp (100%) rename sources/ewol/{ => renderer}/os/eSystemInput.h (100%) rename sources/ewol/{ => renderer}/os/gui.Android.base.cpp (100%) rename sources/ewol/{ => renderer}/os/gui.Android.cpp (100%) rename sources/ewol/{ => renderer}/os/gui.Example.cpp (100%) rename sources/ewol/{ => renderer}/os/gui.IOs.cpp (100%) rename sources/ewol/{ => renderer}/os/gui.MacOs.cpp (100%) rename sources/ewol/{ => renderer}/os/gui.Windows.cpp (100%) rename sources/ewol/{ => renderer}/os/gui.X11.cpp (97%) rename sources/ewol/{ => renderer}/os/gui.h (100%) rename sources/ewol/{SimpleConfigFile.cpp => renderer/resources/Config.cpp} (100%) rename sources/ewol/{SimpleConfigFile.h => renderer/resources/Config.h} (100%) rename sources/ewol/{font/TexturedFont.cpp => renderer/resources/Font.cpp} (100%) rename sources/ewol/{font/TexturedFont.h => renderer/resources/Font.h} (100%) rename sources/ewol/{font => renderer/resources}/FontFreeType.cpp (100%) rename sources/ewol/{font => renderer/resources}/FontFreeType.h (100%) rename sources/ewol/{texture/TextureFile.cpp => renderer/resources/Image.cpp} (100%) rename sources/ewol/{texture/TextureFile.h => renderer/resources/Image.h} (100%) rename sources/ewol/{Mesh => renderer/resources}/Mesh.cpp (95%) rename sources/ewol/{Mesh => renderer/resources}/Mesh.h (100%) rename sources/ewol/{Mesh => renderer/resources}/MeshObj.cpp (95%) rename sources/ewol/{Mesh => renderer/resources}/MeshObj.h (100%) rename sources/ewol/{openGL => renderer/resources}/Program.cpp (81%) rename sources/ewol/{openGL => renderer/resources}/Program.h (79%) rename sources/ewol/{ => renderer/resources}/Resource.h (100%) rename sources/ewol/{openGL => renderer/resources}/Shader.cpp (100%) rename sources/ewol/{openGL => renderer/resources}/Shader.h (100%) rename sources/ewol/{texture => renderer/resources}/Texture.cpp (100%) rename sources/ewol/{texture => renderer/resources}/Texture.h (100%) rename sources/ewol/{openGL => renderer/resources}/VirtualBufferObject.cpp (100%) rename sources/ewol/{openGL => renderer/resources}/VirtualBufferObject.h (100%) rename sources/ewol/{ => renderer/resources}/font/Font.h (100%) rename sources/ewol/{ => renderer/resources}/font/GlyphProperty.h (100%) rename sources/ewol/{ => renderer/resources}/font/Kerning.h (100%) rename sources/ewol/{texture/TextureBMP.cpp => renderer/resources/image/ImageBMP.cpp} (100%) rename sources/ewol/{texture/TextureBMP.h => renderer/resources/image/ImageBMP.h} (100%) rename sources/ewol/{texture/TexturePNG.cpp => renderer/resources/image/ImagePNG.cpp} (97%) rename sources/ewol/{texture/TexturePNG.h => renderer/resources/image/ImagePNG.h} (100%) rename sources/ewol/{texture/TextureSVG.cpp => renderer/resources/image/ImageSVG.cpp} (100%) rename sources/ewol/{texture/TextureSVG.h => renderer/resources/image/ImageSVG.h} (100%) diff --git a/external/etk b/external/etk index 5145f629..a8cafb59 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit 5145f629a8758ddd5025857e6333a5a0e21d68cc +Subproject commit a8cafb5969640bd14ed9ba0dd3dfa718124e2101 diff --git a/sources/ewol/compositing/Cursor.cpp b/sources/ewol/commandLine.cpp similarity index 100% rename from sources/ewol/compositing/Cursor.cpp rename to sources/ewol/commandLine.cpp diff --git a/sources/ewol/commandLine.h b/sources/ewol/commandLine.h new file mode 100644 index 00000000..20f7b161 --- /dev/null +++ b/sources/ewol/commandLine.h @@ -0,0 +1,37 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __EWOL_COMMAND_LINE_H__ +#define __EWOL_COMMAND_LINE_H__ + +namespace ewol +{ + namespace commandLine { + /** + * @brief Remove all the element bufferised in the commandLine system + */ + void Clean(void); + /** + * @brief Get the number of element in the Command Line + * @return the number of element + */ + int32_t Size(void); + /** + * @brief Get an element with a specific ID + * @return The cmdLine Id element + */ + etk::UString Get(int32_t id); + /** + * @brief Add one element at the Command Line + * @param[in] newElement String in the input that might be added. + */ + void Add(etk::UString& newElement); + }; +}; + +#endif diff --git a/sources/ewol/compositing/Cursor.h b/sources/ewol/compositing/Cursor.h deleted file mode 100644 index e114ede3..00000000 --- a/sources/ewol/compositing/Cursor.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_CURSOR_H__ -#define __EWOL_CURSOR_H__ - -namespace ewol -{ - class Cursor : public ewol::Compositing - { - protected: - - public: - - }; -}; - -#endif - diff --git a/sources/ewol/config.cpp b/sources/ewol/config.cpp new file mode 100644 index 00000000..c2068d25 --- /dev/null +++ b/sources/ewol/config.cpp @@ -0,0 +1,52 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include + +#undef __class__ +#define __class__ "ewol::config" + +static etk::UString l_fontConfigFolder = "DATA::fonts"; +static etk::UString l_fontConfigName = "Arial"; +static int32_t l_fontConfigSize = 10; + +void ewol::config_PRIVATE::Init(void) +{ + // reset font properties + l_fontConfigFolder = "DATA::fonts"; + l_fontConfigName = "Arial"; + l_fontConfigSize = 10; + ewol::FreeTypeInit(); +} + +void ewol::config_PRIVATE::UnInit(void) +{ + // UnInit FreeTypes + ewol::FreeTypeUnInit(); +} + +void ewol::config::FontFolder(etk::UString folder) +{ + l_fontConfigFolder = folder; +} + +void ewol::config::FontSetDefault(etk::UString fontName, int32_t size) +{ + l_fontConfigName = fontName; + l_fontConfigSize = size; +} + +etk::UString& ewol::config::FontGetDefaultName(void) +{ + return l_fontConfigName; +} + +int32_t ewol::config::FontGetDefaultSize(void) +{ + return l_fontConfigSize; +} \ No newline at end of file diff --git a/sources/ewol/config.h b/sources/ewol/config.h new file mode 100644 index 00000000..b2bedfc1 --- /dev/null +++ b/sources/ewol/config.h @@ -0,0 +1,52 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __EWOL_CONFIG_H__ +#define __EWOL_CONFIG_H__ + +namespace ewol +{ + namespace config + { + /** + * @brief Specify the default font folder for the Ewol search system (only needed when embended font) + * @param[in] folder basic folder of the font (ex: DATA:fonts) + */ + void FontFolder(etk::UString folder); + /** + * @brief Set the defaut font for all the widgets and basics display. + * @param[in] fontName The font name requested (not case sensitive) ex "Arial". + * @param[in] size The default size of the font default=10. + */ + void FontSetDefault(etk::UString fontName, int32_t size); + /** + * @brief Get the current default font name + * @raturn a reference on the font name string + */ + etk::UString& FontGetDefaultName(void); + /** + * @brief Get the default font size. + * @return the font size. + */ + int32_t FontGetDefaultSize(void); + }; + namespace config_PRIVATE + { + /** + * Init the configuration + */ + void Init(void); + /** + * UnInit the configuration + */ + void UnInit(void); + }; +}; + +#endif + diff --git a/sources/ewol/ewol.cpp b/sources/ewol/ewol.cpp index a081d431..65a57ba5 100644 --- a/sources/ewol/ewol.cpp +++ b/sources/ewol/ewol.cpp @@ -15,6 +15,16 @@ #undef __class__ #define __class__ "ewol" + +int32_t ewol::Run(int32_t argc, const char* argv[]); +{ + + // call standard RUN ... + +} + + + void ewol::DisplayWindows(ewol::Windows * windows) { // Remove current Focus : @@ -197,3 +207,9 @@ int64_t ewol::GetTime(void) { return guiInterface::GetTime(); } + + + + + + diff --git a/sources/ewol/ewol.h b/sources/ewol/ewol.h index 6d7786e4..0219b03b 100644 --- a/sources/ewol/ewol.h +++ b/sources/ewol/ewol.h @@ -14,49 +14,74 @@ #include #include -#if 1 - -namespace ewol { +namespace ewol +{ + /** + * @brief This is the only one things the User might done in his main(); + * @note To answare you before you ask the question, this is really simple: + * Due to the fect that the current system is multiple-platform, you "main" + * Does not exist in the android platform, then ewol call other start + * and stop function, to permit to have only one code + * @note The main can not be in the ewol, due to the fact thet is an librairy + * @param[in] argc Standard argc + * @param[in] argv Standard argv + * @return normal error int for the application error management + */ + int32_t Run(int32_t argc, const char* argv[]); + /** + * @brief Request the stop of the program (teminate all the process) no more call at hte application without APP_UnInit(); + */ void Stop(void); - void DisplayWindows(ewol::Windows * windows); - // only on computer - void ChangeSize(etk::Vector2D size); - void ChangePos(etk::Vector2D pos); - void GetAbsPos(etk::Vector2D& pos); - void KeyboardShow(void); - void KeyboardHide(void); + /** + * @brief Set a windows to diaplay + * @param[in] windows The requested windows that migt be use for the display + */ + void WindowsSet(ewol::Windows * windows); + /** + * @brief Add a PopUp at the current windows ==> this widget is display over the current element + * @param[in] tmpWidget A pointer on the pop-up widget that might be displayed + */ + void WindowsPopUpAdd(ewol::Widget * tmpWidget); + /** + * @brief Change the windows size + * @note work only on computer + * @param[in] size The new windows size + */ + void ChangeSize(etkVector2D size); + /** + * @brief Change the windows curent position + * @note work only on computer + * @param[in] pos The new windows position + */ + void ChangePos(etkVector2D pos); + /** + * @brief Generate the action of redrawing all the display. + */ void ForceRedrawAll(void); - void PopUpWidgetPush(ewol::Widget * tmpWidget); - namespace CmdLine { - void Clean(void); - int32_t Nb(void); - etk::UString Get(int32_t id); - void Add(etk::UString& newElement); - }; - // TODO : This might be deprecated ... - bool IsSetCapsLock(void); - bool IsSetShift(void); - bool IsSetCtrl(void); - bool IsSetMeta(void); - bool IsSetAlt(void); - bool IsSetAltGr(void); - bool IsSetVerNum(void); - bool IsSetInsert(void); - // basic shortcut setting (set default value, the configutration file will overloaded it automaticly - namespace shortCut { - void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString data); - void Add(const char * descriptiveString, const char * generateEventId, etk::UString data); - }; - // TODO : This is dangerous and might be deprecated ... Soon - int32_t GetCurrentWidth(void); - int32_t GetCurrentHeight(void); - - void SetTitle(etk::UString title); + /** + * @brief Force the calculation of all the size of the widgets + */ void RequestUpdateSize(void); - + /** + * @brief Change the status of the Keyboard displat + * @note Specific for mobile platform + * @param[in] hide Status of the visibility of the keyboard + */ + void Keyboard(bool hide); + /** + * @brief Change the title display. + * @param[in] title the new title that might be displayed + */ + void SetTitle(etk::UString title); + /** + * @brief Get EWOL version + * @return The string that describe ewol version + */ etk::UString GetVersion(void); - - // get current time in ms... + /** + * @brief Get current time in us... + * @return The current time + */ int64_t GetTime(void); /** * @brief This is to transfert the event from one widget to another one @@ -70,49 +95,12 @@ namespace ewol { SCREEN_ORIENTATION_LANDSCAPE, SCREEN_ORIENTATION_PORTRAIT, } orientation_te; + /** + * @brief + * @param[in] + */ void ForceOrientation(ewol::orientation_te orientation); + }; -#else - -namespace ewol { - // stop the program : - void Stop(void); - // display a specific windows - void WindowsSet(ewol::Windows * windows); - void WindowsPopUpAdd(ewol::Widget * tmpWidget); - // only on computer - // change the windows size - void ChangeSize(int32_t w, int32_t h); - // change the windows curent position - void ChangePos(int32_t x, int32_t y); - // force the redraw of all the widget (this was a bad case ... - void ForceRedrawAll(void); - // force the calculation of all the sizes - void RequestUpdateSize(void); - // get the cmd line for computer call - etk::Vector CmdLineGet(void); - // get the special key properties - enum { - EWOL_KEY_LEFT = 1 << 0, - EWOL_KEY_RIGHT = 1 << 1, - EWOL_KEY_CAP_LOCK = 1 << 2, - EWOL_KEY_SHIFT = 1 << 3, - EWOL_KEY_CTRL = 1 << 4, - EWOL_KEY_META = 1 << 5, - EWOL_KEY_ALT = 1 << 6, - EWOL_KEY_ALT_GR = 1 << 7, - EWOL_KEY_VER_NUM = 1 << 8, - EWOL_KEY_INSERT = 1 << 9, - }; - int32_t KeyboardGetStatus(void); - // set the vew title - void SetTitle(etk::UString title); - // get EWOL version - etk::UString GetVersion(void); - // get current time in ms... - int64_t GetTime(void); -}; -#endif - #endif diff --git a/sources/ewol/font/DistantFieldFont.cpp b/sources/ewol/font/DistantFieldFont.cpp deleted file mode 100644 index 63088e45..00000000 --- a/sources/ewol/font/DistantFieldFont.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include -#include -#include - - -static int32_t nextP2(int32_t value) -{ - int32_t val=1; - for (int32_t iii=1; iii<31; iii++) { - if (value <= val) { - return val; - } - val *=2; - } - EWOL_CRITICAL("impossible CASE...."); - return val; -} - -static int32_t simpleSQRT(int32_t value) -{ - int32_t val=1; - for (int32_t iii=1; iii<1000; iii++) { - val =iii*iii; - if (value <= val) { - return iii; - } - } - EWOL_CRITICAL("impossible CASE...."); - return val; -} - -#define SPECIAL_BORDER (5) -#define SPECIAL_UPSCALER (8) - -ewol::DistantFieldFont::DistantFieldFont(etk::UString fontName) : - ewol::Texture(fontName), - m_font(NULL), - m_lastGlyphPos(0,0), - m_lastRawHeigh(0) -{ - int32_t tmpSize = 0; - // extarct name and size : - char * tmpData = fontName.c_str(); - char * tmpPos = strchr(tmpData, ':'); - - if (tmpPos==NULL) { - m_size = 1; - EWOL_CRITICAL("Can not parse the font name : \"" << fontName << "\" ??? ':' " ); - return; - } else { - if (sscanf(tmpPos+1, "%d", &tmpSize)!=1) { - m_size = 1; - EWOL_CRITICAL("Can not parse the font name : \"" << fontName << "\" ==> size ???"); - return; - } - } - m_name = fontName.Extract(0, (tmpPos - tmpData)); - m_size = tmpSize; - - //EWOL_CRITICAL("Load FONT name : \"" << m_name << "\" ==> size=" << m_size); - ewol::resource::Keep(m_name, m_font); - if (NULL == m_font) { - return; - } - - // set the bassic charset: - m_listElement.Clear(); - freeTypeFontElement_ts tmpchar1; - tmpchar1.property.m_UVal = 0; - m_listElement.PushBack(tmpchar1); - for (int32_t iii=0x20/*'A'*/; iii determine the texture Size - GlyphProperty tmpproperty; - tmpproperty.m_UVal = 'A'; - m_font->GetGlyphProperty(m_size, tmpproperty); - - int32_t nbElement = 0xFF - 0x20 + 1; - int32_t coter = simpleSQRT(nbElement); - // note : +1 is for the overlapping of the glyph (Part 1) - int32_t glyphMaxWidth = tmpproperty.m_advance.x +1 + SPECIAL_BORDER*2; - int32_t glyphMaxHeight = tmpproperty.m_advance.y +1 + SPECIAL_BORDER*2; - int32_t textureWidth = nextP2(coter*glyphMaxWidth); - int32_t nbRaws = textureWidth / glyphMaxWidth; - if (nbRaws <= 0) { - EWOL_ERROR("devide by 0"); - nbRaws = 1; - } - int32_t nbLine = (nbElement / nbRaws) + 1; - int32_t textureHeight = nextP2(nbLine*glyphMaxHeight); - // for android : - textureHeight = etk_max(textureHeight, textureWidth); - textureWidth = textureHeight; - - - EWOL_DEBUG("Generate a text texture for char(" << nbRaws << "," << nbLine << ") with size=(" << textureWidth << "," << textureHeight << ")"); - // resize must be done on the texture ... - SetImageSize(etk::Vector2D(textureWidth,textureHeight)); - // now we can acces directly on the image - m_data.SetFillColor(draw::Color(0xFFFFFF00)); - m_data.Clear(); - - m_height = m_font->GetHeight(m_size); - - draw::Image tmpUpScaledImage(etk::Vector2D(1024,1024)); - - int32_t CurrentLineHigh = 0; - etk::Vector2D glyphPosition(1,1); - for (int32_t iii=0; iiiGetGlyphProperty(m_size, m_listElement[iii].property)) { - EWOL_DEBUG("Generate Font Element : '" << m_listElement[iii].property.m_UVal << "'= '" << (char)m_listElement[iii].property.m_UVal << "'"); - // clean the temporary image : - tmpUpScaledImage.SetFillColor(draw::Color(0xFFFFFF00)); - tmpUpScaledImage.Clear(); - /* - // check internal property: - // enought in the texture : - //if (m_data.GetWidth() < m_lastGlyphPos.x + m_listElement[iii].property.m_sizeTexture.x - // resize if needed ... - - // line size : - - // draw - - // move the curent pointer of drawing: - */ - // change line if needed ... - if (glyphPosition.x+m_listElement[iii].property.m_sizeTexture.x > textureWidth) { - glyphPosition.x = 0; - glyphPosition.y += CurrentLineHigh; - CurrentLineHigh = 0; - } - // draw the glyph - m_font->DrawGlyph(tmpUpScaledImage, m_size*SPECIAL_UPSCALER, etk::Vector2D(SPECIAL_BORDER*SPECIAL_UPSCALER,SPECIAL_BORDER*SPECIAL_UPSCALER), m_listElement[iii].property, 0); - // set video position - m_listElement[iii].posStart.u = (float)(glyphPosition.x) / (float)textureWidth; - m_listElement[iii].posStart.v = (float)(glyphPosition.y) / (float)textureHeight; - m_listElement[iii].posStop.u = (float)(glyphPosition.x + m_listElement[iii].property.m_sizeTexture.x+2*SPECIAL_BORDER) / (float)textureWidth; - m_listElement[iii].posStop.v = (float)(glyphPosition.y + m_listElement[iii].property.m_sizeTexture.y+2*SPECIAL_BORDER) / (float)textureHeight; - /* - EWOL_DEBUG("generate '" << (char)m_listElement[iii].property.m_UVal << "'"); - EWOL_DEBUG(" in tex : " << glyphPosition << " ==> " << m_listElement[iii].posStart.u<< "," << m_listElement[iii].posStart.v ); - EWOL_DEBUG(" m_sizeTexture =" << m_listElement[iii].property.m_sizeTexture ); - EWOL_DEBUG(" m_bearing =" << m_listElement[iii].property.m_bearing ); - EWOL_DEBUG(" m_advance =" << m_listElement[iii].property.m_advance ); - */ - // generate the distance field from this element ... - tmpUpScaledImage.DistanceField(etk::Vector2D(0,0), m_listElement[iii].property.m_sizeTexture*etk::Vector2D(SPECIAL_UPSCALER,SPECIAL_UPSCALER)+etk::Vector2D(2*SPECIAL_BORDER*SPECIAL_UPSCALER,2*SPECIAL_BORDER*SPECIAL_UPSCALER), SPECIAL_UPSCALER, SPECIAL_UPSCALER/2); - // copy data with downscaling : (subSampling) - etk::Vector2D tmpPos(0,0); - for (tmpPos.y = 0; tmpPos.y(SPECIAL_UPSCALER,SPECIAL_UPSCALER) + etk::Vector2D(SPECIAL_UPSCALER/2,SPECIAL_UPSCALER/2)) ); - } - } - - // update the maximum of the line hight : - if (CurrentLineHigh(iii, jjj) ); - // set only alpha : - tlpppp.a = etk_min( tlpppp.a+0x60, 0xFF); - // real set of color - m_data.Set(etk::Vector2D(iii, jjj), tlpppp ); - } - } - #endif - EWOL_DEBUG("End generation of the Fond bitmap, start adding texture"); - Flush(); - -} - -ewol::DistantFieldFont::~DistantFieldFont(void) -{ - if (NULL!= m_font) { - ewol::resource::Release(m_font); - } -} - - -bool ewol::DistantFieldFont::HasName(etk::UString& fileName) -{ - etk::UString tmpName = m_name; - tmpName += ":"; - tmpName += m_size; - EWOL_VERBOSE("S : check : " << fileName << " ?= " << tmpName << " = " << (fileName==tmpName) ); - return (fileName==tmpName); -} - - - -int32_t ewol::DistantFieldFont::Draw(etk::Vector2D textPos, - const etk::UString& unicodeString, - etk::Vector > & coord, - etk::Vector & coordTex) -{ - float totalSize = 0; - etk::Vector2D tmpPos = textPos; - for(int32_t iii=0; iii bitmapDrawPos[4]; - bitmapDrawPos[0].x = 10; - bitmapDrawPos[1].x = 400; - bitmapDrawPos[2].x = 400; - bitmapDrawPos[3].x = 10; - - bitmapDrawPos[0].y = 400; - bitmapDrawPos[1].y = 400; - bitmapDrawPos[2].y = 10; - bitmapDrawPos[3].y = 10; - /* texture Position : - * 0------1 - * | | - * | | - * 3------2 - */ - texCoord_ts texturePos[4]; - texturePos[0].u = 0; - texturePos[1].u = 1; - texturePos[2].u = 1; - texturePos[3].u = 0; - - texturePos[0].v = 0; - texturePos[1].v = 0; - texturePos[2].v = 1; - texturePos[3].v = 1; - - // NOTE : Android does not support the Quads elements ... - /* Step 1 : - * ******** - * ****** - * **** - * ** - * - */ - // set texture coordonates : - coordTex.PushBack(texturePos[0]); - coordTex.PushBack(texturePos[1]); - coordTex.PushBack(texturePos[2]); - // set display positions : - coord.PushBack(bitmapDrawPos[0]); - coord.PushBack(bitmapDrawPos[1]); - coord.PushBack(bitmapDrawPos[2]); - - /* Step 2 : - * - * ** - * **** - * ****** - * ******** - */ - // set texture coordonates : - coordTex.PushBack(texturePos[0]); - coordTex.PushBack(texturePos[2]); - coordTex.PushBack(texturePos[3]); - // set display positions : - coord.PushBack(bitmapDrawPos[0]); - coord.PushBack(bitmapDrawPos[2]); - coord.PushBack(bitmapDrawPos[3]); - } - #endif - return totalSize; -} - -int32_t ewol::DistantFieldFont::Draw(etk::Vector2D textPos, - const uniChar_t unicodeChar, - etk::Vector > & coord, - etk::Vector & coordTex) -{ - float posDrawX = textPos.x; - - int32_t charIndex; - if (unicodeChar < 0x20) { - charIndex = 0; - } else if (unicodeChar < 0x80) { - charIndex = unicodeChar - 0x1F; - } else { - charIndex = 0; - for (int32_t iii=0x80-0x20; iii < m_listElement.Size(); iii++) { - if (m_listElement[iii].property.m_UVal == unicodeChar) { - charIndex = iii; - break; - } - } - } - // 0x01 == 0x20 == ' '; - if (unicodeChar != 0x01) { - /* Bitmap position - * xA xB - * yC *------* - * | | - * | | - * yD *------* - */ - float dxA = -SPECIAL_BORDER + posDrawX + m_listElement[charIndex].property.m_bearing.x; - float dxB = +SPECIAL_BORDER + posDrawX + m_listElement[charIndex].property.m_bearing.x + m_listElement[charIndex].property.m_sizeTexture.x; - float dyC = +SPECIAL_BORDER + textPos.y + m_listElement[charIndex].property.m_bearing.y + m_height - m_size; - float dyD = -SPECIAL_BORDER + dyC - m_listElement[charIndex].property.m_sizeTexture.y; - - float tuA = m_listElement[charIndex].posStart.u; - float tuB = m_listElement[charIndex].posStop.u; - float tvC = m_listElement[charIndex].posStart.v; - float tvD = m_listElement[charIndex].posStop.v; - - - // Clipping and drawing area - if( dxB <= dxA - || dyD >= dyC) { - // nothing to do ... - } else { - /* Bitmap position - * 0------1 - * | | - * | | - * 3------2 - */ - etk::Vector2D bitmapDrawPos[4]; - bitmapDrawPos[0].x = (int32_t)dxA; - bitmapDrawPos[1].x = (int32_t)dxB; - bitmapDrawPos[2].x = (int32_t)dxB; - bitmapDrawPos[3].x = (int32_t)dxA; - - bitmapDrawPos[0].y = (int32_t)dyC; - bitmapDrawPos[1].y = (int32_t)dyC; - bitmapDrawPos[2].y = (int32_t)dyD; - bitmapDrawPos[3].y = (int32_t)dyD; - /* texture Position : - * 0------1 - * | | - * | | - * 3------2 - */ - texCoord_ts texturePos[4]; - texturePos[0].u = tuA; - texturePos[1].u = tuB; - texturePos[2].u = tuB; - texturePos[3].u = tuA; - - texturePos[0].v = tvC; - texturePos[1].v = tvC; - texturePos[2].v = tvD; - texturePos[3].v = tvD; - - // NOTE : Android does not support the Quads elements ... - /* Step 1 : - * ******** - * ****** - * **** - * ** - * - */ - // set texture coordonates : - coordTex.PushBack(texturePos[0]); - coordTex.PushBack(texturePos[1]); - coordTex.PushBack(texturePos[2]); - // set display positions : - coord.PushBack(bitmapDrawPos[0]); - coord.PushBack(bitmapDrawPos[1]); - coord.PushBack(bitmapDrawPos[2]); - - /* Step 2 : - * - * ** - * **** - * ****** - * ******** - */ - // set texture coordonates : - coordTex.PushBack(texturePos[0]); - coordTex.PushBack(texturePos[2]); - coordTex.PushBack(texturePos[3]); - // set display positions : - coord.PushBack(bitmapDrawPos[0]); - coord.PushBack(bitmapDrawPos[2]); - coord.PushBack(bitmapDrawPos[3]); - - } - } - posDrawX += m_listElement[charIndex].property.m_advance.x; - int32_t sizeOut = posDrawX - textPos.x; - textPos.x = posDrawX; - return sizeOut; -} - -etk::Vector2D ewol::DistantFieldFont::GetSize(const etk::UString & unicodeString) -{ - etk::Vector2D outputSize(0,m_height); - for(int32_t iii=0; iii tmpp = GetSize(unicodeString[iii]); - outputSize.x += tmpp.x; - } - return outputSize; -} - - -etk::Vector2D ewol::DistantFieldFont::GetSize(const uniChar_t unicodeChar) -{ - etk::Vector2D outputSize(0,m_height); - int32_t charIndex; - if (unicodeChar >= 0x80) { - charIndex = 0; - } else if (unicodeChar < 0x20) { - charIndex = 0; - } else if (unicodeChar < 0x80) { - charIndex = unicodeChar - 0x1F; - } else { - for (int32_t iii=0x80-0x20; iii < m_listElement.Size(); iii++) { - if (m_listElement[iii].property.m_UVal == unicodeChar) { - charIndex = iii; - break; - } - } - // TODO : Update if possible the mapping - charIndex = 0; - } - outputSize.x = m_listElement[charIndex].property.m_advance.x; - return outputSize; -} - - diff --git a/sources/ewol/font/DistantFieldFont.h b/sources/ewol/font/DistantFieldFont.h deleted file mode 100644 index dd6e9c6c..00000000 --- a/sources/ewol/font/DistantFieldFont.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_DISTANT_FIELD_FONT_H__ -#define __EWOL_DISTANT_FIELD_FONT_H__ - -#include -#include -#include - -namespace ewol -{ - class DistantFieldFont : public ewol::Texture { - - typedef struct { - GlyphProperty property; - texCoord_ts posStart; - texCoord_ts posStop; - }freeTypeFontElement_ts; - private: - int32_t m_size; - int32_t m_height; - ewol::Font* m_font; - etk::Vector m_listElement; - // for the texture generation : - etk::Vector2D m_lastGlyphPos; - int32_t m_lastRawHeigh; - public: - DistantFieldFont(etk::UString fontName); - ~DistantFieldFont(void); - virtual bool HasName(etk::UString& fileName); - const char* GetType(void) { return "ewol::TexturedFont"; }; - int32_t getFontSize(void) { return m_size; }; - int32_t Draw(etk::Vector2D textPos, - const etk::UString& unicodeString, - etk::Vector > & coord, - etk::Vector & coordTex); - int32_t Draw(etk::Vector2D textPos, - const uniChar_t unicodeChar, - etk::Vector > & coord, - etk::Vector & coordTex); - etk::Vector2D GetSize(const etk::UString & unicodeString); - etk::Vector2D GetSize(const uniChar_t unicodeChar); - // TODO : Remove this element, it is stupid ... - int32_t GetHeight(void) { return m_height; }; - int32_t GetFontSize(void) { return m_size; }; - }; - - -}; - -#endif - diff --git a/sources/ewol/font/FontManager.cpp b/sources/ewol/font/FontManager.cpp deleted file mode 100644 index 1eb97bcb..00000000 --- a/sources/ewol/font/FontManager.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include -#include -#include -#include - -static etk::UString l_defaultFontName = ""; -static int32_t l_defaultFontSize = 10; - -void ewol::font::Init(void) -{ - l_defaultFontName = ""; - l_defaultFontSize = 10; - // Specific for free Font - ewol::FreeTypeInit(); -} - -void ewol::font::UnInit(void) -{ - // Specific for free Font - ewol::FreeTypeUnInit(); -} - -void ewol::font::SetDefaultFont(etk::UString fontName) -{ - l_defaultFontName = fontName; -} - -etk::UString& ewol::font::GetDefaultFont(void) -{ - return l_defaultFontName; -} - -void ewol::font::SetDefaultSize(int32_t newSize) -{ - l_defaultFontSize = newSize; -} - -int32_t ewol::font::GetDefaultSize(void) -{ - return l_defaultFontSize; -} - - diff --git a/sources/ewol/font/FontManager.h b/sources/ewol/font/FontManager.h deleted file mode 100644 index cedcda35..00000000 --- a/sources/ewol/font/FontManager.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_FONT_MANAGER_H__ -#define __EWOL_FONT_MANAGER_H__ - -#include -#include -#include - -namespace ewol -{ - namespace font { - void Init(void); - void UnInit(void); - void SetDefaultFont(etk::UString fontName); - etk::UString& GetDefaultFont(void); - void SetDefaultSize(int32_t newSize); - int32_t GetDefaultSize(void); - }; -}; - -#endif - diff --git a/sources/ewol/game/GameElementLua.cpp b/sources/ewol/game/GameElementLua.cpp deleted file mode 100644 index 1600321d..00000000 --- a/sources/ewol/game/GameElementLua.cpp +++ /dev/null @@ -1,929 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include - -/******************************************************************************* - ** Lua abstraction (START) - ******************************************************************************* */ - -#include - -//For every acces : - -static ewol::GameElementLua * tmpObj = NULL; -static etk::Vector * tmpSprite = NULL; -static ewol::SceneElement * tmpScene = NULL; - -template int index(lua_State* L); - -template <> int index(lua_State* L) -{ - bool* ptr = (bool*)lua_touserdata(L, 1); - lua_pushboolean(L, *ptr ? 1 : 0); - return 1; -} - -template <> int index(lua_State* L) -{ - float* ptr = (float*)lua_touserdata(L, 1); - lua_pushnumber(L, *ptr); - return 1; -} - -template int newindex(lua_State* L); - -template <> int newindex(lua_State* L) -{ - bool* ptr = (bool*)lua_touserdata(L, 1); - *ptr = lua_toboolean(L, 3)!=0; - return 0; -} - -template <> int newindex(lua_State* L) -{ - float* ptr = (float*)lua_touserdata(L, 1); - if (!lua_isnumber(L, 3)) { - return luaL_error(L, "new value must be a number"); - } - *ptr = (float)lua_tonumber(L, 3); - return 1; -} - -template class LuaValue -{ - private: - lua_State* L; - etk::UString name; - T* ptr; - public: - LuaValue(lua_State* _L, etk::UString _name) - : L(_L), name(_name), ptr(0) - { - ptr = (T*)lua_newuserdata(L, sizeof(T)); - *ptr = T(); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, index); - lua_setfield(L, -2, "__index"); - lua_pushcfunction(L, newindex); - lua_setfield(L, -2, "__newindex"); - lua_setmetatable(L, -2); - lua_setglobal(L, name.c_str()); - } - virtual ~LuaValue(void) - { - lua_pushnil(L); - lua_setglobal(L, name.c_str()); - ptr = 0; - L = 0; - } - LuaValue& operator=(const T& value) { *ptr = value; return *this; } - operator T() { return *ptr; } -}; - - -/* -template <> int lua_Set(lua_State* L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = luaL_checknumber(L, 1); - tmpObj->AngleSet(value); - // return number of parameters - return 1; -} - - -template <> int lua_Get(lua_State* L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = tmpObj->AngleGet(); - lua_pushnumber(L, value ); - // return number of parameters - return 1; -} -*/ - -LUAMOD_API int lua_GetPos(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, (lua_Number)0 ); - lua_pushnumber(L, (lua_Number)0 ); - return 2; - } - etk::Vector2D tmpPos = tmpObj->PositionGet(); - lua_pushnumber(L, (lua_Number)tmpPos.x ); - lua_pushnumber(L, (lua_Number)tmpPos.y ); - // return number of parameters - return 2; -} - -LUAMOD_API int lua_SetPos(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - return 0; - } - float x = luaL_checknumber(L, 1); - float y = luaL_checknumber(L, 2); - etk::Vector2D tmpPos; - tmpPos.x = x; - tmpPos.y = y; - tmpObj->PositionSet(tmpPos); - // return number of parameters - return 0; -} - -LUAMOD_API int lua_GetSpeed(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, (lua_Number)0 ); - return 1; - } - float tmpPos = tmpObj->SpeedGet(); - lua_pushnumber(L, (lua_Number)tmpPos ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SetSpeed(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - return 0; - } - float x = luaL_checknumber(L, 1); - tmpObj->SpeedSet(x); - // return number of parameters - return 0; -} - -LUAMOD_API int lua_GetPower(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = tmpObj->PowerGet(); - lua_pushnumber(L, (lua_Number)value ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SetPower(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = luaL_checknumber(L, 1); - tmpObj->PowerSet(value); - // return number of parameters - return 1; -} - - -LUAMOD_API int lua_GetGroup(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - int32_t value = tmpObj->GroupGet(); - lua_pushinteger(L, value ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SetGroup(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - int32_t value = luaL_checkint(L, 1); - tmpObj->GroupSet(value); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_GetAngle(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = tmpObj->AngleGet(); - lua_pushnumber(L, value ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SetAngle(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = luaL_checknumber(L, 1); - tmpObj->AngleSet(value); - // return number of parameters - return 1; -} - - -LUAMOD_API int lua_GetSize(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 1; - } - float value = tmpObj->SizeGet(); - lua_pushnumber(L, value ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SetSize(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, 0 ); - return 0; - } - float value = luaL_checknumber(L, 1); - tmpObj->SizeSet(value); - // return number of parameters - return 0; -} - - -LUAMOD_API int lua_GetCanBeCibled(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushboolean(L, false ); - return 1; - } - float value = tmpObj->CanBeCibledGet(); - lua_pushboolean(L, value ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SetCanBeCibled(lua_State *L) -{ - if (NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - return 0; - } - bool value = false; - if ( lua_isboolean( L, 1 ) ) { - value = lua_toboolean( L, 1 ); - } - tmpObj->CanBeCibledSet(value); - // return number of parameters - return 0; -} - - - -LUAMOD_API int lua_SpriteLoad(lua_State *L) -{ - //LUA : int SpriteLoad("fileName", maxSize); => -1 in error ... - if (NULL==tmpScene || NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushnumber(L, (lua_Number)-1 ); - return 1; - } - const char *filename = luaL_checkstring(L, 1); - int32_t maxSize = luaL_checkint(L, 2); - int32_t spriteID = tmpScene->LoadSprite( filename, maxSize); - if (spriteID < 0) { - EWOL_ERROR("Error to load the sprite : " << filename); - } - lua_pushnumber(L, (lua_Number)spriteID ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_SpriteUnLoad(lua_State *L) -{ - // TODO : when supported ... -/* - //LUA : SpriteUnLoad(int); - if (NULL==tmpScene) { - return 1; - } - float a = luaL_checkint(L, 1); - etk::Vector2D tmpPos = tmpObj->PositionGet(); - tmpPos.y = a; - tmpObj->PositionSet(tmpPos); -*/ - // return number of parameters - return 0; -} - -LUAMOD_API int lua_SpriteDraw(lua_State *L) -{ - //LUA : SpriteDraw(int id, posX, posY, angle, size) - - if (NULL==tmpSprite) { - return 0; - } - float spriteID = luaL_checknumber(L, 1); - etk::Vector2D tmpPos; - tmpPos.x = luaL_checknumber(L, 2); - tmpPos.y = luaL_checknumber(L, 3); - float angle = luaL_checknumber(L, 4); - float size = luaL_checknumber(L, 5); - if (spriteID < 0) { - EWOL_ERROR("Can not Draw the sprite : " << spriteID); - return 0; - } - //EWOL_INFO("Draw the sprite : " << spriteID << " pos=" << tmpPos << " angle=" << angle); - (*tmpSprite)[spriteID]->Element(tmpPos, size, angle); - // return number of parameters - return 0; -} - - -LUAMOD_API int lua_ElementAdd(lua_State *L) -{ - //LUA : int ElementAdd("Bullet", group) - - if (NULL==tmpScene) { - EWOL_ERROR("NULL obj..."); - lua_pushinteger(L, 0 ); - return 1; - } - etk::UString elementName = luaL_checkstring(L, 1); - int32_t group = luaL_checkint(L, 2); - // TODO : Remove this when find an other way do do it ... - ewol::GameElementLua * ttmpObj = tmpObj; - etk::Vector * ttmpSprite = tmpSprite; - ewol::SceneElement * ttmpScene = tmpScene; - uint32_t elementId = tmpScene->AddElementNamed(group, elementName); - tmpObj = ttmpObj; - tmpSprite = ttmpSprite; - tmpScene = ttmpScene; - - if (0==elementId) { - EWOL_ERROR("Error creating element : " << elementName); - } - lua_pushinteger(L, elementId ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_ElementSetPos(lua_State *L) -{ - //LUA : ElementSetPos(newElementId, posX, posY); - if (NULL==tmpScene) { - EWOL_ERROR("ploppp "); - return 0; - } - int32_t idElement = luaL_checkint(L, 1); - ewol::GameElement* tmpElem = tmpScene->GetElement(idElement); - if (NULL != tmpElem) { - etk::Vector2D tmpPos; - tmpPos.x = luaL_checknumber(L, 2); - tmpPos.y = luaL_checknumber(L, 3); - tmpElem->PositionSet(tmpPos); - } else { - EWOL_ERROR("Get element unique ID : " << idElement); - } - // return number of parameters - return 0; -} - -LUAMOD_API int lua_ElementGetPos(lua_State *L) -{ - //LUA : ElementSetPos(newElementId, posX, posY); - if (NULL==tmpScene) { - EWOL_ERROR("ploppp "); - lua_pushnumber(L, (lua_Number)0 ); - lua_pushnumber(L, (lua_Number)0 ); - return 2; - } - int32_t idElement = luaL_checkint(L, 1); - ewol::GameElement* tmpElem = tmpScene->GetElement(idElement); - if (NULL != tmpElem) { - etk::Vector2D tmpPos = tmpElem->PositionGet(); - lua_pushnumber(L, (lua_Number)tmpPos.x ); - lua_pushnumber(L, (lua_Number)tmpPos.y ); - } else { - lua_pushnumber(L, (lua_Number)0.0 ); - lua_pushnumber(L, (lua_Number)0.0 ); - EWOL_ERROR("Get element unique ID : " << idElement); - } - // return number of parameters - return 2; -} - -LUAMOD_API int lua_ElementSetPower(lua_State *L) -{ - //LUA : ElementSetPower(newElementId, 1); - - if (NULL==tmpScene) { - return 0; - } - int32_t idElement = luaL_checkint(L, 1); - ewol::GameElement* tmpElem = tmpScene->GetElement(idElement); - if (NULL != tmpElem) { - int32_t power = luaL_checkint(L, 2); - tmpElem->PowerSet(power); - } - // return number of parameters - return 0; -} - -LUAMOD_API int lua_ElementSetAngle(lua_State *L) -{ - //LUA : ElementSetAngle(newElementId, m_angle); - - if (NULL==tmpScene) { - return 0; - } - int32_t idElement = luaL_checkint(L, 1); - ewol::GameElement* tmpElem = tmpScene->GetElement(idElement); - if (NULL != tmpElem) { - float angle = luaL_checknumber(L, 2); - tmpElem->AngleSet(angle); - } - // return number of parameters - return 1; -} - - -LUAMOD_API int lua_GetNearestEnemy(lua_State *L) -{ - //LUA : int GetNearestEnemy() - if (NULL==tmpScene || NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushinteger(L, 0 ); - return 1; - } - uint32_t elementId = tmpScene->GetNearestEnemy(tmpObj->PositionGet(), tmpObj->GroupGet()); - lua_pushinteger(L, elementId ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_ElmentExisted(lua_State *L) -{ - //LUA : ElementSetPos(newElementId, posX, posY); - if (NULL==tmpScene) { - EWOL_ERROR("NULL obj..."); - lua_pushboolean(L, false ); - return 1; - } - int32_t idElement = luaL_checkint(L, 1); - if (0 != idElement) { - ewol::GameElement* tmpElem = tmpScene->GetElement(idElement); - if (NULL != tmpElem) { - lua_pushboolean(L, true ); - } else { - lua_pushboolean(L, false ); - } - } else { - lua_pushboolean(L, false ); - } - // return number of parameters - return 1; -} - -LUAMOD_API int lua_HaveImpact(lua_State *L) -{ - //LUA : ElementSetPos(newElementId, posX, posY); - if (NULL==tmpScene || NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - lua_pushboolean(L, false ); - return 1; - } - - // TODO : Remove this when find an other way do do it ... - ewol::GameElementLua * ttmpObj = tmpObj; - etk::Vector * ttmpSprite = tmpSprite; - ewol::SceneElement * ttmpScene = tmpScene; - - bool result = tmpScene->HaveImpact(tmpObj->GroupGet(), tmpObj->TypeGet(), tmpObj->PositionGet(), tmpObj->SizeGet()); - - tmpObj = ttmpObj; - tmpSprite = ttmpSprite; - tmpScene = ttmpScene; - - lua_pushboolean(L, result ); - // return number of parameters - return 1; -} - -LUAMOD_API int lua_Explosion(lua_State *L) -{ - //LUA : ElementSetPos(newElementId, posX, posY); - if (NULL==tmpScene || NULL==tmpObj) { - EWOL_ERROR("NULL obj..."); - return 0; - } - - // TODO : Remove this when find an other way do do it ... - ewol::GameElementLua * ttmpObj = tmpObj; - etk::Vector * ttmpSprite = tmpSprite; - ewol::SceneElement * ttmpScene = tmpScene; - - tmpScene->Explosion(tmpObj->GroupGet(), tmpObj->TypeGet(), tmpObj->PositionGet(), 0.01, tmpObj->PowerGet()); - - tmpObj = ttmpObj; - tmpSprite = ttmpSprite; - tmpScene = ttmpScene; - - // return number of parameters - return 0; -} - - -static const luaL_Reg functionsTable[] = { - // local element section - { "GetPos", lua_GetPos }, - { "SetPos", lua_SetPos }, - { "GetSpeed", lua_GetSpeed }, - { "SetSpeed", lua_SetSpeed }, - { "GetAngle", lua_GetAngle }, - { "SetAngle", lua_SetAngle }, - { "GetSize", lua_GetSize }, - { "SetSize", lua_SetSize }, - { "GetPower", lua_GetPower }, - { "SetPower", lua_SetPower }, - { "GetGroup", lua_GetGroup }, - { "SetGroup", lua_SetGroup }, - { "GetCanBeCibled", lua_GetCanBeCibled }, - { "SetCanBeCibled", lua_SetCanBeCibled }, - // other element section - { "ElementAdd", lua_ElementAdd }, - { "ElementExisted", lua_ElmentExisted }, - { "ElementSetPos", lua_ElementSetPos }, - { "ElementGetPos", lua_ElementGetPos }, - { "ElementSetPower", lua_ElementSetPower }, - { "ElementSetAngle", lua_ElementSetAngle }, - { "GetNearestEnemy", lua_GetNearestEnemy }, - { "HaveImpact", lua_HaveImpact }, - { "Explosion", lua_Explosion }, - // Sprite section - { "SpriteLoad", lua_SpriteLoad }, - { "SpriteUnLoad", lua_SpriteUnLoad }, - { "SpriteDraw", lua_SpriteDraw }, - { NULL, NULL } -}; - - -//http://www.swig.org/Doc1.3/Lua.html#Lua_nn13 -//http://stackoverflow.com/questions/2521244/how-to-wrap-a-c-function-whose-parameters-are-pointer-to-structs-so-that-it-can -LUAMOD_API int luaopen_myLib(lua_State *L) { - luaL_register(L, "GameElement", functionsTable); - lua_pop(L, 1); - return 1; -} - -/******************************************************************************* - ** Lua abstraction (END) - ******************************************************************************* */ - -#undef __class__ -#define __class__ "GameElementLua" - -ewol::GameElementLua::GameElementLua(ewol::SceneElement & sceneElement, etk::UString& tmpName) : - ewol::GameElement(sceneElement, tmpName), - m_luaState(NULL) -{ - tmpObj = this; - tmpScene = &m_sceneElement; - etk::FSNode fileElement(etk::UString("DATA:") + tmpName); - etk::UString tmpCompleatName = fileElement.GetName(); - - // create state - m_luaState = luaL_newstate(); - if (m_luaState == NULL) { - EWOL_ERROR("LUA: cannot create state: not enough memory"); - return; - } - luaL_openlibs(m_luaState); - // open internal specific elements ... - luaopen_myLib(m_luaState); -/* - LuaValue *myBool = new LuaValue(m_luaState, "m_testBool"); - LuaValue *myValue = new LuaValue(m_luaState, "m_testFloat"); - *myBool = false; - *myValue = 18; -*/ - int32_t fileSize = fileElement.FileSize(); - if (0==fileSize) { - EWOL_ERROR("This file is empty : " << fileElement); - return; - } - if (false == fileElement.FileOpenRead()) { - EWOL_ERROR("Can not open the file : " << fileElement); - return; - } - // allocate data - char * fileBuffer = new char[fileSize+5]; - if (NULL == fileBuffer) { - EWOL_ERROR("Error Memory allocation size=" << fileSize); - return; - } - memset(fileBuffer, 0, (fileSize+5)*sizeof(char)); - // load data from the file : - fileElement.FileRead(fileBuffer, 1, fileSize); - // close the file: - fileElement.FileClose(); - - if (luaL_loadbuffer(m_luaState, fileBuffer, fileSize, tmpName.c_str())) { - //if (luaL_loadfile(m_luaState, "/home/heero/dev/perso/TethysDefender/assets/elementGame/Cube.lua" ) ) { - EWOL_ERROR("LUA: " << lua_tostring(m_luaState, -1)); - return; - } - - if (NULL != fileBuffer) { - delete[] fileBuffer; - } - // Call the basic for initialise all the element defined by the user... - if (lua_pcall(m_luaState, 0, 0, 0)) { - EWOL_ERROR("LUA: " << lua_tostring(m_luaState, -1)); - return; - } -/* - EWOL_INFO("retreave element : " << *myValue << " and : " << *myBool); -*/ - tmpObj = NULL; - tmpScene = NULL; - Init(); - -} - - -ewol::GameElementLua::~GameElementLua(void) -{ - UnInit(); - if (NULL != m_luaState) { - lua_close(m_luaState); - m_luaState = NULL; - } -} - -void ewol::GameElementLua::Init(void) -{ - tmpObj = this; - tmpScene = &m_sceneElement; - if (NULL != m_luaState) { - // call the init function - lua_getglobal(m_luaState, "Init"); - if(!lua_isfunction(m_luaState,-1)) { - EWOL_WARNING("LUA: Not Find Init function "); - lua_pop(m_luaState,1); - } else { - // do the call (0 arguments, 0 result) - if (lua_pcall(m_luaState, 0, 0, 0) != 0) { - EWOL_ERROR("LUA: error running function 'Init':" << lua_tostring(m_luaState, -1)); - return; - } - } - } - tmpObj = NULL; - tmpScene = NULL; -} - - -void ewol::GameElementLua::UnInit(void) -{ - tmpObj = this; - tmpScene = &m_sceneElement; - if (NULL != m_luaState) { - // call the init function - lua_getglobal(m_luaState, "UnInit"); - if(!lua_isfunction(m_luaState,-1)) { - EWOL_WARNING("LUA: Not Find 'UnInit' function "); - lua_pop(m_luaState,1); - } else { - // do the call (0 arguments, 0 result) - if (lua_pcall(m_luaState, 0, 0, 0) != 0) { - EWOL_ERROR("LUA: error running function 'UnInit':" << lua_tostring(m_luaState, -1)); - } - } - } - tmpObj = NULL; - tmpScene = NULL; -} - - -bool ewol::GameElementLua::Process(int64_t time, int32_t deltaTime) -{ - tmpObj = this; - tmpScene = &m_sceneElement; - bool retVal = false; - if (NULL != m_luaState) { - // call the init function - lua_getglobal(m_luaState, "Process"); - if(!lua_isfunction(m_luaState,-1)) { - EWOL_WARNING("LUA: Not Find 'Process' function "); - lua_pop(m_luaState,1); - } else { - lua_pushnumber(m_luaState, (int32_t)time); // push 1st argument - lua_pushnumber(m_luaState, (int32_t)deltaTime); // push 2nd argument - // do the call (2 arguments, 1 result) - if (lua_pcall(m_luaState, 2, 1, 0) != 0) { - EWOL_ERROR("LUA: error running function 'Process':" << lua_tostring(m_luaState, -1)); - } else { - // retrieve result - if (!lua_isboolean(m_luaState, -1)) { - EWOL_ERROR("LUA: function 'Process' must return a boolean"); - } else { - retVal = lua_toboolean(m_luaState, -1); - lua_pop(m_luaState, 1); - } - } - } - } - tmpObj = NULL; - tmpScene = NULL; - - return retVal; -} - - -void ewol::GameElementLua::Draw(void) -{ - tmpObj = this; - tmpSprite = &m_sceneElement.animated; - if (NULL != m_luaState) { - // call the Draw function - lua_getglobal(m_luaState, "Draw"); - if(!lua_isfunction(m_luaState,-1)) { - EWOL_WARNING("LUA: Not Find 'Draw' function "); - lua_pop(m_luaState,1); - } else { - // do the call (0 arguments, 0 result) - if (lua_pcall(m_luaState, 0, 0, 0) != 0) { - EWOL_ERROR("LUA: error running function 'Draw':" << lua_tostring(m_luaState, -1)); - } - } - } - tmpObj = NULL; - tmpSprite = NULL; -} - - -bool ewol::GameElementLua::HaveImpact(int32_t group, int32_t type, etk::Vector2D position, float size) -{ - // todo set a flag that permit lua to direct control of this ... - if (false == ewol::GameElement::HaveImpact(group, type, position, size) ) { - return false; - } - //HaveImpact(group, type, posX, posY, size, quadDistance) - tmpObj = this; - bool retVal = true; - if (NULL != m_luaState) { - // call the init function - lua_getglobal(m_luaState, "HaveImpact"); - if(!lua_isfunction(m_luaState,-1)) { - EWOL_VERBOSE("LUA: Not Find 'HaveImpact' function "); - lua_pop(m_luaState,1); - } else { - lua_pushnumber(m_luaState, group); - lua_pushnumber(m_luaState, type); - lua_pushnumber(m_luaState, position.x); - lua_pushnumber(m_luaState, position.y); - lua_pushnumber(m_luaState, size); - float quadDistance = quadDist(m_position, position); - lua_pushnumber(m_luaState, quadDistance); - // do the call (6 arguments, 1 result) - if (lua_pcall(m_luaState, 6, 1, 0) != 0) { - EWOL_ERROR("LUA: error running function 'Process':" << lua_tostring(m_luaState, -1)); - } else { - // retrieve result - if (!lua_isboolean(m_luaState, -1)) { - EWOL_ERROR("LUA: function 'Process' must return a boolean"); - } else { - retVal = lua_toboolean(m_luaState, -1); - lua_pop(m_luaState, 1); - } - } - } - } - tmpObj = NULL; - - return retVal; -} - - -bool ewol::GameElementLua::Explosion(int32_t group, int32_t type, etk::Vector2D position, float pxAtenuation, float power) -{ - tmpObj = this; - bool retVal = false; - if (NULL != m_luaState) { - // call the init function - lua_getglobal(m_luaState, "Explosion"); - if(!lua_isfunction(m_luaState,-1)) { - EWOL_VERBOSE("LUA: Not Find 'Explosion' function "); - lua_pop(m_luaState,1); - } else { - lua_pushnumber(m_luaState, group); - lua_pushnumber(m_luaState, type); - lua_pushnumber(m_luaState, position.x); - lua_pushnumber(m_luaState, position.y); - lua_pushnumber(m_luaState, pxAtenuation); - lua_pushnumber(m_luaState, power); - float quadDistance = quadDist(m_position, position); - lua_pushnumber(m_luaState, quadDistance); - // do the call (7 arguments, 1 result) - if (lua_pcall(m_luaState, 7, 1, 0) != 0) { - EWOL_ERROR("LUA: error running function 'Explosion':" << lua_tostring(m_luaState, -1)); - } else { - // retrieve result - if (!lua_isboolean(m_luaState, -1)) { - EWOL_ERROR("LUA: function 'Process' must return a boolean"); - } else { - retVal = lua_toboolean(m_luaState, -1); - lua_pop(m_luaState, 1); - } - } - - } - } - tmpObj = NULL; - return retVal; -} - -etk::UString ewol::GameElementLua::Message(etk::UString control, etk::UString message) -{ - tmpObj = this; - if (NULL != m_luaState) { - // call the init function - lua_getglobal(m_luaState, "Message"); - if(!lua_isfunction(m_luaState,-1)) { - lua_pop(m_luaState,1); - } else { - lua_pushstring(m_luaState, control.c_str()); - lua_pushstring(m_luaState, message.c_str()); - // do the call (2 arguments, 0 result) - if (lua_pcall(m_luaState, 2, 0, 0) != 0) { - EWOL_ERROR("LUA: error running function 'Message':" << lua_tostring(m_luaState, -1)); - } - } - } - tmpObj = NULL; - return ""; -} - -static ewol::GameElement* LoadSceneElement_lua(ewol::SceneElement & sceneElement, etk::UString& elementName, etk::UString& userString) -{ - // try to find the file : - etk::UString tmpName = userString; - tmpName += elementName; - tmpName += ".lua"; - // added a new element : - etk::FSNode fileElement(etk::UString("DATA:") + tmpName); - if (false == fileElement.Exist()) { - EWOL_ERROR("Can not find Game element : " << elementName << " ==> " << tmpName); - return NULL; - } - EWOL_VERBOSE("We find Game element : " << elementName << " ==> " << tmpName); - ewol::GameElementLua * tmpElement = new ewol::GameElementLua(sceneElement, tmpName); - if (NULL == tmpElement) { - EWOL_ERROR("Can not Allocat : " << elementName); - return NULL; - } - return tmpElement; -} - -void ewol::RegisterLuaElementInFolder(ewol::SceneElement & sceneElement, etk::UString folder) -{ - // TODO : parsing the folder ... - sceneElement.RegisterElementType("??????", &LoadSceneElement_lua, folder); -} - - -void ewol::RegisterLuaElementSpecify(ewol::SceneElement & sceneElement, etk::UString folder, etk::UString name) -{ - sceneElement.RegisterElementType(name, &LoadSceneElement_lua, folder); -} diff --git a/sources/ewol/game/GameElementLua.h b/sources/ewol/game/GameElementLua.h deleted file mode 100644 index 337adc6a..00000000 --- a/sources/ewol/game/GameElementLua.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_GAME_ELEMENT_LUA_H__ -#define __EWOL_GAME_ELEMENT_LUA_H__ - -#include -#include -#include -#include -#include -#include - -#include - -namespace ewol { - class GameElementLua : public ewol::GameElement - { - private: - lua_State *m_luaState; // internal Lua state - public: - GameElementLua(ewol::SceneElement & sceneElement, etk::UString& tmpName); - ~GameElementLua(void); - - virtual void Init(void); - virtual void UnInit(void); - virtual bool Process(int64_t time, int32_t deltaTime); - virtual void Draw(void); - virtual bool HaveImpact(int32_t group, int32_t type, etk::Vector2D position, float size); - virtual bool Explosion(int32_t group, int32_t type, etk::Vector2D position, float pxAtenuation, float power); - virtual etk::UString Message(etk::UString control, etk::UString message); - }; - void RegisterLuaElementInFolder(ewol::SceneElement & sceneElement, etk::UString folder); - void RegisterLuaElementSpecify(ewol::SceneElement & sceneElement, etk::UString folder, etk::UString name); -}; - -#endif diff --git a/sources/ewol/key.cpp b/sources/ewol/key.cpp new file mode 100644 index 00000000..3221ba46 --- /dev/null +++ b/sources/ewol/key.cpp @@ -0,0 +1,184 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +etk::CCout& ewol::keyEvent::operator <<(etk::CCout &os, const ewol::keyEvent::event_te obj) +{ + switch(obj) { + default: + case ewol::keyEvent::None : + os << "None"; + break; + case ewol::keyEvent::MouseDown : + os << "MouseDown"; + break; + case ewol::keyEvent::MouseMove : + os << "MouseMove"; + break; + case ewol::keyEvent::MouseSingle : + os << "MouseSingle"; + break; + case ewol::keyEvent::MouseDouble : + os << "MouseDouble"; + break; + case ewol::keyEvent::MouseTriple : + os << "MouseTriple"; + break; + case ewol::keyEvent::MouseQuad : + os << "MouseQuad"; + break; + case ewol::keyEvent::MouseQuinte : + os << "MouseQuinte"; + break; + case ewol::keyEvent::MouseUp : + os << "MouseUp"; + break; + case ewol::keyEvent::MouseEnter : + os << "MouseEnter"; + break; + case ewol::keyEvent::MouseLeave : + os << "MouseLeave"; + break; + case ewol::keyEvent::MouseAbort : + os << "MouseAbort"; + break; + case ewol::keyEvent::MouseTransfer : + os << "MouseTransfer"; + break; + case ewol::keyEvent::KeyboardLeft : + os << "KeyboardLeft"; + break; + case ewol::keyEvent::KeyboardRight : + os << "KeyboardRight"; + break; + case ewol::keyEvent::KeyboardUp : + os << "KeyboardUp"; + break; + case ewol::keyEvent::KeyboardDown : + os << "KeyboardDown"; + break; + case ewol::keyEvent::KeyboardPageUp : + os << "KeyboardPageUp"; + break; + case ewol::keyEvent::KeyboardPageDown : + os << "KeyboardPageDown"; + break; + case ewol::keyEvent::KeyboardStart : + os << "KeyboardStart"; + break; + case ewol::keyEvent::KeyboardEnd : + os << "KeyboardEnd"; + break; + case ewol::keyEvent::KeyboardCenter : + os << "KeyboardCenter"; + break; + case ewol::keyEvent::KeyboardStopDefil : + os << "KeyboardStopDefil"; + break; + case ewol::keyEvent::KeyboardWait : + os << "KeyboardWait"; + break; + case ewol::keyEvent::KeyboardInsert : + os << "KeyboardInsert"; + break; + case ewol::keyEvent::KeyboardF1 : + os << "KeyboardF1"; + break; + case ewol::keyEvent::KeyboardF2 : + os << "KeyboardF2"; + break; + case ewol::keyEvent::KeyboardF3 : + os << "KeyboardF3"; + break; + case ewol::keyEvent::KeyboardF4 : + os << "KeyboardF4"; + break; + case ewol::keyEvent::KeyboardF5 : + os << "KeyboardF5"; + break; + case ewol::keyEvent::KeyboardF6 : + os << "KeyboardF6"; + break; + case ewol::keyEvent::KeyboardF7 : + os << "KeyboardF7"; + break; + case ewol::keyEvent::KeyboardF8 : + os << "KeyboardF8"; + break; + case ewol::keyEvent::KeyboardF9 : + os << "KeyboardF9"; + break; + case ewol::keyEvent::KeyboardF10 : + os << "KeyboardF10"; + break; + case ewol::keyEvent::KeyboardF11 : + os << "KeyboardF11"; + break; + case ewol::keyEvent::KeyboardF12 : + os << "KeyboardF12"; + break; + case ewol::keyEvent::KeyboardCapLock : + os << "KeyboardCapLock"; + break; + case ewol::keyEvent::KeyboardShiftLeft : + os << "KeyboardShiftLeft"; + break; + case ewol::keyEvent::KeyboardShiftRight : + os << "KeyboardShiftRight"; + break; + case ewol::keyEvent::KeyboardCtrlLeft : + os << "KeyboardCtrlLeft"; + break; + case ewol::keyEvent::KeyboardCtrlRight : + os << "KeyboardCtrlRight"; + break; + case ewol::keyEvent::KeyboardMetaLeft : + os << "KeyboardMetaLeft"; + break; + case ewol::keyEvent::KeyboardMetaRight : + os << "KeyboardMetaRight"; + break; + case ewol::keyEvent::KeyboardAlt : + os << "KeyboardAlt"; + break; + case ewol::keyEvent::KeyboardAltGr : + os << "KeyboardAltGr"; + break; + case ewol::keyEvent::KeyboardContextMenu : + os << "KeyboardContextMenu"; + break; + case ewol::keyEvent::KeyboardVerNum : + os << "KeyboardVerNum"; + break; + } + return os; +} + +} + +etk::CCout& ewol::keyEvent::operator <<(etk::CCout &os, const ewol::keyEvent::input_te obj) +{ + switch(obj) { + default: + case ewol::keyEvent::NoUnknowne : + os << "Unknow"; + break; + case ewol::keyEvent::Mouse : + os << "Mouse"; + break; + case ewol::keyEvent::Finger : + os << "Finger"; + break; + case ewol::keyEvent::Stylet : + os << "Stylet"; + break; + } + return os; +} + + + diff --git a/sources/ewol/key.h b/sources/ewol/key.h new file mode 100644 index 00000000..a7c4e001 --- /dev/null +++ b/sources/ewol/key.h @@ -0,0 +1,93 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __EWOL_KEY_H__ +#define __EWOL_KEY_H__ + +#include +#include + +namespace ewol +{ + namespace keyEvent + { + // event from all the type of input : + typedef enum { + None, + MouseDown, + MouseMove, + MouseSingle, + MouseDouble, + MouseTriple, + MouseQuad, + MouseQuinte, + MouseUp, + MouseEnter, + MouseLeave, + MouseAbort, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has lost the events) + MouseTransfer, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event) + KeyboardLeft, + KeyboardRight, + KeyboardUp, + KeyboardDown, + KeyboardPageUp, + KeyboardPageDown, + KeyboardStart, + KeyboardEnd, + KeyboardCenter, + KeyboardStopDefil, + KeyboardWait, + KeyboardInsert, + KeyboardF1, + KeyboardF2, + KeyboardF3, + KeyboardF4, + KeyboardF5, + KeyboardF6, + KeyboardF7, + KeyboardF8, + KeyboardF9, + KeyboardF10, + KeyboardF11, + KeyboardF12, + KeyboardCapLock, + KeyboardShiftLeft, + KeyboardShiftRight, + KeyboardCtrlLeft, + KeyboardCtrlRight, + KeyboardMetaLeft, + KeyboardMetaRight, + KeyboardAlt, + KeyboardAltGr, + KeyboardContextMenu, + KeyboardVerNum, + } event_te; + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const ewol::keyEvent::event_te obj); + + // type of input : Notye that the keyboard is not prevent due to the fact that data is too different + typedef enum { + Unknow, + Mouse, + Finger, + Stylet, + } input_te; + /** + * @brief Debug operator To display the curent element in a Human redeable information + */ + etk::CCout& operator <<(etk::CCout &os, const ewol::keyEvent::input_te obj); + }; +}; + + + +#endif + + diff --git a/sources/ewol/oObject/2DColored.cpp b/sources/ewol/oObject/2DColored.cpp deleted file mode 100644 index 5e7a2a85..00000000 --- a/sources/ewol/oObject/2DColored.cpp +++ /dev/null @@ -1,601 +0,0 @@ -/** - ******************************************************************************* - * @file ewol/oObject/2DColored.cpp - * @brief ewol OpenGl Object system (Sources) - * @author Edouard DUPIN - * @date 09/11/2011 - * @par Project - * ewol - * - * @par Copyright - * Copyright 2011 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - -#include -#include -#include - - -#undef __class__ -#define __class__ "ewol::OObject2DColored" - - -ewol::OObject2DColored::OObject2DColored(void) -{ - m_triElement = 0; - SetColor(1.0, 1.0, 1.0, 1.0); - etk::UString tmpString("DATA:color.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - } -} - - -ewol::OObject2DColored::~OObject2DColored(void) -{ - m_coord.Clear(); - m_coordColor.Clear(); - ewol::resource::Release(m_GLprogram); -} - - -void ewol::OObject2DColored::Draw(void) -{ - if (m_coord.Size()<=0) { - return; - } - if (m_GLprogram==NULL) { - EWOL_ERROR("No shader ..."); - return; - } - //glScalef(m_scaling.x, m_scaling.y, 1.0); - m_GLprogram->Use(); - // set Matrix : translation/positionMatrix - etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix(); - m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); - // position : - m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]); - // color : - m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); - // Request the draw of the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - m_GLprogram->UnUse(); -} - -void ewol::OObject2DColored::Clear(void) -{ - m_coord.Clear(); - m_coordColor.Clear(); -} - - -void generatePolyGone(etk::Vector > & input, etk::Vector > & output ) -{ - if (input.Size()<3) { - return; - } - // TODO : Regenerate a linear poligone generation - for (int32_t iii=1; iii " << output.Size() ); -} - -void SutherlandHodgman(etk::Vector > & input, etk::Vector > & output, float sx, float sy, float ex, float ey) -{ - // with Sutherland-Hodgman-Algorithm - if (input.Size() <0) { - return; - } - //int32_t sizeInit=input.Size(); - // last element : - etk::Vector2D destPoint; - etk::Vector2D lastElement = input[input.Size()-1]; - bool inside = true; - if (lastElement.x < sx) { - inside = false; - } - //EWOL_DEBUG("generate an crop : "); - for(int32_t iii=0; iii OUT "); - //new point intersection ... - //y=aaax+bbb - float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x); - float bbb = lastElement.y - (aaa*lastElement.x); - destPoint.y = aaa*sx + bbb; - destPoint.x = sx; - output.PushBack(destPoint); - } else { - //EWOL_DEBUG("element OUT ==> OUT "); - } - inside = false; - } else { - if(true == inside) { - //EWOL_DEBUG("element IN ==> IN "); - output.PushBack(input[iii]); - } else { - //EWOL_DEBUG("element OUT ==> IN "); - //new point intersection ... - //y=aaax+bbb - float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x); - float bbb = lastElement.y - (aaa*lastElement.x); - destPoint.y = aaa*sx + bbb; - destPoint.x = sx; - output.PushBack(destPoint); - output.PushBack(input[iii]); - } - inside = true; - } - // update the last point position : - lastElement.x = input[iii].x; - lastElement.y = input[iii].y; - } - - //EWOL_DEBUG("generate an crop on element : " << sizeInit << " ==> " << output.Size() << "intermediate (1)"); - input = output; - output.Clear(); - lastElement = input[input.Size()-1]; - inside = true; - if (lastElement.y < sy) { - inside = false; - } - for(int32_t iii=0; iii OUT "); - //new point intersection ... - //x=aaay+bbb - float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y); - float bbb = lastElement.x - (aaa*lastElement.y); - destPoint.y = sy; - destPoint.x = sy*aaa + bbb; - output.PushBack(destPoint); - } else { - //EWOL_DEBUG("element OUT ==> OUT "); - } - inside = false; - } else { - if(true == inside) { - //EWOL_DEBUG("element IN ==> IN "); - output.PushBack(input[iii]); - } else { - //EWOL_DEBUG("element OUT ==> IN "); - //new point intersection ... - //y=aaax+bbb - float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y); - float bbb = lastElement.x - (aaa*lastElement.y); - destPoint.y = sy; - destPoint.x = sy*aaa + bbb; - output.PushBack(destPoint); - output.PushBack(input[iii]); - } - inside = true; - } - // update the last point position : - lastElement.x = input[iii].x; - lastElement.y = input[iii].y; - } - - input = output; - output.Clear(); - lastElement = input[input.Size()-1]; - inside = true; - if (lastElement.x > ex) { - inside = false; - } - //EWOL_DEBUG("generate an crop : "); - for(int32_t iii=0; iii ex) { - if(true == inside) { - //EWOL_DEBUG("element IN ==> OUT "); - //new point intersection ... - //y=aaax+bbb - float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x); - float bbb = lastElement.y - (aaa*lastElement.x); - destPoint.y = aaa*ex + bbb; - destPoint.x = ex; - output.PushBack(destPoint); - } else { - //EWOL_DEBUG("element OUT ==> OUT "); - } - inside = false; - } else { - if(true == inside) { - //EWOL_DEBUG("element IN ==> IN "); - output.PushBack(input[iii]); - } else { - //EWOL_DEBUG("element OUT ==> IN "); - //new point intersection ... - //y=aaax+bbb - float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x); - float bbb = lastElement.y - (aaa*lastElement.x); - destPoint.y = aaa*ex + bbb; - destPoint.x = ex; - output.PushBack(destPoint); - output.PushBack(input[iii]); - } - inside = true; - } - // update the last point position : - lastElement.x = input[iii].x; - lastElement.y = input[iii].y; - } - - input = output; - output.Clear(); - lastElement = input[input.Size()-1]; - inside = true; - if (lastElement.y > ey) { - inside = false; - } - for(int32_t iii=0; iii ey) { - if(true == inside) { - //EWOL_DEBUG("element IN ==> OUT "); - //new point intersection ... - //x=aaay+bbb - float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y); - float bbb = lastElement.x - (aaa*lastElement.y); - destPoint.y = ey; - destPoint.x = ey*aaa + bbb; - output.PushBack(destPoint); - } else { - //EWOL_DEBUG("element OUT ==> OUT "); - } - inside = false; - } else { - if(true == inside) { - //EWOL_DEBUG("element IN ==> IN "); - output.PushBack(input[iii]); - } else { - //EWOL_DEBUG("element OUT ==> IN "); - //new point intersection ... - //y=aaax+bbb - float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y); - float bbb = lastElement.x - (aaa*lastElement.y); - destPoint.y = ey; - destPoint.x = ey*aaa + bbb; - output.PushBack(destPoint); - output.PushBack(input[iii]); - } - inside = true; - } - // update the last point position : - lastElement.x = input[iii].x; - lastElement.y = input[iii].y; - } - - - //EWOL_DEBUG("generate an crop on element : " << sizeInit << " ==> " << output.Size() ); -} - - -void ewol::OObject2DColored::GenerateTriangle(void) -{ - m_triElement = 0; - - m_coord.PushBack(m_triangle[0]); - m_coordColor.PushBack(m_color[0]); - m_coord.PushBack(m_triangle[1]); - m_coordColor.PushBack(m_color[1]); - m_coord.PushBack(m_triangle[2]); - m_coordColor.PushBack(m_color[2]); -} - - -void ewol::OObject2DColored::SetColor(draw::Color color) -{ - if (m_triElement < 1) { - m_color[0] = color; - } - if (m_triElement < 2) { - m_color[1] = color; - } - if (m_triElement < 3) { - m_color[2] = color; - } -} - - -void ewol::OObject2DColored::SetColor(float red, float green, float blue, float alpha) -{ - if (m_triElement < 1) { - m_color[0] = draw::Color(red, green, blue, alpha); - } - if (m_triElement < 2) { - m_color[1] = draw::Color(red, green, blue, alpha); - } - if (m_triElement < 3) { - m_color[2] = draw::Color(red, green, blue, alpha); - } - -} - -void ewol::OObject2DColored::SetPoint(etk::Vector2D point) -{ - // TODO : Clean this : - etk::Vector2D tmpElement; - tmpElement.x = point.x; - tmpElement.y = point.y; - m_triangle[m_triElement] = tmpElement; - m_triElement++; - if (m_triElement>=3) { - GenerateTriangle(); - } -} - -void ewol::OObject2DColored::SetPoint(float x, float y) -{ - m_triangle[m_triElement].x = x; - m_triangle[m_triElement].y = y; - m_triElement++; - if (m_triElement>=3) { - GenerateTriangle(); - } -} - - -void ewol::OObject2DColored::ResetCount(void) -{ - m_triElement = 0; - m_color[1] = m_color[0]; - m_color[2] = m_color[0]; -} - -void ewol::OObject2DColored::Line(float sx, float sy, float ex, float ey, float thickness) -{ - ResetCount(); - if (sx == ex && sy == ey) { - EWOL_WARNING("Try to draw an line width 0"); - return; - } - //teta = tan-1(oposer/adjacent) - float teta = 0; - if (sx <= ex) { - teta = atan((ey-sy)/(ex-sx)); - } else { - teta = M_PI + atan((ey-sy)/(ex-sx)); - } - if (teta < 0) { - teta += 2*M_PI; - } else if (teta > 2*M_PI) { - teta -= 2*M_PI; - } - //EWOL_DEBUG("teta = " << (teta*180/(M_PI)) << " deg." ); - float offsety = sin(teta-M_PI/2) * (thickness/2); - float offsetx = cos(teta-M_PI/2) * (thickness/2); - - SetPoint(sx - offsetx, sy - offsety); - SetPoint(sx + offsetx, sy + offsety); - SetPoint(ex + offsetx, ey + offsety); - - SetPoint(ex + offsetx, ey + offsety); - SetPoint(ex - offsetx, ey - offsety); - SetPoint(sx - offsetx, sy - offsety); -} - -void ewol::OObject2DColored::Rectangle(float x, float y, float w, float h) -{ - ResetCount(); - /* - x += 3; - y += 3; - w -= 6; - h -= 6; - */ - /* Bitmap position - * xA xB - * yC *------* - * | | - * | | - * yD *------* - */ - float dxA = x; - float dxB = x + w; - float dyC = y; - float dyD = y + h; - - if (true == m_hasClipping) { - if (dxA < m_clipping.x) { - dxA = m_clipping.x; - } - if (dxB > m_clipping.x + m_clipping.w) { - dxB = m_clipping.x + m_clipping.w; - } - if (dyC < m_clipping.y) { - dyC = m_clipping.y; - } - if (dyD > m_clipping.y + m_clipping.h) { - dyD = m_clipping.y + m_clipping.h; - } - } - if( dyC >= dyD - || dxA >= dxB) { - return; - } - SetPoint(dxA, dyD); - SetPoint(dxA, dyC); - SetPoint(dxB, dyC); - - SetPoint(dxB, dyC); - SetPoint(dxB, dyD); - SetPoint(dxA, dyD); -} - -void ewol::OObject2DColored::RectangleBorder(float x, float y, float w, float h, float thickness) -{ - // TODO : This did not manage the thickness of the line ... - Line(x, y, x+w, y, thickness); - Line(x+w, y, x+w, y+h, thickness); - Line(x+w, y+h, x, y+h, thickness); - Line(x, y+h, x, y, thickness); -} - -void ewol::OObject2DColored::Circle(float x, float y, float radius, float thickness) -{ - ResetCount(); - if (radius<0) { - radius *= -1; - } - if (radius < thickness/2) { - Disc(x, y, thickness/2 + radius); - } - int32_t nbOcurence = radius; - if (nbOcurence < 10) - { - nbOcurence = 10; - } - for (int32_t iii=0; iii " << angleStop << " ocurence=" << (angleLinear*180/(M_PI)) ); - - int32_t nbOcurence = radius*0.50; - if (nbOcurence < 15) - { - nbOcurence = 15; - } - - // TODO : Generate a poligone instead if this ... - for (int32_t iii=0; iii -#include - -namespace ewol { - class OObject2DColored :public ewol::OObject - { - public: - OObject2DColored(void); - virtual ~OObject2DColored(void); - public: - virtual void Draw(void); - protected: - ewol::Program* m_GLprogram; - int32_t m_GLPosition; - int32_t m_GLMatrix; - int32_t m_GLColor; - etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordColor; //!< internal color of the different point - draw::Colorf m_color[3]; - int32_t m_triElement; - etk::Vector2D m_triangle[3]; - void GenerateTriangle(void); - void ResetCount(void); - public: - void Clear(void); - void SetColor(float red, float green, float blue, float alpha = 1.0); - void SetColor(draw::Color color); - void SetPoint(etk::Vector2D point); - void SetPoint(float x, float y); - void Line(float sx, float sy, float ex, float ey, float thickness); - void Rectangle(float x, float y, float w, float h); - void RectangleBorder(float x, float y, float w, float h, float thickness); - void Circle(float x, float y, float radius, float thickness); - void CirclePart(float x, float y, float radius, float thickness, float angleStart, float angleStop); - void Disc(float x, float y, float radius); - void DiscPart(float x, float y, float radius, float angleStart, float angleStop); - }; -}; - -#endif - diff --git a/sources/ewol/oObject/2DTextColored.cpp b/sources/ewol/oObject/2DTextColored.cpp deleted file mode 100644 index d69c58fa..00000000 --- a/sources/ewol/oObject/2DTextColored.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "ewol::OObject2DTextColored" - -void ewol::OObject2DTextColored::SetFontProperty(etk::UString fontName, int32_t fontSize) -{ - // remove old one - if (NULL != m_font) { - ewol::resource::Release(m_font); - m_font = NULL; - } - etk::UString tmpName = fontName; - tmpName += ":"; - tmpName += fontSize; - // link to new One - if (false == ewol::resource::Keep(tmpName, m_font)) { - EWOL_ERROR("Can not get font resource"); - } -} - -void ewol::OObject2DTextColored::SetFont(etk::UString fontName) -{ - // get old size - int32_t fontSize = ewol::font::GetDefaultSize(); - if (NULL != m_font) { - fontSize = m_font->GetFontSize(); - } - SetFontProperty(fontName, fontSize); -} - -void ewol::OObject2DTextColored::SetSize(int32_t fontSize) -{ - // get old size - etk::UString fontName = ewol::font::GetDefaultFont(); - if (NULL != m_font) { - fontName = m_font->GetName(); - } - SetFontProperty(fontName, fontSize); -} - -ewol::OObject2DTextColored::OObject2DTextColored(etk::UString fontName, int32_t size) : - m_font(NULL) -{ - m_color = draw::color::black; - SetFontProperty(fontName, size); - etk::UString tmpString("DATA:text.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - } -} - - -// open with default font ... -ewol::OObject2DTextColored::OObject2DTextColored(void) : - m_font(NULL) -{ - m_color = draw::color::black; - SetFontProperty(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize()); - etk::UString tmpString("DATA:text.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - } -} - - -ewol::OObject2DTextColored::~OObject2DTextColored(void) -{ - if (NULL != m_font) { - ewol::resource::Release(m_font); - m_font = NULL; - } - ewol::resource::Release(m_GLprogram); -} - -void ewol::OObject2DTextColored::Draw(void) -{ - if (m_coord.Size()<=0 || NULL == m_font) { - // TODO : a remètre ... - //EWOL_WARNING("Nothink to draw..."); - return; - } - if (m_font == NULL) { - EWOL_WARNING("no font..."); - return; - } - if (m_GLprogram==NULL) { - EWOL_ERROR("No shader ..."); - return; - } - m_GLprogram->Use(); - // set Matrix : translation/positionMatrix - etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix(); - m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); - // TextureID - m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId()); - // position : - m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]); - // Texture : - m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]); - // color : - m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); - // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - m_GLprogram->UnUse(); -} - -void ewol::OObject2DTextColored::Clear(void) -{ - m_coord.Clear(); - m_coordTex.Clear(); - m_coordColor.Clear(); - m_displayMode.Clear(); -} - -int32_t ewol::OObject2DTextColored::Text(etk::Vector2D textPos, const etk::UString& unicodeString, ewol::font::mode_te displayMode) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return 0; - } - int32_t nbElementInTheArray = m_coord.Size(); - int32_t size = 0; - size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex, m_displayMode, m_hasClipping, m_clipping, displayMode); - // set the color ... - for (int32_t iii=nbElementInTheArray; iii textPos, const uniChar_t unicodeChar, ewol::font::mode_te displayMode) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return 0; - } - int32_t nbElementInTheArray = m_coord.Size(); - int32_t size = 0; - size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex, m_displayMode, m_hasClipping, m_clipping, displayMode); - for (int32_t iii=nbElementInTheArray; iii ewol::OObject2DTextColored::GetSize(const uniChar_t unicodeChar) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return etk::Vector2D(0,0); - } - return m_font->GetSize(unicodeChar); -} - -etk::Vector2D ewol::OObject2DTextColored::GetSize(const etk::UString& unicodeString) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return etk::Vector2D(0,0); - } - return m_font->GetSize(unicodeString); -} - diff --git a/sources/ewol/oObject/2DTextColored.h b/sources/ewol/oObject/2DTextColored.h deleted file mode 100644 index 6a3a9080..00000000 --- a/sources/ewol/oObject/2DTextColored.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#ifndef __EWOL_O_OBJECT_2D_TEXT_COLORED_H__ -#define __EWOL_O_OBJECT_2D_TEXT_COLORED_H__ - -#include -#include -#include - -namespace ewol { - class OObject2DTextColored :public ewol::OObject - { - public: - OObject2DTextColored(etk::UString FontName, int32_t size); - OObject2DTextColored(void); - virtual ~OObject2DTextColored(void); - public: - virtual void Draw(void); - void SetColor(float red, float green, float blue, float alpha = 1.0); - void SetColor(draw::Color color); - // set a specific text - void Clear(void); - int32_t Text(etk::Vector2D textPos, const etk::UString& unicodeString, ewol::font::mode_te displayMode = ewol::font::Regular); - int32_t Text(etk::Vector2D textPos, const uniChar_t unicodeChar, ewol::font::mode_te displayMode = ewol::font::Regular); - protected: - ewol::Program* m_GLprogram; - int32_t m_GLPosition; - int32_t m_GLMatrix; - int32_t m_GLColor; - int32_t m_GLtextMode; - int32_t m_GLtexture; - int32_t m_GLtexID; - ewol::TexturedFont* m_font; //!< ewol font system - draw::Color m_color; //!< tmp text color ... - etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point - etk::Vector m_displayMode; //!< Display mode availlable (bold/...) - public: - void SetFont(etk::UString fontName); - void SetSize(int32_t fontSize); - void SetFontProperty(etk::UString fontName, int32_t fontSize); - int32_t GetHeight(void) { return (NULL!=m_font)?m_font->GetHeight():10; }; - etk::Vector2D GetSize(const uniChar_t unicodeChar); - etk::Vector2D GetSize(const etk::UString& unicodeString); - }; -}; - -#endif - diff --git a/sources/ewol/oObject/2DTextShader.cpp b/sources/ewol/oObject/2DTextShader.cpp deleted file mode 100644 index 5c4c2df4..00000000 --- a/sources/ewol/oObject/2DTextShader.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "ewol::OObject2DTextShader" - -float DF_SoftEdge_min = 0.45; -float DF_SoftEdge_max = 0.55; -int32_t DF_SoftEdge = 0; - - - -void ewol::OObject2DTextShader::SetFontProperty(etk::UString fontName, int32_t fontSize) -{ - // remove old one - if (NULL != m_font) { - ewol::resource::Release(m_font); - m_font = NULL; - } - etk::UString tmpName = fontName; - tmpName += ":"; - tmpName += fontSize; - // link to new One - if (false == ewol::resource::Keep(tmpName, m_font)) { - EWOL_ERROR("Can not get font resource"); - } -} - -void ewol::OObject2DTextShader::SetFont(etk::UString fontName) -{ - // get old size - int32_t fontSize = ewol::font::GetDefaultSize(); - if (NULL != m_font) { - fontSize = m_font->GetFontSize(); - } - SetFontProperty(fontName, fontSize); -} - -void ewol::OObject2DTextShader::SetSize(int32_t fontSize) -{ - // get old size - etk::UString fontName = ewol::font::GetDefaultFont(); - if (NULL != m_font) { - fontName = m_font->GetName(); - } - SetFontProperty(fontName, fontSize); -} - -ewol::OObject2DTextShader::OObject2DTextShader(etk::UString fontName, int32_t size) : - m_font(NULL) -{ - m_color = draw::color::black; - SetFontProperty(fontName, size); - etk::UString tmpString("DATA:fontDistanceField/font1.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - m_GLSoftEdgeMin = m_GLprogram->GetUniform("EW_SoftEdgeMin"); - m_GLSoftEdgeMax = m_GLprogram->GetUniform("EW_SoftEdgeMax"); - m_GLSoftEdge = m_GLprogram->GetUniform("EW_SoftEdge"); - } -} - - -// open with default font ... -ewol::OObject2DTextShader::OObject2DTextShader(void) : - m_font(NULL) -{ - m_color = draw::color::black; - SetFontProperty(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize()); - etk::UString tmpString("DATA:fontDistanceField/font1.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - m_GLSoftEdgeMin = m_GLprogram->GetUniform("EW_SoftEdgeMin"); - m_GLSoftEdgeMax = m_GLprogram->GetUniform("EW_SoftEdgeMax"); - m_GLSoftEdge = m_GLprogram->GetUniform("EW_SoftEdge"); - } -} - - -ewol::OObject2DTextShader::~OObject2DTextShader(void) -{ - if (NULL != m_font) { - ewol::resource::Release(m_font); - m_font = NULL; - } - ewol::resource::Release(m_GLprogram); -} - -void ewol::OObject2DTextShader::Draw(void) -{ - if (m_coord.Size()<=0 || NULL == m_font) { - // TODO : a remètre ... - //EWOL_WARNING("Nothink to draw..."); - return; - } - if (m_font == NULL) { - EWOL_WARNING("no font..."); - return; - } - if (m_GLprogram==NULL) { - EWOL_ERROR("No shader ..."); - return; - } - m_GLprogram->Use(); - // set Matrix : translation/positionMatrix - etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix(); - m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); - // TextureID - m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId()); - // position : - m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]); - // Texture : - m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]); - // color : - m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); - // set some other specific properties : - m_GLprogram->Uniform1f(m_GLSoftEdgeMin, DF_SoftEdge_min); - m_GLprogram->Uniform1f(m_GLSoftEdgeMax, DF_SoftEdge_max); - m_GLprogram->Uniform1i(m_GLSoftEdge, DF_SoftEdge); - // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - m_GLprogram->UnUse(); -} - -void ewol::OObject2DTextShader::Clear(void) -{ - m_coord.Clear(); - m_coordTex.Clear(); - m_coordColor.Clear(); -} - -int32_t ewol::OObject2DTextShader::Text(etk::Vector2D textPos, const etk::UString& unicodeString) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return 0; - } - int32_t nbElementInTheArray = m_coord.Size(); - int32_t size = 0; - if (true==m_hasClipping) { - size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex); - } else { - size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex); - } - // set the color ... - for (int32_t iii=nbElementInTheArray; iii textPos, const uniChar_t unicodeChar) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return 0; - } - int32_t nbElementInTheArray = m_coord.Size(); - int32_t size = 0; - if (true==m_hasClipping) { - size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex); - } else { - size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex); - } - for (int32_t iii=nbElementInTheArray; iii ewol::OObject2DTextShader::GetSize(const uniChar_t unicodeChar) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return etk::Vector2D(0,0); - } - return m_font->GetSize(unicodeChar); -} - -etk::Vector2D ewol::OObject2DTextShader::GetSize(const etk::UString& unicodeString) -{ - if (m_font == NULL) { - EWOL_ERROR("Font Id is not corectly defined"); - return etk::Vector2D(0,0); - } - return m_font->GetSize(unicodeString); -} - diff --git a/sources/ewol/oObject/2DTextShader.h b/sources/ewol/oObject/2DTextShader.h deleted file mode 100644 index b8c1eb5d..00000000 --- a/sources/ewol/oObject/2DTextShader.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#ifndef __EWOL_O_OBJECT_2D_TEXT_SHADER_H__ -#define __EWOL_O_OBJECT_2D_TEXT_SHADER_H__ - -#include -#include -#include - -namespace ewol { - class OObject2DTextShader :public ewol::OObject - { - public: - OObject2DTextShader(etk::UString FontName, int32_t size); - OObject2DTextShader(void); - virtual ~OObject2DTextShader(void); - public: - virtual void Draw(void); - void SetColor(float red, float green, float blue, float alpha = 1.0); - void SetColor(draw::Color color); - // set a specific text - void Clear(void); - int32_t Text(etk::Vector2D textPos, const etk::UString& unicodeString); - int32_t Text(etk::Vector2D textPos, const uniChar_t unicodeChar); - protected: - ewol::Program* m_GLprogram; - int32_t m_GLPosition; - int32_t m_GLMatrix; - int32_t m_GLColor; - int32_t m_GLtexture; - int32_t m_GLtexID; - int32_t m_GLSoftEdgeMin; - int32_t m_GLSoftEdgeMax; - int32_t m_GLSoftEdge; - ewol::DistantFieldFont* m_font; //!< ewol font system - draw::Color m_color; //!< tmp text color ... - etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point - bool m_bold; - bool m_italic; - public: - void SetBold(bool newVal) { m_bold=newVal; }; - void SetItalic(bool newVal) { m_italic=newVal; }; - void SetFont(etk::UString fontName); - void SetSize(int32_t fontSize); - void SetFontProperty(etk::UString fontName, int32_t fontSize); - int32_t GetHeight(void) { return (NULL!=m_font)?m_font->GetHeight():10; }; - etk::Vector2D GetSize(const uniChar_t unicodeChar); - etk::Vector2D GetSize(const etk::UString& unicodeString); - }; -}; - -#endif diff --git a/sources/ewol/oObject/2DTextured.cpp b/sources/ewol/oObject/2DTextured.cpp deleted file mode 100644 index 41a0a4aa..00000000 --- a/sources/ewol/oObject/2DTextured.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include -#include - -#undef __class__ -#define __class__ "ewol::OObject2DTextured" - - -ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX, float sizeY) -{ - EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\""); - ewol::TextureFile* resourceFile = NULL; - if (false == ewol::resource::Keep(textureName, resourceFile, etk::Vector2D(sizeX,sizeY)) ) { - EWOL_CRITICAL("can not get a resource Texture"); - } - m_resource = resourceFile; - etk::UString tmpString("DATA:textured.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - } -} - -ewol::OObject2DTextured::OObject2DTextured( float sizeX, float sizeY) -{ - if (false == ewol::resource::Keep(m_resource) ) { - EWOL_CRITICAL("can not get a resource Texture"); - } - if (NULL!=m_resource) { - m_resource->SetImageSize(etk::Vector2D(sizeX,sizeY)); - draw::Image& tmpImage = m_resource->Get(); - tmpImage.SetFillColor(draw::color::black); - tmpImage.Clear(); - m_resource->Flush(); - } - etk::UString tmpString("DATA:textured.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - } -} - - -ewol::OObject2DTextured::~OObject2DTextured(void) -{ - if (NULL != m_resource) { - ewol::resource::Release(m_resource); - } - ewol::resource::Release(m_GLprogram); -} - -void ewol::OObject2DTextured::Draw(void) -{ - if (m_coord.Size()<=0) { - return; - } - if (NULL == m_resource) { - EWOL_WARNING("Texture does not exist ..."); - return; - } - if (m_GLprogram==NULL) { - EWOL_ERROR("No shader ..."); - return; - } - m_GLprogram->Use(); - // set Matrix : translation/positionMatrix - etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix(); - m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); - // TextureID - m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId()); - // position : - m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]); - // Texture : - m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]); - // color : - m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); - // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - m_GLprogram->UnUse(); -} - -void ewol::OObject2DTextured::Clear(void) -{ - m_coord.Clear(); - m_coordTex.Clear(); - m_coordColor.Clear(); -} - -void ewol::OObject2DTextured::Rectangle(float x, float y, float w, float h, draw::Color tmpColor) -{ - Rectangle(x, y, w, h, 0.0, 0.0, 1.0, 1.0, tmpColor); -} - -void ewol::OObject2DTextured::Rectangle(float x, float y, float w, float h, float texX, float texY, float texSX, float texSY, draw::Color tmpColor) -{ - /* - x += 3; - y += 3; - w -= 6; - h -= 6; - */ - //EWOL_DEBUG("Add rectangle : ..."); - etk::Vector2D point; - texCoord_ts tex; - - tex.u = texX; - tex.v = texSY; - point.x = x; - point.y = y; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - - tex.u = texSX; - tex.v = texSY; - point.x = x + w; - point.y = y; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - - tex.u = texSX; - tex.v = texY; - point.x = x + w; - point.y = y + h; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - tex.u = texX; - tex.v = texY; - point.x = x; - point.y = y + h; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - tex.u = texX; - tex.v = texSY; - point.x = x; - point.y = y; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); -} diff --git a/sources/ewol/oObject/2DTextured.h b/sources/ewol/oObject/2DTextured.h deleted file mode 100644 index 3af72863..00000000 --- a/sources/ewol/oObject/2DTextured.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#ifndef __EWOL_O_OBJECT_2D_TEXTURED_H__ -#define __EWOL_O_OBJECT_2D_TEXTURED_H__ - -#include -#include - -namespace ewol { - class OObject2DTextured :public ewol::OObject - { - public: - OObject2DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1); - OObject2DTextured(float sizeX=-1, float sizeY=-1); - virtual ~OObject2DTextured(void); - public: - virtual void Draw(void); - void Clear(void); - void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0, draw::Color tmpColor=draw::color::white); - void Rectangle(float x, float y, float w, float h, draw::Color tmpColor); - protected: - ewol::Program* m_GLprogram; - int32_t m_GLPosition; - int32_t m_GLMatrix; - int32_t m_GLColor; - int32_t m_GLtexture; - int32_t m_GLtexID; - ewol::Texture* m_resource; //!< texture resources - etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point - public: - draw::Image* GetImage(void) - { - if (NULL == m_resource) { - return NULL; - } - draw::Image& tmpImage = m_resource->Get(); - return &tmpImage; - }; - void Flush(void) - { - if (NULL != m_resource) { - m_resource->Flush(); - } - } - }; -}; - -#endif - diff --git a/sources/ewol/oObject/3DTextured.cpp b/sources/ewol/oObject/3DTextured.cpp deleted file mode 100644 index 90929102..00000000 --- a/sources/ewol/oObject/3DTextured.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include - -#undef __class__ -#define __class__ "ewol::OObject3DTextured" - - -ewol::OObject3DTextured::OObject3DTextured(etk::UString textureName, float sizeX, float sizeY) -{ - EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\""); - if (false == ewol::resource::Keep(textureName, m_resource, etk::Vector2D(sizeX,sizeY)) ) { - EWOL_CRITICAL("can not get a resource Texture"); - } - etk::UString tmpString("DATA:textured3D.prog"); - // get the shader resource : - m_GLPosition = 0; - if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { - m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d"); - m_GLColor = m_GLprogram->GetAttribute("EW_color"); - m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->GetUniform("EW_texID"); - } -} - - -ewol::OObject3DTextured::~OObject3DTextured(void) -{ - if (NULL != m_resource) { - ewol::resource::Release(m_resource); - } - ewol::resource::Release(m_GLprogram); -} - -void ewol::OObject3DTextured::Draw(void) -{ - if (m_coord.Size()<=0) { - return; - } - if (NULL == m_resource) { - EWOL_WARNING("Texture does not exist ..."); - return; - } - if (m_GLprogram==NULL) { - EWOL_ERROR("No shader ..."); - return; - } - //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); - m_GLprogram->Use(); - // set Matrix : translation/positionMatrix - etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix(); - m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); - // TextureID - m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId()); - // position : - m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_coord[0]); - // Texture : - m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]); - // color : - m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); - // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_coord.Size()); - m_GLprogram->UnUse(); -} - -void ewol::OObject3DTextured::Clear(void) -{ - m_coord.Clear(); - m_coordTex.Clear(); - m_coordColor.Clear(); -} - -void ewol::OObject3DTextured::Rectangle(float x, float y, float w, float h, draw::Color tmpColor) -{ - Rectangle(x, y, w, h, 0.0, 0.0, 1.0, 1.0, tmpColor); -} - -void ewol::OObject3DTextured::Rectangle(float x, float y, float w, float h, float texX, float texY, float texSX, float texSY, draw::Color tmpColor) -{ - /* - x += 3; - y += 3; - w -= 6; - h -= 6; - */ - //EWOL_DEBUG("Add rectangle : ..."); - etk::Vector3D point; - texCoord_ts tex; - point.z = 0; - - tex.u = texX; - tex.v = texSY; - point.x = x; - point.y = y; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - - tex.u = texSX; - tex.v = texSY; - point.x = x + w; - point.y = y; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - - tex.u = texSX; - tex.v = texY; - point.x = x + w; - point.y = y + h; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - tex.u = texX; - tex.v = texY; - point.x = x; - point.y = y + h; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); - - tex.u = texX; - tex.v = texSY; - point.x = x; - point.y = y; - m_coord.PushBack(point); - m_coordTex.PushBack(tex); - m_coordColor.PushBack(tmpColor); -} diff --git a/sources/ewol/oObject/3DTextured.h b/sources/ewol/oObject/3DTextured.h deleted file mode 100644 index 961a903a..00000000 --- a/sources/ewol/oObject/3DTextured.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#ifndef __EWOL_O_OBJECT_3D_TEXTURED_H__ -#define __EWOL_O_OBJECT_3D_TEXTURED_H__ - -#include -#include - -namespace ewol { - class OObject3DTextured :public ewol::OObject - { - public: - OObject3DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1); - virtual ~OObject3DTextured(void); - public: - virtual void Draw(void); - void Clear(void); - void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0, draw::Color tmpColor=draw::color::white); - void Rectangle(float x, float y, float w, float h, draw::Color tmpColor); - protected: - ewol::Program* m_GLprogram; - int32_t m_GLPosition; - int32_t m_GLMatrix; - int32_t m_GLColor; - int32_t m_GLtexture; - int32_t m_GLtexID; - ewol::TextureFile* m_resource; //!< texture resources - etk::Vector > m_coord; //!< internal coord of the object - etk::Vector m_coordTex; //!< internal texture coordinate for every point - etk::Vector m_coordColor; //!< internal color of the different point - }; -}; - -#endif - diff --git a/sources/ewol/oObject/OObject.cpp b/sources/ewol/oObject/OObject.cpp deleted file mode 100644 index 8977cac4..00000000 --- a/sources/ewol/oObject/OObject.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include - - -#undef __class__ -#define __class__ "ewol::OObject" - - -ewol::OObject::OObject(void) -{ - m_hasClipping = false; - m_scaling.x = 1.0; - m_scaling.y = 1.0; - m_clipping.x = 0; - m_clipping.y = 0; - m_clipping.w = 1024; - m_clipping.h = 1024; - m_nbLoadedTime = 1; -} - - -ewol::OObject::~OObject(void) -{ - -} - diff --git a/sources/ewol/oObject/OObject.h b/sources/ewol/oObject/OObject.h deleted file mode 100644 index 34fad201..00000000 --- a/sources/ewol/oObject/OObject.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_O_OBJECT_H__ -#define __EWOL_O_OBJECT_H__ - -#include -#include -#include -#include -#include - -namespace ewol { - extern "C" { - typedef struct { - int32_t f; - int32_t s; - int32_t t; - }linkCoord_ts; - }; - - class OObject - { - protected: - int32_t m_nbLoadedTime; //!< specific in case of non multiple allocation - bool m_hasClipping; - clipping_ts m_clipping; - etk::Vector2D m_scaling; //!< scaling ol the object - public: - OObject(void); - virtual ~OObject(void); - void clippingSet(clipping_ts clip) {m_clipping = clip; m_hasClipping = true;}; - void clippingDisable(void) {m_hasClipping = false;}; - void clippingEnable(void) {m_hasClipping = true;}; - void scalingSet(etk::Vector2D scale) {m_scaling = scale;}; - virtual void Draw(void) = 0; - /** - * @brief Increase the number of element registered on this class ==> this is specific to decrese the memory usage in special case (scene) - */ - void IncreaseLoadedTime(void) { m_nbLoadedTime++;}; - /** - * @brief Decrease the number of element registered on this class ==> this is specific to decrese the memory usage in special case (scene) - * @return true, if no more element registered on it ... - */ - bool DecreaseLoadedTime(void) { m_nbLoadedTime--; if (m_nbLoadedTime <= 0) { return true;} else { return false;} }; - }; -}; - -#endif - - -#include -#include -#include -#include diff --git a/sources/ewol/oObject/Sprite.cpp b/sources/ewol/oObject/Sprite.cpp deleted file mode 100644 index 8d55c03b..00000000 --- a/sources/ewol/oObject/Sprite.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include -#include - -#undef __class__ -#define __class__ "Sprite" - - -ewol::Sprite::Sprite(etk::UString spriteName, float sizeX, float sizeY) : - ewol::OObject3DTextured(spriteName, sizeX, sizeY) -{ - m_name = spriteName; -} - - -ewol::Sprite::~Sprite(void) -{ - -} - -void ewol::Sprite::Element(etk::Vector2D pos, float size, float angle) -{ - draw::Color tmpColor(0xFFFFFFFF); - etk::Vector3D pos2; - pos2.x = pos.x; - pos2.y = pos.y; - pos2.z = 0.0; - Element(pos2, size, angle, tmpColor); -} - -void ewol::Sprite::Element(etk::Vector3D pos, float size, float angle) -{ - draw::Color tmpColor(0xFFFFFFFF); - Element(pos, size, angle, tmpColor); -} - -void ewol::Sprite::Element(etk::Vector2D pos, float size, float angle, draw::Color tmpColor) -{ - etk::Vector3D pos2; - pos2.x = pos.x; - pos2.y = pos.y; - pos2.z = 0.0; - Element(pos2, size, angle, tmpColor); -} - - -void ewol::Sprite::Element(etk::Vector3D pos, float size, float angle, draw::Color tmpColor) -{ - angle -= M_PI/4; - size *= 0.7; - texCoord_ts texA, texB, texC, texD; - texA.u = 0.0; - texA.v = 0.0; - texB.u = 0.0; - texB.v = 1.0; - texC.u = 1.0; - texC.v = 1.0; - texD.u = 1.0; - texD.v = 0.0; - - draw::Colorf localColor = tmpColor; - etk::Vector3D point = pos; - float yyySin = sin(angle) * size; - float xxxCos = cos(angle) * size; - - point.x = xxxCos + pos.x; - point.y = yyySin + pos.y; - m_coord.PushBack(point); - m_coordTex.PushBack(texB); - m_coordColor.PushBack(localColor); - - point.x = yyySin + pos.x; - point.y = -xxxCos + pos.y; - m_coord.PushBack(point); - m_coordTex.PushBack(texC); - m_coordColor.PushBack(localColor); - - point.x = -xxxCos + pos.x; - point.y = -yyySin + pos.y; - m_coord.PushBack(point); - m_coordTex.PushBack(texD); - m_coordColor.PushBack(localColor); - - m_coord.PushBack(point); - m_coordTex.PushBack(texD); - m_coordColor.PushBack(localColor); - - point.x = -yyySin + pos.x; - point.y = xxxCos + pos.y; - m_coord.PushBack(point); - m_coordTex.PushBack(texA); - m_coordColor.PushBack(localColor); - - point.x = xxxCos + pos.x; - point.y = yyySin + pos.y; - m_coord.PushBack(point); - m_coordTex.PushBack(texB); - m_coordColor.PushBack(localColor); -} - diff --git a/sources/ewol/oObject/Sprite.h b/sources/ewol/oObject/Sprite.h deleted file mode 100644 index cbaba027..00000000 --- a/sources/ewol/oObject/Sprite.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_O_OBJECT_SPRITE_H__ -#define __EWOL_O_OBJECT_SPRITE_H__ - -#include -#include - -namespace ewol { - class Sprite :public ewol::OObject3DTextured - { - private: - etk::UString m_name; - public: - Sprite(etk::UString spriteName, float sizeX=-1, float sizeY=-1); - virtual ~Sprite(void); - void Element(etk::Vector2D pos, float size, float angle); - void Element(etk::Vector3D pos, float size, float angle); - void Element(etk::Vector2D pos, float size, float angle, draw::Color tmpColor); - void Element(etk::Vector3D pos, float size, float angle, draw::Color tmpColor); - bool HasName(etk::UString& name) { return name == m_name; }; - }; -}; - -#endif - diff --git a/sources/ewol/ResourceManager.cpp b/sources/ewol/renderer/ResourceManager.cpp similarity index 100% rename from sources/ewol/ResourceManager.cpp rename to sources/ewol/renderer/ResourceManager.cpp diff --git a/sources/ewol/ResourceManager.h b/sources/ewol/renderer/ResourceManager.h similarity index 100% rename from sources/ewol/ResourceManager.h rename to sources/ewol/renderer/ResourceManager.h diff --git a/sources/ewol/audio/audio.cpp b/sources/ewol/renderer/audio/audio.cpp similarity index 100% rename from sources/ewol/audio/audio.cpp rename to sources/ewol/renderer/audio/audio.cpp diff --git a/sources/ewol/audio/audio.h b/sources/ewol/renderer/audio/audio.h similarity index 100% rename from sources/ewol/audio/audio.h rename to sources/ewol/renderer/audio/audio.h diff --git a/sources/ewol/audio/decWav.cpp b/sources/ewol/renderer/audio/decWav.cpp similarity index 100% rename from sources/ewol/audio/decWav.cpp rename to sources/ewol/renderer/audio/decWav.cpp diff --git a/sources/ewol/audio/decWav.h b/sources/ewol/renderer/audio/decWav.h similarity index 100% rename from sources/ewol/audio/decWav.h rename to sources/ewol/renderer/audio/decWav.h diff --git a/sources/ewol/audio/interfacePortAudio.cpp b/sources/ewol/renderer/audio/interfacePortAudio.cpp similarity index 100% rename from sources/ewol/audio/interfacePortAudio.cpp rename to sources/ewol/renderer/audio/interfacePortAudio.cpp diff --git a/sources/ewol/audio/interfacePortAudio.h b/sources/ewol/renderer/audio/interfacePortAudio.h similarity index 100% rename from sources/ewol/audio/interfacePortAudio.h rename to sources/ewol/renderer/audio/interfacePortAudio.h diff --git a/sources/ewol/openGL/openGL.cpp b/sources/ewol/renderer/openGL/openGL.cpp similarity index 100% rename from sources/ewol/openGL/openGL.cpp rename to sources/ewol/renderer/openGL/openGL.cpp diff --git a/sources/ewol/openGL/openGL.h b/sources/ewol/renderer/openGL/openGL.h similarity index 100% rename from sources/ewol/openGL/openGL.h rename to sources/ewol/renderer/openGL/openGL.h diff --git a/sources/ewol/os/Fps.h b/sources/ewol/renderer/os/Fps.h similarity index 100% rename from sources/ewol/os/Fps.h rename to sources/ewol/renderer/os/Fps.h diff --git a/sources/ewol/os/eSystem.cpp b/sources/ewol/renderer/os/eSystem.cpp similarity index 100% rename from sources/ewol/os/eSystem.cpp rename to sources/ewol/renderer/os/eSystem.cpp diff --git a/sources/ewol/os/eSystem.h b/sources/ewol/renderer/os/eSystem.h similarity index 100% rename from sources/ewol/os/eSystem.h rename to sources/ewol/renderer/os/eSystem.h diff --git a/sources/ewol/os/eSystemInput.cpp b/sources/ewol/renderer/os/eSystemInput.cpp similarity index 100% rename from sources/ewol/os/eSystemInput.cpp rename to sources/ewol/renderer/os/eSystemInput.cpp diff --git a/sources/ewol/os/eSystemInput.h b/sources/ewol/renderer/os/eSystemInput.h similarity index 100% rename from sources/ewol/os/eSystemInput.h rename to sources/ewol/renderer/os/eSystemInput.h diff --git a/sources/ewol/os/gui.Android.base.cpp b/sources/ewol/renderer/os/gui.Android.base.cpp similarity index 100% rename from sources/ewol/os/gui.Android.base.cpp rename to sources/ewol/renderer/os/gui.Android.base.cpp diff --git a/sources/ewol/os/gui.Android.cpp b/sources/ewol/renderer/os/gui.Android.cpp similarity index 100% rename from sources/ewol/os/gui.Android.cpp rename to sources/ewol/renderer/os/gui.Android.cpp diff --git a/sources/ewol/os/gui.Example.cpp b/sources/ewol/renderer/os/gui.Example.cpp similarity index 100% rename from sources/ewol/os/gui.Example.cpp rename to sources/ewol/renderer/os/gui.Example.cpp diff --git a/sources/ewol/os/gui.IOs.cpp b/sources/ewol/renderer/os/gui.IOs.cpp similarity index 100% rename from sources/ewol/os/gui.IOs.cpp rename to sources/ewol/renderer/os/gui.IOs.cpp diff --git a/sources/ewol/os/gui.MacOs.cpp b/sources/ewol/renderer/os/gui.MacOs.cpp similarity index 100% rename from sources/ewol/os/gui.MacOs.cpp rename to sources/ewol/renderer/os/gui.MacOs.cpp diff --git a/sources/ewol/os/gui.Windows.cpp b/sources/ewol/renderer/os/gui.Windows.cpp similarity index 100% rename from sources/ewol/os/gui.Windows.cpp rename to sources/ewol/renderer/os/gui.Windows.cpp diff --git a/sources/ewol/os/gui.X11.cpp b/sources/ewol/renderer/os/gui.X11.cpp similarity index 97% rename from sources/ewol/os/gui.X11.cpp rename to sources/ewol/renderer/os/gui.X11.cpp index c1865121..ddcc7ce6 100644 --- a/sources/ewol/os/gui.X11.cpp +++ b/sources/ewol/renderer/os/gui.X11.cpp @@ -365,6 +365,25 @@ void AddDecoration(void) } } +static void setVSync(bool sync) +{ + // Function pointer for the wgl extention function we need to enable/disable + typedef int32_t (APIENTRY *PFNWGLSWAPINTERVALPROC)( int ); + PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; + const char *extensions = (char*)glGetString( GL_EXTENSIONS ); + if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 ) { + EWOL_ERROR("Can not set the vertical synchronisation status" << sync); + return; + } else { + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)glXGetProcAddress( (const GLubyte *)"wglSwapIntervalEXT" ); + if(wglSwapIntervalEXT) { + wglSwapIntervalEXT(sync); + } else { + EWOL_ERROR("Can not set the vertical synchronisation status" << sync); + } + } +} + bool CreateOGlContext(void) { #ifdef DEBUG_X11_EVENT @@ -379,6 +398,10 @@ bool CreateOGlContext(void) } else { EWOL_INFO("XF86 DRI NOT available\n"); } + + // Enable vertical synchronisation : (some computer has synchronisation disable) + setVSync(true); + return true; } diff --git a/sources/ewol/os/gui.h b/sources/ewol/renderer/os/gui.h similarity index 100% rename from sources/ewol/os/gui.h rename to sources/ewol/renderer/os/gui.h diff --git a/sources/ewol/SimpleConfigFile.cpp b/sources/ewol/renderer/resources/Config.cpp similarity index 100% rename from sources/ewol/SimpleConfigFile.cpp rename to sources/ewol/renderer/resources/Config.cpp diff --git a/sources/ewol/SimpleConfigFile.h b/sources/ewol/renderer/resources/Config.h similarity index 100% rename from sources/ewol/SimpleConfigFile.h rename to sources/ewol/renderer/resources/Config.h diff --git a/sources/ewol/font/TexturedFont.cpp b/sources/ewol/renderer/resources/Font.cpp similarity index 100% rename from sources/ewol/font/TexturedFont.cpp rename to sources/ewol/renderer/resources/Font.cpp diff --git a/sources/ewol/font/TexturedFont.h b/sources/ewol/renderer/resources/Font.h similarity index 100% rename from sources/ewol/font/TexturedFont.h rename to sources/ewol/renderer/resources/Font.h diff --git a/sources/ewol/font/FontFreeType.cpp b/sources/ewol/renderer/resources/FontFreeType.cpp similarity index 100% rename from sources/ewol/font/FontFreeType.cpp rename to sources/ewol/renderer/resources/FontFreeType.cpp diff --git a/sources/ewol/font/FontFreeType.h b/sources/ewol/renderer/resources/FontFreeType.h similarity index 100% rename from sources/ewol/font/FontFreeType.h rename to sources/ewol/renderer/resources/FontFreeType.h diff --git a/sources/ewol/texture/TextureFile.cpp b/sources/ewol/renderer/resources/Image.cpp similarity index 100% rename from sources/ewol/texture/TextureFile.cpp rename to sources/ewol/renderer/resources/Image.cpp diff --git a/sources/ewol/texture/TextureFile.h b/sources/ewol/renderer/resources/Image.h similarity index 100% rename from sources/ewol/texture/TextureFile.h rename to sources/ewol/renderer/resources/Image.h diff --git a/sources/ewol/Mesh/Mesh.cpp b/sources/ewol/renderer/resources/Mesh.cpp similarity index 95% rename from sources/ewol/Mesh/Mesh.cpp rename to sources/ewol/renderer/resources/Mesh.cpp index dd516acb..565227d4 100644 --- a/sources/ewol/Mesh/Mesh.cpp +++ b/sources/ewol/renderer/resources/Mesh.cpp @@ -15,7 +15,7 @@ ewol::Mesh::Mesh(etk::UString genName) : ewol::Resource(genName), m_texture1(NULL) { - etk::UString tmpString("textured3D.prog"); + etk::UString tmpString("DATA:textured3D.prog"); // get the shader resource : m_GLPosition = 0; if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) { @@ -56,6 +56,7 @@ void ewol::Mesh::Draw(void) EWOL_ERROR("No shader ..."); return; } + glEnable(GL_DEPTH_TEST); //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); m_GLprogram->Use(); // set Matrix : translation/positionMatrix @@ -78,5 +79,6 @@ void ewol::Mesh::Draw(void) // Request the draw od the elements : glDrawArrays(GL_TRIANGLES, 0, m_vertices.Size()); m_GLprogram->UnUse(); + glDisable(GL_DEPTH_TEST); } diff --git a/sources/ewol/Mesh/Mesh.h b/sources/ewol/renderer/resources/Mesh.h similarity index 100% rename from sources/ewol/Mesh/Mesh.h rename to sources/ewol/renderer/resources/Mesh.h diff --git a/sources/ewol/Mesh/MeshObj.cpp b/sources/ewol/renderer/resources/MeshObj.cpp similarity index 95% rename from sources/ewol/Mesh/MeshObj.cpp rename to sources/ewol/renderer/resources/MeshObj.cpp index 72e67525..68d716a0 100644 --- a/sources/ewol/Mesh/MeshObj.cpp +++ b/sources/ewol/renderer/resources/MeshObj.cpp @@ -16,7 +16,7 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) : ewol::Mesh(_fileName) { - etk::FSNode fileName(etk::UString("DATA:") + _fileName); + etk::FSNode fileName(_fileName); // Get the fileSize ... int32_t size = fileName.FileSize(); if (size == 0 ) { @@ -27,7 +27,7 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) : EWOL_ERROR("Can not find the file name=\"" << fileName << "\""); return; } - char inputDataLine[2018]; + char inputDataLine[2048]; etk::Vector indicesVertices; @@ -104,7 +104,8 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) : EWOL_INFO("Release previous loaded texture ... "); ewol::resource::Release(m_texture1); } - if (false == ewol::resource::Keep(tmpVal, m_texture1, tmpSize)) { + etk::UString tmpFilename = fileName.GetRelativeFolder() + tmpVal; + if (false == ewol::resource::Keep(tmpFilename, m_texture1, tmpSize)) { EWOL_ERROR("Can not load specific texture : " << tmpVal); } } else if( inputDataLine[0]=='m' diff --git a/sources/ewol/Mesh/MeshObj.h b/sources/ewol/renderer/resources/MeshObj.h similarity index 100% rename from sources/ewol/Mesh/MeshObj.h rename to sources/ewol/renderer/resources/MeshObj.h diff --git a/sources/ewol/openGL/Program.cpp b/sources/ewol/renderer/resources/Program.cpp similarity index 81% rename from sources/ewol/openGL/Program.cpp rename to sources/ewol/renderer/resources/Program.cpp index 17513a45..7bceb9d5 100644 --- a/sources/ewol/openGL/Program.cpp +++ b/sources/ewol/renderer/resources/Program.cpp @@ -404,56 +404,6 @@ void ewol::Program::Uniform4i(int32_t idElem, int32_t value1, int32_t value2, in checkGlError("glUniform4i", __LINE__); } -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::Program::Uniform1ui(int32_t idElem, uint32_t value1) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - glUniform1ui(m_elementList[idElem].m_elementId, value1); - checkGlError("glUniform1ui", __LINE__); -} -void ewol::Program::Uniform2ui(int32_t idElem, uint32_t value1, uint32_t value2) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - glUniform2ui(m_elementList[idElem].m_elementId, value1, value2); - checkGlError("glUniform2ui", __LINE__); -} -void ewol::Program::Uniform3ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - glUniform3ui(m_elementList[idElem].m_elementId, value1, value2, value3); - checkGlError("glUniform3ui", __LINE__); -} -void ewol::Program::Uniform4ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3, uint32_t value4) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - glUniform4ui(m_elementList[idElem].m_elementId, value1, value2, value3, value4); - checkGlError("glUniform4ui", __LINE__); -} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -621,88 +571,6 @@ void ewol::Program::Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value checkGlError("glUniform4iv", __LINE__); } -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::Program::Uniform1uiv(int32_t idElem, int32_t nbElement, uint32_t *value) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - if (0==nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (NULL==value) { - EWOL_ERROR("NULL Input pointer to send at open GL ..."); - return; - } - glUniform1uiv(m_elementList[idElem].m_elementId, nbElement, value); - checkGlError("glUniform1uiv", __LINE__); -} -void ewol::Program::Uniform2uiv(int32_t idElem, int32_t nbElement, uint32_t *value) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - if (0==nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (NULL==value) { - EWOL_ERROR("NULL Input pointer to send at open GL ..."); - return; - } - glUniform2uiv(m_elementList[idElem].m_elementId, nbElement, value); - checkGlError("glUniform2uiv", __LINE__); -} -void ewol::Program::Uniform3uiv(int32_t idElem, int32_t nbElement, uint32_t *value) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - if (0==nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (NULL==value) { - EWOL_ERROR("NULL Input pointer to send at open GL ..."); - return; - } - glUniform3uiv(m_elementList[idElem].m_elementId, nbElement, value); - checkGlError("glUniform3uiv", __LINE__); -} -void ewol::Program::Uniform4uiv(int32_t idElem, int32_t nbElement, uint32_t *value) -{ - if (idElem<0 || idElem>m_elementList.Size()) { - EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]"); - return; - } - if (false == m_elementList[idElem].m_isLinked) { - return; - } - if (0==nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (NULL==value) { - EWOL_ERROR("NULL Input pointer to send at open GL ..."); - return; - } - glUniform4uiv(m_elementList[idElem].m_elementId, nbElement, value); - checkGlError("glUniform4uiv", __LINE__); -} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/sources/ewol/openGL/Program.h b/sources/ewol/renderer/resources/Program.h similarity index 79% rename from sources/ewol/openGL/Program.h rename to sources/ewol/renderer/resources/Program.h index d4b35aad..6958dbec 100644 --- a/sources/ewol/openGL/Program.h +++ b/sources/ewol/renderer/resources/Program.h @@ -157,37 +157,6 @@ namespace ewol */ void Uniform4i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3, int32_t value4); - /** - * @brief Send 1 unsigned integer uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] value1 Value to send at the Uniform - */ - void Uniform1ui(int32_t idElem, uint32_t value1); - /** - * @brief Send 2 unsigned integer uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] value1 Value to send at the Uniform - * @param[in] value2 Value to send at the Uniform - */ - void Uniform2ui(int32_t idElem, uint32_t value1, uint32_t value2); - /** - * @brief Send 3 unsigned integer uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] value1 Value to send at the Uniform - * @param[in] value2 Value to send at the Uniform - * @param[in] value3 Value to send at the Uniform - */ - void Uniform3ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3); - /** - * @brief Send 4 unsigned integer uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] value1 Value to send at the Uniform - * @param[in] value2 Value to send at the Uniform - * @param[in] value3 Value to send at the Uniform - * @param[in] value4 Value to send at the Uniform - */ - void Uniform4ui(int32_t idElem, uint32_t value1, uint32_t value2, uint32_t value3, uint32_t value4); - /** * @brief Send "vec1" uniform element to the spefified ID (not send if does not really exist in the OpenGL program) * @param[in] idElem Id of the uniform that might be sended. @@ -246,35 +215,6 @@ namespace ewol */ void Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value); - /** - * @brief Send "uvec1" uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the Attribute that might be sended. - * @param[in] nbElement Number of element sended - * @param[in] value Pointer on the data - */ - void Uniform1uiv(int32_t idElem, int32_t nbElement, uint32_t *value); - /** - * @brief Send "uvec2" uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] nbElement Number of element sended - * @param[in] value Pointer on the data - */ - void Uniform2uiv(int32_t idElem, int32_t nbElement, uint32_t *value); - /** - * @brief Send "uvec3" uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] nbElement Number of element sended - * @param[in] value Pointer on the data - */ - void Uniform3uiv(int32_t idElem, int32_t nbElement, uint32_t *value); - /** - * @brief Send "uvec4" uniform element to the spefified ID (not send if does not really exist in the OpenGL program) - * @param[in] idElem Id of the uniform that might be sended. - * @param[in] nbElement Number of element sended - * @param[in] value Pointer on the data - */ - void Uniform4uiv(int32_t idElem, int32_t nbElement, uint32_t *value); - /** * @brief Request the processing of this program */ diff --git a/sources/ewol/Resource.h b/sources/ewol/renderer/resources/Resource.h similarity index 100% rename from sources/ewol/Resource.h rename to sources/ewol/renderer/resources/Resource.h diff --git a/sources/ewol/openGL/Shader.cpp b/sources/ewol/renderer/resources/Shader.cpp similarity index 100% rename from sources/ewol/openGL/Shader.cpp rename to sources/ewol/renderer/resources/Shader.cpp diff --git a/sources/ewol/openGL/Shader.h b/sources/ewol/renderer/resources/Shader.h similarity index 100% rename from sources/ewol/openGL/Shader.h rename to sources/ewol/renderer/resources/Shader.h diff --git a/sources/ewol/texture/Texture.cpp b/sources/ewol/renderer/resources/Texture.cpp similarity index 100% rename from sources/ewol/texture/Texture.cpp rename to sources/ewol/renderer/resources/Texture.cpp diff --git a/sources/ewol/texture/Texture.h b/sources/ewol/renderer/resources/Texture.h similarity index 100% rename from sources/ewol/texture/Texture.h rename to sources/ewol/renderer/resources/Texture.h diff --git a/sources/ewol/openGL/VirtualBufferObject.cpp b/sources/ewol/renderer/resources/VirtualBufferObject.cpp similarity index 100% rename from sources/ewol/openGL/VirtualBufferObject.cpp rename to sources/ewol/renderer/resources/VirtualBufferObject.cpp diff --git a/sources/ewol/openGL/VirtualBufferObject.h b/sources/ewol/renderer/resources/VirtualBufferObject.h similarity index 100% rename from sources/ewol/openGL/VirtualBufferObject.h rename to sources/ewol/renderer/resources/VirtualBufferObject.h diff --git a/sources/ewol/font/Font.h b/sources/ewol/renderer/resources/font/Font.h similarity index 100% rename from sources/ewol/font/Font.h rename to sources/ewol/renderer/resources/font/Font.h diff --git a/sources/ewol/font/GlyphProperty.h b/sources/ewol/renderer/resources/font/GlyphProperty.h similarity index 100% rename from sources/ewol/font/GlyphProperty.h rename to sources/ewol/renderer/resources/font/GlyphProperty.h diff --git a/sources/ewol/font/Kerning.h b/sources/ewol/renderer/resources/font/Kerning.h similarity index 100% rename from sources/ewol/font/Kerning.h rename to sources/ewol/renderer/resources/font/Kerning.h diff --git a/sources/ewol/texture/TextureBMP.cpp b/sources/ewol/renderer/resources/image/ImageBMP.cpp similarity index 100% rename from sources/ewol/texture/TextureBMP.cpp rename to sources/ewol/renderer/resources/image/ImageBMP.cpp diff --git a/sources/ewol/texture/TextureBMP.h b/sources/ewol/renderer/resources/image/ImageBMP.h similarity index 100% rename from sources/ewol/texture/TextureBMP.h rename to sources/ewol/renderer/resources/image/ImageBMP.h diff --git a/sources/ewol/texture/TexturePNG.cpp b/sources/ewol/renderer/resources/image/ImagePNG.cpp similarity index 97% rename from sources/ewol/texture/TexturePNG.cpp rename to sources/ewol/renderer/resources/image/ImagePNG.cpp index 57fd0d12..51d038b9 100644 --- a/sources/ewol/texture/TexturePNG.cpp +++ b/sources/ewol/renderer/resources/image/ImagePNG.cpp @@ -24,7 +24,7 @@ static void local_ReadData(png_structp png_ptr, png_bytep data, png_size_t lengt fileNode->FileRead(data, 1, length); } } - +/* static void LocalWriteData(png_structp png_ptr, png_bytep data, png_size_t length) { etk::FSNode* fileNode = static_cast(png_get_io_ptr(png_ptr)); @@ -40,13 +40,10 @@ static void localFlushData(png_structp png_ptr) fileNode->FileFlush(); } } - +*/ bool ewol::imagePNG::GenerateImage(etk::UString & inputFile, draw::Image & ouputImage) { - int32_t m_width = 0; - int32_t m_height = 0; - etk::FSNode fileName(inputFile); if (false==fileName.Exist()) { @@ -59,7 +56,7 @@ bool ewol::imagePNG::GenerateImage(etk::UString & inputFile, draw::Image & ouput } // Vars - int x, y, address = 0; + int x, y = 0; int rowbytes; unsigned char header[8]; png_infop info_ptr; diff --git a/sources/ewol/texture/TexturePNG.h b/sources/ewol/renderer/resources/image/ImagePNG.h similarity index 100% rename from sources/ewol/texture/TexturePNG.h rename to sources/ewol/renderer/resources/image/ImagePNG.h diff --git a/sources/ewol/texture/TextureSVG.cpp b/sources/ewol/renderer/resources/image/ImageSVG.cpp similarity index 100% rename from sources/ewol/texture/TextureSVG.cpp rename to sources/ewol/renderer/resources/image/ImageSVG.cpp diff --git a/sources/ewol/texture/TextureSVG.h b/sources/ewol/renderer/resources/image/ImageSVG.h similarity index 100% rename from sources/ewol/texture/TextureSVG.h rename to sources/ewol/renderer/resources/image/ImageSVG.h diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index f3ebebbc..263c7cc2 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -12,50 +12,6 @@ #include #include -char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type) -{ - char * returnValue = "?"; - switch(type) { - case ewol::EVENT_KB_MOVE_TYPE_NONE: returnValue = "---"; break; - case ewol::EVENT_KB_MOVE_TYPE_LEFT: returnValue = "LEFT"; break; - case ewol::EVENT_KB_MOVE_TYPE_RIGHT: returnValue = "RIGHT"; break; - case ewol::EVENT_KB_MOVE_TYPE_UP: returnValue = "UP"; break; - case ewol::EVENT_KB_MOVE_TYPE_DOWN: returnValue = "DOWN"; break; - case ewol::EVENT_KB_MOVE_TYPE_PAGE_UP: returnValue = "PAGE_UP"; break; - case ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN: returnValue = "PAGE_DOWN"; break; - case ewol::EVENT_KB_MOVE_TYPE_START: returnValue = "START"; break; - case ewol::EVENT_KB_MOVE_TYPE_END: returnValue = "END"; break; - case ewol::EVENT_KB_MOVE_TYPE_CENTER: returnValue = "CENTER"; break; - case ewol::EVENT_KB_MOVE_TYPE_ARRET_DEFIL: returnValue = "ARRET_DEFIL"; break; - case ewol::EVENT_KB_MOVE_TYPE_WAIT: returnValue = "WAIT"; break; - case ewol::EVENT_KB_MOVE_TYPE_INSERT: returnValue = "INSERT"; break; - case ewol::EVENT_KB_MOVE_TYPE_F1: returnValue = "F1"; break; - case ewol::EVENT_KB_MOVE_TYPE_F2: returnValue = "F2"; break; - case ewol::EVENT_KB_MOVE_TYPE_F3: returnValue = "F3"; break; - case ewol::EVENT_KB_MOVE_TYPE_F4: returnValue = "F4"; break; - case ewol::EVENT_KB_MOVE_TYPE_F5: returnValue = "F5"; break; - case ewol::EVENT_KB_MOVE_TYPE_F6: returnValue = "F6"; break; - case ewol::EVENT_KB_MOVE_TYPE_F7: returnValue = "F7"; break; - case ewol::EVENT_KB_MOVE_TYPE_F8: returnValue = "F8"; break; - case ewol::EVENT_KB_MOVE_TYPE_F9: returnValue = "F9"; break; - case ewol::EVENT_KB_MOVE_TYPE_F10: returnValue = "F10"; break; - case ewol::EVENT_KB_MOVE_TYPE_F11: returnValue = "F11"; break; - case ewol::EVENT_KB_MOVE_TYPE_F12: returnValue = "F12"; break; - case ewol::EVENT_KB_MOVE_TYPE_CAPLOCK: returnValue = "CAPLOCK"; break; - case ewol::EVENT_KB_MOVE_TYPE_SHIFT_LEFT: returnValue = "SHIFT_LEFT"; break; - case ewol::EVENT_KB_MOVE_TYPE_SHIFT_RIGHT: returnValue = "SHIFT_RIGHT"; break; - case ewol::EVENT_KB_MOVE_TYPE_CTRL_LEFT: returnValue = "CTRL_LEFT"; break; - case ewol::EVENT_KB_MOVE_TYPE_CTRL_RIGHT: returnValue = "CTRL_RIGHT"; break; - case ewol::EVENT_KB_MOVE_TYPE_META_LEFT: returnValue = "META_LEFT"; break; - case ewol::EVENT_KB_MOVE_TYPE_META_RIGHT: returnValue = "META_RIGHT"; break; - case ewol::EVENT_KB_MOVE_TYPE_ALT: returnValue = "ALT"; break; - case ewol::EVENT_KB_MOVE_TYPE_ALT_GR: returnValue = "ALT_GR"; break; - case ewol::EVENT_KB_MOVE_TYPE_CONTEXT_MENU: returnValue = "CONTEXT_MENU"; break; - case ewol::EVENT_KB_MOVE_TYPE_VER_NUM: returnValue = "VER_NUM"; break; - } - return returnValue; -} - #undef __class__ #define __class__ "Widget" diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index f33f7ddb..8c9e9ff0 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -21,71 +21,6 @@ namespace ewol { #include namespace ewol { - typedef enum { - EVENT_INPUT_TYPE_DOWN, - EVENT_INPUT_TYPE_MOVE, - EVENT_INPUT_TYPE_SINGLE, - EVENT_INPUT_TYPE_DOUBLE, - EVENT_INPUT_TYPE_TRIPLE, - EVENT_INPUT_TYPE_QUAD, - EVENT_INPUT_TYPE_QUINTE, - EVENT_INPUT_TYPE_UP, - EVENT_INPUT_TYPE_ENTER, - EVENT_INPUT_TYPE_LEAVE, - EVENT_INPUT_TYPE_ABORT, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has lost the events) - EVENT_INPUT_TYPE_TRANSFERT, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event) - } eventInputType_te; - - typedef enum { - EVENT_KB_TYPE_DOWN, - EVENT_KB_TYPE_UP, - } eventKbType_te; - - typedef enum { - EVENT_KB_MOVE_TYPE_NONE, - EVENT_KB_MOVE_TYPE_LEFT, - EVENT_KB_MOVE_TYPE_RIGHT, - EVENT_KB_MOVE_TYPE_UP, - EVENT_KB_MOVE_TYPE_DOWN, - EVENT_KB_MOVE_TYPE_PAGE_UP, - EVENT_KB_MOVE_TYPE_PAGE_DOWN, - EVENT_KB_MOVE_TYPE_START, - EVENT_KB_MOVE_TYPE_END, - EVENT_KB_MOVE_TYPE_CENTER, - EVENT_KB_MOVE_TYPE_ARRET_DEFIL, - EVENT_KB_MOVE_TYPE_WAIT, - EVENT_KB_MOVE_TYPE_INSERT, - EVENT_KB_MOVE_TYPE_F1, - EVENT_KB_MOVE_TYPE_F2, - EVENT_KB_MOVE_TYPE_F3, - EVENT_KB_MOVE_TYPE_F4, - EVENT_KB_MOVE_TYPE_F5, - EVENT_KB_MOVE_TYPE_F6, - EVENT_KB_MOVE_TYPE_F7, - EVENT_KB_MOVE_TYPE_F8, - EVENT_KB_MOVE_TYPE_F9, - EVENT_KB_MOVE_TYPE_F10, - EVENT_KB_MOVE_TYPE_F11, - EVENT_KB_MOVE_TYPE_F12, - EVENT_KB_MOVE_TYPE_CAPLOCK, - EVENT_KB_MOVE_TYPE_SHIFT_LEFT, - EVENT_KB_MOVE_TYPE_SHIFT_RIGHT, - EVENT_KB_MOVE_TYPE_CTRL_LEFT, - EVENT_KB_MOVE_TYPE_CTRL_RIGHT, - EVENT_KB_MOVE_TYPE_META_LEFT, - EVENT_KB_MOVE_TYPE_META_RIGHT, - EVENT_KB_MOVE_TYPE_ALT, - EVENT_KB_MOVE_TYPE_ALT_GR, - EVENT_KB_MOVE_TYPE_CONTEXT_MENU, - EVENT_KB_MOVE_TYPE_VER_NUM, - } eventKbMoveType_te; - - typedef enum { - INPUT_TYPE_UNKNOW, - INPUT_TYPE_MOUSE, - INPUT_TYPE_FINGER, - } inputType_te; - char* GetCharTypeMoveEvent(eventKbMoveType_te type); class DrawProperty{