From 9e054a2df1b19894cf30c97ff14bb302b0781691 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Wed, 16 Jul 2014 15:39:18 +0200 Subject: [PATCH] using doubles --- Apps/SandBox/wallPaper.cpp | 2 +- Apps/SandBox/wallPaper.h | 6 +++++- include/Container/convert.h | 8 ++++---- include/Utils/Qt/qtQGLV.h | 27 +++++++++++++++++++++++++-- include/Utils/Qt/qtSimple.h | 21 +++++++++++++++++++-- src/Utils/vbo.cpp | 4 +--- 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Apps/SandBox/wallPaper.cpp b/Apps/SandBox/wallPaper.cpp index 04112b41..0cdc7c9e 100644 --- a/Apps/SandBox/wallPaper.cpp +++ b/Apps/SandBox/wallPaper.cpp @@ -43,7 +43,7 @@ void MyQT::cb_initGL() m_render = new Algo::Render::GL2::MapRender(); // create VBO for position - m_positionVBO = new Utils::VBO(); + m_positionVBO = new Utils::VBO(&converterDF); m_positionVBO->updateData(position); m_shader = new Utils::ShaderSimpleColor(); diff --git a/Apps/SandBox/wallPaper.h b/Apps/SandBox/wallPaper.h index f0b58aaf..52c2e989 100644 --- a/Apps/SandBox/wallPaper.h +++ b/Apps/SandBox/wallPaper.h @@ -46,7 +46,7 @@ using namespace CGoGN ; -struct PFP: public PFP_STANDARD +struct PFP: public PFP_DOUBLE { // definition of the map typedef EmbeddedMap2 MAP ; @@ -67,7 +67,11 @@ public: VertexAttribute position ; Algo::Render::GL2::MapRender* m_render; + + // converter for automatic conversion when updating VBOs + ConvertVec3dToVec3f converterDF; Utils::VBO* m_positionVBO; + Utils::ShaderSimpleColor* m_shader; // FOR WALL PAPER diff --git a/include/Container/convert.h b/include/Container/convert.h index 8fadfabe..54950847 100644 --- a/include/Container/convert.h +++ b/include/Container/convert.h @@ -319,7 +319,8 @@ protected: public: ConvertVec3dToVec3f(): - ConvertBuffer(sizeof(Geom::Vec3d)) + ConvertBuffer(sizeof(Geom::Vec3d)), + m_typedBuffer(NULL) {} ~ConvertVec3dToVec3f() @@ -349,15 +350,14 @@ public: { // cast ptr in & out with right type const Geom::Vec3d* typedIn = reinterpret_cast(ptrIn); - Geom::Vec3f* typedOut = reinterpret_cast(m_buffer); + Geom::Vec3f* typedOut = m_typedBuffer; // compute conversion for (unsigned int i = 0; i < m_nb; ++i) { const Geom::Vec3d& vd = *typedIn++; *typedOut++ = Geom::Vec3f(float(vd[0]),float(vd[1]),float(vd[2])); -// Geom::Vec3f& vf = *typedOut++; -// vf[0]=vd[0];vf[1]=vd[1];vf[2]=vd[2]; } + } unsigned int vectorSize() diff --git a/include/Utils/Qt/qtQGLV.h b/include/Utils/Qt/qtQGLV.h index 6bf1cea8..956a1453 100644 --- a/include/Utils/Qt/qtQGLV.h +++ b/include/Utils/Qt/qtQGLV.h @@ -193,12 +193,35 @@ public: /** * set width and pos center of object to draw */ - void setParamObject(float width, float* pos) { m_qglWidget->setParamObject(width, pos); } + template + inline void setParamObject(T width, T* pos) + { + float posF[3]; + posF[0]=float(pos[0]); + posF[1]=float(pos[1]); + posF[2]=float(pos[2]); + m_qglWidget->setParamObject(float(width), posF); + } + /** * set BB min & max corner of object to draw */ - void setObjectBB(float* bbmin, float* bbmax) { m_qglWidget->setObjectBB(bbmin, bbmax); } + inline void setObjectBB(float* bbmin, float* bbmax) { m_qglWidget->setObjectBB(bbmin, bbmax); } + + template + void setObjectBB(T* bbmin, T* bbmax) + { + float bbminF[3]; + bbminF[0]=float(bbmin[0]); + bbminF[1]=float(bbmin[1]); + bbminF[2]=float(bbmin[2]); + float bbmaxF[3]; + bbmaxF[0]=float(bbmax[0]); + bbmaxF[1]=float(bbmax[1]); + bbmaxF[2]=float(bbmax[2]); + m_qglWidget->setObjectBB(bbminF, bbmaxF); + } /** * @brief get pointer on QGLViewer widget for direct access diff --git a/include/Utils/Qt/qtSimple.h b/include/Utils/Qt/qtSimple.h index 9ebea2b5..c62b4100 100644 --- a/include/Utils/Qt/qtSimple.h +++ b/include/Utils/Qt/qtSimple.h @@ -195,9 +195,26 @@ public: /** * set width and pos center of object to draw */ - void setParamObject(float width, float* pos) { m_glWidget->setParamObject(width, pos); } + template + inline void setParamObject(T width, T* pos) + { + float posF[3]; + posF[0]=float(pos[0]); + posF[1]=float(pos[1]); + posF[2]=float(pos[2]); + m_glWidget->setParamObject(float(width), posF); + } + + template + inline void resetCenterOfRotation(T width, T* pos) + { + float posF[3]; + posF[0]=float(pos[0]); + posF[1]=float(pos[1]); + posF[2]=float(pos[2]); + m_glWidget->resetCenterOfRotation(float(width), posF); + } - void resetCenterOfRotation(float width, float* pos) { m_glWidget->resetCenterOfRotation(width, pos); } /** * make the contex of glWidget current diff --git a/src/Utils/vbo.cpp b/src/Utils/vbo.cpp index aac1b062..8a63a3d0 100644 --- a/src/Utils/vbo.cpp +++ b/src/Utils/vbo.cpp @@ -131,8 +131,6 @@ void VBO::updateData_withConversion(const AttributeMultiVectorGen* attrib, Conve m_name = attrib->getName(); m_typeName = attrib->getTypeName(); - -// m_data_size = attrib->getSizeOfType() / conv->sizeElt(); m_data_size = conv->vectorSize(); // alloue la memoire pour le buffer et initialise le conv @@ -142,7 +140,7 @@ void VBO::updateData_withConversion(const AttributeMultiVectorGen* attrib, Conve unsigned int byteTableSize; unsigned int nbb = attrib->getBlocksPointers(addr, byteTableSize); - m_nbElts = nbb * attrib->getBlockSize()*m_data_size; +// m_nbElts = nbb * attrib->getBlockSize()/m_data_size; // bind buffer to update glBindBuffer(GL_ARRAY_BUFFER, *m_id); -- GitLab