Commit f4fac0c4 authored by Sauvage's avatar Sauvage
Browse files

Merge remote-tracking branch 'CGoGNcentral/develop' into develop

Conflicts:
	CGoGN/include/Utils/sphericalHarmonics.hpp
parents 9ce3d307 413a821f
......@@ -2,4 +2,5 @@
CMakeLists.txt.user
bin/
ThirdParty/bin/
SCHNApps/bin
\ No newline at end of file
SCHNApps/bin/
windows_dependencies/
......@@ -2,26 +2,6 @@ cmake_minimum_required(VERSION 2.8)
project(benches)
#SET(CMAKE_BUILD_TYPE Release)
#SET(CMAKE_BUILD_TYPE Debug)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
# define includes path
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
#IF(WIN32)
# link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) ${Boost_LIBRARY_DIRS} )
#ELSE(WIN32)
# link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
#ENDIF(WIN32)
add_executable(bench_trav bench_trav.cpp )
target_link_libraries( bench_trav ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
......
......@@ -72,7 +72,7 @@ int main(int argc, char **argv)
std::vector<VertexAttribute<typename PFP::VEC3, MAP> > attr;
attr.push_back(position);
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.05) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices /20) ;
VertexAttribute<PFP::VEC3, MAP> normal = myMap.addAttribute<PFP::VEC3,VERTEX,MAP>( "normal") ;
VertexAttribute<PFP::VEC3, MAP> position2 = myMap.addAttribute<PFP::VEC3,VERTEX,MAP>( "pos2") ;
......
......@@ -54,19 +54,19 @@ int main(int argc, char **argv)
std::vector<VertexAttribute<typename PFP::VEC3, MAP> > attr;
attr.push_back(position);
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices / 10) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices / 10);
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices / 10);
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;
......
......@@ -81,9 +81,11 @@ int main()
});
centerFace /=nbVert;
centerVol += centerFace;
nbFaces++;
});
centerVol /= nbFaces;
centerMesh += centerVol;
nbVols++;
});
centerMesh /= nbVols;
CGoGNout<< "Traverse with foreach in " << ch.elapsed()<< " ms"<< CGoGNendl;
......@@ -110,9 +112,11 @@ int main()
}
centerFace /=nbVert;
centerVol += centerFace;
nbFaces++;
}
centerVol /= nbFaces;
centerMesh += centerVol;
nbVols++;
}
CGoGNout<< "Traverse with traversor in " << ch.elapsed()<< " ms"<< CGoGNendl;
......
IF (ONELIB)
project(Apps)
IF (CGoGN_ONELIB)
SET(CGoGN_LIBS cgogn)
ELSE (ONELIB)
SET(CGoGN_LIBS algo topology container utils)
ENDIF (ONELIB)
ELSE ()
SET(CGoGN_LIBS algo) # topology container utils include by dependencies
ENDIF ()
IF (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/${ConfigurationName} ${Boost_LIBRARY_DIRS})
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual
link_directories( ${CGoGN_ROOT_DIR}/windows_dependencies/lib/)
IF((CGoGN_WITH_QTCREATOR))
link_directories( ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE})
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE}) # Release/Debug added automatically by visual
ELSE()
link_directories( ${CGoGN_ROOT_DIR}/bin/$(ConfigurationName))
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual
ENDIF()
ELSE()
link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE} )
IF(APPLE)
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE}/Contents/MacOS/ )
ELSE()
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE} )
ENDIF()
ENDIF()
include_directories(
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES})
#include_directories(
# ${CGoGN_ROOT_DIR}/include
# ${CGoGN_EXT_INCLUDES})
IF (COMPILE_SANDBOX)
IF (CGoGN_COMPILE_SANDBOX)
add_subdirectory(SandBox)
ENDIF()
IF (COMPILE_EXAMPLES AND WITH_QT)
add_subdirectory(Examples)
IF (CGoGN_COMPILE_EXAMPLES AND CGoGN_WITH_QT)
add_subdirectory(Examples)
ENDIF()
IF (COMPILE_TUTOS)
IF (CGoGN_COMPILE_TUTOS)
add_subdirectory(Tuto)
ENDIF()
IF (COMPILE_BENCHES)
IF (CGoGN_COMPILE_BENCHES)
add_subdirectory(Benches)
ENDIF()
IF (COMPILE_TESTS)
IF (CGoGN_COMPILE_TESTS)
add_subdirectory(Tests)
ENDIF()
#IF (WITH_QT)
# add_subdirectory(Tuto)
# add_subdirectory(Examples)
# IF (NOT DONOT_COMPILE_SANDBOX)
# add_subdirectory(SandBox)
# ENDIF (NOT DONOT_COMPILE_SANDBOX)
#ENDIF (WITH_QT)
#add_subdirectory(Tests)
#add_subdirectory(Benches)
#add_subdirectory(Tuto/Traversals)
#add_subdirectory(Tuto/Attributes)
#add_subdirectory(Tuto/Markers)
#add_subdirectory(Tuto/Boundary)
#add_subdirectory(Tuto/Modelling)
......@@ -2,71 +2,65 @@ cmake_minimum_required(VERSION 2.8)
project(examples)
#SET(CMAKE_BUILD_TYPE Release)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
# define includes path
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# define libs path
#IF(WIN32)
# link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) ${Boost_LIBRARY_DIRS} )
#ELSE(WIN32)
# link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
#ENDIF(WIN32)
#define exec to compile
QT4_WRAP_CPP( frame_manip_moc frame_manip.h )
qt_wrap_cpp( frame_manip_moc frame_manip.h )
add_executable( frame_manip frame_manip.cpp ${frame_manip_moc} )
target_link_libraries( frame_manip ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( texturesExample_moc texturesExample.h )
#need to define that we use Qt (only once per cmake directory!)
qt_use_cgogn_modules(frame_manip)
qt_wrap_cpp( texturesExample_moc texturesExample.h )
add_executable( texturesExample texturesExample.cpp ${texturesExample_moc} )
target_link_libraries( texturesExample ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP(simpleMap3_moc simpleMap3.h)
qt_wrap_cpp(simpleMap3_moc simpleMap3.h)
add_executable( simpleMap3 simpleMap3.cpp ${simpleMap3_moc} )
target_link_libraries( simpleMap3 ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( simpleGMap2_moc simpleGMap2.h )
qt_wrap_cpp( simpleGMap2_moc simpleGMap2.h )
add_executable( simpleGMap2 simpleGMap2.cpp ${simpleGMap2_moc} )
target_link_libraries( simpleGMap2 ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( simpleGMap3_moc simpleGMap3.h )
qt_wrap_cpp( simpleGMap3_moc simpleGMap3.h )
add_executable( simpleGMap3 simpleGMap3.cpp ${simpleGMap3_moc} )
target_link_libraries( simpleGMap3 ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( extrusionView_moc extrusionView.h )
qt_wrap_cpp( extrusionView_moc extrusionView.h )
add_executable( extrusionView extrusionView.cpp ${extrusionView_moc} )
target_link_libraries( extrusionView ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( viewer_ui viewer.ui )
QT4_WRAP_CPP( viewer_moc viewer.h )
qt_wrap_ui( viewer_ui viewer.ui )
qt_wrap_cpp( viewer_moc viewer.h )
add_executable( viewer viewer.cpp ${viewer_moc} ${viewer_ui} )
target_link_libraries( viewer ${CGoGN_LIBS} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( clipping_ui clipping.ui )
QT4_WRAP_CPP( clipping_moc clipping.h )
add_executable( clipping clipping.cpp ${clipping_ui} ${clipping_moc} )
target_link_libraries( clipping ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
IF (HAS_CPP11_REGEX)
qt_wrap_ui( clipping_ui clipping.ui )
qt_wrap_cpp( clipping_moc clipping.h )
add_executable( clipping clipping.cpp ${clipping_ui} ${clipping_moc} )
target_link_libraries( clipping ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
ENDIF()
QT4_WRAP_UI( volumeExplorer_ui volumeExplorer.ui )
QT4_WRAP_CPP( volumeExplorer_moc volumeExplorer.h )
qt_wrap_ui( volumeExplorer_ui volumeExplorer.ui )
qt_wrap_cpp( volumeExplorer_moc volumeExplorer.h )
add_executable( volumeExplorer volumeExplorer.cpp ${volumeExplorer_ui} ${volumeExplorer_moc} )
target_link_libraries( volumeExplorer ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( mcmesh_ui mcmesh.ui )
QT4_WRAP_CPP( mcmesh_moc mcmesh.h )
qt_wrap_ui( mcmesh_ui mcmesh.ui )
qt_wrap_cpp( mcmesh_moc mcmesh.h )
add_executable( mcmesh mcmesh.cpp ${mcmesh_moc} ${mcmesh_ui} )
target_link_libraries( mcmesh ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( concave_rendering_moc concave_rendering.h )
qt_wrap_cpp( concave_rendering_moc concave_rendering.h )
add_executable( concave_rendering concave_rendering.cpp ${concave_rendering_moc} ${concave_rendering_ui} )
target_link_libraries( concave_rendering ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( viewerOBJ_moc viewerOBJ.h )
qt_wrap_cpp( viewerOBJ_moc viewerOBJ.h )
add_executable( viewerOBJ viewerOBJ.cpp ${viewerOBJ_moc} )
target_link_libraries( viewerOBJ ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
......@@ -26,6 +26,10 @@
#include "Utils/vbo.h"
#include "Utils/static_assert.h"
#include <QColorDialog>
#include <QTimer>
/*******************************************************************************
* MISCELLANOUS
*******************************************************************************/
......@@ -692,7 +696,7 @@ Clipping::Clipping():
m_timer(NULL),
m_lastAnimatedClippingPreset(NULL)
{
m_coeffTopoExplod = Geom::Vec3f(0.9,0.9,0.9);
m_coeffTopoExplod = Geom::Vec3f(0.9f,0.9f,0.9f);
}
void Clipping::initGUI()
......@@ -856,10 +860,10 @@ void Clipping::cb_initGL()
// setup clipping shapes
m_planeDrawable = new Utils::Grid;
m_planeDrawable->setColor(Geom::Vec4f(1.0, 0.0, 0.0, 1.0));
m_planeDrawable->setColor(Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f));
m_planeDrawable->updatePrecisionDrawing(5);
m_sphereDrawable = new Utils::IcoSphere;
m_sphereDrawable->setColor(Geom::Vec4f(0.0, 0.4, 1.0, 1.0));
m_sphereDrawable->setColor(Geom::Vec4f(0.0f, 0.4f, 1.0f, 1.0f));
m_sphereDrawable->updatePrecisionDrawing(1);
// setup clipping picking frame
......
......@@ -134,12 +134,19 @@ void MyQT::cb_redraw()
for (std::vector<Utils::Pickable*>::iterator it=m_pickables.begin(); it != m_pickables.end(); ++it)
{
if (*it == m_lastPickedObject)
glLineWidth(2.0);
(*it)->setLineWidth(3.0);
else
glLineWidth(1.0);
(*it)->setLineWidth(1.0);
(*it)->draw();
}
m_nbFrames++;
if (m_nbFrames >=40)
{
std::cout << 40000.0/m_frame_ch.elapsed()<< " fps"<<std::endl;
m_nbFrames = 0;
m_frame_ch.start();
}
}
void MyQT::cb_mousePress(int /*button*/, int x, int y)
......
......@@ -27,9 +27,11 @@
#include <iostream>
#include "Utils/Qt/qtSimple.h"
//#include "Utils/Qt/qtSimple.h"
#include "Utils/Qt/qtQGLV.h"
#include "Utils/frameManipulator.h"
#include "Utils/drawer.h"
#include "Utils/chrono.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class MapRender; }}}}
......@@ -43,10 +45,11 @@ using namespace CGoGN ;
* A class for a little interface and rendering
*/
class MyQT: public Utils::QT::SimpleQT
class MyQT: public Utils::QT::SimpleQGLV
{
Q_OBJECT
public:
// render
Algo::Render::GL2::MapRender* m_render;
......@@ -68,7 +71,10 @@ public:
// width of cube of pickable
unsigned int NBP;
MyQT():m_render(NULL), m_positionVBO(NULL),NBP(2){}
Utils::Chrono m_frame_ch;
unsigned int m_nbFrames;
MyQT():m_render(NULL), m_positionVBO(NULL),NBP(2),m_nbFrames(0){}
// callbacks of simpleQT to overdefine:
void cb_redraw();
......
......@@ -29,7 +29,8 @@ MCMesh::MCMesh() :
m_drawFaces(true),
m_render(NULL),
m_flatShader(NULL),
m_simpleColorShader(NULL)
m_simpleColorShader(NULL),
m_linesShader(NULL)
{}
void MCMesh::initGUI()
......@@ -58,31 +59,67 @@ void MCMesh::cb_initGL()
m_flatShader->setDiffuse(colDif);
m_flatShader->setExplode(1.0f);
m_simpleColorShader = new Utils::ShaderSimpleColor();
m_simpleColorShader->setAttributePosition(m_positionVBO);
//m_simpleColorShader = new Utils::ShaderSimpleColor();
//m_simpleColorShader->setAttributePosition(m_positionVBO);
m_linesShader = new Utils::ShaderBoldLines();
m_linesShader->setAttributePosition(m_positionVBO);
registerShader(m_flatShader);
registerShader(m_simpleColorShader);
// registerShader(m_simpleColorShader);
registerShader(m_linesShader);
m_dr = new Utils::Drawer();
m_dr->newList();
m_dr->pointSize(4.0f);
m_dr->lineWidth(25.0f);
m_dr->begin(GL_LINES);
m_dr->color3f(1.0,0.0,0.0);
m_dr->vertex3f(15.0,15.0,65.0);
m_dr->vertex3f(110.0,110.0,65.0);
m_dr->color3f(0.0,1.0,0.0);
m_dr->vertex3f(110.0,15.0,75.0);
m_dr->vertex3f(15.0,110.0,75.0);
m_dr->end();
m_dr->endList();
}
void MCMesh::cb_redraw()
{
glEnable(GL_BLEND);
m_dr->callList(0.1f);
if (m_drawEdges)
// {
// glLineWidth(1.0f);
// if (m_drawFaces)
// {
// Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
// m_simpleColorShader->setColor(c);
// }
// else
// {
// Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f);
// m_simpleColorShader->setColor(c);
// }
// m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
// }
{
glLineWidth(1.0f);
m_linesShader->setLineWidth(2.0f);
if (m_drawFaces)
{
Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c);
m_linesShader->setColor(c);
}
else
{
Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c);
m_linesShader->setColor(c);
}
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
m_render->draw(m_linesShader, Algo::Render::GL2::LINES);
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glEnable(GL_POLYGON_OFFSET_FILL);
......
......@@ -39,9 +39,11 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderBoldLines.h"
#include "Utils/vbo.h"
#include "Algo/Geometry/boundingbox.h"
#include "Utils/drawer.h"
using namespace CGoGN ;
......@@ -79,9 +81,14 @@ public:
Algo::Render::GL2::MapRender* m_render ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_colorVBO ;
Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::ShaderBoldLines* m_linesShader ;
Utils::Drawer* m_dr;
DATATYPE valLabel;
SAlgo::MC::Image<DATATYPE>* myImg;
......
......@@ -45,7 +45,7 @@ Viewer::Viewer() :
faceShrinkage = 1.0f ;
colClear = Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f) ;
colDif = Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f) ;
colDif = Geom::Vec4f(0.3f, 0.5f, 0.2f, 1.0f) ;
colSpec = Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f) ;
colNormal = Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f) ;
shininess = 80.0f ;
......@@ -92,31 +92,32 @@ void Viewer::cb_initGL()
m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ;
m_phongShader = new Utils::ShaderPhong() ;
m_phongShader = new Utils::ShaderPhong(true,false) ;
m_phongShader->setAttributePosition(m_positionVBO) ;
m_phongShader->setAttributeNormal(m_normalVBO) ;
m_phongShader->setAmbiant(colClear) ;
m_phongShader->setDiffuse(colDif) ;
m_phongShader->setSpecular(colSpec) ;
m_phongShader->setShininess(shininess) ;
m_phongShader->setBackColor(Geom::Vec4f(0.9f, 0.0f, 0.0f, 0.0f));
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->setBackColor(Geom::Vec4f(0.9f, 0.0f, 0.0f, 0.0f));
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setAttributePosition(m_positionVBO) ;
m_vectorShader->setAttributeVector(m_normalVBO) ;
m_vectorShader->setColor(colNormal) ;
m_simpleColorShader = new Utils::ShaderSimpleColor() ;
m_simpleColorShader = new Utils::ShaderSimpleColor(true) ;
m_simpleColorShader->setAttributePosition(m_positionVBO) ;
Geom::Vec4f c(0.0f, 0.0f, 0.0f, 1.0f) ;
m_simpleColorShader->setColor(c) ;
m_pointSprite = new Utils::PointSprite() ;
m_pointSprite->setAttributePosition(m_positionVBO) ;
m_pointSprite->setColor(Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)) ;
......@@ -132,25 +133,31 @@ 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);
m_simpleColorShader->setColor(Geom::Vec4f(1.,1.,0.,0.));
glLineWidth(1.0f) ;
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
}
if(m_drawTopo)
{
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ;
}
if(m_drawFaces)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
glDepthFunc(GL_LESS);
if (m_drawEdges||m_drawTopo)
{
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
}
switch(m_renderStyle)
{
case FLAT :
......@@ -163,11 +170,7 @@ void Viewer::cb_redraw()
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
if(m_drawTopo)
{
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ;
}
if(m_drawNormals)
{
......@@ -178,7 +181,7 @@ void Viewer::cb_redraw()
}
m_nbFrames++;
if (m_nbFrames >=100)
if (m_nbFrames >=500)
{
std::cout << 100000.0/m_frame_ch.elapsed()<< " fps"<<std::endl;
m_nbFrames = 0;
......@@ -210,6 +213,60 @@ void Viewer::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'd':
{
m_phongShader->setDoubleSided(true);
m_flatShader->setDoubleSided(true);
updateGL();
}
break;
case 'D':
{
m_phongShader->setDoubleSided(false);
m_flatShader->setDoubleSided(false);
updateGL();
}
break;
case 'q':
{
Utils::Chrono ch;
ch.start();
for (int i = 0; i < 1000; ++i)
{
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES);
glFlush();
}
std::cout << "speed render " << 1000.0*1000.0/ch.elapsed() << " fps " << std::endl;
}