Commit e38ed6af authored by Lionel Untereiner's avatar Lionel Untereiner

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

Conflicts:
	Apps/Tuto/Modelling/tuto_oper2.cpp
	apps_cmake.txt
	src/Utils/clippingShader.cpp
parents c8558691 65df6922
......@@ -837,9 +837,6 @@ void Clipping::importMesh(std::string& filename)
void Clipping::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
m_render_topo = new Algo::Render::GL2::Topo3RenderMap<PFP>();
......
......@@ -139,9 +139,6 @@ unsigned int nb_ears;
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
......
......@@ -59,9 +59,6 @@ MAP myMap;
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
......
......@@ -57,9 +57,6 @@ PFP::MAP myMap;
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
m_frame = new Utils::FrameManipulator();
// frame is rendered twice the size of normal
......
......@@ -49,8 +49,6 @@ void MCMesh::cb_initGL()
Geom::Vec4f colDif(0.8f, 0.9f, 0.7f, 1.0f);
Geom::Vec4f colSpec(0.9f, 0.9f, 0.9f, 1.0f);
Utils::GLSLShader::setCurrentOGLVersion(2);
m_render = new Algo::Render::GL2::MapRender();
m_positionVBO = new Utils::VBO();
......
......@@ -60,8 +60,6 @@ void SimpleGMap2::initGUI()
void SimpleGMap2::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(1) ;
Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
......
......@@ -122,8 +122,6 @@ void SimpleGMap3::cb_keyPress(int code)
void SimpleGMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
......
......@@ -95,8 +95,6 @@ void SimpleMap3::initGUI()
void SimpleMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
......@@ -110,10 +108,10 @@ void SimpleMap3::cb_initGL()
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo->updateData(myMap, position, 0.9f,0.9f,0.8f);
m_render_topo_boundary = new Algo::Render::GL2::TopoRenderMap<PFP>();
m_render_topo_boundary = new Algo::Render::GL2::TopoRender();
m_render_topo_boundary->setDartWidth(2.0f);
m_render_topo_boundary->setInitialDartsColor(0.4f,0.8f,0.4f);
m_render_topo_boundary->updateDataBoundary(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_primal = new Algo::Render::GL2::Topo3PrimalRender<PFP>();
m_render_topo_primal->setDartWidth(2.0f);
......
......@@ -58,7 +58,7 @@ public:
VertexAttribute<VEC3, MAP> position ;
Algo::Render::GL2::Topo3RenderMap<PFP>* m_render_topo;
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo_boundary;
Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Algo::Render::GL2::Topo3PrimalRender<PFP>* m_render_topo_primal;
SimpleMap3() ;
......
......@@ -48,9 +48,6 @@ TexView::~TexView()
void TexView::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create VBO for position
m_positionVBO = new Utils::VBO;
m_texcoordVBO = new Utils::VBO;
......
......@@ -23,7 +23,6 @@
*******************************************************************************/
#include "viewer.h"
#include "Utils/chrono.h"
Viewer::Viewer() :
m_renderStyle(FLAT),
......@@ -38,7 +37,8 @@ Viewer::Viewer() :
m_flatShader(NULL),
m_vectorShader(NULL),
m_simpleColorShader(NULL),
m_pointSprite(NULL)
m_pointSprite(NULL),
m_nbFrames(0)
{
normalScaleFactor = 1.0f ;
vertexScaleFactor = 0.1f ;
......@@ -78,12 +78,14 @@ void Viewer::initGUI()
void Viewer::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl;
Utils::GLSLShader::areShadersSupported();
int major = 0;
int minor = 0;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
CGoGNout <<"Using GL "<< major <<"."<< minor << CGoGNendl;
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
......@@ -98,12 +100,12 @@ void Viewer::cb_initGL()
m_phongShader->setSpecular(colSpec) ;
m_phongShader->setShininess(shininess) ;
m_flatShader = new Utils::ShaderFlat() ;
m_flatShader = new Utils::ShaderSimpleFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ;
m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
m_flatShader->setExplode(faceShrinkage) ;
// m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
// m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setAttributePosition(m_positionVBO) ;
......@@ -130,12 +132,14 @@ void Viewer::cb_redraw()
{
if(m_drawVertices)
{
glDepthFunc(GL_LEQUAL);
m_pointSprite->setSize(vertexScaleFactor) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
}
if(m_drawEdges)
{
glDepthFunc(GL_LEQUAL);
glLineWidth(1.0f) ;
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
}
......@@ -146,10 +150,10 @@ void Viewer::cb_redraw()
glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
glDepthFunc(GL_LESS);
switch(m_renderStyle)
{
case FLAT :
m_flatShader->setExplode(faceShrinkage) ;
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
break ;
case PHONG :
......@@ -161,6 +165,7 @@ void Viewer::cb_redraw()
if(m_drawTopo)
{
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ;
}
......@@ -171,6 +176,14 @@ void Viewer::cb_redraw()
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
m_nbFrames++;
if (m_nbFrames >=100)
{
std::cout << 100000.0/m_frame_ch.elapsed()<< " fps"<<std::endl;
m_nbFrames = 0;
m_frame_ch.start();
}
}
void Viewer::cb_Open()
......@@ -543,7 +556,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -42,12 +42,13 @@
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vbo.h"
#include "Utils/chrono.h"
#include "Utils/Qt/qtInputs.h"
......@@ -104,17 +105,20 @@ public:
VertexAttribute<VEC3, MAP> normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRenderMap<PFP>* m_topoRender ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO;
Utils::ShaderPhong* m_phongShader ;
Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleFlat* m_flatShader ;
Utils::ShaderVectorPerVertex* m_vectorShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::PointSprite* m_pointSprite ;
Utils::Chrono m_frame_ch;
unsigned int m_nbFrames;
Viewer() ;
void initGUI() ;
......
......@@ -96,9 +96,6 @@ void ObjView::cb_keyPress(int k)
void ObjView::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
m_dr = new Utils::Drawer;
// create VBO for position
......
......@@ -208,11 +208,6 @@ void MyQT::cb_Save()
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl;
Utils::GLSLShader::areShadersSupported();
// create the renders
m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
......@@ -463,13 +458,13 @@ int main(int argc, char **argv)
{
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
int nb = 8;
int nb = 32;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
for (unsigned int i = position.begin(); i != position.end(); position.next(i))
{
VEC3 pert(float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0));
VEC3 pert(float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0));
position[i]+= pert;
}
......
......@@ -82,10 +82,8 @@ void Viewer::initGUI()
void Viewer::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
......@@ -232,7 +230,7 @@ void Viewer::cb_keyPress(int keycode)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
updateGL();
break;
......@@ -267,7 +265,7 @@ void Viewer::cb_keyPress(int keycode)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
updateGL();
break;
......@@ -338,7 +336,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -103,7 +103,7 @@ public:
VertexAttribute<VEC3, MAP> normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRenderMap<PFP>* m_topoRender ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO;
......
......@@ -75,8 +75,7 @@ void MyQT::traversors(int x)
// update all color to grey
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
m_render_topo->addColoredDart(d,0.5f,0.5f,0.5f);
}
switch(x)
......@@ -85,7 +84,7 @@ void MyQT::traversors(int x)
{
Traversor2VVaE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
......@@ -94,14 +93,14 @@ void MyQT::traversors(int x)
Traversor2VVaF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 2:
{
Traversor2EEaV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 3:
......@@ -109,63 +108,63 @@ void MyQT::traversors(int x)
Traversor2EEaF<MAP> trav(myMap,m_selected);
float c=0.0f;
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,c);
m_render_topo->addColoredDart(b,0.0f,1.0f,c);
}
break;
case 4:
{
Traversor2FFaV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 5:
{
Traversor2FFaE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 6:
{
Traversor2FV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 7:
{
Traversor2FE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 8:
{
Traversor2EV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 9:
{
Traversor2EF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 10:
{
Traversor2VE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 11:
{
Traversor2VF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
default:
......@@ -178,9 +177,8 @@ void MyQT::traversors(int x)
void MyQT::createMap(int n)
{
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
colorDarts = myMap.addAttribute<VEC3, DART, MAP>("color");
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, n, n, true);
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, n, n, true);
grid.embedIntoGrid(position, 1.,1.,0.);
// bounding box of scene
......@@ -197,31 +195,28 @@ void MyQT::createMap(int n)
m_render_topo->setInitialDartsColor(0.5f,0.5f,0.5f);