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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Etienne Schmitt
CGoGN
Commits
5ae47e69
Commit
5ae47e69
authored
Apr 05, 2011
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oubli ajout vbo.h et hpp
parent
b833e0e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
199 additions
and
0 deletions
+199
-0
include/Utils/vbo.h
include/Utils/vbo.h
+110
-0
include/Utils/vbo.hpp
include/Utils/vbo.hpp
+89
-0
No files found.
include/Utils/vbo.h
0 → 100644
View file @
5ae47e69
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __CGoGN_GLSL_VBO__
#define __CGoGN_GLSL_VBO__
#include <vector>
#include <GL/glew.h>
#include "Topology/generic/attributeHandler.h"
#include "Container/convert.h"
namespace
CGoGN
{
namespace
Utils
{
class
GLSLShader
;
/**
* Encaptusaltion of OpenGL Vertex Buffer Object
* Manage
* - alloc /release of GL buffer
* - ref by Shaders
* - size of data (invidual cells)
*/
class
VBO
{
protected:
// VBO id
GLuint
m_id
;
// size of data (in floats)
unsigned
int
m_data_size
;
// shaders that ref this vbo
std
::
vector
<
GLSLShader
*>
m_refs
;
public:
/**
* constructor: allocate the OGL VBO
*/
VBO
();
/**
* destructor: release the OGL VBO and clean references between VBO/Shaders
*/
~
VBO
();
/**
* get id of vbo
*/
unsigned
int
id
()
const
{
return
m_id
;}
/**
* get dataSize
*/
unsigned
int
dataSize
()
const
{
return
m_data_size
;}
/**
* set the data size (in number of float)
*/
void
setDataSize
(
unsigned
int
ds
)
{
m_data_size
=
ds
;}
/**
* reference vbo as used by shader sh
*/
void
ref
(
GLSLShader
*
sh
);
/**
* update data from attribute handler to the vbo
*/
template
<
typename
ATTR_HANDLER
>
void
updateData
(
const
ATTR_HANDLER
&
attrib
);
/**
* update data from attribute handler to the vbo, with conversion
*/
template
<
typename
ATTR_HANDLER
>
void
updateData
(
const
ATTR_HANDLER
&
attrib
,
ConvertAttrib
*
conv
);
};
}
}
#include "Utils/vbo.hpp"
#endif
include/Utils/vbo.hpp
0 → 100644
View file @
5ae47e69
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace
CGoGN
{
namespace
Utils
{
template
<
typename
ATTR_HANDLER
>
void
VBO
::
updateData
(
const
ATTR_HANDLER
&
attrib
)
{
m_data_size
=
sizeof
(
typename
ATTR_HANDLER
::
DATA_TYPE
)
/
sizeof
(
float
);
AttributeMultiVector
<
typename
ATTR_HANDLER
::
DATA_TYPE
>*
mv
=
attrib
.
getDataVector
()
;
std
::
vector
<
void
*>
addr
;
unsigned
int
byteTableSize
;
unsigned
int
nbb
=
mv
->
getBlocksPointers
(
addr
,
byteTableSize
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
glBufferData
(
GL_ARRAY_BUFFER
,
nbb
*
byteTableSize
,
0
,
GL_STREAM_DRAW
);
unsigned
int
offset
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
nbb
;
++
i
)
{
glBufferSubDataARB
(
GL_ARRAY_BUFFER
,
offset
,
byteTableSize
,
addr
[
i
]);
offset
+=
byteTableSize
;
}
}
template
<
typename
ATTR_HANDLER
>
void
VBO
::
updateData
(
const
ATTR_HANDLER
&
attrib
,
ConvertAttrib
*
conv
)
{
m_data_size
=
conv
->
sizeElt
();
AttributeMultiVector
<
typename
ATTR_HANDLER
::
DATA_TYPE
>*
mv
=
attrib
.
getDataVector
()
;
std
::
vector
<
void
*>
addr
;
unsigned
int
byteTableSize
;
unsigned
int
nbb
=
mv
->
getBlocksPointers
(
addr
,
byteTableSize
);
// alloue la memoire pour le buffer et initialise le conv
conv
->
reserve
(
mv
->
getBlockSize
());
// bind buffer to update
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
glBufferData
(
GL_ARRAY_BUFFER
,
nbb
*
conv
->
sizeBuffer
(),
0
,
GL_STREAM_DRAW
);
unsigned
int
offset
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
nbb
;
++
i
)
{
// convertit les donnees dans le buffer de conv
conv
->
convert
(
addr
[
i
]);
// update sub-vbo
glBufferSubDataARB
(
GL_ARRAY_BUFFER
,
offset
,
conv
->
sizeBuffer
(),
conv
->
buffer
());
// block suivant
offset
+=
conv
->
sizeBuffer
();
}
// libere la memoire de la conversion
conv
->
release
();
}
}
}
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