diff --git a/Apps/SandBox/wallPaper.cpp b/Apps/SandBox/wallPaper.cpp index 04112b41eee7c8e34baa358393689e04e5867e3c..0cdc7c9e2aff560d2f5f6768a03f1c6d8b460f98 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 f0b58aaf0b0ae375890a0cabe73ea9e01b6a088e..52c2e9895a53c96e5cc63a25064bec200601cd1c 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 8fadfabe56899ed7273dd2fc8bc9d9d29d1b5f38..5495084789bdfd5319a11e063e69991e4aced0cb 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 6bf1cea8f869d88021b43378103fca684ec21d6c..956a1453f6f4dc5361de9a72b44174f44d4b6cc6 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 9ebea2b5a06daec2245f6e81e4de5395572ac292..c62b4100495daac683bd52c86c3a2565d1a63bfc 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 aac1b062bbd29eab4fae01567caa91066d4ad2b8..8a63a3d01373b65215b11bc460818cede6589a86 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);