Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
8e1fe5d7
Commit
8e1fe5d7
authored
Jun 05, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed data structure in VBO_ITEM.
parent
e9ebdf25
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
50 deletions
+24
-50
vbo_item.cpp
common/gal/opengl/vbo_item.cpp
+4
-17
vbo_item.h
include/gal/opengl/vbo_item.h
+20
-33
No files found.
common/gal/opengl/vbo_item.cpp
View file @
8e1fe5d7
...
...
@@ -83,19 +83,19 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
vertex
=
*
m_transform
*
vertex
;
// Replace only coordinates, leave color as it is
memcpy
(
&
m_vertPtr
->
struc
.
coord
,
&
vertex
[
0
],
CoordByteSize
);
memcpy
(
&
m_vertPtr
->
x
,
&
vertex
[
0
],
CoordByteSize
);
}
else
{
// Add the new vertex
memcpy
(
&
m_vertPtr
->
struc
.
coord
,
aVertex
,
CoordByteSize
);
memcpy
(
&
m_vertPtr
->
x
,
aVertex
,
CoordByteSize
);
}
// Apply currently used color
memcpy
(
&
m_vertPtr
->
struc
.
colo
r
,
m_color
,
ColorByteSize
);
memcpy
(
&
m_vertPtr
->
r
,
m_color
,
ColorByteSize
);
// Apply currently used shader
memcpy
(
&
m_vertPtr
->
s
truc
.
s
hader
,
m_shader
,
ShaderByteSize
);
memcpy
(
&
m_vertPtr
->
shader
,
m_shader
,
ShaderByteSize
);
// Move to the next free space
m_vertPtr
++
;
...
...
@@ -206,19 +206,6 @@ void VBO_ITEM::UseShader( const GLfloat* aShader )
}
/*
// TODO
void SetVbo( int aVboId )
{
}
int GetVbo() const
{
}
*/
void
VBO_ITEM
::
useNewBlock
()
{
VBO_VERTEX
*
newVertBlock
=
new
VBO_VERTEX
[
BLOCK_SIZE
];
...
...
include/gal/opengl/vbo_item.h
View file @
8e1fe5d7
...
...
@@ -40,25 +40,13 @@
namespace
KiGfx
{
typedef
struct
VBO_VERTEX
_DATA
typedef
struct
VBO_VERTEX
{
GLfloat
x
,
y
,
z
;
// Coordinates
GLfloat
r
,
g
,
b
,
a
;
// Color
GLfloat
shader
[
4
];
// Shader type & params
}
VBO_VERTEX_DATA
;
typedef
struct
VBO_VERTEX_STRUCT
{
GLfloat
coord
[
3
];
// Coordinates
GLfloat
color
[
4
];
// Color
GLfloat
shader
[
4
];
// Shader type & params
}
VBO_VERTEX_STRUCT
;
typedef
union
VBO_VERTEX
{
VBO_VERTEX_DATA
data
;
VBO_VERTEX_STRUCT
struc
;
}
VBO_VERTEX
;
class
VBO_ITEM
{
...
...
@@ -159,28 +147,27 @@ public:
static
const
int
VertByteSize
=
sizeof
(
VBO_VERTEX
);
static
const
int
VertStride
=
VertByteSize
/
sizeof
(
GLfloat
);
static
const
int
CoordStride
=
sizeof
(
VBO_VERTEX_STRUCT
().
coord
)
/
sizeof
(
GLfloat
);
static
const
int
CoordByteSize
=
sizeof
(
VBO_VERTEX_STRUCT
().
coord
);
static
const
int
CoordByteSize
=
sizeof
(
VBO_VERTEX
().
x
)
+
sizeof
(
VBO_VERTEX
().
y
)
+
sizeof
(
VBO_VERTEX
().
z
);
static
const
int
CoordStride
=
CoordByteSize
/
sizeof
(
GLfloat
);
// Offset of color data from the beginning of each vertex data
static
const
int
ColorByteOffset
=
offsetof
(
VBO_VERTEX_STRUCT
,
color
);
static
const
int
ColorByteOffset
=
offsetof
(
VBO_VERTEX
,
r
);
static
const
int
ColorOffset
=
ColorByteOffset
/
sizeof
(
GLfloat
);
static
const
int
ColorStride
=
sizeof
(
VBO_VERTEX_STRUCT
().
color
)
/
sizeof
(
GLfloat
);
static
const
int
ColorByteSize
=
sizeof
(
VBO_VERTEX_STRUCT
().
color
);
static
const
int
ColorByteSize
=
sizeof
(
VBO_VERTEX
().
r
)
+
sizeof
(
VBO_VERTEX
().
g
)
+
sizeof
(
VBO_VERTEX
().
b
)
+
sizeof
(
VBO_VERTEX
().
a
);
static
const
int
ColorStride
=
ColorByteSize
/
sizeof
(
GLfloat
);
// Shader attributes
static
const
int
ShaderByteOffset
=
offsetof
(
VBO_VERTEX_STRUCT
,
shader
);
static
const
int
ShaderByteOffset
=
offsetof
(
VBO_VERTEX
,
shader
);
static
const
int
ShaderOffset
=
ShaderByteOffset
/
sizeof
(
GLfloat
);
static
const
int
Shader
Stride
=
sizeof
(
VBO_VERTEX_STRUCT
().
shader
)
/
sizeof
(
GLfloat
);
static
const
int
Shader
ByteSize
=
sizeof
(
VBO_VERTEX_STRUCT
().
shader
);
static
const
int
Shader
ByteSize
=
sizeof
(
VBO_VERTEX
().
shader
);
static
const
int
Shader
Stride
=
ShaderByteSize
/
sizeof
(
GLfloat
);
static
const
int
IndStride
=
1
;
static
const
int
IndByteSize
=
IndStride
*
sizeof
(
GLuint
);
private
:
///< VBO ids in which the item is stored.
//int m_vboId; // not used yet
///< Contains vertices coordinates and colors.
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
GLfloat
*
m_vertices
;
...
...
@@ -216,7 +203,7 @@ private:
///< Flag telling if the item should be recached in VBO or not.
bool
m_isDirty
;
///< Current transform matrix for every new vertex pushed.
///< Current transform matrix
applied
for every new vertex pushed.
const
glm
::
mat4
*
m_transform
;
};
}
// namespace KiGfx
...
...
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