Commit f54ee8ca authored by Pierre Kraemer's avatar Pierre Kraemer

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

Conflicts:
	CGoGN/src/Utils/GLSLShader.cpp
parents 8c427fb1 80265842
......@@ -19,7 +19,11 @@ IF (WIN32)
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(
......
......@@ -14,7 +14,7 @@ add_executable( frame_manip frame_manip.cpp ${frame_manip_moc} )
target_link_libraries( frame_manip ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
#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} )
......@@ -40,10 +40,12 @@ 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} )
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} )
IF (CGoGN_GCC_4_9)
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()
qt_wrap_ui( volumeExplorer_ui volumeExplorer.ui )
qt_wrap_cpp( volumeExplorer_moc volumeExplorer.h )
......
......@@ -140,6 +140,13 @@ void MyQT::cb_redraw()
(*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();
......
......@@ -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,33 @@ 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,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,0,0.2,0)) ;
m_flatShader = new Utils::ShaderSimpleFlat() ;
m_flatShader = new Utils::ShaderSimpleFlat(true,false) ;
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,0,0.2,0)) ;
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 +134,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 +171,7 @@ void Viewer::cb_redraw()
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
if(m_drawTopo)
{
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ;
}
if(m_drawNormals)
{
......@@ -210,6 +214,32 @@ void Viewer::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'n':
m_flatShader->setNoClippingPlane();
m_phongShader->setNoClippingPlane();
m_topoRender->setNoClippingPlane();
m_simpleColorShader->setNoClippingPlane();
m_pointSprite->setNoClippingPlane();
m_vectorShader->setNoClippingPlane();
break;
case 'N':
{
const Geom::Vec3f& Pc = bb.center();
const Geom::Vec3f& Nc = bb.diag();
Geom::Vec4f planeClip(Nc[0],Nc[1],Nc[2],-(Pc*Nc));
m_flatShader->setClippingPlane(planeClip);
m_phongShader->setClippingPlane(planeClip);
m_topoRender->setClippingPlane(planeClip);
m_simpleColorShader->setClippingPlane(planeClip);
m_pointSprite->setClippingPlane(planeClip);
m_vectorShader->setClippingPlane(planeClip);
}
break;
case 'c' :
myMap.check();
break;
......@@ -578,6 +608,18 @@ void Viewer::importMesh(std::string& filename)
m_normalVBO->updateData(normal) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
const Geom::Vec3f& Pc = bb.center();
const Geom::Vec3f& Nc = bb.diag();
Geom::Vec4f planeClip(Nc[0],Nc[1],Nc[2],-(Pc*Nc));
// m_flatShader->setClippingPlane(planeClip);
// m_phongShader->setClippingPlane(planeClip);
// m_topoRender->setClippingPlane(planeClip);
// m_simpleColorShader->setClippingPlane(planeClip);
// m_pointSprite->setClippingPlane(planeClip);
// m_vectorShader->setClippingPlane(planeClip);
updateGLMatrices() ;
std::cout << "#vertices -> " << Algo::Topo::getNbOrbits<VERTEX>(myMap) << std::endl;
......
......@@ -73,16 +73,12 @@ void MyQT::clipping_onoff(bool x)
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
float d = -(pos*normal);
m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
m_topo_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
}
else
{
m_explode_render->setNoClippingPlane();
m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_topo_render->setNoClippingPlane();
}
updateGL();
}
......@@ -206,7 +202,7 @@ void MyQT::cb_initGL()
{
// create the renders
m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
// SelectorDartNoBoundary<MAP> nb(myMap);
m_topo_render->updateData(myMap, position, 0.8f, 0.8f, 0.8f);
......@@ -217,8 +213,6 @@ void MyQT::cb_initGL()
m_explode_render->setBackColor(Geom::Vec4f(0.9f,0.9f,0.9f,1.0f));
m_explode_render->setColorLine(Geom::Vec4f(0.8f,0.2f,0.2f,1.0f));
m_sh1 = static_cast<Utils::ClippingShader*>(m_topo_render->shader1());
m_sh2 = static_cast<Utils::ClippingShader*>(m_topo_render->shader2());
registerShader(m_explode_render->shaderFaces());
registerShader(m_explode_render->shaderLines());
......@@ -227,15 +221,6 @@ void MyQT::cb_initGL()
m_frame = new Utils::FrameManipulator();
m_frame->setSize(m_WidthObj/2.0f);
m_sh1->insertClippingCode();
m_sh2->insertClippingCode();
clip_id1 = m_sh1->addClipPlane();
clip_id2 = m_sh2->addClipPlane();
m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), m_PosObj);
m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj);
m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1)));
}
......@@ -370,9 +355,8 @@ void MyQT::cb_mouseMove(int buttons, int x, int y)
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
float d = -(pos*normal);
m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
m_topo_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
m_begX = x;
m_begY = y;
......@@ -484,28 +468,6 @@ int main(int argc, char **argv)
dock.slider_explode_face->setValue(100);
sqt.clipping_onoff(true);
// Utils::Chrono ch;
// ch.start();
// float vol = Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms // val="<<vol<< std::endl;
// std::cout << "Compute Volume ->"<< std::endl;
// ch.start();
// vol = Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// et on attend la fin.
return app.exec();
}
......@@ -93,8 +93,8 @@ class MyQT: public Utils::QT::SimpleQGLV
int clip_id2;
// shader of toporender3
Utils::ClippingShader* m_sh1;
Utils::ClippingShader* m_sh2;
// Utils::ClippingShader* m_sh1;
// Utils::ClippingShader* m_sh2;
Utils::Chrono m_frame_ch;
unsigned int m_nbFrames;
......
......@@ -124,7 +124,6 @@ void MyQT::createMap()
// initialization GL callback
void MyQT::cb_initGL()
{
// create the render
m_render = new Algo::Render::GL2::MapRender();
......
......@@ -53,7 +53,7 @@ ELSE()
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${shaders_src} )
ENDIF()
add_dependencies(shader_target shader_to_h) #ensure that shader_to_h is compiled
file(
GLOB # WARNING NO MORE RECURSE TO AVOID TAKING QT FILES
......@@ -107,11 +107,9 @@ link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
IF (CGoGN_ONELIB)
IF(CGoGN_WITH_QT)
add_definitions(-DCGoGN_QT_DLL_EXPORT)
add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils_withQt})
qt_use_modules(cgogn Gui OpenGL Xml Svg)
IF(${CGoGN_DESIRED_QT_VERSION} STREQUAL "5")
qt_use_modules(cgogn Widgets)
ENDIF()
ELSE()
add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils} )
ENDIF()
......
......@@ -71,7 +71,7 @@ public:
*/
template<typename PFP, unsigned int ORBIT>
void updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT,typename PFP::MAP::IMPL>& colorPerXXX) ;
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT,typename PFP::MAP>& colorPerXXX) ;
/**
* update drawing buffers
......@@ -85,7 +85,7 @@ public:
*/
template<typename PFP, unsigned int ORBIT>
void updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normals, const AttributeHandler<typename PFP::VEC3,ORBIT,typename PFP::MAP::IMPL>& colorPerXXX) ;
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normals, const AttributeHandler<typename PFP::VEC3,ORBIT,typename PFP::MAP>& colorPerXXX) ;
/**
......
......@@ -51,7 +51,7 @@ m_nbTris(0)
template<typename PFP, unsigned int ORBIT>
void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT, typename PFP::MAP::IMPL>& colorPerXXX)
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT, typename PFP::MAP>& colorPerXXX)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
......@@ -101,8 +101,8 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor
template<typename PFP, unsigned int ORBIT>
void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normals,
const AttributeHandler<typename PFP::VEC3,ORBIT, typename PFP::MAP::IMPL>& colorPerXXX)
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normals,
const AttributeHandler<typename PFP::VEC3,ORBIT, typename PFP::MAP>& colorPerXXX)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
......
......@@ -158,6 +158,10 @@ public:
Utils::GLSLShader* shader1() { return static_cast<Utils::GLSLShader*>(m_shader1); }
Utils::GLSLShader* shader2() { return static_cast<Utils::GLSLShader*>(m_shader2); }
void setClippingPlane(const Geom::Vec4f& plane);
void setNoClippingPlane();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
......
......@@ -71,8 +71,8 @@ Topo3Render<PFP>::Topo3Render():
m_vbo3->setDataSize(3);
m_vbo4->setDataSize(3);
m_shader1 = new Utils::ShaderSimpleColor();
m_shader2 = new Utils::ShaderColorPerVertex();
m_shader1 = new Utils::ShaderSimpleColor(true,false);
m_shader2 = new Utils::ShaderColorPerVertex(true,false);
// binding VBO - VA
m_vaId = m_shader1->setAttributePosition(m_vbo1);
......@@ -109,6 +109,22 @@ Topo3Render<PFP>::~Topo3Render()
delete[] m_bufferDartPosition;
}
template<typename PFP>
void Topo3Render<PFP>::setClippingPlane(const Geom::Vec4f& plane)
{
m_shader1->setClippingPlane(plane);
m_shader2->setClippingPlane(plane);
}
template<typename PFP>
void Topo3Render<PFP>::setNoClippingPlane()
{
this->setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f));
}
template<typename PFP>
void Topo3Render<PFP>::setDartWidth(float dw)
{
......
......@@ -148,6 +148,10 @@ public:
Utils::GLSLShader* shader1() { return static_cast<Utils::GLSLShader*>(m_shader1); }
Utils::GLSLShader* shader2() { return static_cast<Utils::GLSLShader*>(m_shader2); }
void setClippingPlane(const Geom::Vec4f& plane);
void setNoClippingPlane();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
......
......@@ -62,8 +62,8 @@ TopoPrimalRender<PFP>::TopoPrimalRender():
m_vbo1->setDataSize(3);
m_vbo2->setDataSize(3);
m_shader1 = new Utils::ShaderSimpleColor();
m_shader2 = new Utils::ShaderColorPerVertex();
m_shader1 = new Utils::ShaderSimpleColor(true,false);
m_shader2 = new Utils::ShaderColorPerVertex(true,false);
// binding VBO - VA
m_vaId = m_shader1->setAttributePosition(m_vbo1);
......@@ -98,6 +98,20 @@ TopoPrimalRender<PFP>::~TopoPrimalRender()
delete[] m_bufferDartPosition;
}
template<typename PFP>
void TopoPrimalRender<PFP>::setClippingPlane(const Geom::Vec4f& plane)
{
m_shader1->setClippingPlane(plane);
m_shader2->setClippingPlane(plane);
}
template<typename PFP>
void TopoPrimalRender<PFP>::setNoClippingPlane()
{
this->setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f));
}
template <typename PFP>
void TopoPrimalRender<PFP>::setDartWidth(float dw)
{
......
......@@ -177,6 +177,10 @@ public:
*/
~TopoGenRender();
void setClippingPlane(const Geom::Vec4f& plane);
void setNoClippingPlane();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
......
......@@ -65,26 +65,25 @@ public:
*/
enum shaderType {VERTEX_SHADER = 1, FRAGMENT_SHADER = 2, GEOMETRY_SHADER = 3 };
static unsigned int CURRENT_OGL_VERSION;
static unsigned int MAJOR_OGL_CORE;
static unsigned int MINOR_OGL_CORE;
#ifdef CGOGN_USE_OGL_CORE_PROFILE
static const unsigned int CURRENT_OGL_VERSION = 3;
static const unsigned int MAJOR_OGL_CORE = 3;
static const unsigned int MINOR_OGL_CORE = 3;
#else
static const unsigned int CURRENT_OGL_VERSION = 2;
static const unsigned int MAJOR_OGL_CORE = 2;
static const unsigned int MINOR_OGL_CORE = 1;
#endif
static std::set< std::pair<void*, GLSLShader*> >* m_registeredShaders;
// static glm::mat4* s_current_matrices;
static Utils::GL_Matrices* s_current_matrices;
protected:
static std::string DEFINES_GL2;
static std::string DEFINES_GL3;
static std::string* DEFINES_GL;
static std::string defines_Geom(const std::string& primitivesIn, const std::string& primitivesOut, int maxVert);
static std::string defines_gl();
int m_nbMaxVertices;
GLuint m_vao;
......@@ -210,9 +209,9 @@ public:
*/
virtual ~GLSLShader();
static void setCurrentOGLVersion(unsigned int version);
// static void setCurrentOGLVersion(unsigned int version);
static void setCurrentOGLVersion(unsigned int major,unsigned int minor);
// static void setCurrentOGLVersion(unsigned int major,unsigned int minor);
/*
* search file in different path
......
......@@ -107,6 +107,14 @@ public:
QSize minimumSizeHint() const;
QSize sizeHint() const;
inline int pixelRatio() const
{
#if (QT_VERSION>>16) == 5
return this->devicePixelRatio();
#else
return 1;
#endif
}
};
......
......@@ -65,8 +65,6 @@ class CGoGN_UTILS_API GLWidget : public QGLWidget
public:
GLWidget(SimpleQT* cbs, QWidget *parent = 0);
GLWidget(SimpleQT* cbs, QGLFormat& format, QWidget *parent = 0);
~GLWidget();
QSize minimumSizeHint() const;
......@@ -250,6 +248,15 @@ protected:
* get the focale distance
*/
float getScale() { return scalefactor / foc; }
inline int pixelRatio() const
{
#if (QT_VERSION>>16) == 5
return this->devicePixelRatio();
#else
return 1;
#endif
}
};
} // namespace QT
......
......@@ -43,6 +43,8 @@ protected:
// shader sources
static std::string vertexShaderText;
static std::string fragmentShaderText;
static std::string vertexShaderClipText;
static std::string fragmentShaderClipText;
VBO* m_vboPos;
VBO* m_vboCol;
......@@ -50,10 +52,15 @@ protected:
CGoGNGLuint m_unif_alpha;
float m_opacity;
/// clipping
CGoGNGLuint m_unif_planeClip;
Geom::Vec4f m_planeClip;
void restoreUniformsAttribs();
public:
ShaderColorPerVertex(bool black_is_transparent = false);
ShaderColorPerVertex(bool withClipping = false, bool black_is_transparent = false);
/**
* set the VBO of position (vec3)
......@@ -71,6 +78,8 @@ public:
void setOpacity(float op);
float getOpacity() const { return m_opacity;}