Commit 9e054a2d authored by Sylvain Thery's avatar Sylvain Thery

using doubles

parent f5529246
......@@ -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();
......
......@@ -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<VEC3, MAP> 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
......
......@@ -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<const Geom::Vec3d*>(ptrIn);
Geom::Vec3f* typedOut = reinterpret_cast<Geom::Vec3f*>(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()
......
......@@ -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<typename T>
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 <typename T>
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
......
......@@ -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<typename T>
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<typename T>
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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment