- recommitted last working version of the trimesh_QT_shared project contained in the git repository
This commit is contained in:
parent
59dd06f949
commit
6bb2ed6382
|
@ -44,15 +44,13 @@ Initial release.
|
||||||
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
|
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GLArea::GLArea (CMesh& m, MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent,QGLWidget* sharedcont)
|
GLArea::GLArea (CMeshO& m, MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent,QGLWidget* sharedcont)
|
||||||
:QGLWidget (parent,sharedcont),vaohandlespecificicforglcontext(0),mesh(m),feeder(feed),sem(0)
|
:QGLWidget (parent,sharedcont),mesh(m),feeder(feed),rq(),drawmode(MDM_SMOOTH)
|
||||||
{
|
{
|
||||||
drawmode= MDM_SMOOTH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLArea::~GLArea()
|
GLArea::~GLArea()
|
||||||
{
|
{
|
||||||
glDeleteVertexArrays(1,&vaohandlespecificicforglcontext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLArea::initializeGL()
|
void GLArea::initializeGL()
|
||||||
|
@ -67,7 +65,6 @@ void GLArea::initializeGL()
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glGenVertexArrays(1,&vaohandlespecificicforglcontext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLArea::resizeGL (int w, int h)
|
void GLArea::resizeGL (int w, int h)
|
||||||
|
@ -80,13 +77,16 @@ void GLArea::resizeGL (int w, int h)
|
||||||
void GLArea::paintGL ()
|
void GLArea::paintGL ()
|
||||||
{
|
{
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
//GLenum err = glGetError();
|
//GLenum err = glGetError();
|
||||||
//assert(err == GL_NO_ERROR);
|
//assert(err == GL_NO_ERROR);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(25, GLArea::width()/(float)GLArea::height(), 0.1, 100);
|
gluPerspective(25, GLArea::width()/(float)GLArea::height(), 0.1, 100);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluLookAt(0,0,5, 0,0,0, 0,1,0);
|
gluLookAt(0,0,5, 0,0,0, 0,1,0);
|
||||||
track.center=vcg::Point3f(0, 0, 0);
|
track.center=vcg::Point3f(0, 0, 0);
|
||||||
|
@ -98,34 +98,34 @@ void GLArea::paintGL ()
|
||||||
vcg::glScale(d);
|
vcg::glScale(d);
|
||||||
glTranslate(-mesh.bbox.Center());
|
glTranslate(-mesh.bbox.Center());
|
||||||
|
|
||||||
if (sem == true)
|
if (mesh.VN() > 0)
|
||||||
{
|
{
|
||||||
glBindVertexArray(vaohandlespecificicforglcontext);
|
|
||||||
switch(drawmode)
|
switch(drawmode)
|
||||||
{
|
{
|
||||||
case MDM_SMOOTH:
|
case MDM_SMOOTH:
|
||||||
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
case MDM_FLAT:
|
||||||
|
feeder.drawTriangles(rq);
|
||||||
|
case MDM_WIRE:
|
||||||
|
feeder.drawWire(rq);
|
||||||
break;
|
break;
|
||||||
case MDM_POINTS:
|
case MDM_POINTS:
|
||||||
feeder.drawPoints(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
feeder.drawPoints(rq);
|
||||||
break;
|
|
||||||
case MDM_WIRE:
|
|
||||||
feeder.drawWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
|
||||||
break;
|
break;
|
||||||
case MDM_FLATWIRE:
|
case MDM_FLATWIRE:
|
||||||
feeder.drawFlatWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
feeder.drawFlatWire(rq);
|
||||||
break;
|
|
||||||
case MDM_FLAT:
|
|
||||||
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
glBindVertexArray(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
track.DrawPostApply();
|
track.DrawPostApply();
|
||||||
|
glPopMatrix();
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
glPopAttrib();
|
||||||
|
//doneCurrent();
|
||||||
GLenum err = glGetError();
|
GLenum err = glGetError();
|
||||||
assert(err == GL_NO_ERROR);
|
assert(err == GL_NO_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -183,72 +183,79 @@ void GLArea::wheelEvent (QWheelEvent * e)
|
||||||
updateGL ();
|
updateGL ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLArea::setupEnvironment(MyDrawMode mode)
|
void GLArea::updateRequested(MyDrawMode md,vcg::GLFeederInfo::ReqAtts& reqatts)
|
||||||
{
|
{
|
||||||
sem = false;
|
drawmode = md;
|
||||||
drawmode=mode;
|
rq = reqatts;
|
||||||
makeCurrent();
|
|
||||||
std::vector<bool> import(8,false);
|
|
||||||
|
|
||||||
switch(drawmode)
|
|
||||||
{
|
|
||||||
case MDM_SMOOTH:
|
|
||||||
case MDM_WIRE:
|
|
||||||
feeder.attributesToBeImportedInTriangleBasedPipeline(import,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
|
||||||
break;
|
|
||||||
case MDM_POINTS:
|
|
||||||
feeder.attributesToBeImportedInPointBasedPipeline(import,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
|
||||||
break;
|
|
||||||
case MDM_FLAT:
|
|
||||||
case MDM_FLATWIRE:
|
|
||||||
feeder.attributesToBeImportedInTriangleBasedPipeline(import,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
feeder.updateClientSideEnvironmentVAO(vaohandlespecificicforglcontext,import);
|
|
||||||
sem = true;
|
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLArea::resetTrackBall()
|
||||||
|
{
|
||||||
|
makeCurrent();
|
||||||
|
track.Reset();
|
||||||
|
updateGL();
|
||||||
|
doneCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
SharedDataOpenGLContext::SharedDataOpenGLContext( CMesh& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent /*= 0*/ )
|
|
||||||
:QGLWidget(parent),feeder(mesh,mi,100000),vaohandlespecificicforglcontext(0),drawmode(MDM_SMOOTH)
|
|
||||||
|
SharedDataOpenGLContext::SharedDataOpenGLContext( CMeshO& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent /*= 0*/ )
|
||||||
|
:QGLWidget(parent),feeder(mesh,mi,100000)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedDataOpenGLContext::~SharedDataOpenGLContext()
|
SharedDataOpenGLContext::~SharedDataOpenGLContext()
|
||||||
{
|
{
|
||||||
makeCurrent();
|
deAllocateBO();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedDataOpenGLContext::myInitGL()
|
void SharedDataOpenGLContext::myInitGL()
|
||||||
{
|
{
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
glewInit();
|
glewInit();
|
||||||
glGenVertexArrays(1,&vaohandlespecificicforglcontext);
|
doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedDataOpenGLContext::passInfoToOpenGL(int mode)
|
void SharedDataOpenGLContext::passInfoToOpenGL(int mode)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
drawmode = static_cast<MyDrawMode>(mode);
|
MyDrawMode drawmode = static_cast<MyDrawMode>(mode);
|
||||||
//_tsbm.setUpBuffers();
|
//_tsbm.setUpBuffers();
|
||||||
|
vcg::GLFeederInfo::ReqAtts req;
|
||||||
|
bool allocated = false;
|
||||||
switch(drawmode)
|
switch(drawmode)
|
||||||
{
|
{
|
||||||
case MDM_SMOOTH:
|
case MDM_SMOOTH:
|
||||||
case MDM_WIRE:
|
case MDM_WIRE:
|
||||||
feeder.tryToAllocatePerTriangleAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
req[vcg::GLFeederInfo::ATT_VERTPOSITION] = true;
|
||||||
|
req[vcg::GLFeederInfo::ATT_VERTNORMAL] = true;
|
||||||
|
req[vcg::GLFeederInfo::ATT_VERTINDEX] = true;
|
||||||
|
req.primitiveModality() = vcg::GLFeederInfo::PR_TRIANGLES;
|
||||||
break;
|
break;
|
||||||
case MDM_POINTS:
|
case MDM_POINTS:
|
||||||
feeder.tryToAllocatePerPointAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
req[vcg::GLFeederInfo::ATT_VERTPOSITION] = true;
|
||||||
|
req[vcg::GLFeederInfo::ATT_VERTNORMAL] = true;
|
||||||
|
req.primitiveModality() = vcg::GLFeederInfo::PR_POINTS;
|
||||||
break;
|
break;
|
||||||
case MDM_FLAT:
|
case MDM_FLAT:
|
||||||
case MDM_FLATWIRE:
|
case MDM_FLATWIRE:
|
||||||
feeder.tryToAllocatePerTriangleAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
req[vcg::GLFeederInfo::ATT_VERTPOSITION] = true;
|
||||||
|
req[vcg::GLFeederInfo::ATT_FACENORMAL] = true;
|
||||||
|
req.primitiveModality() = vcg::GLFeederInfo::PR_TRIANGLES;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
emit dataReadyToBeRead(drawmode);
|
vcg::GLFeederInfo::ReqAtts rq = feeder.setupRequestedAttributes(req,allocated);
|
||||||
|
doneCurrent();
|
||||||
|
emit dataReadyToBeRead(drawmode,rq);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SharedDataOpenGLContext::deAllocateBO()
|
||||||
|
{
|
||||||
|
makeCurrent();
|
||||||
|
feeder.deAllocateBO();
|
||||||
|
doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ Initial release.
|
||||||
|
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "ml_scene_renderer.h"
|
#include "ml_scene_renderer.h"
|
||||||
#include "ml_atomic_guard.h"
|
|
||||||
/// declaring edge and face type
|
/// declaring edge and face type
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,10 +52,11 @@ class SharedDataOpenGLContext : public QGLWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SharedDataOpenGLContext(CMesh& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent = 0);
|
SharedDataOpenGLContext(CMeshO& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent = 0);
|
||||||
~SharedDataOpenGLContext();
|
~SharedDataOpenGLContext();
|
||||||
|
|
||||||
void myInitGL();
|
void myInitGL();
|
||||||
|
void deAllocateBO();
|
||||||
|
|
||||||
MLThreadSafeGLMeshAttributesFeeder feeder;
|
MLThreadSafeGLMeshAttributesFeeder feeder;
|
||||||
|
|
||||||
|
@ -65,21 +65,17 @@ public slots:
|
||||||
void passInfoToOpenGL(int mode);
|
void passInfoToOpenGL(int mode);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataReadyToBeRead(MyDrawMode mode);
|
void dataReadyToBeRead(MyDrawMode,vcg::GLFeederInfo::ReqAtts&);
|
||||||
private:
|
|
||||||
GLuint vaohandlespecificicforglcontext;
|
|
||||||
MyDrawMode drawmode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLArea:public QGLWidget
|
class GLArea:public QGLWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent = NULL,QGLWidget* sharedcont = NULL);
|
GLArea (CMeshO& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent = NULL,QGLWidget* sharedcont = NULL);
|
||||||
~GLArea();
|
~GLArea();
|
||||||
|
void resetTrackBall();
|
||||||
/// we choosed a subset of the avaible drawing modes
|
/// we choosed a subset of the avaible drawing modes
|
||||||
public slots:
|
|
||||||
void setupEnvironment(MyDrawMode mode);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// signal for setting the statusbar message
|
/// signal for setting the statusbar message
|
||||||
|
@ -96,30 +92,18 @@ protected:
|
||||||
void mouseMoveEvent(QMouseEvent*e);
|
void mouseMoveEvent(QMouseEvent*e);
|
||||||
void mouseReleaseEvent(QMouseEvent*e);
|
void mouseReleaseEvent(QMouseEvent*e);
|
||||||
void wheelEvent(QWheelEvent*e);
|
void wheelEvent(QWheelEvent*e);
|
||||||
|
public slots:
|
||||||
|
void updateRequested(MyDrawMode,vcg::GLFeederInfo::ReqAtts&);
|
||||||
private:
|
private:
|
||||||
MLAtomicGuard sem;
|
|
||||||
|
|
||||||
GLuint vaohandlespecificicforglcontext;
|
|
||||||
/// the active mesh instance
|
/// the active mesh instance
|
||||||
CMesh& mesh;
|
CMeshO& mesh;
|
||||||
/// the active manipulator
|
/// the active manipulator
|
||||||
vcg::Trackball track;
|
vcg::Trackball track;
|
||||||
/// mesh data structure initializer
|
/// mesh data structure initializer
|
||||||
void initMesh(QString message);
|
void initMesh(QString message);
|
||||||
//MLThreadSafeMemoryInfo& mi;
|
|
||||||
MLThreadSafeGLMeshAttributesFeeder& feeder;
|
|
||||||
|
|
||||||
MyDrawMode drawmode;
|
MyDrawMode drawmode;
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder& feeder;
|
||||||
|
vcg::GLFeederInfo::ReqAtts rq;
|
||||||
};
|
};
|
||||||
|
|
||||||
//class GLAreaEXT:public GLArea
|
|
||||||
//{
|
|
||||||
// Q_OBJECT
|
|
||||||
//public:
|
|
||||||
// GLAreaEXT (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget * parent = NULL,QGLWidget* shared = NULL);
|
|
||||||
// ~GLAreaEXT();
|
|
||||||
//
|
|
||||||
// void paintGL ();
|
|
||||||
//};
|
|
||||||
|
|
||||||
#endif /*GLAREA_H_ */
|
#endif /*GLAREA_H_ */
|
||||||
|
|
|
@ -49,12 +49,10 @@ MainWindow::MainWindow (QWidget * parent)
|
||||||
for(int ii = 0;ii < 2;++ii)
|
for(int ii = 0;ii < 2;++ii)
|
||||||
{
|
{
|
||||||
glar[ii] = new GLArea(mesh,shared->feeder,NULL,shared);
|
glar[ii] = new GLArea(mesh,shared->feeder,NULL,shared);
|
||||||
connect (shared,SIGNAL(dataReadyToBeRead(MyDrawMode)),glar[ii], SLOT (setupEnvironment(MyDrawMode)));
|
connect (shared,SIGNAL(dataReadyToBeRead(MyDrawMode,vcg::GLFeederInfo::ReqAtts&)),glar[ii], SLOT (updateRequested(MyDrawMode,vcg::GLFeederInfo::ReqAtts&)));
|
||||||
tmp->addWidget(glar[ii]);
|
tmp->addWidget(glar[ii]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
connect (ui.loadMeshPushButton, SIGNAL (clicked()),this, SLOT (chooseMesh()));
|
connect (ui.loadMeshPushButton, SIGNAL (clicked()),this, SLOT (chooseMesh()));
|
||||||
connect (ui.loadTetrahedronPushButton, SIGNAL (clicked()),this, SLOT (loadTetrahedron()));
|
connect (ui.loadTetrahedronPushButton, SIGNAL (clicked()),this, SLOT (loadTetrahedron()));
|
||||||
connect (ui.loadDodecahedronPushButton, SIGNAL (clicked()),this, SLOT (loadDodecahedron()));
|
connect (ui.loadDodecahedronPushButton, SIGNAL (clicked()),this, SLOT (loadDodecahedron()));
|
||||||
|
@ -69,10 +67,10 @@ void MainWindow::chooseMesh()
|
||||||
QString fileName = QFileDialog::getOpenFileName(this,
|
QString fileName = QFileDialog::getOpenFileName(this,
|
||||||
tr("Open Mesh"), QDir::currentPath(),
|
tr("Open Mesh"), QDir::currentPath(),
|
||||||
tr("Poly Model (*.ply)"));
|
tr("Poly Model (*.ply)"));
|
||||||
int err=vcg::tri::io::ImporterPLY<CMesh>::Open(mesh,(fileName.toStdString()).c_str());
|
int err=vcg::tri::io::ImporterPLY<CMeshO>::Open(mesh,(fileName.toStdString()).c_str());
|
||||||
if(err!=0)
|
if(err!=0)
|
||||||
{
|
{
|
||||||
const char* errmsg=vcg::tri::io::ImporterPLY<CMesh>::ErrorMsg(err);
|
const char* errmsg=vcg::tri::io::ImporterPLY<CMeshO>::ErrorMsg(err);
|
||||||
QMessageBox::warning(this,tr("Error Loading Mesh"),QString(errmsg));
|
QMessageBox::warning(this,tr("Error Loading Mesh"),QString(errmsg));
|
||||||
}
|
}
|
||||||
initMesh(fileName);
|
initMesh(fileName);
|
||||||
|
@ -94,13 +92,17 @@ void MainWindow::loadDodecahedron()
|
||||||
|
|
||||||
void MainWindow::initMesh(QString message)
|
void MainWindow::initMesh(QString message)
|
||||||
{
|
{
|
||||||
ui.statusbar->showMessage(message);
|
if (shared != NULL)
|
||||||
|
shared->deAllocateBO();
|
||||||
// update bounding box
|
// update bounding box
|
||||||
vcg::tri::UpdateBounding<CMesh>::Box(mesh);
|
vcg::tri::UpdateBounding<CMeshO>::Box(mesh);
|
||||||
// update Normals
|
// update Normals
|
||||||
vcg::tri::UpdateNormal<CMesh>::PerVertexNormalizedPerFaceNormalized(mesh);
|
vcg::tri::UpdateNormal<CMeshO>::PerVertexNormalizedPerFaceNormalized(mesh);
|
||||||
shared->feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
|
||||||
shared->passInfoToOpenGL(ui.drawModeComboBox->currentIndex());
|
shared->passInfoToOpenGL(ui.drawModeComboBox->currentIndex());
|
||||||
|
for(size_t ii = 0;ii < 2;++ii)
|
||||||
|
if (glar[ii] != NULL)
|
||||||
|
glar[ii]->resetTrackBall();
|
||||||
|
ui.statusbar->showMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
SharedDataOpenGLContext* shared;
|
SharedDataOpenGLContext* shared;
|
||||||
MLThreadSafeMemoryInfo mi;
|
MLThreadSafeMemoryInfo mi;
|
||||||
/// the active mesh instance
|
/// the active mesh instance
|
||||||
CMesh mesh;
|
CMeshO mesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*MAINWINDOW_H_ */
|
#endif /*MAINWINDOW_H_ */
|
||||||
|
|
|
@ -10,15 +10,19 @@
|
||||||
#include <wrap/io_trimesh/import.h>
|
#include <wrap/io_trimesh/import.h>
|
||||||
|
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
class CFace;
|
class CFaceO;
|
||||||
class CVertex;
|
class CVertexO;
|
||||||
|
|
||||||
struct MyUsedTypes : public UsedTypes< Use<CVertex> ::AsVertexType,
|
struct MyUsedTypes : public UsedTypes< Use<CVertexO> ::AsVertexType,
|
||||||
Use<CFace> ::AsFaceType>{};
|
Use<CFaceO> ::AsFaceType>{};
|
||||||
|
|
||||||
/// compositing wanted proprieties
|
/// compositing wanted proprieties
|
||||||
class CVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags>{};
|
class CVertexO : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags>{};
|
||||||
class CFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {};
|
class CFaceO : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {};
|
||||||
class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> > {};
|
class CMeshO : public vcg::tri::TriMesh< std::vector<CVertexO>, std::vector<CFaceO> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
vcg::Box3f bbox;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,126 +1,201 @@
|
||||||
#include "ml_scene_renderer.h"
|
#include "ml_scene_renderer.h"
|
||||||
#include "ml_thread_safe_memory_info.h"
|
#include "ml_thread_safe_memory_info.h"
|
||||||
|
#include "glarea.h"
|
||||||
|
|
||||||
MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeGLMeshAttributesFeeder(CMesh& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles)
|
#include <vector>
|
||||||
:GLMeshAttributesFeeder<CMesh>(mesh,gpumeminfo,perbatchtriangles),_lock(QReadWriteLock::Recursive)
|
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeGLMeshAttributesFeeder(CMeshO& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles)
|
||||||
|
:GLMeshAttributesFeeder<CMeshO>(mesh,gpumeminfo,perbatchtriangles),_lock(QReadWriteLock::Recursive)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::setPerBatchTriangles( size_t perbatchtriangles )
|
void MLThreadSafeGLMeshAttributesFeeder::setPerBatchTriangles( size_t perbatchtriangles )
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&_lock);
|
QWriteLocker locker(&_lock);
|
||||||
GLMeshAttributesFeeder<CMesh>::setPerBatchTriangles(perbatchtriangles);
|
GLMeshAttributesFeeder<CMeshO>::setPerBatchPrimitives(perbatchtriangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MLThreadSafeGLMeshAttributesFeeder::perBatchTriangles() const
|
size_t MLThreadSafeGLMeshAttributesFeeder::perBatchTriangles() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&_lock);
|
QReadLocker locker(&_lock);
|
||||||
return GLMeshAttributesFeeder<CMesh>::perBatchTriangles();
|
return GLMeshAttributesFeeder<CMeshO>::perBatchPrimitives();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MLThreadSafeGLMeshAttributesFeeder::renderedWithBO() const
|
bool MLThreadSafeGLMeshAttributesFeeder::renderedWithBO() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&_lock);
|
QReadLocker locker(&_lock);
|
||||||
return GLMeshAttributesFeeder<CMesh>::renderedWithBO();
|
return GLMeshAttributesFeeder<CMeshO>::isPossibleToUseBORendering();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::update( int mask )
|
void MLThreadSafeGLMeshAttributesFeeder::meshAttributesUpdated( int mask )
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&_lock);
|
QWriteLocker locker(&_lock);
|
||||||
GLMeshAttributesFeeder<CMesh>::update(mask);
|
GLMeshAttributesFeeder<CMeshO>::meshAttributesUpdated(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::drawWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
vcg::GLFeederInfo::ReqAtts MLThreadSafeGLMeshAttributesFeeder::setupRequestedAttributes(const vcg::GLFeederInfo::ReqAtts& rq,bool& allocated )
|
||||||
{
|
{
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
QWriteLocker locker(&_lock);
|
||||||
drawTriangles(vaohandlespecificperopenglcontext,nm,cm,vcg::GLFeedEnum::TX_NONE);
|
return GLMeshAttributesFeeder<CMeshO>::setupRequestedAttributes(rq,allocated);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::drawFlatWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm,const std::vector<GLuint>& textureindex )
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::drawWire(vcg::GLFeederInfo::ReqAtts& rq)
|
||||||
|
{
|
||||||
|
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT );
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
drawTriangles(rq);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::drawFlatWire(vcg::GLFeederInfo::ReqAtts& rq)
|
||||||
{
|
{
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT );
|
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT );
|
||||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(1.0, 1);
|
glPolygonOffset(1.0, 1);
|
||||||
drawTriangles(vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NR_PERFACE,cm,tm,textureindex);
|
drawTriangles(rq);
|
||||||
|
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||||
glColor3f(.3f,.3f,.3f);
|
|
||||||
|
|
||||||
drawWire(vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE);
|
ReqAtts tmp = rq;
|
||||||
|
tmp[ATT_VERTCOLOR] = false;
|
||||||
|
tmp[ATT_FACECOLOR] = false;
|
||||||
|
tmp[ATT_MESHCOLOR] = false;
|
||||||
|
|
||||||
|
glColor3f(.3f,.3f,.3f);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
QReadLocker locker(&_lock);
|
||||||
|
GLMeshAttributesFeeder<CMeshO>::drawTriangles(tmp,_textids.textId());
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::drawPoints(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
void MLThreadSafeGLMeshAttributesFeeder::drawPoints(vcg::GLFeederInfo::ReqAtts& rq)
|
||||||
{
|
|
||||||
passPointsToOpenGL(vaohandlespecificperopenglcontext,cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::passPointsToOpenGL(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
|
||||||
{
|
|
||||||
QWriteLocker locker(&_lock);
|
|
||||||
GLMeshAttributesFeeder<CMesh>::passPointsToOpenGL(vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NR_PERVERT,cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::drawTriangles(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm,const std::vector<GLuint>& textureindex )
|
|
||||||
{
|
{
|
||||||
QReadLocker locker(&_lock);
|
QReadLocker locker(&_lock);
|
||||||
GLMeshAttributesFeeder<CMesh>::drawTriangles(vaohandlespecificperopenglcontext,nm,cm,tm,textureindex);
|
GLMeshAttributesFeeder<CMeshO>::drawPoints(rq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::passTrianglesToOpenGL(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm )
|
void MLThreadSafeGLMeshAttributesFeeder::drawTriangles(vcg::GLFeederInfo::ReqAtts& rq)
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&_lock);
|
QReadLocker locker(&_lock);
|
||||||
GLMeshAttributesFeeder<CMesh>::passTrianglesToOpenGL(vaohandlespecificperopenglcontext,nm,cm,tm);
|
GLMeshAttributesFeeder<CMeshO>::drawTriangles(rq,_textids.textId());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MLThreadSafeGLMeshAttributesFeeder::tryToAllocatePerTriangleAttributesInBO( GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm )
|
void MLThreadSafeGLMeshAttributesFeeder::drawBBox(vcg::GLFeederInfo::ReqAtts& rq)
|
||||||
{
|
|
||||||
QWriteLocker locker(&_lock);
|
|
||||||
return GLMeshAttributesFeeder<CMesh>::tryToAllocatePerTriangleAttributesInBO(vaohandlespecificperopenglcontext,nm,cm,tm);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MLThreadSafeGLMeshAttributesFeeder::tryToAllocatePerPointAttributesInBO( GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
|
||||||
{
|
|
||||||
QWriteLocker locker(&_lock);
|
|
||||||
return GLMeshAttributesFeeder<CMesh>::tryToAllocatePerPointAttributesInBO(vaohandlespecificperopenglcontext,nm,cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MLThreadSafeGLMeshAttributesFeeder::updateClientSideEnvironmentVAO( GLuint& vaohandle,const std::vector<bool>& importattribute) const
|
|
||||||
{
|
{
|
||||||
QReadLocker locker(&_lock);
|
QReadLocker locker(&_lock);
|
||||||
|
|
||||||
glBindVertexArray(vaohandle);
|
vcg::Box3f& b = _mesh.bbox;
|
||||||
int ii = 0;
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
for(std::vector<GLBufferObject*>::const_iterator it = _bo.begin();it != _bo.end();++it)
|
glDisable(GL_LIGHTING);
|
||||||
{
|
GLuint bbhandle;
|
||||||
BO_NAMES boname = static_cast<BO_NAMES>(ii);
|
glGenBuffers(1,&bbhandle);
|
||||||
GLBufferObject* cbo = _bo.at(boname);
|
std::vector<vcg::Point3f> bbox(12 * 2);
|
||||||
if (!cbo->_isvalid)
|
|
||||||
disableClientState(boname,importattribute);
|
//0
|
||||||
else
|
bbox[0] = vcg::Point3f((float)b.min[0],(float)b.min[1],(float)b.min[2]);
|
||||||
{
|
bbox[1] = vcg::Point3f((float)b.max[0],(float)b.min[1],(float)b.min[2]);
|
||||||
glBindBuffer(cbo->_target, cbo->_bohandle);
|
|
||||||
setBufferPointerEnableClientState(boname);
|
//1
|
||||||
glBindBuffer(cbo->_target, 0);
|
bbox[2] = vcg::Point3f((float)b.max[0],(float)b.min[1],(float)b.min[2]);
|
||||||
}
|
bbox[3] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.min[2]);
|
||||||
++ii;
|
|
||||||
}
|
//2
|
||||||
glBindVertexArray(0);
|
bbox[4] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.min[2]);
|
||||||
return true;
|
bbox[5] = vcg::Point3f((float)b.min[0],(float)b.max[1],(float)b.min[2]);
|
||||||
|
|
||||||
|
//3
|
||||||
|
bbox[6] = vcg::Point3f((float)b.min[0],(float)b.max[1],(float)b.min[2]);
|
||||||
|
bbox[7] = vcg::Point3f((float)b.min[0],(float)b.min[1],(float)b.min[2]);
|
||||||
|
|
||||||
|
//4
|
||||||
|
bbox[8] = vcg::Point3f((float)b.min[0],(float)b.min[1],(float)b.min[2]);
|
||||||
|
bbox[9] = vcg::Point3f((float)b.min[0],(float)b.min[1],(float)b.max[2]);
|
||||||
|
|
||||||
|
//5
|
||||||
|
bbox[10] = vcg::Point3f((float)b.min[0],(float)b.min[1],(float)b.max[2]);
|
||||||
|
bbox[11] = vcg::Point3f((float)b.max[0],(float)b.min[1],(float)b.max[2]);
|
||||||
|
|
||||||
|
//6
|
||||||
|
bbox[12] = vcg::Point3f((float)b.max[0],(float)b.min[1],(float)b.max[2]);
|
||||||
|
bbox[13] = vcg::Point3f((float)b.max[0],(float)b.min[1],(float)b.min[2]);
|
||||||
|
|
||||||
|
//7
|
||||||
|
bbox[14] = vcg::Point3f((float)b.max[0],(float)b.min[1],(float)b.max[2]);
|
||||||
|
bbox[15] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.max[2]);
|
||||||
|
|
||||||
|
//8
|
||||||
|
bbox[16] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.max[2]);
|
||||||
|
bbox[17] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.min[2]);
|
||||||
|
|
||||||
|
//9
|
||||||
|
bbox[18] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.max[2]);
|
||||||
|
bbox[19] = vcg::Point3f((float)b.min[0],(float)b.max[1],(float)b.max[2]);
|
||||||
|
|
||||||
|
//10
|
||||||
|
bbox[20] = vcg::Point3f((float)b.min[0],(float)b.max[1],(float)b.max[2]);
|
||||||
|
bbox[21] = vcg::Point3f((float)b.min[0],(float)b.min[1],(float)b.max[2]);
|
||||||
|
|
||||||
|
//11
|
||||||
|
bbox[22] = vcg::Point3f((float)b.min[0],(float)b.max[1],(float)b.max[2]);
|
||||||
|
bbox[23] = vcg::Point3f((float)b.min[0],(float)b.max[1],(float)b.min[2]);
|
||||||
|
|
||||||
|
glColor3f(1.0f,1.0f,1.0f);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,bbhandle);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, 12 * 2 * sizeof(vcg::Point3f), &(bbox[0]), GL_STATIC_DRAW);
|
||||||
|
glVertexPointer(3,GL_FLOAT,0,0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDrawArrays(GL_LINES,0,24);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDeleteBuffers(1,&bbhandle);
|
||||||
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::attributesToBeImportedInPointBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm ) const
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::deAllocateBO()
|
||||||
{
|
{
|
||||||
QReadLocker locker(&_lock);
|
QWriteLocker locker(&_lock);
|
||||||
GLMeshAttributesFeeder<CMesh>::attributesToBeImportedInPointBasedPipeline(importattribute,nm,cm);
|
GLMeshAttributesFeeder<CMeshO>::buffersDeAllocationRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeGLMeshAttributesFeeder::attributesToBeImportedInTriangleBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm, TEXTURE_MODALITY tm ) const
|
MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeTextureNamesContainer::MLThreadSafeTextureNamesContainer()
|
||||||
|
:_tmid(),_lock(QReadWriteLock::Recursive)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeTextureNamesContainer::~MLThreadSafeTextureNamesContainer()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeTextureNamesContainer::push_back( GLuint textid )
|
||||||
|
{
|
||||||
|
QWriteLocker locker(&_lock);
|
||||||
|
_tmid.push_back(textid);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeTextureNamesContainer::size() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&_lock);
|
QReadLocker locker(&_lock);
|
||||||
GLMeshAttributesFeeder<CMesh>::attributesToBeImportedInTriangleBasedPipeline(importattribute,nm,cm,tm);
|
return _tmid.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeTextureNamesContainer::empty() const
|
||||||
|
{
|
||||||
|
QReadLocker locker(&_lock);
|
||||||
|
return _tmid.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeTextureNamesContainer::clear()
|
||||||
|
{
|
||||||
|
QWriteLocker locker(&_lock);
|
||||||
|
_tmid.clear();
|
||||||
}
|
}
|
|
@ -24,58 +24,74 @@
|
||||||
#ifndef __ML_SCENE_RENDERER_H
|
#ifndef __ML_SCENE_RENDERER_H
|
||||||
#define __ML_SCENE_RENDERER_H
|
#define __ML_SCENE_RENDERER_H
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include "mesh.h"
|
||||||
|
#include <wrap/gl/gl_mesh_attributes_feeder.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
#include "mesh.h"
|
|
||||||
|
|
||||||
#include <GL/glew.h>
|
|
||||||
#include <wrap/gl/gl_mesh_attributes_feeder.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MLThreadSafeMemoryInfo;
|
class MLThreadSafeMemoryInfo;
|
||||||
|
|
||||||
|
|
||||||
class MLThreadSafeGLMeshAttributesFeeder : public vcg::GLMeshAttributesFeeder<CMesh>
|
class MLThreadSafeGLMeshAttributesFeeder : public vcg::GLMeshAttributesFeeder<CMeshO>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MLThreadSafeGLMeshAttributesFeeder(CMesh& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles);
|
struct MLThreadSafeTextureNamesContainer
|
||||||
~MLThreadSafeGLMeshAttributesFeeder() {};
|
{
|
||||||
void setPerBatchTriangles(size_t perbatchtriangles);
|
MLThreadSafeTextureNamesContainer();
|
||||||
size_t perBatchTriangles() const;
|
~MLThreadSafeTextureNamesContainer();
|
||||||
bool renderedWithBO() const;
|
|
||||||
void update(int mask);
|
|
||||||
|
|
||||||
void passTrianglesToOpenGL(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm );
|
|
||||||
|
|
||||||
void passPointsToOpenGL(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm );
|
|
||||||
|
|
||||||
bool tryToAllocatePerTriangleAttributesInBO( GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm );
|
|
||||||
|
|
||||||
bool tryToAllocatePerPointAttributesInBO( GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm );
|
|
||||||
|
|
||||||
GLuint bufferObjectHandle() const;
|
|
||||||
|
|
||||||
void drawWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm);
|
|
||||||
|
|
||||||
void drawFlatWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm,const std::vector<GLuint>& textureindex = std::vector<GLuint>());
|
|
||||||
|
|
||||||
void drawPoints(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm);
|
|
||||||
|
|
||||||
void drawTriangles(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm,const std::vector<GLuint>& textureindex = std::vector<GLuint>() );
|
|
||||||
|
|
||||||
bool enableClientSideEnvironmentVAO(GLuint& vaohandle) const;
|
|
||||||
|
|
||||||
bool updateClientSideEnvironmentVAO(GLuint& vaohandle,const std::vector<bool>& importattribute) const;
|
|
||||||
|
|
||||||
void attributesToBeImportedInPointBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm) const;
|
|
||||||
|
|
||||||
void attributesToBeImportedInTriangleBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm, TEXTURE_MODALITY tm ) const;
|
|
||||||
|
|
||||||
|
void push_back(GLuint textid);
|
||||||
|
size_t size() const;
|
||||||
|
bool empty() const;
|
||||||
|
void clear();
|
||||||
|
GLuint& operator[](size_t ii) {return _tmid[ii];};
|
||||||
|
inline std::vector<GLuint>& textId() {return _tmid;};
|
||||||
private:
|
private:
|
||||||
|
std::vector<GLuint> _tmid;
|
||||||
mutable QReadWriteLock _lock;
|
mutable QReadWriteLock _lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder(CMeshO& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles);
|
||||||
|
~MLThreadSafeGLMeshAttributesFeeder() {};
|
||||||
|
|
||||||
|
void setPerBatchTriangles(size_t perbatchtriangles);
|
||||||
|
|
||||||
|
size_t perBatchTriangles() const;
|
||||||
|
|
||||||
|
bool renderedWithBO() const;
|
||||||
|
|
||||||
|
GLuint bufferObjectHandle() const;
|
||||||
|
|
||||||
|
void meshAttributesUpdated(int mask);
|
||||||
|
|
||||||
|
vcg::GLFeederInfo::ReqAtts setupRequestedAttributes(const vcg::GLFeederInfo::ReqAtts& rq,bool& allocated);
|
||||||
|
|
||||||
|
void deAllocateBO();
|
||||||
|
|
||||||
|
void drawWire(vcg::GLFeederInfo::ReqAtts& rq);
|
||||||
|
|
||||||
|
void drawFlatWire(vcg::GLFeederInfo::ReqAtts& rq);
|
||||||
|
|
||||||
|
void drawPoints(vcg::GLFeederInfo::ReqAtts& rq);
|
||||||
|
|
||||||
|
void drawTriangles(vcg::GLFeederInfo::ReqAtts& rq);
|
||||||
|
|
||||||
|
void drawBBox(vcg::GLFeederInfo::ReqAtts& rq);
|
||||||
|
|
||||||
|
inline CMeshO& mesh() {return _mesh;}
|
||||||
|
|
||||||
|
inline MLThreadSafeTextureNamesContainer& textureIDContainer() {return _textids;}
|
||||||
|
|
||||||
|
void buffersDeAllocationRequested();
|
||||||
|
private:
|
||||||
|
mutable QReadWriteLock _lock;
|
||||||
|
MLThreadSafeTextureNamesContainer _textids;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "ml_thread_safe_memory_info.h"
|
#include "ml_thread_safe_memory_info.h"
|
||||||
|
|
||||||
MLThreadSafeMemoryInfo::MLThreadSafeMemoryInfo( long long unsigned int originalmem )
|
MLThreadSafeMemoryInfo::MLThreadSafeMemoryInfo( std::ptrdiff_t originalmem )
|
||||||
:vcg::NotThreadSafeMemoryInfo(originalmem),lock(QReadWriteLock::Recursive)
|
:vcg::NotThreadSafeMemoryInfo(originalmem),lock(QReadWriteLock::Recursive)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -33,32 +33,32 @@ MLThreadSafeMemoryInfo::~MLThreadSafeMemoryInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeMemoryInfo::acquiredMemory(long long unsigned int mem)
|
void MLThreadSafeMemoryInfo::acquiredMemory(std::ptrdiff_t mem)
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&lock);
|
QWriteLocker locker(&lock);
|
||||||
vcg::NotThreadSafeMemoryInfo::acquiredMemory(mem);
|
vcg::NotThreadSafeMemoryInfo::acquiredMemory(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long unsigned int MLThreadSafeMemoryInfo::usedMemory() const
|
std::ptrdiff_t MLThreadSafeMemoryInfo::usedMemory() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&lock);
|
QReadLocker locker(&lock);
|
||||||
return vcg::NotThreadSafeMemoryInfo::usedMemory();
|
return vcg::NotThreadSafeMemoryInfo::usedMemory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long long unsigned int MLThreadSafeMemoryInfo::currentFreeMemory() const
|
std::ptrdiff_t MLThreadSafeMemoryInfo::currentFreeMemory() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&lock);
|
QReadLocker locker(&lock);
|
||||||
return vcg::NotThreadSafeMemoryInfo::currentFreeMemory();
|
return vcg::NotThreadSafeMemoryInfo::currentFreeMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLThreadSafeMemoryInfo::releasedMemory(long long unsigned int mem)
|
void MLThreadSafeMemoryInfo::releasedMemory(std::ptrdiff_t mem)
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&lock);
|
QWriteLocker locker(&lock);
|
||||||
vcg::NotThreadSafeMemoryInfo::releasedMemory(mem);
|
vcg::NotThreadSafeMemoryInfo::releasedMemory(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MLThreadSafeMemoryInfo::isAdditionalMemoryAvailable( long long unsigned int mem )
|
bool MLThreadSafeMemoryInfo::isAdditionalMemoryAvailable( std::ptrdiff_t mem )
|
||||||
{
|
{
|
||||||
QReadLocker locker(&lock);
|
QReadLocker locker(&lock);
|
||||||
return vcg::NotThreadSafeMemoryInfo::isAdditionalMemoryAvailable(mem);
|
return vcg::NotThreadSafeMemoryInfo::isAdditionalMemoryAvailable(mem);
|
||||||
|
|
|
@ -26,28 +26,25 @@
|
||||||
|
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
#include "mesh.h"
|
#include <wrap/system/memory_info.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
|
||||||
#include <wrap/gl/gl_mesh_attributes_feeder.h>
|
|
||||||
|
|
||||||
|
|
||||||
class MLThreadSafeMemoryInfo : public vcg::NotThreadSafeMemoryInfo
|
class MLThreadSafeMemoryInfo : public vcg::NotThreadSafeMemoryInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MLThreadSafeMemoryInfo(long long unsigned int originalmem);
|
MLThreadSafeMemoryInfo(std::ptrdiff_t originalmem);
|
||||||
|
|
||||||
~MLThreadSafeMemoryInfo();
|
~MLThreadSafeMemoryInfo();
|
||||||
|
|
||||||
void acquiredMemory(long long unsigned int mem);
|
void acquiredMemory(std::ptrdiff_t mem);
|
||||||
|
|
||||||
long long unsigned int usedMemory() const;
|
std::ptrdiff_t usedMemory() const;
|
||||||
|
|
||||||
long long unsigned int currentFreeMemory() const;
|
std::ptrdiff_t currentFreeMemory() const;
|
||||||
|
|
||||||
void releasedMemory(long long unsigned int mem = 0);
|
void releasedMemory(std::ptrdiff_t mem = 0);
|
||||||
|
|
||||||
bool isAdditionalMemoryAvailable(long long unsigned int mem);
|
bool isAdditionalMemoryAvailable(std::ptrdiff_t mem);
|
||||||
private:
|
private:
|
||||||
//mutable objects can be modified from the declared const functions
|
//mutable objects can be modified from the declared const functions
|
||||||
//in this way we have not to modified the basic vcg::MemoryInfo interface for the logically const functions
|
//in this way we have not to modified the basic vcg::MemoryInfo interface for the logically const functions
|
||||||
|
|
Loading…
Reference in New Issue