- recommitted last working version of the trimesh_QT_shared project contained in the git repository

This commit is contained in:
granzuglia 2015-07-30 11:13:19 +00:00
parent 59dd06f949
commit 6bb2ed6382
12 changed files with 1078 additions and 993 deletions

View File

@ -1,254 +1,261 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
* Copyright(C) 2007 \/)\/ * * Copyright(C) 2007 \/)\/ *
* Visual Computing Lab /\/| * * Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | * * ISTI - Italian National Research Council | *
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.1 2007/10/18 08:52:06 benedetti Revision 1.1 2007/10/18 08:52:06 benedetti
Initial release. Initial release.
****************************************************************************/ ****************************************************************************/
#include "glarea.h" #include "glarea.h"
#include <QKeyEvent> #include <QKeyEvent>
#include <QKeyEvent> #include <QKeyEvent>
#include <QWheelEvent> #include <QWheelEvent>
#include <wrap/qt/trackball.h> #include <wrap/qt/trackball.h>
#include <cassert> #include <cassert>
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#define glGenVertexArrays glGenVertexArraysAPPLE #define glGenVertexArrays glGenVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE #define glBindVertexArray glBindVertexArrayAPPLE
#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() makeCurrent();
{ glewExperimental=GL_TRUE;
makeCurrent(); glewInit();
glewExperimental=GL_TRUE; glClearColor(0, 0, 0, 0);
glewInit(); glEnable(GL_LIGHTING);
glClearColor(0, 0, 0, 0); glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING); glEnable(GL_NORMALIZE);
glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL);
glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE);
glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); }
glEnable(GL_DEPTH_TEST);
glGenVertexArrays(1,&vaohandlespecificicforglcontext); void GLArea::resizeGL (int w, int h)
} {
makeCurrent();
void GLArea::resizeGL (int w, int h) glViewport (0, 0, (GLsizei) w, (GLsizei) h);
{ //initializeGL();
makeCurrent(); }
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
//initializeGL(); void GLArea::paintGL ()
} {
makeCurrent();
void GLArea::paintGL () glPushAttrib(GL_ALL_ATTRIB_BITS);
{ //GLenum err = glGetError();
makeCurrent(); //assert(err == GL_NO_ERROR);
//GLenum err = glGetError(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//assert(err == GL_NO_ERROR); glMatrixMode(GL_PROJECTION);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix();
glMatrixMode(GL_PROJECTION); 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);
track.radius= 1; track.radius= 1;
track.GetView(); track.GetView();
track.Apply(); track.Apply();
glPushMatrix(); glPushMatrix();
float d=2.0f/mesh.bbox.Diag(); float d=2.0f/mesh.bbox.Diag();
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: case MDM_FLAT:
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); feeder.drawTriangles(rq);
break; case MDM_WIRE:
case MDM_POINTS: feeder.drawWire(rq);
feeder.drawPoints(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE); break;
break; case MDM_POINTS:
case MDM_WIRE: feeder.drawPoints(rq);
feeder.drawWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE); break;
break; case MDM_FLATWIRE:
case MDM_FLATWIRE: feeder.drawFlatWire(rq);
feeder.drawFlatWire(vaohandlespecificicforglcontext,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); break;
break; default:
case MDM_FLAT: break;
feeder.drawTriangles(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); }
break; }
default: glPopMatrix();
break;
} track.DrawPostApply();
glBindVertexArray(0); glPopMatrix();
} glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopMatrix(); glPopAttrib();
track.DrawPostApply(); //doneCurrent();
GLenum err = glGetError(); GLenum err = glGetError();
assert(err == GL_NO_ERROR); assert(err == GL_NO_ERROR);
} }
void GLArea::keyReleaseEvent (QKeyEvent * e) void GLArea::keyReleaseEvent (QKeyEvent * e)
{ {
e->ignore (); e->ignore ();
if (e->key () == Qt::Key_Control) if (e->key () == Qt::Key_Control)
track.ButtonUp (QT2VCG (Qt::NoButton, Qt::ControlModifier)); track.ButtonUp (QT2VCG (Qt::NoButton, Qt::ControlModifier));
if (e->key () == Qt::Key_Shift) if (e->key () == Qt::Key_Shift)
track.ButtonUp (QT2VCG (Qt::NoButton, Qt::ShiftModifier)); track.ButtonUp (QT2VCG (Qt::NoButton, Qt::ShiftModifier));
if (e->key () == Qt::Key_Alt) if (e->key () == Qt::Key_Alt)
track.ButtonUp (QT2VCG (Qt::NoButton, Qt::AltModifier)); track.ButtonUp (QT2VCG (Qt::NoButton, Qt::AltModifier));
updateGL (); updateGL ();
} }
void GLArea::keyPressEvent (QKeyEvent * e) void GLArea::keyPressEvent (QKeyEvent * e)
{ {
e->ignore (); e->ignore ();
if (e->key () == Qt::Key_Control) if (e->key () == Qt::Key_Control)
track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ControlModifier)); track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ControlModifier));
if (e->key () == Qt::Key_Shift) if (e->key () == Qt::Key_Shift)
track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ShiftModifier)); track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ShiftModifier));
if (e->key () == Qt::Key_Alt) if (e->key () == Qt::Key_Alt)
track.ButtonDown (QT2VCG (Qt::NoButton, Qt::AltModifier)); track.ButtonDown (QT2VCG (Qt::NoButton, Qt::AltModifier));
updateGL (); updateGL ();
} }
void GLArea::mousePressEvent (QMouseEvent * e) void GLArea::mousePressEvent (QMouseEvent * e)
{ {
e->accept (); e->accept ();
setFocus (); setFocus ();
track.MouseDown (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ())); track.MouseDown (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ()));
updateGL (); updateGL ();
} }
void GLArea::mouseMoveEvent (QMouseEvent * e) void GLArea::mouseMoveEvent (QMouseEvent * e)
{ {
if (e->buttons ()) { if (e->buttons ()) {
track.MouseMove (QT2VCG_X(this,e), QT2VCG_Y(this,e)); track.MouseMove (QT2VCG_X(this,e), QT2VCG_Y(this,e));
updateGL (); updateGL ();
} }
} }
void GLArea::mouseReleaseEvent (QMouseEvent * e) void GLArea::mouseReleaseEvent (QMouseEvent * e)
{ {
track.MouseUp (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ())); track.MouseUp (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ()));
updateGL (); updateGL ();
} }
void GLArea::wheelEvent (QWheelEvent * e) void GLArea::wheelEvent (QWheelEvent * e)
{ {
const int WHEEL_STEP = 120; const int WHEEL_STEP = 120;
track.MouseWheel (e->delta () / float (WHEEL_STEP), QTWheel2VCG (e->modifiers ())); track.MouseWheel (e->delta () / float (WHEEL_STEP), QTWheel2VCG (e->modifiers ()));
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(); updateGL();
std::vector<bool> import(8,false); }
switch(drawmode) void GLArea::resetTrackBall()
{ {
case MDM_SMOOTH: makeCurrent();
case MDM_WIRE: track.Reset();
feeder.attributesToBeImportedInTriangleBasedPipeline(import,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); updateGL();
break; doneCurrent();
case MDM_POINTS: }
feeder.attributesToBeImportedInPointBasedPipeline(import,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE);
break;
case MDM_FLAT:
case MDM_FLATWIRE: SharedDataOpenGLContext::SharedDataOpenGLContext( CMeshO& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent /*= 0*/ )
feeder.attributesToBeImportedInTriangleBasedPipeline(import,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); :QGLWidget(parent),feeder(mesh,mi,100000)
break; {
default: }
break;
} SharedDataOpenGLContext::~SharedDataOpenGLContext()
feeder.updateClientSideEnvironmentVAO(vaohandlespecificicforglcontext,import); {
sem = true; deAllocateBO();
updateGL(); }
}
void SharedDataOpenGLContext::myInitGL()
{
SharedDataOpenGLContext::SharedDataOpenGLContext( CMesh& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent /*= 0*/ ) makeCurrent();
:QGLWidget(parent),feeder(mesh,mi,100000),vaohandlespecificicforglcontext(0),drawmode(MDM_SMOOTH) glewInit();
{ doneCurrent();
} }
SharedDataOpenGLContext::~SharedDataOpenGLContext() void SharedDataOpenGLContext::passInfoToOpenGL(int mode)
{ {
makeCurrent(); makeCurrent();
} MyDrawMode drawmode = static_cast<MyDrawMode>(mode);
//_tsbm.setUpBuffers();
void SharedDataOpenGLContext::myInitGL() vcg::GLFeederInfo::ReqAtts req;
{ bool allocated = false;
makeCurrent(); switch(drawmode)
glewInit(); {
glGenVertexArrays(1,&vaohandlespecificicforglcontext); case MDM_SMOOTH:
} case MDM_WIRE:
req[vcg::GLFeederInfo::ATT_VERTPOSITION] = true;
void SharedDataOpenGLContext::passInfoToOpenGL(int mode) req[vcg::GLFeederInfo::ATT_VERTNORMAL] = true;
{ req[vcg::GLFeederInfo::ATT_VERTINDEX] = true;
makeCurrent(); req.primitiveModality() = vcg::GLFeederInfo::PR_TRIANGLES;
drawmode = static_cast<MyDrawMode>(mode); break;
//_tsbm.setUpBuffers(); case MDM_POINTS:
switch(drawmode) req[vcg::GLFeederInfo::ATT_VERTPOSITION] = true;
{ req[vcg::GLFeederInfo::ATT_VERTNORMAL] = true;
case MDM_SMOOTH: req.primitiveModality() = vcg::GLFeederInfo::PR_POINTS;
case MDM_WIRE: break;
feeder.tryToAllocatePerTriangleAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); case MDM_FLAT:
break; case MDM_FLATWIRE:
case MDM_POINTS: req[vcg::GLFeederInfo::ATT_VERTPOSITION] = true;
feeder.tryToAllocatePerPointAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERVERT,vcg::GLFeedEnum::CL_NONE); req[vcg::GLFeederInfo::ATT_FACENORMAL] = true;
break; req.primitiveModality() = vcg::GLFeederInfo::PR_TRIANGLES;
case MDM_FLAT: break;
case MDM_FLATWIRE: default:
feeder.tryToAllocatePerTriangleAttributesInBO(vaohandlespecificicforglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE,vcg::GLFeedEnum::TX_NONE); break;
break; }
default: vcg::GLFeederInfo::ReqAtts rq = feeder.setupRequestedAttributes(req,allocated);
break; doneCurrent();
} emit dataReadyToBeRead(drawmode,rq);
emit dataReadyToBeRead(drawmode);
} }
void SharedDataOpenGLContext::deAllocateBO()
{
makeCurrent();
feeder.deAllocateBO();
doneCurrent();
}

View File

@ -1,125 +1,109 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
* Copyright(C) 2007 \/)\/ * * Copyright(C) 2007 \/)\/ *
* Visual Computing Lab /\/| * * Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | * * ISTI - Italian National Research Council | *
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.1 2007/10/18 08:52:06 benedetti Revision 1.1 2007/10/18 08:52:06 benedetti
Initial release. Initial release.
****************************************************************************/ ****************************************************************************/
#ifndef GLAREA_H_ #ifndef GLAREA_H_
#define GLAREA_H_ #define GLAREA_H_
/// Opengl related imports /// Opengl related imports
#include <GL/glew.h> #include <GL/glew.h>
#include <QGLWidget> #include <QGLWidget>
/// wrapper imports /// wrapper imports
#include <wrap/gui/trackball.h> #include <wrap/gui/trackball.h>
#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
enum MyDrawMode{MDM_SMOOTH=0,MDM_POINTS,MDM_WIRE,MDM_FLATWIRE,MDM_FLAT};
enum MyDrawMode{MDM_SMOOTH=0,MDM_POINTS,MDM_WIRE,MDM_FLATWIRE,MDM_FLAT};
class SharedDataOpenGLContext : public QGLWidget
class SharedDataOpenGLContext : public QGLWidget {
{ Q_OBJECT
Q_OBJECT public:
public: SharedDataOpenGLContext(CMeshO& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent = 0);
SharedDataOpenGLContext(CMesh& mesh,MLThreadSafeMemoryInfo& mi,QWidget* parent = 0); ~SharedDataOpenGLContext();
~SharedDataOpenGLContext();
void myInitGL();
void myInitGL(); void deAllocateBO();
MLThreadSafeGLMeshAttributesFeeder feeder; MLThreadSafeGLMeshAttributesFeeder feeder;
public slots: public slots:
/// widget-based user interaction slots /// widget-based user interaction 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
}; {
Q_OBJECT
class GLArea:public QGLWidget public:
{ GLArea (CMeshO& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent = NULL,QGLWidget* sharedcont = NULL);
Q_OBJECT ~GLArea();
public: void resetTrackBall();
GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget* parent = NULL,QGLWidget* sharedcont = NULL); /// we choosed a subset of the avaible drawing modes
~GLArea();
/// we choosed a subset of the avaible drawing modes signals:
public slots: /// signal for setting the statusbar message
void setupEnvironment(MyDrawMode mode); void setStatusBar(QString message);
protected:
signals: /// opengl initialization and drawing calls
/// signal for setting the statusbar message void initializeGL ();
void setStatusBar(QString message); void resizeGL (int w, int h);
protected: void paintGL ();
/// opengl initialization and drawing calls /// keyboard and mouse event callbacks
void initializeGL (); void keyReleaseEvent(QKeyEvent * e);
void resizeGL (int w, int h); void keyPressEvent(QKeyEvent * e);
void paintGL (); void mousePressEvent(QMouseEvent*e);
/// keyboard and mouse event callbacks void mouseMoveEvent(QMouseEvent*e);
void keyReleaseEvent(QKeyEvent * e); void mouseReleaseEvent(QMouseEvent*e);
void keyPressEvent(QKeyEvent * e); void wheelEvent(QWheelEvent*e);
void mousePressEvent(QMouseEvent*e); public slots:
void mouseMoveEvent(QMouseEvent*e); void updateRequested(MyDrawMode,vcg::GLFeederInfo::ReqAtts&);
void mouseReleaseEvent(QMouseEvent*e); private:
void wheelEvent(QWheelEvent*e); /// the active mesh instance
private: CMeshO& mesh;
MLAtomicGuard sem; /// the active manipulator
vcg::Trackball track;
GLuint vaohandlespecificicforglcontext; /// mesh data structure initializer
/// the active mesh instance void initMesh(QString message);
CMesh& mesh; MyDrawMode drawmode;
/// the active manipulator MLThreadSafeGLMeshAttributesFeeder& feeder;
vcg::Trackball track; vcg::GLFeederInfo::ReqAtts rq;
/// mesh data structure initializer };
void initMesh(QString message);
//MLThreadSafeMemoryInfo& mi; #endif /*GLAREA_H_ */
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_ */

View File

@ -1,48 +1,48 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
* Copyright(C) 2007 \/)\/ * * Copyright(C) 2007 \/)\/ *
* Visual Computing Lab /\/| * * Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | * * ISTI - Italian National Research Council | *
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
****************************************************************************/ ****************************************************************************/
/** /**
* Minimal QT trimesh viewer * Minimal QT trimesh viewer
* *
* This sample shows how to use togheter: * This sample shows how to use togheter:
* - the Opengl module in QT using the designer * - the Opengl module in QT using the designer
* - the trimesh loading and initialization * - the trimesh loading and initialization
* - basic usage of the default manipulators (the "Trackball") * - basic usage of the default manipulators (the "Trackball")
*/ */
#include <QApplication> #include <QApplication>
#include "mainwindow.h" #include "mainwindow.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
MainWindow mw; MainWindow mw;
mw.show(); mw.show();
return app.exec(); return app.exec();
} }

View File

@ -1,111 +1,113 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
* Copyright(C) 2007 \/)\/ * * Copyright(C) 2007 \/)\/ *
* Visual Computing Lab /\/| * * Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | * * ISTI - Italian National Research Council | *
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
****************************************************************************/ ****************************************************************************/
#include "mainwindow.h" #include "mainwindow.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
MainWindow::MainWindow (QWidget * parent) MainWindow::MainWindow (QWidget * parent)
:QMainWindow (parent),mi(1000000000),mesh() :QMainWindow (parent),mi(1000000000),mesh()
{ {
ui.setupUi (this); ui.setupUi (this);
QLayout* tmp = ui.glFrame->layout(); QLayout* tmp = ui.glFrame->layout();
//parent is set to NULL in order to avoid QT bug on MAC (business as usual...). //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... //The QGLWidget are destroyed by hand in the MainWindow destructor...
shared = new SharedDataOpenGLContext(mesh,mi,NULL); shared = new SharedDataOpenGLContext(mesh,mi,NULL);
shared->setHidden(true); shared->setHidden(true);
shared->myInitGL(); shared->myInitGL();
connect (ui.drawModeComboBox, SIGNAL (currentIndexChanged(int)),shared, SLOT (passInfoToOpenGL(int))); connect (ui.drawModeComboBox, SIGNAL (currentIndexChanged(int)),shared, SLOT (passInfoToOpenGL(int)));
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.loadTetrahedronPushButton, SIGNAL (clicked()),this, SLOT (loadTetrahedron()));
connect (ui.loadMeshPushButton, SIGNAL (clicked()),this, SLOT (chooseMesh())); connect (ui.loadDodecahedronPushButton, SIGNAL (clicked()),this, SLOT (loadDodecahedron()));
connect (ui.loadTetrahedronPushButton, SIGNAL (clicked()),this, SLOT (loadTetrahedron())); //from toolFrame to glArea through mainwindow
connect (ui.loadDodecahedronPushButton, SIGNAL (clicked()),this, SLOT (loadDodecahedron()));
//from toolFrame to glArea through mainwindow }
} // mesh chooser file dialog
void MainWindow::chooseMesh()
// mesh chooser file dialog {
void MainWindow::chooseMesh() mesh.Clear();
{ QString fileName = QFileDialog::getOpenFileName(this,
mesh.Clear(); tr("Open Mesh"), QDir::currentPath(),
QString fileName = QFileDialog::getOpenFileName(this, tr("Poly Model (*.ply)"));
tr("Open Mesh"), QDir::currentPath(), int err=vcg::tri::io::ImporterPLY<CMeshO>::Open(mesh,(fileName.toStdString()).c_str());
tr("Poly Model (*.ply)")); if(err!=0)
int err=vcg::tri::io::ImporterPLY<CMesh>::Open(mesh,(fileName.toStdString()).c_str()); {
if(err!=0) const char* errmsg=vcg::tri::io::ImporterPLY<CMeshO>::ErrorMsg(err);
{ QMessageBox::warning(this,tr("Error Loading Mesh"),QString(errmsg));
const char* errmsg=vcg::tri::io::ImporterPLY<CMesh>::ErrorMsg(err); }
QMessageBox::warning(this,tr("Error Loading Mesh"),QString(errmsg)); initMesh(fileName);
} }
initMesh(fileName);
} void MainWindow::loadTetrahedron()
{
void MainWindow::loadTetrahedron() mesh.Clear();
{ vcg::tri::Tetrahedron(mesh);
mesh.Clear(); initMesh(tr("Tethraedron [builtin]"));
vcg::tri::Tetrahedron(mesh); }
initMesh(tr("Tethraedron [builtin]"));
} void MainWindow::loadDodecahedron()
{
void MainWindow::loadDodecahedron() mesh.Clear();
{ vcg::tri::Dodecahedron(mesh);
mesh.Clear(); initMesh(tr("Dodecahedron [builtin]"));
vcg::tri::Dodecahedron(mesh); }
initMesh(tr("Dodecahedron [builtin]"));
} void MainWindow::initMesh(QString message)
{
void MainWindow::initMesh(QString message) if (shared != NULL)
{ shared->deAllocateBO();
ui.statusbar->showMessage(message); // update bounding box
// update bounding box vcg::tri::UpdateBounding<CMeshO>::Box(mesh);
vcg::tri::UpdateBounding<CMesh>::Box(mesh); // update Normals
// update Normals vcg::tri::UpdateNormal<CMeshO>::PerVertexNormalizedPerFaceNormalized(mesh);
vcg::tri::UpdateNormal<CMesh>::PerVertexNormalizedPerFaceNormalized(mesh); shared->passInfoToOpenGL(ui.drawModeComboBox->currentIndex());
shared->feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL); for(size_t ii = 0;ii < 2;++ii)
shared->passInfoToOpenGL(ui.drawModeComboBox->currentIndex()); if (glar[ii] != NULL)
} glar[ii]->resetTrackBall();
ui.statusbar->showMessage(message);
MainWindow::~MainWindow() }
{
for(int ii = 0;ii < 2;++ii) MainWindow::~MainWindow()
delete glar[ii]; {
delete shared; for(int ii = 0;ii < 2;++ii)
} delete glar[ii];
delete shared;
}

View File

@ -1,61 +1,61 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
* Copyright(C) 2007 \/)\/ * * Copyright(C) 2007 \/)\/ *
* Visual Computing Lab /\/| * * Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | * * ISTI - Italian National Research Council | *
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
****************************************************************************/ ****************************************************************************/
#ifndef MAINWINDOW_H_ #ifndef MAINWINDOW_H_
#define MAINWINDOW_H_ #define MAINWINDOW_H_
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "glarea.h" #include "glarea.h"
#include "ml_thread_safe_memory_info.h" #include "ml_thread_safe_memory_info.h"
class MainWindow:public QMainWindow class MainWindow:public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWindow(QWidget * parent = 0); MainWindow(QWidget * parent = 0);
~MainWindow(); ~MainWindow();
public slots: public slots:
void chooseMesh(); void chooseMesh();
void loadTetrahedron(); void loadTetrahedron();
void loadDodecahedron(); void loadDodecahedron();
void initMesh(QString message); void initMesh(QString message);
signals: signals:
void loadMesh(QString newMesh); void loadMesh(QString newMesh);
private: private:
Ui::mainWindow ui; Ui::mainWindow ui;
GLArea* glar[2]; GLArea* glar[2];
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_ */

View File

@ -1,201 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>mainWindow</class> <class>mainWindow</class>
<widget class="QMainWindow" name="mainWindow"> <widget class="QMainWindow" name="mainWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>715</width> <width>715</width>
<height>579</height> <height>579</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Trimesh QT</string> <string>Trimesh QT</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
<widget class="QFrame" name="toolsFrame"> <widget class="QFrame" name="toolsFrame">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="drawModeLabel"> <widget class="QLabel" name="drawModeLabel">
<property name="text"> <property name="text">
<string>Draw &amp;Mode :</string> <string>Draw &amp;Mode :</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>drawModeComboBox</cstring> <cstring>drawModeComboBox</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="drawModeComboBox"> <widget class="QComboBox" name="drawModeComboBox">
<item> <item>
<property name="text"> <property name="text">
<string>Smooth</string> <string>Smooth</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Points</string> <string>Points</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Wire</string> <string>Wire</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Flat Wire</string> <string>Flat Wire</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Flat</string> <string>Flat</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item> <item>
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="loadMeshPushButton"> <widget class="QPushButton" name="loadMeshPushButton">
<property name="text"> <property name="text">
<string>Load &amp;Mesh</string> <string>Load &amp;Mesh</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="loadTetrahedronPushButton"> <widget class="QPushButton" name="loadTetrahedronPushButton">
<property name="text"> <property name="text">
<string>Load &amp;Tetrahedron</string> <string>Load &amp;Tetrahedron</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="loadDodecahedronPushButton"> <widget class="QPushButton" name="loadDodecahedronPushButton">
<property name="text"> <property name="text">
<string>Load &amp;Dodecahedron</string> <string>Load &amp;Dodecahedron</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QFrame" name="glFrame"> <widget class="QFrame" name="glFrame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>715</width> <width>715</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>drawModeComboBox</tabstop> <tabstop>drawModeComboBox</tabstop>
<tabstop>loadMeshPushButton</tabstop> <tabstop>loadMeshPushButton</tabstop>
<tabstop>loadTetrahedronPushButton</tabstop> <tabstop>loadTetrahedronPushButton</tabstop>
<tabstop>loadDodecahedronPushButton</tabstop> <tabstop>loadDodecahedronPushButton</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -1,24 +1,28 @@
#ifndef MESH_H #ifndef MESH_H
#define MESH_H #define MESH_H
/// vcg imports /// vcg imports
#include <vcg/complex/complex.h> #include <vcg/complex/complex.h>
#include <vcg/complex/algorithms/update/bounding.h> #include <vcg/complex/algorithms/update/bounding.h>
#include <vcg/complex/algorithms/update/normal.h> #include <vcg/complex/algorithms/update/normal.h>
#include <vcg/complex/algorithms/create/platonic.h> #include <vcg/complex/algorithms/create/platonic.h>
#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

View File

@ -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);
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); QReadLocker locker(&_lock);
GLMeshAttributesFeeder<CMeshO>::drawTriangles(rq,_textids.textId());
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 void MLThreadSafeGLMeshAttributesFeeder::drawBBox(vcg::GLFeederInfo::ReqAtts& rq)
{ {
QReadLocker locker(&_lock); QReadLocker locker(&_lock);
GLMeshAttributesFeeder<CMesh>::attributesToBeImportedInPointBasedPipeline(importattribute,nm,cm);
vcg::Box3f& b = _mesh.bbox;
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_LIGHTING);
GLuint bbhandle;
glGenBuffers(1,&bbhandle);
std::vector<vcg::Point3f> bbox(12 * 2);
//0
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]);
//1
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]);
//2
bbox[4] = vcg::Point3f((float)b.max[0],(float)b.max[1],(float)b.min[2]);
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::attributesToBeImportedInTriangleBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm, TEXTURE_MODALITY tm ) const
void MLThreadSafeGLMeshAttributesFeeder::deAllocateBO()
{
QWriteLocker locker(&_lock);
GLMeshAttributesFeeder<CMeshO>::buffersDeAllocationRequested();
}
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();
}

View File

@ -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
{
MLThreadSafeTextureNamesContainer();
~MLThreadSafeTextureNamesContainer();
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:
std::vector<GLuint> _tmid;
mutable QReadWriteLock _lock;
};
MLThreadSafeGLMeshAttributesFeeder(CMeshO& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles);
~MLThreadSafeGLMeshAttributesFeeder() {}; ~MLThreadSafeGLMeshAttributesFeeder() {};
void setPerBatchTriangles(size_t perbatchtriangles); void setPerBatchTriangles(size_t perbatchtriangles);
size_t perBatchTriangles() const; size_t perBatchTriangles() const;
bool renderedWithBO() 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; GLuint bufferObjectHandle() const;
void drawWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm); void meshAttributesUpdated(int mask);
void drawFlatWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm,const std::vector<GLuint>& textureindex = std::vector<GLuint>()); vcg::GLFeederInfo::ReqAtts setupRequestedAttributes(const vcg::GLFeederInfo::ReqAtts& rq,bool& allocated);
void drawPoints(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm); void deAllocateBO();
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; void drawWire(vcg::GLFeederInfo::ReqAtts& rq);
bool updateClientSideEnvironmentVAO(GLuint& vaohandle,const std::vector<bool>& importattribute) const; void drawFlatWire(vcg::GLFeederInfo::ReqAtts& rq);
void attributesToBeImportedInPointBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm) const; void drawPoints(vcg::GLFeederInfo::ReqAtts& rq);
void attributesToBeImportedInTriangleBasedPipeline( std::vector<bool> &importattribute, NORMAL_MODALITY nm, COLOR_MODALITY cm, TEXTURE_MODALITY tm ) const; 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: private:
mutable QReadWriteLock _lock; mutable QReadWriteLock _lock;
MLThreadSafeTextureNamesContainer _textids;
}; };
#endif #endif

View File

@ -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);

View File

@ -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

View File

@ -1,56 +1,56 @@
# Base options # Base options
TEMPLATE = app TEMPLATE = app
LANGUAGE = C++ LANGUAGE = C++
# QT modules # QT modules
QT += opengl QT += opengl
# Executable name # Executable name
TARGET = trimesh_qt TARGET = trimesh_qt
# Directories # Directories
DESTDIR = . DESTDIR = .
UI_DIR = build/ui UI_DIR = build/ui
MOC_DIR = build/moc MOC_DIR = build/moc
OBJECTS_DIR = build/obj OBJECTS_DIR = build/obj
# Lib headers # Lib headers
INCLUDEPATH += . INCLUDEPATH += .
INCLUDEPATH += ../../.. INCLUDEPATH += ../../..
# Lib sources # Lib sources
SOURCES += ../../../wrap/ply/plylib.cpp SOURCES += ../../../wrap/ply/plylib.cpp
SOURCES += ../../../wrap/gui/trackball.cpp SOURCES += ../../../wrap/gui/trackball.cpp
SOURCES += ../../../wrap/gui/trackmode.cpp SOURCES += ../../../wrap/gui/trackmode.cpp
# Compile glew # Compile glew
DEFINES += GLEW_STATIC DEFINES += GLEW_STATIC
INCLUDEPATH += ../../../../lib/glew/include INCLUDEPATH += ../../../../lib/glew/include
SOURCES += ../../../../lib/glew/src/glew.c SOURCES += ../../../../lib/glew/src/glew.c
# Awful problem with windows.. # Awful problem with windows..
win32{ win32{
DEFINES += NOMINMAX DEFINES += NOMINMAX
} }
# Input # Input
HEADERS += mainwindow.h HEADERS += mainwindow.h
HEADERS += glarea.h HEADERS += glarea.h
HEADERS += ml_thread_safe_memory_info.h HEADERS += ml_thread_safe_memory_info.h
HEADERS += ml_scene_renderer.h HEADERS += ml_scene_renderer.h
HEADERS += ml_atomic_guard.h HEADERS += ml_atomic_guard.h
SOURCES += main.cpp SOURCES += main.cpp
SOURCES += mainwindow.cpp SOURCES += mainwindow.cpp
SOURCES += glarea.cpp SOURCES += glarea.cpp
SOURCES += ml_thread_safe_memory_info.cpp SOURCES += ml_thread_safe_memory_info.cpp
SOURCES += ml_scene_renderer.cpp SOURCES += ml_scene_renderer.cpp
FORMS += mainwindow.ui FORMS += mainwindow.ui
linux-g++:LIBS += -lGLU linux-g++:LIBS += -lGLU
linux-g++-32:LIBS += -lGLU linux-g++-32:LIBS += -lGLU
linux-g++-64:LIBS += -lGLU linux-g++-64:LIBS += -lGLU