Commit f2d8b081 authored by Sylvain Thery's avatar Sylvain Thery

remove useless shader referencing VBO

remove vbo unbinding in shader (was only called when VBO was destructed,
shader is then invalid or destructed just after)

=> remove the bug of Drawer delete
parent e664bed6
......@@ -54,8 +54,6 @@ public:
{
int va_id;
VBO* vbo_ptr;
// GLuint vbo_id;
// unsigned int size;
};
/**
......@@ -118,7 +116,6 @@ protected:
/**
* a set of pair VA_id / VBO_id
*/
// std::vector<pair<int,unsigned int> > m_va_vbo_binding;
std::vector<VAStr> m_va_vbo_binding;
static std::vector<std::string> m_pathes;
......@@ -341,10 +338,6 @@ public:
*/
void addPathFileSeach(const std::string& path);
/**
* remove VBO index from binding
*/
void unbindVBO(VBO* ptr);
/**
* remove VBO index from binding
......@@ -365,7 +358,7 @@ public:
/**
* get binding VA VBO
*/
const std::vector<VAStr>& getVA_VBO_Bindings() { return m_va_vbo_binding; }
// const std::vector<VAStr>& getVA_VBO_Bindings() { return m_va_vbo_binding; }
void bindAttrib(unsigned int att, const char* name) const;
......
......@@ -95,11 +95,8 @@ public:
void bind() const { glBindBuffer(GL_ARRAY_BUFFER,m_id); }
/**
* reference vbo as used by shader sh
* alloc buffer of same size than parameter
*/
void ref(GLSLShader* sh);
void sameAllocSameBufferSize(const VBO& vbo);
/**
......
......@@ -908,25 +908,9 @@ void GLSLShader::addPathFileSeach(const std::string& path)
m_pathes.push_back(path);
}
void GLSLShader::unbindVBO(VBO* ptr)
{
unsigned int nb = m_va_vbo_binding.size();
for (unsigned int i = 0; i < nb; ++i)
{
if (m_va_vbo_binding[i].vbo_ptr == ptr)
{
if (i != (nb-1))
m_va_vbo_binding[i] = m_va_vbo_binding[nb-1];
m_va_vbo_binding.pop_back();
return;
}
}
}
unsigned int GLSLShader::bindVA_VBO(const std::string& name, VBO* vbo)
{
vbo->ref(this);
GLint idVA = glGetAttribLocation(this->m_program_object, name.c_str());
//valid ?
if (idVA < 0)
......@@ -951,11 +935,16 @@ unsigned int GLSLShader::bindVA_VBO(const std::string& name, VBO* vbo)
return (m_va_vbo_binding.size() -1);
}
void GLSLShader::changeVA_VBO(unsigned int id, VBO* vbo)
{
m_va_vbo_binding[id].vbo_ptr = vbo;
}
void GLSLShader::unbindVA(const std::string& name)
{
GLint idVA = glGetAttribLocation(this->m_program_object, name.c_str());
......@@ -980,6 +969,9 @@ void GLSLShader::unbindVA(const std::string& name)
CGoGNerr << "GLSLShader: Attribute "<<name<< " not binded"<< CGoGNendl;
}
void GLSLShader::setCurrentOGLVersion(unsigned int version)
{
CURRENT_OGL_VERSION = version;
......
......@@ -57,9 +57,9 @@ Drawer::Drawer() : m_currentWidth(1.0f)
Drawer::~Drawer()
{
Utils::GLSLShader::unregisterShader(NULL, m_shader);
delete m_shader;
delete m_vboPos;
delete m_vboCol;
delete m_shader;
}
void Drawer::lineWidth(float lw)
......
......@@ -109,7 +109,6 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0)
m_vbo1 = new Utils::VBO();
m_vbo1->setDataSize(4);
m_vbo1->ref(this);
bindVA_VBO("VertexPosition", m_vbo1);
......
......@@ -60,24 +60,13 @@ VBO::VBO(const VBO& vbo) :
VBO::~VBO()
{
std::cout << "VBO delete"<< std::endl;
if (m_lock)
releasePtr();
glDeleteBuffers(1, &m_id);
for(std::vector<GLSLShader*>::iterator it = m_refs.begin(); it != m_refs.end(); ++it)
{
(*it)->unbindVBO(this);
}
}
void VBO::ref(GLSLShader* sh)
{
//already referenced ?
for(std::vector<GLSLShader*>::iterator it = m_refs.begin(); it != m_refs.end(); ++it)
if (*it == sh)
return;
// no then add
m_refs.push_back(sh);
}
void VBO::sameAllocSameBufferSize(const VBO& vbo)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment