- updated version of the shared context - multiple windows renderer
This commit is contained in:
parent
8842cea2b3
commit
1864d686c0
|
@ -30,6 +30,7 @@ Initial release.
|
|||
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "glarea.h"
|
||||
#include <QKeyEvent>
|
||||
#include <QKeyEvent>
|
||||
|
@ -39,14 +40,14 @@ Initial release.
|
|||
|
||||
#ifdef Q_OS_MAC
|
||||
#define glGenVertexArrays glGenVertexArraysAPPLE
|
||||
#define glBindVertexArrays glBindVertexArraysAPPLE
|
||||
#define glBindVertexArray glBindVertexArrayAPPLE
|
||||
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
|
||||
#endif
|
||||
|
||||
GLArea::GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget * parent)
|
||||
:QGLWidget (parent),vaohandlespecificicforglcontext(0),mesh(m),feeder(feed)
|
||||
GLArea::GLArea (CMesh& m, MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent,QGLWidget* sharedcont)
|
||||
:QGLWidget (parent,sharedcont),vaohandlespecificicforglcontext(0),mesh(m),feeder(feed),sem(0)
|
||||
{
|
||||
drawmode= SMOOTH;
|
||||
drawmode= MDM_SMOOTH;
|
||||
}
|
||||
|
||||
GLArea::~GLArea()
|
||||
|
@ -54,21 +55,11 @@ GLArea::~GLArea()
|
|||
glDeleteVertexArrays(1,&vaohandlespecificicforglcontext);
|
||||
}
|
||||
|
||||
|
||||
void GLArea::selectDrawMode(int mode)
|
||||
{
|
||||
feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||
drawmode=DrawMode(mode);
|
||||
updateGL();
|
||||
}
|
||||
|
||||
void GLArea::initializeGL ()
|
||||
void GLArea::initializeGL()
|
||||
{
|
||||
makeCurrent();
|
||||
glewExperimental=GL_TRUE;
|
||||
glewInit();
|
||||
if (vaohandlespecificicforglcontext == 0)
|
||||
glGenVertexArrays(1,&vaohandlespecificicforglcontext);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
@ -76,18 +67,21 @@ void GLArea::initializeGL ()
|
|||
glEnable(GL_COLOR_MATERIAL);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glGenVertexArrays(1,&vaohandlespecificicforglcontext);
|
||||
}
|
||||
|
||||
void GLArea::resizeGL (int w, int h)
|
||||
{
|
||||
makeCurrent();
|
||||
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
|
||||
initializeGL();
|
||||
//initializeGL();
|
||||
}
|
||||
|
||||
void GLArea::paintGL ()
|
||||
{
|
||||
makeCurrent();
|
||||
//GLenum err = glGetError();
|
||||
//assert(err == GL_NO_ERROR);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
@ -102,34 +96,38 @@ void GLArea::paintGL ()
|
|||
glPushMatrix();
|
||||
float d=2.0f/mesh.bbox.Diag();
|
||||
vcg::glScale(d);
|
||||
glTranslate(mesh.bbox.Center());
|
||||
// the trimesh drawing calls
|
||||
glTranslate(-mesh.bbox.Center());
|
||||
|
||||
switch(drawmode)
|
||||
if (sem == true)
|
||||
{
|
||||
case SMOOTH:
|
||||
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
case POINTS:
|
||||
feeder.drawPoints(vaohandlespecificicforglcontext,vcg::GLFeedEnum::CL_NONE);
|
||||
break;
|
||||
case WIRE:
|
||||
feeder.drawWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
||||
break;
|
||||
case FLATWIRE:
|
||||
feeder.drawFlatWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
case FLAT:
|
||||
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
glBindVertexArray(vaohandlespecificicforglcontext);
|
||||
switch(drawmode)
|
||||
{
|
||||
case MDM_SMOOTH:
|
||||
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
case MDM_POINTS:
|
||||
feeder.drawPoints(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
||||
break;
|
||||
case MDM_WIRE:
|
||||
feeder.drawWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
||||
break;
|
||||
case MDM_FLATWIRE:
|
||||
feeder.drawFlatWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
case MDM_FLAT:
|
||||
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
track.DrawPostApply();
|
||||
GLenum err = glGetError();
|
||||
assert(err == GL_NO_ERROR);
|
||||
GLenum err = glGetError();
|
||||
assert(err == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void GLArea::keyReleaseEvent (QKeyEvent * e)
|
||||
|
@ -184,3 +182,73 @@ void GLArea::wheelEvent (QWheelEvent * e)
|
|||
track.MouseWheel (e->delta () / float (WHEEL_STEP), QTWheel2VCG (e->modifiers ()));
|
||||
updateGL ();
|
||||
}
|
||||
|
||||
void GLArea::setupEnvironment(MyDrawMode mode)
|
||||
{
|
||||
sem = false;
|
||||
drawmode=mode;
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
SharedDataOpenGLContext::SharedDataOpenGLContext( CMesh& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent /*= 0*/ )
|
||||
:QGLWidget(parent),feeder(mesh,mi,100000),vaohandlespecificicforglcontext(0),drawmode(MDM_SMOOTH)
|
||||
{
|
||||
}
|
||||
|
||||
SharedDataOpenGLContext::~SharedDataOpenGLContext()
|
||||
{
|
||||
makeCurrent();
|
||||
}
|
||||
|
||||
void SharedDataOpenGLContext::myInitGL()
|
||||
{
|
||||
makeCurrent();
|
||||
glewInit();
|
||||
glGenVertexArrays(1,&vaohandlespecificicforglcontext);
|
||||
}
|
||||
|
||||
void SharedDataOpenGLContext::passInfoToOpenGL(int mode)
|
||||
{
|
||||
makeCurrent();
|
||||
drawmode = static_cast<MyDrawMode>(mode);
|
||||
//_tsbm.setUpBuffers();
|
||||
switch(drawmode)
|
||||
{
|
||||
case MDM_SMOOTH:
|
||||
case MDM_WIRE:
|
||||
feeder.tryToAllocatePerTriangleAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
case MDM_POINTS:
|
||||
feeder.tryToAllocatePerPointAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
|
||||
break;
|
||||
case MDM_FLAT:
|
||||
case MDM_FLATWIRE:
|
||||
feeder.tryToAllocatePerTriangleAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
emit dataReadyToBeRead(drawmode);
|
||||
}
|
||||
|
|
|
@ -37,26 +37,50 @@ Initial release.
|
|||
#include <GL/glew.h>
|
||||
#include <QGLWidget>
|
||||
|
||||
|
||||
/// wrapper imports
|
||||
#include <wrap/gui/trackball.h>
|
||||
|
||||
|
||||
#include "mesh.h"
|
||||
#include "ml_scene_renderer.h"
|
||||
#include "ml_atomic_guard.h"
|
||||
/// declaring edge and face type
|
||||
|
||||
|
||||
enum MyDrawMode{MDM_SMOOTH=0,MDM_POINTS,MDM_WIRE,MDM_FLATWIRE,MDM_FLAT};
|
||||
|
||||
class SharedDataOpenGLContext : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SharedDataOpenGLContext(CMesh& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent = 0);
|
||||
~SharedDataOpenGLContext();
|
||||
|
||||
void myInitGL();
|
||||
|
||||
MLThreadSafeGLMeshAttributesFeeder feeder;
|
||||
|
||||
public slots:
|
||||
/// widget-based user interaction slots
|
||||
void passInfoToOpenGL(int mode);
|
||||
|
||||
signals:
|
||||
void dataReadyToBeRead(MyDrawMode mode);
|
||||
private:
|
||||
GLuint vaohandlespecificicforglcontext;
|
||||
MyDrawMode drawmode;
|
||||
};
|
||||
|
||||
class GLArea:public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget * parent = 0);
|
||||
GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent = NULL,QGLWidget* sharedcont = NULL);
|
||||
~GLArea();
|
||||
/// we choosed a subset of the avaible drawing modes
|
||||
enum DrawMode{SMOOTH=0,POINTS,WIRE,FLATWIRE,FLAT};
|
||||
public slots:
|
||||
/// widget-based user interaction slots
|
||||
void selectDrawMode(int mode);
|
||||
public slots:
|
||||
void setupEnvironment(MyDrawMode mode);
|
||||
|
||||
signals:
|
||||
/// signal for setting the statusbar message
|
||||
void setStatusBar(QString message);
|
||||
|
@ -73,17 +97,29 @@ protected:
|
|||
void mouseReleaseEvent(QMouseEvent*e);
|
||||
void wheelEvent(QWheelEvent*e);
|
||||
private:
|
||||
MLAtomicGuard sem;
|
||||
|
||||
GLuint vaohandlespecificicforglcontext;
|
||||
/// the active mesh instance
|
||||
CMesh& mesh;
|
||||
/// the active manipulator
|
||||
vcg::Trackball track;
|
||||
/// the current drawmode
|
||||
DrawMode drawmode;
|
||||
/// mesh data structure initializer
|
||||
void initMesh(QString message);
|
||||
//MLThreadSafeMemoryInfo& mi;
|
||||
MLThreadSafeGLMeshAttributesFeeder& feeder;
|
||||
|
||||
MyDrawMode drawmode;
|
||||
};
|
||||
|
||||
//class GLAreaEXT:public GLArea
|
||||
//{
|
||||
// Q_OBJECT
|
||||
//public:
|
||||
// GLAreaEXT (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget * parent = NULL,QGLWidget* shared = NULL);
|
||||
// ~GLAreaEXT();
|
||||
//
|
||||
// void paintGL ();
|
||||
//};
|
||||
|
||||
#endif /*GLAREA_H_ */
|
||||
|
|
|
@ -42,7 +42,7 @@ $Log: not supported by cvs2svn $
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
MainWindow *mw = new MainWindow;
|
||||
mw->show();
|
||||
MainWindow mw;
|
||||
mw.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -31,23 +31,30 @@ $Log: not supported by cvs2svn $
|
|||
#include "mainwindow.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
MainWindow::MainWindow (QWidget * parent)
|
||||
:QMainWindow (parent),mi(1000000000),mesh(),feeder(mesh,mi,100000)
|
||||
:QMainWindow (parent),mi(1000000000),mesh()
|
||||
{
|
||||
ui.setupUi (this);
|
||||
QLayout* tmp = ui.glFrame->layout();
|
||||
|
||||
//parent is set to NULL in order to avoid QT bug on MAC (business as usual...).
|
||||
//The QGLWidget are destroyed by hand in the MainWindow destructor...
|
||||
shared = new SharedDataOpenGLContext(mesh,mi,NULL);
|
||||
shared->setHidden(true);
|
||||
shared->myInitGL();
|
||||
connect (ui.drawModeComboBox, SIGNAL (currentIndexChanged(int)),shared, SLOT (passInfoToOpenGL(int)));
|
||||
|
||||
for(int ii = 0;ii < 2;++ii)
|
||||
{
|
||||
glar[ii] = new GLArea(mesh,feeder,this);
|
||||
|
||||
connect (ui.drawModeComboBox, SIGNAL (currentIndexChanged(int)),
|
||||
glar[ii], SLOT (selectDrawMode(int)));
|
||||
|
||||
glar[ii] = new GLArea(mesh,shared->feeder,NULL,shared);
|
||||
connect (shared,SIGNAL(dataReadyToBeRead(MyDrawMode)),glar[ii], SLOT (setupEnvironment(MyDrawMode)));
|
||||
tmp->addWidget(glar[ii]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
connect (ui.loadMeshPushButton, SIGNAL (clicked()),this, SLOT (chooseMesh()));
|
||||
connect (ui.loadTetrahedronPushButton, SIGNAL (clicked()),this, SLOT (loadTetrahedron()));
|
||||
connect (ui.loadDodecahedronPushButton, SIGNAL (clicked()),this, SLOT (loadDodecahedron()));
|
||||
|
@ -87,15 +94,18 @@ void MainWindow::loadDodecahedron()
|
|||
|
||||
void MainWindow::initMesh(QString message)
|
||||
{
|
||||
//feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||
ui.statusbar->showMessage(message);
|
||||
// update bounding box
|
||||
vcg::tri::UpdateBounding<CMesh>::Box(mesh);
|
||||
// update Normals
|
||||
vcg::tri::UpdateNormal<CMesh>::PerVertexNormalizedPerFaceNormalized(mesh);
|
||||
shared->feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||
shared->passInfoToOpenGL(ui.drawModeComboBox->currentIndex());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
for(int ii = 0;ii < 2;++ii)
|
||||
{
|
||||
feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||
glar[ii]->updateGL();
|
||||
}
|
||||
ui.statusbar->showMessage(message);
|
||||
}
|
||||
delete glar[ii];
|
||||
delete shared;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@ $Log: not supported by cvs2svn $
|
|||
#include "glarea.h"
|
||||
#include "ml_thread_safe_memory_info.h"
|
||||
|
||||
|
||||
class MainWindow:public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(QWidget * parent = 0);
|
||||
~MainWindow();
|
||||
public slots:
|
||||
void chooseMesh();
|
||||
void loadTetrahedron();
|
||||
|
@ -50,11 +52,10 @@ private:
|
|||
Ui::mainWindow ui;
|
||||
GLArea* glar[2];
|
||||
|
||||
GLArea* shared;
|
||||
SharedDataOpenGLContext* shared;
|
||||
MLThreadSafeMemoryInfo mi;
|
||||
/// the active mesh instance
|
||||
CMesh mesh;
|
||||
MLThreadSafeGLMeshAttributesFeeder feeder;
|
||||
};
|
||||
|
||||
#endif /*MAINWINDOW_H_ */
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef __ML_ATOMIC_GUARD_H
|
||||
#define __ML_ATOMIC_GUARD_H
|
||||
|
||||
class MLAtomicGuard
|
||||
{
|
||||
public:
|
||||
MLAtomicGuard(bool val)
|
||||
:_lock(QReadWriteLock::Recursive),_guard(val) {}
|
||||
|
||||
~MLAtomicGuard() {}
|
||||
|
||||
MLAtomicGuard& operator=(bool v)
|
||||
{
|
||||
QWriteLocker locker(&_lock);
|
||||
_guard = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(bool v) const
|
||||
{
|
||||
QReadLocker locker(&_lock);
|
||||
return (_guard == v);
|
||||
}
|
||||
|
||||
bool operator!=(bool v) const
|
||||
{
|
||||
QReadLocker locker(&_lock);
|
||||
return (_guard != v);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _guard;
|
||||
mutable QReadWriteLock _lock;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -38,12 +38,12 @@ void MLThreadSafeGLMeshAttributesFeeder::drawWire(GLuint& vaohandlespecificperop
|
|||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
void MLThreadSafeGLMeshAttributesFeeder::drawFlatWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm )
|
||||
void MLThreadSafeGLMeshAttributesFeeder::drawFlatWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm,const std::vector<GLuint>& textureindex )
|
||||
{
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT );
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0, 1);
|
||||
drawTriangles(vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NR_PERFACE,cm,tm);
|
||||
drawTriangles(vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NR_PERFACE,cm,tm,textureindex);
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
@ -54,16 +54,73 @@ void MLThreadSafeGLMeshAttributesFeeder::drawFlatWire(GLuint& vaohandlespecificp
|
|||
glPopAttrib();
|
||||
}
|
||||
|
||||
void MLThreadSafeGLMeshAttributesFeeder::drawPoints(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
||||
void MLThreadSafeGLMeshAttributesFeeder::drawPoints(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
||||
{
|
||||
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 )
|
||||
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);
|
||||
GLMeshAttributesFeeder<CMesh>::drawTriangles(vaohandlespecificperopenglcontext,nm,cm,tm,textureindex);
|
||||
}
|
||||
|
||||
void MLThreadSafeGLMeshAttributesFeeder::passTrianglesToOpenGL(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm )
|
||||
{
|
||||
QWriteLocker locker(&_lock);
|
||||
GLMeshAttributesFeeder<CMesh>::passTrianglesToOpenGL(vaohandlespecificperopenglcontext,nm,cm,tm);
|
||||
}
|
||||
|
||||
bool MLThreadSafeGLMeshAttributesFeeder::tryToAllocatePerTriangleAttributesInBO( GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm )
|
||||
{
|
||||
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);
|
||||
|
||||
glBindVertexArray(vaohandle);
|
||||
int ii = 0;
|
||||
for(std::vector<GLBufferObject*>::const_iterator it = _bo.begin();it != _bo.end();++it)
|
||||
{
|
||||
BO_NAMES boname = static_cast<BO_NAMES>(ii);
|
||||
GLBufferObject* cbo = _bo.at(boname);
|
||||
if (!cbo->_isvalid)
|
||||
disableClientState(boname,importattribute);
|
||||
else
|
||||
{
|
||||
glBindBuffer(cbo->_target, cbo->_bohandle);
|
||||
setBufferPointerEnableClientState(boname);
|
||||
glBindBuffer(cbo->_target, 0);
|
||||
}
|
||||
++ii;
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MLThreadSafeGLMeshAttributesFeeder::attributesToBeImportedInPointBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm ) const
|
||||
{
|
||||
QReadLocker locker(&_lock);
|
||||
GLMeshAttributesFeeder<CMesh>::attributesToBeImportedInPointBasedPipeline(importattribute,nm,cm);
|
||||
}
|
||||
|
||||
void MLThreadSafeGLMeshAttributesFeeder::attributesToBeImportedInTriangleBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm, TEXTURE_MODALITY tm ) const
|
||||
{
|
||||
QReadLocker locker(&_lock);
|
||||
GLMeshAttributesFeeder<CMesh>::attributesToBeImportedInTriangleBasedPipeline(importattribute,nm,cm,tm);
|
||||
}
|
||||
|
|
|
@ -47,13 +47,33 @@ public:
|
|||
size_t perBatchTriangles() const;
|
||||
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);
|
||||
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::COLOR_MODALITY cm);
|
||||
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 drawTriangles(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm);
|
||||
private:
|
||||
mutable QReadWriteLock _lock;
|
||||
};
|
||||
|
|
|
@ -35,38 +35,31 @@ MLThreadSafeMemoryInfo::~MLThreadSafeMemoryInfo()
|
|||
|
||||
void MLThreadSafeMemoryInfo::acquiredMemory(long long unsigned int mem)
|
||||
{
|
||||
lock.lockForWrite();
|
||||
QWriteLocker locker(&lock);
|
||||
vcg::NotThreadSafeMemoryInfo::acquiredMemory(mem);
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
long long unsigned int MLThreadSafeMemoryInfo::usedMemory() const
|
||||
{
|
||||
lock.lockForRead();
|
||||
long long unsigned int tmp = vcg::NotThreadSafeMemoryInfo::usedMemory();
|
||||
lock.unlock();
|
||||
return tmp;
|
||||
QReadLocker locker(&lock);
|
||||
return vcg::NotThreadSafeMemoryInfo::usedMemory();
|
||||
|
||||
}
|
||||
|
||||
long long unsigned int MLThreadSafeMemoryInfo::currentFreeMemory() const
|
||||
{
|
||||
lock.lockForRead();
|
||||
long long unsigned int tmp = vcg::NotThreadSafeMemoryInfo::currentFreeMemory();
|
||||
lock.unlock();
|
||||
return tmp;
|
||||
QReadLocker locker(&lock);
|
||||
return vcg::NotThreadSafeMemoryInfo::currentFreeMemory();
|
||||
}
|
||||
|
||||
void MLThreadSafeMemoryInfo::releasedMemory(long long unsigned int mem)
|
||||
{
|
||||
lock.lockForWrite();
|
||||
QWriteLocker locker(&lock);
|
||||
vcg::NotThreadSafeMemoryInfo::releasedMemory(mem);
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
bool MLThreadSafeMemoryInfo::isAdditionalMemoryAvailable( long long unsigned int mem )
|
||||
{
|
||||
lock.lockForRead();
|
||||
bool tmp = vcg::NotThreadSafeMemoryInfo::isAdditionalMemoryAvailable(mem);
|
||||
lock.unlock();
|
||||
return tmp;
|
||||
QReadLocker locker(&lock);
|
||||
return vcg::NotThreadSafeMemoryInfo::isAdditionalMemoryAvailable(mem);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ HEADERS += mainwindow.h
|
|||
HEADERS += glarea.h
|
||||
HEADERS += ml_thread_safe_memory_info.h
|
||||
HEADERS += ml_scene_renderer.h
|
||||
HEADERS += ml_atomic_guard.h
|
||||
|
||||
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
Loading…
Reference in New Issue