Commit 21e86c78 authored by Lionel Untereiner's avatar Lionel Untereiner

Merge branch 'develop' into 'master'

Develop

See merge request !1
parents c9128d9f a0a2dc32
...@@ -837,9 +837,6 @@ void Clipping::importMesh(std::string& filename) ...@@ -837,9 +837,6 @@ void Clipping::importMesh(std::string& filename)
void Clipping::cb_initGL() void Clipping::cb_initGL()
{ {
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render // create the render
m_render = new Algo::Render::GL2::MapRender(); m_render = new Algo::Render::GL2::MapRender();
m_render_topo = new Algo::Render::GL2::Topo3RenderMap<PFP>(); m_render_topo = new Algo::Render::GL2::Topo3RenderMap<PFP>();
......
...@@ -139,9 +139,6 @@ unsigned int nb_ears; ...@@ -139,9 +139,6 @@ unsigned int nb_ears;
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render // create the render
m_render = new Algo::Render::GL2::MapRender(); m_render = new Algo::Render::GL2::MapRender();
......
...@@ -59,9 +59,6 @@ MAP myMap; ...@@ -59,9 +59,6 @@ MAP myMap;
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render // create the render
m_render = new Algo::Render::GL2::MapRender(); m_render = new Algo::Render::GL2::MapRender();
......
...@@ -57,9 +57,6 @@ PFP::MAP myMap; ...@@ -57,9 +57,6 @@ PFP::MAP myMap;
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
m_frame = new Utils::FrameManipulator(); m_frame = new Utils::FrameManipulator();
// frame is rendered twice the size of normal // frame is rendered twice the size of normal
......
...@@ -49,8 +49,6 @@ void MCMesh::cb_initGL() ...@@ -49,8 +49,6 @@ void MCMesh::cb_initGL()
Geom::Vec4f colDif(0.8f, 0.9f, 0.7f, 1.0f); Geom::Vec4f colDif(0.8f, 0.9f, 0.7f, 1.0f);
Geom::Vec4f colSpec(0.9f, 0.9f, 0.9f, 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_render = new Algo::Render::GL2::MapRender();
m_positionVBO = new Utils::VBO(); m_positionVBO = new Utils::VBO();
...@@ -170,7 +168,8 @@ void MCMesh::updateRender() ...@@ -170,7 +168,8 @@ void MCMesh::updateRender()
void MCMesh::fromFile(char* fname) void MCMesh::fromFile(char* fname)
{ {
myImg = new SAlgo::MC::Image<DATATYPE>(); myImg = new SAlgo::MC::Image<DATATYPE>();
myImg->loadInrgz(fname); //myImg->loadInrgz(fname);
myImg->loadVox(fname);
CGoGNout << "Image chargee"<<CGoGNendl; CGoGNout << "Image chargee"<<CGoGNendl;
CGoGNout << myImg->getWidthX() <<"x"<< myImg->getWidthY() <<"x"<< myImg->getWidthZ() << "voxels"<<CGoGNendl; CGoGNout << myImg->getWidthX() <<"x"<< myImg->getWidthY() <<"x"<< myImg->getWidthZ() << "voxels"<<CGoGNendl;
} }
......
...@@ -60,8 +60,6 @@ void SimpleGMap2::initGUI() ...@@ -60,8 +60,6 @@ void SimpleGMap2::initGUI()
void SimpleGMap2::cb_initGL() void SimpleGMap2::cb_initGL()
{ {
Utils::GLSLShader::setCurrentOGLVersion(1) ;
Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ; Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ; VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ; float tailleX = bb.size(0) ;
......
...@@ -122,8 +122,6 @@ void SimpleGMap3::cb_keyPress(int code) ...@@ -122,8 +122,6 @@ void SimpleGMap3::cb_keyPress(int code)
void SimpleGMap3::cb_initGL() void SimpleGMap3::cb_initGL()
{ {
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ; Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ; VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ; float tailleX = bb.size(0) ;
......
...@@ -95,8 +95,6 @@ void SimpleMap3::initGUI() ...@@ -95,8 +95,6 @@ void SimpleMap3::initGUI()
void SimpleMap3::cb_initGL() void SimpleMap3::cb_initGL()
{ {
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ; Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ; VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ; float tailleX = bb.size(0) ;
...@@ -110,10 +108,10 @@ void SimpleMap3::cb_initGL() ...@@ -110,10 +108,10 @@ void SimpleMap3::cb_initGL()
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f); 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->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->setDartWidth(2.0f);
m_render_topo_boundary->setInitialDartsColor(0.4f,0.8f,0.4f); 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 = new Algo::Render::GL2::Topo3PrimalRender<PFP>();
m_render_topo_primal->setDartWidth(2.0f); m_render_topo_primal->setDartWidth(2.0f);
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
VertexAttribute<VEC3, MAP> position ; VertexAttribute<VEC3, MAP> position ;
Algo::Render::GL2::Topo3RenderMap<PFP>* m_render_topo; 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; Algo::Render::GL2::Topo3PrimalRender<PFP>* m_render_topo_primal;
SimpleMap3() ; SimpleMap3() ;
......
...@@ -48,9 +48,6 @@ TexView::~TexView() ...@@ -48,9 +48,6 @@ TexView::~TexView()
void TexView::cb_initGL() void TexView::cb_initGL()
{ {
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create VBO for position // create VBO for position
m_positionVBO = new Utils::VBO; m_positionVBO = new Utils::VBO;
m_texcoordVBO = new Utils::VBO; m_texcoordVBO = new Utils::VBO;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
*******************************************************************************/ *******************************************************************************/
#include "viewer.h" #include "viewer.h"
#include "Utils/chrono.h"
Viewer::Viewer() : Viewer::Viewer() :
m_renderStyle(FLAT), m_renderStyle(FLAT),
...@@ -32,13 +31,14 @@ Viewer::Viewer() : ...@@ -32,13 +31,14 @@ Viewer::Viewer() :
m_drawFaces(true), m_drawFaces(true),
m_drawNormals(false), m_drawNormals(false),
m_drawTopo(false), m_drawTopo(false),
m_drawBoundaryTopo(true), m_drawBoundaryTopo(false),
m_render(NULL), m_render(NULL),
m_phongShader(NULL), m_phongShader(NULL),
m_flatShader(NULL), m_flatShader(NULL),
m_vectorShader(NULL), m_vectorShader(NULL),
m_simpleColorShader(NULL), m_simpleColorShader(NULL),
m_pointSprite(NULL) m_pointSprite(NULL),
m_nbFrames(0)
{ {
normalScaleFactor = 1.0f ; normalScaleFactor = 1.0f ;
vertexScaleFactor = 0.1f ; vertexScaleFactor = 0.1f ;
...@@ -78,14 +78,16 @@ void Viewer::initGUI() ...@@ -78,14 +78,16 @@ void Viewer::initGUI()
void Viewer::cb_initGL() void Viewer::cb_initGL()
{ {
Utils::GLSLShader::setCurrentOGLVersion(2) ; int major = 0;
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl; int minor = 0;
Utils::GLSLShader::areShadersSupported(); glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
CGoGNout <<"Using GL "<< major <<"."<< minor << CGoGNendl;
m_render = new Algo::Render::GL2::MapRender() ; 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) ; m_topoRender->setInitialDartsColor(1.0f, 1.00f, 1.00f) ;
m_positionVBO = new Utils::VBO() ; m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ; m_normalVBO = new Utils::VBO() ;
...@@ -98,12 +100,12 @@ void Viewer::cb_initGL() ...@@ -98,12 +100,12 @@ void Viewer::cb_initGL()
m_phongShader->setSpecular(colSpec) ; m_phongShader->setSpecular(colSpec) ;
m_phongShader->setShininess(shininess) ; m_phongShader->setShininess(shininess) ;
m_flatShader = new Utils::ShaderFlat() ; m_flatShader = new Utils::ShaderSimpleFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ; m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ; m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ; m_flatShader->setDiffuse(colDif) ;
m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ; // m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
m_flatShader->setExplode(faceShrinkage) ; // m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ; m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setAttributePosition(m_positionVBO) ; m_vectorShader->setAttributePosition(m_positionVBO) ;
...@@ -130,12 +132,14 @@ void Viewer::cb_redraw() ...@@ -130,12 +132,14 @@ void Viewer::cb_redraw()
{ {
if(m_drawVertices) if(m_drawVertices)
{ {
glDepthFunc(GL_LEQUAL);
m_pointSprite->setSize(vertexScaleFactor) ; m_pointSprite->setSize(vertexScaleFactor) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ; m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
} }
if(m_drawEdges) if(m_drawEdges)
{ {
glDepthFunc(GL_LEQUAL);
glLineWidth(1.0f) ; glLineWidth(1.0f) ;
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ; m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
} }
...@@ -146,10 +150,10 @@ void Viewer::cb_redraw() ...@@ -146,10 +150,10 @@ void Viewer::cb_redraw()
glEnable(GL_LIGHTING) ; glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ; glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ; glPolygonOffset(1.0f, 1.0f) ;
glDepthFunc(GL_LESS);
switch(m_renderStyle) switch(m_renderStyle)
{ {
case FLAT : case FLAT :
m_flatShader->setExplode(faceShrinkage) ;
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ; m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
break ; break ;
case PHONG : case PHONG :
...@@ -161,6 +165,7 @@ void Viewer::cb_redraw() ...@@ -161,6 +165,7 @@ void Viewer::cb_redraw()
if(m_drawTopo) if(m_drawTopo)
{ {
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ; m_topoRender->drawTopo() ;
} }
...@@ -171,6 +176,14 @@ void Viewer::cb_redraw() ...@@ -171,6 +176,14 @@ void Viewer::cb_redraw()
glLineWidth(1.0f) ; glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ; 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() void Viewer::cb_Open()
...@@ -539,11 +552,14 @@ void Viewer::importMesh(std::string& filename) ...@@ -539,11 +552,14 @@ void Viewer::importMesh(std::string& filename)
// myMap.enableQuickTraversal<VERTEX>() ; // myMap.enableQuickTraversal<VERTEX>() ;
std::cout << "The mesh is " << (myMap.isOpen() ? "open" : "closed") << std::endl;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS) ; m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ; m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ; 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, true) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ; bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ; normalBaseSize = bb.diagSize() / 100.0f ;
......
...@@ -42,12 +42,13 @@ ...@@ -42,12 +42,13 @@
#include "Algo/Render/GL2/topoRender.h" #include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h" #include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderSimpleFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h" #include "Utils/Shaders/shaderVectorPerVertex.h"