diff --git a/gale/resource/Program.cpp b/gale/resource/Program.cpp index 49e2fbb..f59fa4c 100644 --- a/gale/resource/Program.cpp +++ b/gale/resource/Program.cpp @@ -361,6 +361,34 @@ void gale::resource::Program::reload() { ////////////////////////////////////////////////////////////////////////////////////////////// +void gale::resource::Program::sendAttribute(int32_t _idElem, + int32_t _nbElement, + const void* _pointer, + int32_t _jumpBetweenSample) { + std::unique_lock lock(m_mutex); + if (m_exist == false) { + return; + } + if ( _idElem < 0 + || (size_t)_idElem > m_elementList.size()) { + GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); + return; + } + if (m_elementList[_idElem].m_isLinked == false) { + return; + } + //GALE_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " element"); + glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL + _nbElement, // 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 + _pointer); // Pointer on the buffer + checkGlError("glVertexAttribPointer", __LINE__, _idElem); + glEnableVertexAttribArray(m_elementList[_idElem].m_elementId); + checkGlError("glEnableVertexAttribArray", __LINE__, _idElem); +} + void gale::resource::Program::sendAttributePointer(int32_t _idElem, const ememory::SharedPtr& _vbo, int32_t _index, diff --git a/gale/resource/VirtualBufferObject.cpp b/gale/resource/VirtualBufferObject.cpp index 797b4e3..e2e0182 100644 --- a/gale/resource/VirtualBufferObject.cpp +++ b/gale/resource/VirtualBufferObject.cpp @@ -20,11 +20,9 @@ void gale::resource::VirtualBufferObject::init(int32_t _number) { } void gale::resource::VirtualBufferObject::clear() { - for (auto &it : m_vbo) { - it = 0; - } - for (auto &it : m_vboUsed) { - it = false; + // DO not clear the m_vbo indexed in the graphic cards ... + for (size_t iii=0; iii lock(m_mutex, std::defer_lock); if (lock.try_lock() == false) { //Lock error ==> try later ... return false; } - if (false == m_exist) { + if (m_exist == false) { // Allocate and assign a Vertex Array Object to our handle gale::openGL::genBuffers(m_vbo); } m_exist = true; for (size_t iii=0; iii lock(m_mutex); // request to the manager to be call at the next update ... getManager().update(ememory::dynamicPointerCast(sharedFromThis())); + GALE_ERROR("Request flush of VBO: [" << getId() << "] '" << getName() << "'"); } void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {