- removed "glIndexPointer invalid operation" bug
This commit is contained in:
parent
1d9d1e6324
commit
69bc2244d1
|
@ -30,6 +30,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include<cstdio>
|
||||||
|
|
||||||
//#include <GL/glew.h>
|
//#include <GL/glew.h>
|
||||||
#include <wrap/gl/space.h>
|
#include <wrap/gl/space.h>
|
||||||
|
@ -176,7 +177,7 @@ namespace vcg
|
||||||
_bo[FACECOLORBO] = new GLBufferObject(4,GL_UNSIGNED_BYTE);
|
_bo[FACECOLORBO] = new GLBufferObject(4,GL_UNSIGNED_BYTE);
|
||||||
_bo[VERTTEXTUREBO] = new GLBufferObject(2,GL_FLOAT);
|
_bo[VERTTEXTUREBO] = new GLBufferObject(2,GL_FLOAT);
|
||||||
_bo[WEDGETEXTUREBO] = new GLBufferObject(2,GL_FLOAT);
|
_bo[WEDGETEXTUREBO] = new GLBufferObject(2,GL_FLOAT);
|
||||||
_bo[VERTINDEXBO] = new GLBufferObject(3,GL_INT);
|
_bo[VERTINDEXBO] = new GLBufferObject(3,GL_UNSIGNED_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
~GLMeshAttributesFeeder()
|
~GLMeshAttributesFeeder()
|
||||||
|
@ -282,11 +283,7 @@ namespace vcg
|
||||||
std::vector<bool> importattribute(_bo.size());
|
std::vector<bool> importattribute(_bo.size());
|
||||||
std::vector<bool> attributestobeupdated;
|
std::vector<bool> attributestobeupdated;
|
||||||
attributesToBeImportedInPointBasedPipeline(importattribute, nm, cm);
|
attributesToBeImportedInPointBasedPipeline(importattribute, nm, cm);
|
||||||
GLenum err = glGetError();
|
|
||||||
assert(err == GL_NO_ERROR);
|
|
||||||
bool immediatemode = !(buffersAllocationFunction(vaohandlespecificperopenglcontext,nm,cm,TX_NONE,importattribute,attributestobeupdated));
|
bool immediatemode = !(buffersAllocationFunction(vaohandlespecificperopenglcontext,nm,cm,TX_NONE,importattribute,attributestobeupdated));
|
||||||
err = glGetError();
|
|
||||||
assert(err == GL_NO_ERROR);
|
|
||||||
std::vector<GLuint> textureindex;
|
std::vector<GLuint> textureindex;
|
||||||
if (immediatemode)
|
if (immediatemode)
|
||||||
immediateMode(nm,cm,TX_NONE,textureindex);
|
immediateMode(nm,cm,TX_NONE,textureindex);
|
||||||
|
@ -296,18 +293,8 @@ namespace vcg
|
||||||
for(size_t hh = 0;hh < attributestobeupdated.size();++hh)
|
for(size_t hh = 0;hh < attributestobeupdated.size();++hh)
|
||||||
somethingtoupdate = somethingtoupdate || attributestobeupdated[hh];
|
somethingtoupdate = somethingtoupdate || attributestobeupdated[hh];
|
||||||
if (somethingtoupdate)
|
if (somethingtoupdate)
|
||||||
{
|
|
||||||
GLenum err = glGetError();
|
|
||||||
assert(err == GL_NO_ERROR);
|
|
||||||
updateBuffersIndexedPipeline(attributestobeupdated);
|
updateBuffersIndexedPipeline(attributestobeupdated);
|
||||||
err = glGetError();
|
|
||||||
assert(err == GL_NO_ERROR);
|
|
||||||
}
|
|
||||||
err = glGetError();
|
|
||||||
assert(err == GL_NO_ERROR);
|
|
||||||
drawPoints(vaohandlespecificperopenglcontext);
|
drawPoints(vaohandlespecificperopenglcontext);
|
||||||
err = glGetError();
|
|
||||||
assert(err == GL_NO_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +402,7 @@ namespace vcg
|
||||||
|
|
||||||
bool buffersAllocationFunction(GLuint& vaohandlespecificperopenglcontext,NORMAL_MODALITY nm,COLOR_MODALITY cm,TEXTURE_MODALITY tm,const std::vector<bool>& importattribute,std::vector<bool>& attributestobeupdated)
|
bool buffersAllocationFunction(GLuint& vaohandlespecificperopenglcontext,NORMAL_MODALITY nm,COLOR_MODALITY cm,TEXTURE_MODALITY tm,const std::vector<bool>& importattribute,std::vector<bool>& attributestobeupdated)
|
||||||
{
|
{
|
||||||
if (vaohandlespecificperopenglcontext == 0)
|
if (vaohandlespecificperopenglcontext == 0)
|
||||||
//glGenVertexArrays(1,&vaohandle);
|
//glGenVertexArrays(1,&vaohandle);
|
||||||
return false;
|
return false;
|
||||||
bool replicated = (importattribute[FACENORMALBO] || importattribute[FACECOLORBO] || importattribute[WEDGETEXTUREBO]);
|
bool replicated = (importattribute[FACENORMALBO] || importattribute[FACECOLORBO] || importattribute[WEDGETEXTUREBO]);
|
||||||
|
@ -493,7 +480,7 @@ namespace vcg
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int ii = 0;
|
unsigned int ii = 0;
|
||||||
//I have to update the invalid buffers requested to be imported
|
//I have to update the invalid buffers requested to be imported
|
||||||
attributestobeupdated = importattribute;
|
attributestobeupdated = importattribute;
|
||||||
|
@ -505,7 +492,6 @@ namespace vcg
|
||||||
GLenum target = GL_ARRAY_BUFFER;
|
GLenum target = GL_ARRAY_BUFFER;
|
||||||
if (boname == VERTINDEXBO)
|
if (boname == VERTINDEXBO)
|
||||||
target = GL_ELEMENT_ARRAY_BUFFER;
|
target = GL_ELEMENT_ARRAY_BUFFER;
|
||||||
|
|
||||||
glBindVertexArray(vaohandlespecificperopenglcontext);
|
glBindVertexArray(vaohandlespecificperopenglcontext);
|
||||||
bool notvalidbuttoberegenerated = (cbo != NULL) && (!cbo->_isvalid) && (importatt);
|
bool notvalidbuttoberegenerated = (cbo != NULL) && (!cbo->_isvalid) && (importatt);
|
||||||
if (notvalidbuttoberegenerated)
|
if (notvalidbuttoberegenerated)
|
||||||
|
@ -516,8 +502,8 @@ namespace vcg
|
||||||
glBindBuffer(target, cbo->_bohandle);
|
glBindBuffer(target, cbo->_bohandle);
|
||||||
glBufferData(target, dim, NULL, GL_STATIC_DRAW);
|
glBufferData(target, dim, NULL, GL_STATIC_DRAW);
|
||||||
setBufferPointerEnableClientState(boname);
|
setBufferPointerEnableClientState(boname);
|
||||||
glBindBuffer(target, 0);
|
glBindBuffer(target, 0);
|
||||||
_gpumeminfo.acquiredMemory(dim);
|
_gpumeminfo.acquiredMemory(dim);
|
||||||
attributestobeupdated[boname] = true;
|
attributestobeupdated[boname] = true;
|
||||||
cbo->_isvalid = true;
|
cbo->_isvalid = true;
|
||||||
}
|
}
|
||||||
|
@ -971,8 +957,8 @@ namespace vcg
|
||||||
if (_bo[VERTINDEXBO]->_isvalid)
|
if (_bo[VERTINDEXBO]->_isvalid)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,_bo[VERTINDEXBO]->_bohandle);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,_bo[VERTINDEXBO]->_bohandle);
|
||||||
glDrawElements( GL_TRIANGLES, _mesh.fn * _bo[VERTINDEXBO]->_components,GL_UNSIGNED_INT ,NULL);
|
glDrawElements( GL_TRIANGLES, _mesh.fn * _bo[VERTINDEXBO]->_components,GL_UNSIGNED_INT ,NULL);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D,0);
|
glBindTexture(GL_TEXTURE_2D,0);
|
||||||
|
@ -1035,9 +1021,7 @@ namespace vcg
|
||||||
}
|
}
|
||||||
case(VERTINDEXBO):
|
case(VERTINDEXBO):
|
||||||
{
|
{
|
||||||
glIndexPointer(cbo->_gltype, 0, 0);
|
break;
|
||||||
glEnableClientState(GL_INDEX_ARRAY);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1077,7 +1061,6 @@ namespace vcg
|
||||||
}
|
}
|
||||||
case(VERTINDEXBO):
|
case(VERTINDEXBO):
|
||||||
{
|
{
|
||||||
glDisableClientState(GL_INDEX_ARRAY);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue