- sample projects using new rendering engine
This commit is contained in:
parent
69bc2244d1
commit
dca2488ac4
|
@ -0,0 +1,186 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2007 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
History
|
||||||
|
|
||||||
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.1 2007/10/18 08:52:06 benedetti
|
||||||
|
Initial release.
|
||||||
|
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "glarea.h"
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include <wrap/qt/trackball.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#define glGenVertexArrays glGenVertexArraysAPPLE
|
||||||
|
#define glBindVertexArrays glBindVertexArraysAPPLE
|
||||||
|
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GLArea::GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget * parent)
|
||||||
|
:QGLWidget (parent),vaohandlespecificicforglcontext(0),mesh(m),feeder(feed)
|
||||||
|
{
|
||||||
|
drawmode= SMOOTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLArea::~GLArea()
|
||||||
|
{
|
||||||
|
glDeleteVertexArrays(1,&vaohandlespecificicforglcontext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLArea::selectDrawMode(int mode)
|
||||||
|
{
|
||||||
|
feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||||
|
drawmode=DrawMode(mode);
|
||||||
|
updateGL();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
glEnable(GL_NORMALIZE);
|
||||||
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::resizeGL (int w, int h)
|
||||||
|
{
|
||||||
|
makeCurrent();
|
||||||
|
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
|
||||||
|
initializeGL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::paintGL ()
|
||||||
|
{
|
||||||
|
makeCurrent();
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPerspective(25, GLArea::width()/(float)GLArea::height(), 0.1, 100);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluLookAt(0,0,5, 0,0,0, 0,1,0);
|
||||||
|
track.center=vcg::Point3f(0, 0, 0);
|
||||||
|
track.radius= 1;
|
||||||
|
track.GetView();
|
||||||
|
track.Apply();
|
||||||
|
glPushMatrix();
|
||||||
|
float d=2.0f/mesh.bbox.Diag();
|
||||||
|
vcg::glScale(d);
|
||||||
|
glTranslate(mesh.bbox.Center());
|
||||||
|
// the trimesh drawing calls
|
||||||
|
|
||||||
|
switch(drawmode)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
track.DrawPostApply();
|
||||||
|
GLenum err = glGetError();
|
||||||
|
assert(err == GL_NO_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::keyReleaseEvent (QKeyEvent * e)
|
||||||
|
{
|
||||||
|
e->ignore ();
|
||||||
|
if (e->key () == Qt::Key_Control)
|
||||||
|
track.ButtonUp (QT2VCG (Qt::NoButton, Qt::ControlModifier));
|
||||||
|
if (e->key () == Qt::Key_Shift)
|
||||||
|
track.ButtonUp (QT2VCG (Qt::NoButton, Qt::ShiftModifier));
|
||||||
|
if (e->key () == Qt::Key_Alt)
|
||||||
|
track.ButtonUp (QT2VCG (Qt::NoButton, Qt::AltModifier));
|
||||||
|
updateGL ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::keyPressEvent (QKeyEvent * e)
|
||||||
|
{
|
||||||
|
e->ignore ();
|
||||||
|
if (e->key () == Qt::Key_Control)
|
||||||
|
track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ControlModifier));
|
||||||
|
if (e->key () == Qt::Key_Shift)
|
||||||
|
track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ShiftModifier));
|
||||||
|
if (e->key () == Qt::Key_Alt)
|
||||||
|
track.ButtonDown (QT2VCG (Qt::NoButton, Qt::AltModifier));
|
||||||
|
updateGL ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::mousePressEvent (QMouseEvent * e)
|
||||||
|
{
|
||||||
|
e->accept ();
|
||||||
|
setFocus ();
|
||||||
|
track.MouseDown (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ()));
|
||||||
|
updateGL ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::mouseMoveEvent (QMouseEvent * e)
|
||||||
|
{
|
||||||
|
if (e->buttons ()) {
|
||||||
|
track.MouseMove (QT2VCG_X(this,e), QT2VCG_Y(this,e));
|
||||||
|
updateGL ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::mouseReleaseEvent (QMouseEvent * e)
|
||||||
|
{
|
||||||
|
track.MouseUp (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ()));
|
||||||
|
updateGL ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLArea::wheelEvent (QWheelEvent * e)
|
||||||
|
{
|
||||||
|
const int WHEEL_STEP = 120;
|
||||||
|
track.MouseWheel (e->delta () / float (WHEEL_STEP), QTWheel2VCG (e->modifiers ()));
|
||||||
|
updateGL ();
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2007 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
History
|
||||||
|
|
||||||
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.1 2007/10/18 08:52:06 benedetti
|
||||||
|
Initial release.
|
||||||
|
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GLAREA_H_
|
||||||
|
#define GLAREA_H_
|
||||||
|
|
||||||
|
/// Opengl related imports
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <QGLWidget>
|
||||||
|
|
||||||
|
|
||||||
|
/// wrapper imports
|
||||||
|
#include <wrap/gui/trackball.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "mesh.h"
|
||||||
|
#include "ml_scene_renderer.h"
|
||||||
|
/// declaring edge and face type
|
||||||
|
|
||||||
|
class GLArea:public QGLWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
GLArea (CMesh& m,MLThreadSafeGLMeshAttributesFeeder& feed,QWidget * parent = 0);
|
||||||
|
~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);
|
||||||
|
signals:
|
||||||
|
/// signal for setting the statusbar message
|
||||||
|
void setStatusBar(QString message);
|
||||||
|
protected:
|
||||||
|
/// opengl initialization and drawing calls
|
||||||
|
void initializeGL ();
|
||||||
|
void resizeGL (int w, int h);
|
||||||
|
void paintGL ();
|
||||||
|
/// keyboard and mouse event callbacks
|
||||||
|
void keyReleaseEvent(QKeyEvent * e);
|
||||||
|
void keyPressEvent(QKeyEvent * e);
|
||||||
|
void mousePressEvent(QMouseEvent*e);
|
||||||
|
void mouseMoveEvent(QMouseEvent*e);
|
||||||
|
void mouseReleaseEvent(QMouseEvent*e);
|
||||||
|
void wheelEvent(QWheelEvent*e);
|
||||||
|
private:
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /*GLAREA_H_ */
|
|
@ -0,0 +1,48 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2007 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
History
|
||||||
|
|
||||||
|
$Log: not supported by cvs2svn $
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimal QT trimesh viewer
|
||||||
|
*
|
||||||
|
* This sample shows how to use togheter:
|
||||||
|
* - the Opengl module in QT using the designer
|
||||||
|
* - the trimesh loading and initialization
|
||||||
|
* - basic usage of the default manipulators (the "Trackball")
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
MainWindow *mw = new MainWindow;
|
||||||
|
mw->show();
|
||||||
|
return app.exec();
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2007 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
History
|
||||||
|
|
||||||
|
$Log: not supported by cvs2svn $
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
MainWindow::MainWindow (QWidget * parent)
|
||||||
|
:QMainWindow (parent),mi(1000000000),mesh(),feeder(mesh,mi,100000)
|
||||||
|
{
|
||||||
|
ui.setupUi (this);
|
||||||
|
QLayout* tmp = ui.glFrame->layout();
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
|
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()));
|
||||||
|
//from toolFrame to glArea through mainwindow
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// mesh chooser file dialog
|
||||||
|
void MainWindow::chooseMesh()
|
||||||
|
{
|
||||||
|
mesh.Clear();
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this,
|
||||||
|
tr("Open Mesh"), QDir::currentPath(),
|
||||||
|
tr("Poly Model (*.ply)"));
|
||||||
|
int err=vcg::tri::io::ImporterPLY<CMesh>::Open(mesh,(fileName.toStdString()).c_str());
|
||||||
|
if(err!=0)
|
||||||
|
{
|
||||||
|
const char* errmsg=vcg::tri::io::ImporterPLY<CMesh>::ErrorMsg(err);
|
||||||
|
QMessageBox::warning(this,tr("Error Loading Mesh"),QString(errmsg));
|
||||||
|
}
|
||||||
|
initMesh(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::loadTetrahedron()
|
||||||
|
{
|
||||||
|
mesh.Clear();
|
||||||
|
vcg::tri::Tetrahedron(mesh);
|
||||||
|
initMesh(tr("Tethraedron [builtin]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::loadDodecahedron()
|
||||||
|
{
|
||||||
|
mesh.Clear();
|
||||||
|
vcg::tri::Dodecahedron(mesh);
|
||||||
|
initMesh(tr("Dodecahedron [builtin]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::initMesh(QString message)
|
||||||
|
{
|
||||||
|
//feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||||
|
// update bounding box
|
||||||
|
vcg::tri::UpdateBounding<CMesh>::Box(mesh);
|
||||||
|
// update Normals
|
||||||
|
vcg::tri::UpdateNormal<CMesh>::PerVertexNormalizedPerFaceNormalized(mesh);
|
||||||
|
for(int ii = 0;ii < 2;++ii)
|
||||||
|
{
|
||||||
|
feeder.update(vcg::GLMeshAttributesFeeder<CMesh>::ATT_ALL);
|
||||||
|
glar[ii]->updateGL();
|
||||||
|
}
|
||||||
|
ui.statusbar->showMessage(message);
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2007 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/****************************************************************************
|
||||||
|
History
|
||||||
|
|
||||||
|
$Log: not supported by cvs2svn $
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef MAINWINDOW_H_
|
||||||
|
#define MAINWINDOW_H_
|
||||||
|
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
#include "glarea.h"
|
||||||
|
#include "ml_thread_safe_memory_info.h"
|
||||||
|
|
||||||
|
class MainWindow:public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MainWindow(QWidget * parent = 0);
|
||||||
|
public slots:
|
||||||
|
void chooseMesh();
|
||||||
|
void loadTetrahedron();
|
||||||
|
void loadDodecahedron();
|
||||||
|
void initMesh(QString message);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void loadMesh(QString newMesh);
|
||||||
|
private:
|
||||||
|
Ui::mainWindow ui;
|
||||||
|
GLArea* glar[2];
|
||||||
|
|
||||||
|
GLArea* shared;
|
||||||
|
MLThreadSafeMemoryInfo mi;
|
||||||
|
/// the active mesh instance
|
||||||
|
CMesh mesh;
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder feeder;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /*MAINWINDOW_H_ */
|
|
@ -0,0 +1,201 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>mainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="mainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>715</width>
|
||||||
|
<height>579</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Trimesh QT</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="toolsFrame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="drawModeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Draw &Mode :</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>drawModeComboBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="drawModeComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Smooth</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Points</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Wire</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Flat Wire</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Flat</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="loadMeshPushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load &Mesh</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="loadTetrahedronPushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load &Tetrahedron</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="loadDodecahedronPushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load &Dodecahedron</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="glFrame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>715</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>drawModeComboBox</tabstop>
|
||||||
|
<tabstop>loadMeshPushButton</tabstop>
|
||||||
|
<tabstop>loadTetrahedronPushButton</tabstop>
|
||||||
|
<tabstop>loadDodecahedronPushButton</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef MESH_H
|
||||||
|
#define MESH_H
|
||||||
|
|
||||||
|
/// vcg imports
|
||||||
|
#include <vcg/complex/complex.h>
|
||||||
|
#include <vcg/complex/algorithms/update/bounding.h>
|
||||||
|
#include <vcg/complex/algorithms/update/normal.h>
|
||||||
|
#include <vcg/complex/algorithms/create/platonic.h>
|
||||||
|
|
||||||
|
#include <wrap/io_trimesh/import.h>
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
class CFace;
|
||||||
|
class CVertex;
|
||||||
|
|
||||||
|
struct MyUsedTypes : public UsedTypes< Use<CVertex> ::AsVertexType,
|
||||||
|
Use<CFace> ::AsFaceType>{};
|
||||||
|
|
||||||
|
/// compositing wanted proprieties
|
||||||
|
class CVertex : 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 CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> > {};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,69 @@
|
||||||
|
#include "ml_scene_renderer.h"
|
||||||
|
#include "ml_thread_safe_memory_info.h"
|
||||||
|
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder::MLThreadSafeGLMeshAttributesFeeder(CMesh& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles)
|
||||||
|
:GLMeshAttributesFeeder<CMesh>(mesh,gpumeminfo,perbatchtriangles),_lock(QReadWriteLock::Recursive)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::setPerBatchTriangles( size_t perbatchtriangles )
|
||||||
|
{
|
||||||
|
QWriteLocker locker(&_lock);
|
||||||
|
GLMeshAttributesFeeder<CMesh>::setPerBatchTriangles(perbatchtriangles);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t MLThreadSafeGLMeshAttributesFeeder::perBatchTriangles() const
|
||||||
|
{
|
||||||
|
QReadLocker locker(&_lock);
|
||||||
|
return GLMeshAttributesFeeder<CMesh>::perBatchTriangles();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MLThreadSafeGLMeshAttributesFeeder::renderedWithBO() const
|
||||||
|
{
|
||||||
|
QReadLocker locker(&_lock);
|
||||||
|
return GLMeshAttributesFeeder<CMesh>::renderedWithBO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::update( int mask )
|
||||||
|
{
|
||||||
|
QWriteLocker locker(&_lock);
|
||||||
|
GLMeshAttributesFeeder<CMesh>::update(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::drawWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm )
|
||||||
|
{
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
drawTriangles(vaohandlespecificperopenglcontext,nm,cm,vcg::GLFeedEnum::TX_NONE);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::drawFlatWire(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm )
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
|
||||||
|
glColor3f(.3f,.3f,.3f);
|
||||||
|
|
||||||
|
drawWire(vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NR_PERFACE,vcg::GLFeedEnum::CL_NONE);
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeGLMeshAttributesFeeder::drawPoints(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 )
|
||||||
|
{
|
||||||
|
QWriteLocker locker(&_lock);
|
||||||
|
GLMeshAttributesFeeder<CMesh>::passTrianglesToOpenGL(vaohandlespecificperopenglcontext,nm,cm,tm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* MeshLab o o *
|
||||||
|
* A versatile mesh processing toolbox o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2005 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ML_SCENE_RENDERER_H
|
||||||
|
#define __ML_SCENE_RENDERER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
|
#include "mesh.h"
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <wrap/gl/gl_mesh_attributes_feeder.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MLThreadSafeMemoryInfo;
|
||||||
|
|
||||||
|
|
||||||
|
class MLThreadSafeGLMeshAttributesFeeder : public vcg::GLMeshAttributesFeeder<CMesh>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MLThreadSafeGLMeshAttributesFeeder(CMesh& mesh,MLThreadSafeMemoryInfo& gpumeminfo,size_t perbatchtriangles);
|
||||||
|
~MLThreadSafeGLMeshAttributesFeeder() {};
|
||||||
|
void setPerBatchTriangles(size_t perbatchtriangles);
|
||||||
|
size_t perBatchTriangles() const;
|
||||||
|
bool renderedWithBO() const;
|
||||||
|
void update(int mask);
|
||||||
|
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 drawPoints(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::COLOR_MODALITY cm);
|
||||||
|
|
||||||
|
void drawTriangles(GLuint& vaohandlespecificperopenglcontext,vcg::GLFeedEnum::NORMAL_MODALITY nm,vcg::GLFeedEnum::COLOR_MODALITY cm,vcg::GLFeedEnum::TEXTURE_MODALITY tm);
|
||||||
|
private:
|
||||||
|
mutable QReadWriteLock _lock;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,72 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* MeshLab o o *
|
||||||
|
* A versatile mesh processing toolbox o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2005 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ml_thread_safe_memory_info.h"
|
||||||
|
|
||||||
|
MLThreadSafeMemoryInfo::MLThreadSafeMemoryInfo( long long unsigned int originalmem )
|
||||||
|
:vcg::NotThreadSafeMemoryInfo(originalmem),lock(QReadWriteLock::Recursive)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MLThreadSafeMemoryInfo::~MLThreadSafeMemoryInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeMemoryInfo::acquiredMemory(long long unsigned int mem)
|
||||||
|
{
|
||||||
|
lock.lockForWrite();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long unsigned int MLThreadSafeMemoryInfo::currentFreeMemory() const
|
||||||
|
{
|
||||||
|
lock.lockForRead();
|
||||||
|
long long unsigned int tmp = vcg::NotThreadSafeMemoryInfo::currentFreeMemory();
|
||||||
|
lock.unlock();
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MLThreadSafeMemoryInfo::releasedMemory(long long unsigned int mem)
|
||||||
|
{
|
||||||
|
lock.lockForWrite();
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* MeshLab o o *
|
||||||
|
* A versatile mesh processing toolbox o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2005 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* 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 *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ML_THREAD_SAFE_MEMORY_INFO_H
|
||||||
|
#define __ML_THREAD_SAFE_MEMORY_INFO_H
|
||||||
|
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
|
#include "mesh.h"
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <wrap/gl/gl_mesh_attributes_feeder.h>
|
||||||
|
|
||||||
|
|
||||||
|
class MLThreadSafeMemoryInfo : public vcg::NotThreadSafeMemoryInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MLThreadSafeMemoryInfo(long long unsigned int originalmem);
|
||||||
|
|
||||||
|
~MLThreadSafeMemoryInfo();
|
||||||
|
|
||||||
|
void acquiredMemory(long long unsigned int mem);
|
||||||
|
|
||||||
|
long long unsigned int usedMemory() const;
|
||||||
|
|
||||||
|
long long unsigned int currentFreeMemory() const;
|
||||||
|
|
||||||
|
void releasedMemory(long long unsigned int mem = 0);
|
||||||
|
|
||||||
|
bool isAdditionalMemoryAvailable(long long unsigned int mem);
|
||||||
|
private:
|
||||||
|
//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
|
||||||
|
//whose need to lock the mutex for a simple reading operation
|
||||||
|
mutable QReadWriteLock lock;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Base options
|
||||||
|
TEMPLATE = app
|
||||||
|
LANGUAGE = C++
|
||||||
|
|
||||||
|
# QT modules
|
||||||
|
QT += opengl
|
||||||
|
|
||||||
|
# Executable name
|
||||||
|
TARGET = trimesh_qt
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
DESTDIR = .
|
||||||
|
UI_DIR = build/ui
|
||||||
|
MOC_DIR = build/moc
|
||||||
|
OBJECTS_DIR = build/obj
|
||||||
|
|
||||||
|
# Lib headers
|
||||||
|
INCLUDEPATH += .
|
||||||
|
INCLUDEPATH += ../../..
|
||||||
|
|
||||||
|
# Lib sources
|
||||||
|
SOURCES += ../../../wrap/ply/plylib.cpp
|
||||||
|
SOURCES += ../../../wrap/gui/trackball.cpp
|
||||||
|
SOURCES += ../../../wrap/gui/trackmode.cpp
|
||||||
|
|
||||||
|
|
||||||
|
# Compile glew
|
||||||
|
DEFINES += GLEW_STATIC
|
||||||
|
INCLUDEPATH += ../../../../lib/glew/include
|
||||||
|
SOURCES += ../../../../lib/glew/src/glew.c
|
||||||
|
|
||||||
|
# Awful problem with windows..
|
||||||
|
win32{
|
||||||
|
DEFINES += NOMINMAX
|
||||||
|
}
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += mainwindow.h
|
||||||
|
HEADERS += glarea.h
|
||||||
|
HEADERS += ml_thread_safe_memory_info.h
|
||||||
|
HEADERS += ml_scene_renderer.h
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += main.cpp
|
||||||
|
SOURCES += mainwindow.cpp
|
||||||
|
SOURCES += glarea.cpp
|
||||||
|
SOURCES += ml_thread_safe_memory_info.cpp
|
||||||
|
SOURCES += ml_scene_renderer.cpp
|
||||||
|
|
||||||
|
FORMS += mainwindow.ui
|
||||||
|
|
||||||
|
linux-g++:LIBS += -lGLU
|
||||||
|
linux-g++-32:LIBS += -lGLU
|
||||||
|
linux-g++-64:LIBS += -lGLU
|
Loading…
Reference in New Issue