Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
fc493e8f
Commit
fc493e8f
authored
Jul 16, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
automatic double usage !
parent
9e054a2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
42 deletions
+68
-42
Apps/SandBox/wallPaper.cpp
Apps/SandBox/wallPaper.cpp
+2
-2
Apps/SandBox/wallPaper.h
Apps/SandBox/wallPaper.h
+0
-2
include/Container/convert.h
include/Container/convert.h
+32
-37
src/Utils/vbo.cpp
src/Utils/vbo.cpp
+34
-1
No files found.
Apps/SandBox/wallPaper.cpp
View file @
fc493e8f
...
...
@@ -30,7 +30,7 @@ using namespace CGoGN ;
void
MyQT
::
cb_initGL
()
{
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
,
VERTEX
,
MAP
>
(
"position"
);
Algo
::
Surface
::
Tilings
::
Square
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
2
0
);
Algo
::
Surface
::
Tilings
::
Square
::
Cylinder
<
PFP
>
c
(
myMap
,
50
,
5
0
);
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
1.0
);
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
float
lWidthObj
=
std
::
max
<
PFP
::
REAL
>
(
std
::
max
<
PFP
::
REAL
>
(
bb
.
size
(
0
),
bb
.
size
(
1
)),
bb
.
size
(
2
));
...
...
@@ -43,7 +43,7 @@ void MyQT::cb_initGL()
m_render
=
new
Algo
::
Render
::
GL2
::
MapRender
();
// create VBO for position
m_positionVBO
=
new
Utils
::
VBO
(
&
converterDF
);
m_positionVBO
=
new
Utils
::
VBO
();
m_positionVBO
->
updateData
(
position
);
m_shader
=
new
Utils
::
ShaderSimpleColor
();
...
...
Apps/SandBox/wallPaper.h
View file @
fc493e8f
...
...
@@ -68,8 +68,6 @@ public:
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
// converter for automatic conversion when updating VBOs
ConvertVec3dToVec3f
converterDF
;
Utils
::
VBO
*
m_positionVBO
;
Utils
::
ShaderSimpleColor
*
m_shader
;
...
...
include/Container/convert.h
View file @
fc493e8f
...
...
@@ -28,11 +28,6 @@ protected:
*/
unsigned
int
m_nb
;
/**
* size of element in input
*/
unsigned
int
m_szElt
;
/**
* buffer
*/
...
...
@@ -42,9 +37,7 @@ public:
/**
*
*/
ConvertBuffer
()
:
m_size
(
0
),
m_nb
(
0
),
m_szElt
(
0
),
m_buffer
(
NULL
)
{}
ConvertBuffer
(
unsigned
int
sz
)
:
m_size
(
0
),
m_nb
(
0
),
m_szElt
(
sz
),
m_buffer
(
NULL
)
{}
ConvertBuffer
()
:
m_size
(
0
),
m_nb
(
0
),
m_buffer
(
NULL
)
{}
/**
*
...
...
@@ -95,11 +88,8 @@ class ConvertToFloat : public ConvertBuffer
{
protected:
float
*
m_typedBuffer
;
unsigned
int
m_szVect
;
public:
ConvertToFloat
()
:
ConvertBuffer
(
sizeof
(
TYPE_IN
)),
m_szVect
(
1
)
ConvertToFloat
()
{}
~
ConvertToFloat
()
...
...
@@ -119,7 +109,7 @@ public:
void
reserve
(
unsigned
int
nb
)
{
m_nb
=
nb
*
m_szVect
;
// store number of elements
m_nb
=
nb
;
// store number of elements
m_typedBuffer
=
new
float
[
m_nb
];
// allocate buffer
m_buffer
=
m_typedBuffer
;
// store void* casted ptr
m_size
=
m_nb
*
sizeof
(
float
);
// store size of buffer in bytes
...
...
@@ -137,12 +127,7 @@ public:
unsigned
int
vectorSize
()
{
return
m_szVect
;
}
void
setPseudoVectorSize
(
unsigned
int
sz
)
{
m_szVect
=
sz
;
return
1
;
}
};
...
...
@@ -159,8 +144,8 @@ protected:
TYPE_OUT
*
m_typedBuffer
;
public:
ConvertNormalized
()
:
ConvertBuffer
(
sizeof
(
TYPE_IN
))
ConvertNormalized
()
/*
:
ConvertBuffer(sizeof(TYPE_IN))
*/
{}
~
ConvertNormalized
()
...
...
@@ -226,7 +211,11 @@ protected:
TYPE_IN
m_diff
;
public:
ConvertToRGBf
(
TYPE_IN
min
,
TYPE_IN
max
)
:
ConvertBuffer
(
sizeof
(
TYPE_IN
)),
m_min
(
min
),
m_diff
(
max
-
min
)
{}
ConvertToRGBf
(
TYPE_IN
min
,
TYPE_IN
max
)
:
// ConvertBuffer(sizeof(TYPE_IN)),
m_min
(
min
),
m_diff
(
max
-
min
),
m_typedBuffer
(
NULL
)
{}
~
ConvertToRGBf
()
{
...
...
@@ -306,24 +295,26 @@ public:
unsigned
int
vectorSize
()
{
return
1
;
return
3
;
}
};
class
ConvertVec
3dToVec3
f
:
public
ConvertBuffer
template
<
unsigned
int
D
>
class
ConvertVec
XdToVecX
f
:
public
ConvertBuffer
{
protected:
Geom
::
Vec3f
*
m_typedBuffer
;
typedef
Geom
::
Vector
<
D
,
float
>
VECF
;
typedef
Geom
::
Vector
<
D
,
double
>
VECD
;
VECF
*
m_typedBuffer
;
public:
ConvertVec
3dToVec3
f
()
:
ConvertBuffer
(
sizeof
(
Geom
::
Vec3d
)),
ConvertVec
XdToVecX
f
()
:
m_typedBuffer
(
NULL
)
{}
~
ConvertVec
3dToVec3
f
()
~
ConvertVec
XdToVecX
f
()
{
if
(
m_typedBuffer
)
delete
[]
m_typedBuffer
;
...
...
@@ -341,32 +332,36 @@ public:
void
reserve
(
unsigned
int
nb
)
{
m_nb
=
nb
;
// store number of elements
m_typedBuffer
=
new
Geom
::
Vec3f
[
nb
];
// allocate buffer typed (not possible to delete void*)
m_typedBuffer
=
new
VECF
[
nb
];
// allocate buffer typed (not possible to delete void*)
m_buffer
=
m_typedBuffer
;
// store void* casted ptr
m_size
=
nb
*
sizeof
(
Geom
::
Vec3f
);
// store size of buffer in bytes
m_size
=
nb
*
sizeof
(
VECF
);
// store size of buffer in bytes
}
void
convert
(
const
void
*
ptrIn
)
{
// cast ptr in & out with right type
const
Geom
::
Vec3d
*
typedIn
=
reinterpret_cast
<
const
Geom
::
Vec3d
*>
(
ptrIn
);
Geom
::
Vec3f
*
typedOut
=
m_typedBuffer
;
const
VECD
*
typedIn
=
reinterpret_cast
<
const
VECD
*>
(
ptrIn
);
VECF
*
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
]));
const
VECD
&
vd
=
*
typedIn
++
;
for
(
unsigned
int
j
=
0
;
j
<
D
;
++
j
)
(
*
typedOut
)[
j
]
=
float
(
vd
[
j
]);
typedOut
++
;
}
}
unsigned
int
vectorSize
()
{
return
3
;
return
D
;
}
};
typedef
ConvertVecXdToVecXf
<
2
>
ConvertVec2dToVec2f
;
typedef
ConvertVecXdToVecXf
<
3
>
ConvertVec3dToVec3f
;
typedef
ConvertVecXdToVecXf
<
4
>
ConvertVec4dToVec4f
;
typedef
ConvertToFloat
<
double
>
ConvertDoubleToFloat
;
...
...
src/Utils/vbo.cpp
View file @
fc493e8f
...
...
@@ -101,6 +101,39 @@ void VBO::updateData(const AttributeMultiVectorGen* attrib)
return
;
}
const
AttributeMultiVector
<
Geom
::
Vec3d
>*
amv3
=
dynamic_cast
<
const
AttributeMultiVector
<
Geom
::
Vec3d
>*>
(
attrib
);
if
(
amv3
!=
NULL
)
{
ConvertVec3dToVec3f
conv
;
updateData_withConversion
(
attrib
,
&
conv
);
return
;
}
const
AttributeMultiVector
<
Geom
::
Vec2d
>*
amv2
=
dynamic_cast
<
const
AttributeMultiVector
<
Geom
::
Vec2d
>*>
(
attrib
);
if
(
amv2
!=
NULL
)
{
ConvertVec2dToVec2f
conv
;
updateData_withConversion
(
attrib
,
&
conv
);
return
;
}
const
AttributeMultiVector
<
Geom
::
Vec4d
>*
amv4
=
dynamic_cast
<
const
AttributeMultiVector
<
Geom
::
Vec4d
>*>
(
attrib
);
if
(
amv4
!=
NULL
)
{
ConvertVec4dToVec4f
conv
;
updateData_withConversion
(
attrib
,
&
conv
);
return
;
}
const
AttributeMultiVector
<
double
>*
amv1
=
dynamic_cast
<
const
AttributeMultiVector
<
double
>*>
(
attrib
);
if
(
amv1
!=
NULL
)
{
ConvertDoubleToFloat
conv
;
updateData_withConversion
(
attrib
,
&
conv
);
return
;
}
m_name
=
attrib
->
getName
();
m_typeName
=
attrib
->
getTypeName
();
...
...
@@ -140,7 +173,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
*
sizeof
(
float
))
;
// bind buffer to update
glBindBuffer
(
GL_ARRAY_BUFFER
,
*
m_id
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment