[DEBUG] correct the VBO FULL implement
This commit is contained in:
parent
7eef66f2b9
commit
681a46ea70
@ -795,7 +795,7 @@ class X11Interface : public gale::Context {
|
|||||||
// draw after switch the previous windows ...
|
// draw after switch the previous windows ...
|
||||||
//GALE_DEBUG("specialEventThatNeedARedraw"<<specialEventThatNeedARedraw);
|
//GALE_DEBUG("specialEventThatNeedARedraw"<<specialEventThatNeedARedraw);
|
||||||
hasDisplay = OS_Draw(specialEventThatNeedARedraw);
|
hasDisplay = OS_Draw(specialEventThatNeedARedraw);
|
||||||
specialEventThatNeedARedraw=false;
|
specialEventThatNeedARedraw = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -28,12 +28,12 @@ static void checkGlError(const char* _op, int32_t _localLine) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define OPENGL_ERROR(data) do { } while (false)
|
#define OPENGL_ERROR(data) do { } while (false)
|
||||||
#define OPENGL_ERROR(data) GALE_ERROR(data)
|
//#define OPENGL_ERROR(data) GALE_ERROR(data)
|
||||||
//#define OPENGL_WARNING(data) do { } while (false)
|
#define OPENGL_WARNING(data) do { } while (false)
|
||||||
#define OPENGL_WARNING(data) GALE_WARNING(data)
|
//#define OPENGL_WARNING(data) GALE_WARNING(data)
|
||||||
//#define OPENGL_INFO(data) do { } while (false)
|
#define OPENGL_INFO(data) do { } while (false)
|
||||||
#define OPENGL_INFO(data) GALE_INFO(data)
|
//#define OPENGL_INFO(data) GALE_INFO(data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -642,7 +642,7 @@ void gale::openGL::useProgram(int32_t _id) {
|
|||||||
// note : In normal openGL case, the system might call with the program ID and at the end with 0,
|
// note : In normal openGL case, the system might call with the program ID and at the end with 0,
|
||||||
// here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the
|
// here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the
|
||||||
// user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ...
|
// user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ...
|
||||||
if (-1 == _id) {
|
if (_id == -1) {
|
||||||
// not used == > because it is unneded
|
// not used == > because it is unneded
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -657,7 +657,7 @@ void gale::openGL::useProgram(int32_t _id) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (-1 == _id) {
|
if (_id == -1) {
|
||||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||||
if (s_simulationMode == false) {
|
if (s_simulationMode == false) {
|
||||||
#endif
|
#endif
|
||||||
|
@ -152,7 +152,7 @@ void gale::resource::Manager::updateContext() {
|
|||||||
}
|
}
|
||||||
if (resourceListToUpdate.size() != 0) {
|
if (resourceListToUpdate.size() != 0) {
|
||||||
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
|
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
|
||||||
GALE_INFO(" updateContext level (U) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
|
GALE_DEBUG(" updateContext level (U) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
|
||||||
for (auto &it : resourceListToUpdate) {
|
for (auto &it : resourceListToUpdate) {
|
||||||
if ( it != nullptr
|
if ( it != nullptr
|
||||||
&& jjj == it->getResourceLevel()) {
|
&& jjj == it->getResourceLevel()) {
|
||||||
|
@ -427,6 +427,7 @@ void gale::resource::Program::sendAttributePointer(int32_t _idElem,
|
|||||||
(GLvoid *)_offset); // Pointer on the buffer
|
(GLvoid *)_offset); // Pointer on the buffer
|
||||||
checkGlError("glVertexAttribPointer", __LINE__, _idElem);
|
checkGlError("glVertexAttribPointer", __LINE__, _idElem);
|
||||||
glEnableVertexAttribArray(m_elementList[_idElem].m_elementId);
|
glEnableVertexAttribArray(m_elementList[_idElem].m_elementId);
|
||||||
|
m_listOfVBOUsed.push_back(m_elementList[_idElem].m_elementId);
|
||||||
checkGlError("glEnableVertexAttribArray", __LINE__, _idElem);
|
checkGlError("glEnableVertexAttribArray", __LINE__, _idElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,7 +794,7 @@ void gale::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, co
|
|||||||
|
|
||||||
|
|
||||||
void gale::resource::Program::use() {
|
void gale::resource::Program::use() {
|
||||||
GALE_WARNING("Will use program : " << m_program);
|
GALE_VERBOSE("Will use program : " << m_program);
|
||||||
#ifdef PROGRAM_DISPLAY_SPEED
|
#ifdef PROGRAM_DISPLAY_SPEED
|
||||||
g_startTime = gale::getTime();
|
g_startTime = gale::getTime();
|
||||||
#endif
|
#endif
|
||||||
@ -859,11 +860,15 @@ void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenG
|
|||||||
|
|
||||||
|
|
||||||
void gale::resource::Program::unUse() {
|
void gale::resource::Program::unUse() {
|
||||||
GALE_WARNING("Will UN-use program : " << m_program);
|
GALE_VERBOSE("Will UN-use program : " << m_program);
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (m_exist == false) {
|
if (m_exist == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (auto &it : m_listOfVBOUsed) {
|
||||||
|
glDisableVertexAttribArray(it);
|
||||||
|
}
|
||||||
|
m_listOfVBOUsed.clear();
|
||||||
#if 0
|
#if 0
|
||||||
if (m_hasTexture == true) {
|
if (m_hasTexture == true) {
|
||||||
gale::openGL::disable(GL_TEXTURE_2D);
|
gale::openGL::disable(GL_TEXTURE_2D);
|
||||||
|
@ -51,6 +51,7 @@ namespace gale {
|
|||||||
int64_t m_program; //!< openGL id of the current program
|
int64_t m_program; //!< openGL id of the current program
|
||||||
std::vector<ememory::SharedPtr<gale::resource::Shader>> m_shaderList; //!< List of all the shader loaded
|
std::vector<ememory::SharedPtr<gale::resource::Shader>> m_shaderList; //!< List of all the shader loaded
|
||||||
std::vector<gale::resource::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
|
std::vector<gale::resource::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
|
||||||
|
std::vector<int32_t> m_listOfVBOUsed; //!< retain the list of VBO used to disable it when unuse program ...
|
||||||
bool m_hasTexture; //!< A texture has been set to the current shader
|
bool m_hasTexture; //!< A texture has been set to the current shader
|
||||||
bool m_hasTexture1; //!< A texture has been set to the current shader
|
bool m_hasTexture1; //!< A texture has been set to the current shader
|
||||||
protected:
|
protected:
|
||||||
|
@ -20,6 +20,7 @@ void gale::resource::VirtualBufferObject::init(int32_t _number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gale::resource::VirtualBufferObject::clear() {
|
void gale::resource::VirtualBufferObject::clear() {
|
||||||
|
GALE_VERBOSE(" Clear: [" << getId() << "] '" << getName() << "' (size=" << m_buffer[0].size() << ")");
|
||||||
// DO not clear the m_vbo indexed in the graphic cards ...
|
// DO not clear the m_vbo indexed in the graphic cards ...
|
||||||
for (size_t iii=0; iii<m_vboUsed.size(); ++iii) {
|
for (size_t iii=0; iii<m_vboUsed.size(); ++iii) {
|
||||||
m_vboUsed[iii] = false;
|
m_vboUsed[iii] = false;
|
||||||
@ -47,7 +48,7 @@ void gale::resource::VirtualBufferObject::retreiveData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool gale::resource::VirtualBufferObject::updateContext() {
|
bool gale::resource::VirtualBufferObject::updateContext() {
|
||||||
GALE_ERROR(" Start: [" << getId() << "] '" << getName() << "' (size=" << m_buffer[0].size() << ")");
|
GALE_VERBOSE(" Start: [" << getId() << "] '" << getName() << "' (size=" << m_buffer[0].size() << ")");
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
||||||
if (lock.try_lock() == false) {
|
if (lock.try_lock() == false) {
|
||||||
//Lock error ==> try later ...
|
//Lock error ==> try later ...
|
||||||
@ -59,7 +60,7 @@ bool gale::resource::VirtualBufferObject::updateContext() {
|
|||||||
}
|
}
|
||||||
m_exist = true;
|
m_exist = true;
|
||||||
for (size_t iii=0; iii<m_vbo.size(); iii++) {
|
for (size_t iii=0; iii<m_vbo.size(); iii++) {
|
||||||
GALE_INFO("VBO : add [" << getId() << "]=" << m_buffer[iii].size() << "*sizeof(float) OGl_Id=" << m_vbo[iii]);
|
GALE_VERBOSE("VBO : add [" << getId() << "]=" << m_buffer[iii].size() << "*sizeof(float) OGl_Id=" << m_vbo[iii]);
|
||||||
if (m_vboUsed[iii] == true) {
|
if (m_vboUsed[iii] == true) {
|
||||||
// select the buffer to set data inside it ...
|
// select the buffer to set data inside it ...
|
||||||
if (m_buffer[iii].size()>0) {
|
if (m_buffer[iii].size()>0) {
|
||||||
@ -70,7 +71,7 @@ bool gale::resource::VirtualBufferObject::updateContext() {
|
|||||||
}
|
}
|
||||||
// un-bind it to permet to have no error in the next display ...
|
// un-bind it to permet to have no error in the next display ...
|
||||||
gale::openGL::unbindBuffer();
|
gale::openGL::unbindBuffer();
|
||||||
GALE_ERROR(" Stop: [" << getId() << "] '" << getName() << "'");
|
GALE_VERBOSE(" Stop: [" << getId() << "] '" << getName() << "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ void gale::resource::VirtualBufferObject::flush() {
|
|||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
// request to the manager to be call at the next update ...
|
// request to the manager to be call at the next update ...
|
||||||
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
||||||
GALE_ERROR("Request flush of VBO: [" << getId() << "] '" << getName() << "'");
|
GALE_VERBOSE("Request flush of VBO: [" << getId() << "] '" << getName() << "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {
|
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {
|
||||||
@ -158,6 +159,17 @@ vec2 gale::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _
|
|||||||
m_buffer[_id][2*_elementID+1]);
|
m_buffer[_id][2*_elementID+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const float& _data) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
|
if (m_vboSizeDataOffset[_id] == -1) {
|
||||||
|
m_vboSizeDataOffset[_id] = 1;
|
||||||
|
} else if (m_vboSizeDataOffset[_id] != 1) {
|
||||||
|
GALE_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_vboUsed[_id] = true;
|
||||||
|
m_buffer[_id].push_back(_data);
|
||||||
|
}
|
||||||
|
|
||||||
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data) {
|
void gale::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
|
@ -96,6 +96,8 @@ namespace gale {
|
|||||||
void pushOnBuffer(int32_t _id, const etk::Color<float,2>& _data);
|
void pushOnBuffer(int32_t _id, const etk::Color<float,2>& _data);
|
||||||
//! @previous
|
//! @previous
|
||||||
void pushOnBuffer(int32_t _id, const etk::Color<float,1>& _data);
|
void pushOnBuffer(int32_t _id, const etk::Color<float,1>& _data);
|
||||||
|
//! @previous
|
||||||
|
void pushOnBuffer(int32_t _id, const float& _data);
|
||||||
/**
|
/**
|
||||||
* @brief get the data from the graphic card.
|
* @brief get the data from the graphic card.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user