diff --git a/external/ege b/external/ege index 6adec343..eb762e5c 160000 --- a/external/ege +++ b/external/ege @@ -1 +1 @@ -Subproject commit 6adec3434ea382c94554f5d8fac3b60573eae382 +Subproject commit eb762e5c93b8e20ac862b32879da7fb3e55b6fce diff --git a/sources/ewol/resource/Program.cpp b/sources/ewol/resource/Program.cpp index 561f40d6..a89ed848 100644 --- a/sources/ewol/resource/Program.cpp +++ b/sources/ewol/resource/Program.cpp @@ -330,7 +330,6 @@ void ewol::resource::Program::sendAttribute(int32_t _idElem, } void ewol::resource::Program::sendAttributePointer(int32_t _idElem, - int32_t _nbElement, const std::shared_ptr& _vbo, int32_t _index, int32_t _jumpBetweenSample, @@ -347,7 +346,7 @@ void ewol::resource::Program::sendAttributePointer(int32_t _idElem, } glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index)); glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL - _nbElement, // number of elements per vertex, here (r,g,b,a) + _vbo->getElementSize(_index), // number of elements per vertex, here (r,g,b,a) GL_FLOAT, // the type of each element GL_FALSE, // take our values as-is _jumpBetweenSample, // no extra data between each position diff --git a/sources/ewol/resource/Program.h b/sources/ewol/resource/Program.h index 8520c7ec..b13385df 100644 --- a/sources/ewol/resource/Program.h +++ b/sources/ewol/resource/Program.h @@ -87,18 +87,17 @@ namespace ewol { const void* _pointer, int32_t _jumpBetweenSample=0); void sendAttributePointer(int32_t _idElem, - int32_t _nbElement, const std::shared_ptr& _vbo, int32_t _index, int32_t _jumpBetweenSample=0, int32_t _offset=0); - inline void sendAttribute(int32_t _idElem, const std::vector& _data) { + inline void sendAttribute(int32_t _idElem, const std::vector& _data) { sendAttribute(_idElem, 2/*u,v / x,y*/, &_data[0]); } - inline void sendAttribute(int32_t _idElem, const std::vector& _data) { + inline void sendAttribute(int32_t _idElem, const std::vector& _data) { sendAttribute(_idElem, 3/*x,y,z,unused*/, &_data[0], 4*sizeof(btScalar)); } - inline void sendAttribute(int32_t _idElem, const std::vector >& _data) { + inline void sendAttribute(int32_t _idElem, const std::vector>& _data) { sendAttribute(_idElem, 4/*r,g,b,a*/, &_data[0]); } inline void sendAttribute(int32_t _idElem, const std::vector& _data) { diff --git a/sources/ewol/resource/VirtualBufferObject.cpp b/sources/ewol/resource/VirtualBufferObject.cpp index 5d0bb2d2..214abc17 100644 --- a/sources/ewol/resource/VirtualBufferObject.cpp +++ b/sources/ewol/resource/VirtualBufferObject.cpp @@ -20,6 +20,7 @@ void ewol::resource::VirtualBufferObject::init(int32_t _number) { for (size_t iii=0; iii TODO : Maybe update it"); + return; + } m_vboUsed[_id] = true; m_buffer[_id].push_back(_data.x()); m_buffer[_id].push_back(_data.y()); @@ -104,11 +111,20 @@ vec3 ewol::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _ m_buffer[_id][3*_elementID+2]); } -int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec3(int32_t _id) { - return m_buffer[_id].size()/3; +int32_t ewol::resource::VirtualBufferObject::bufferSize(int32_t _id) { + return m_buffer[_id].size()/m_vboSizeDataOffset[_id]; +} +int32_t ewol::resource::VirtualBufferObject::getElementSize(int32_t _id) { + return m_vboSizeDataOffset[_id]; } void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) { + if (m_vboSizeDataOffset[_id] == -1) { + m_vboSizeDataOffset[_id] = 2; + } else if (m_vboSizeDataOffset[_id] != 2) { + EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); + return; + } m_vboUsed[_id] = true; m_buffer[_id].push_back(_data.x()); m_buffer[_id].push_back(_data.y()); @@ -122,6 +138,54 @@ vec2 ewol::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _ m_buffer[_id][2*_elementID+1]); } -int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec2(int32_t _id) { - return m_buffer[_id].size()/2; + +void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { + if (m_vboSizeDataOffset[_id] == -1) { + m_vboSizeDataOffset[_id] = 4; + } else if (m_vboSizeDataOffset[_id] != 4) { + EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); + return; + } + m_vboUsed[_id] = true; + m_buffer[_id].push_back(_data.r()); + m_buffer[_id].push_back(_data.g()); + m_buffer[_id].push_back(_data.b()); + m_buffer[_id].push_back(_data.a()); } + +void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { + if (m_vboSizeDataOffset[_id] == -1) { + m_vboSizeDataOffset[_id] = 3; + } else if (m_vboSizeDataOffset[_id] != 3) { + EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); + return; + } + m_vboUsed[_id] = true; + m_buffer[_id].push_back(_data.r()); + m_buffer[_id].push_back(_data.g()); + m_buffer[_id].push_back(_data.b()); +} + +void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { + if (m_vboSizeDataOffset[_id] == -1) { + m_vboSizeDataOffset[_id] = 2; + } else if (m_vboSizeDataOffset[_id] != 2) { + EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); + return; + } + m_vboUsed[_id] = true; + m_buffer[_id].push_back(_data.r()); + m_buffer[_id].push_back(_data.g()); +} + +void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { + if (m_vboSizeDataOffset[_id] == -1) { + m_vboSizeDataOffset[_id] = 1; + } else if (m_vboSizeDataOffset[_id] != 1) { + EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); + return; + } + m_vboUsed[_id] = true; + m_buffer[_id].push_back(_data.r()); +} + diff --git a/sources/ewol/resource/VirtualBufferObject.h b/sources/ewol/resource/VirtualBufferObject.h index a90b8295..b6e1bf69 100644 --- a/sources/ewol/resource/VirtualBufferObject.h +++ b/sources/ewol/resource/VirtualBufferObject.h @@ -14,7 +14,9 @@ #include #include #include +#include +// TODO : Remove this ... #define NB_VBO_MAX (20) namespace ewol { @@ -29,6 +31,7 @@ namespace ewol { GLuint m_vbo[NB_VBO_MAX]; //!< openGl ID of this VBO bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ... std::vector m_buffer[NB_VBO_MAX]; //!< data that is availlable in the VBO system ... + int8_t m_vboSizeDataOffset[NB_VBO_MAX]; //!< Internal size of the VBO (dynamicly set) protected: /** * @brief Constructor of this VBO. @@ -47,29 +50,56 @@ namespace ewol { * @brief get the real openGL ID. * @return the Ogl id reference of this VBO. */ - GLuint getGL_ID(int32_t id) { return m_vbo[id]; }; + GLuint getGL_ID(int32_t _id) { + return m_vbo[_id]; + }; /** * @brief get a reference on hte buffer data for this VBO. * @param[in] id Id of the buffer requested * @return A reference on the data. */ - std::vector& getRefBuffer(int32_t id) { m_vboUsed[id] = true; return m_buffer[id]; }; + std::vector& getRefBuffer(int32_t _id) { + m_vboUsed[_id] = true; + return m_buffer[_id]; + }; + /** + * @brief Get the buffer Number of element. + * @param[in] _id VBO Element + * @return Number of Float in the buffer. + */ + int32_t bufferSize(int32_t _id); + /** + * @brief Get the offset between element. + * @param[in] _id VBO Element + * @return Number of Float to jump between target. + */ + int32_t getElementSize(int32_t _id); /** * @brief push data on a buffer with a custum type : - * @param[in] id Id of the buffer requested. - * @param[in] data Direct data that might be set. + * @param[in] _id Id of the buffer requested. + * @param[in] _data Direct data that might be set. */ - void pushOnBuffer(int32_t id, const vec3& data); - vec3 getOnBufferVec3(int32_t id, int32_t elementID); - int32_t sizeOnBufferVec3(int32_t id); + void pushOnBuffer(int32_t _id, const vec3& _data); + vec3 getOnBufferVec3(int32_t _id, int32_t _elementID); /** * @brief push data on a buffer with a custum type : - * @param[in] id Id of the buffer requested. - * @param[in] data Direct data that might be set. + * @param[in] _id Id of the buffer requested. + * @param[in] _data Direct data that might be set. */ - void pushOnBuffer(int32_t id, const vec2& data); - vec2 getOnBufferVec2(int32_t id, int32_t elementID); - int32_t sizeOnBufferVec2(int32_t id); + void pushOnBuffer(int32_t _id, const vec2& _data); + vec2 getOnBufferVec2(int32_t _id, int32_t _elementID); + /** + * @brief push data on a buffer with a custum type : + * @param[in] _id Id of the buffer requested. + * @param[in] _data Direct data that might be set (Color). + */ + void pushOnBuffer(int32_t _id, const etk::Color& _data); + //! @previous + void pushOnBuffer(int32_t _id, const etk::Color& _data); + //! @previous + void pushOnBuffer(int32_t _id, const etk::Color& _data); + //! @previous + void pushOnBuffer(int32_t _id, const etk::Color& _data); /** * @brief get the data from the graphic card. */