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
32784ea1
Commit
32784ea1
authored
May 13, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added possibility of adding multiple vertices to VBO_ITEM at once
parent
bce9f685
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
25 deletions
+43
-25
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+10
-22
vbo_item.cpp
common/gal/opengl/vbo_item.cpp
+32
-3
vbo_item.h
include/gal/opengl/vbo_item.h
+1
-0
No files found.
common/gal/opengl/opengl_gal.cpp
View file @
32784ea1
...
...
@@ -651,28 +651,16 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
VECTOR2D
v3
(
aEndPoint
.
x
-
(
aWidth
*
cos
(
beta
)
/
2.0
),
aEndPoint
.
y
+
(
aWidth
*
sin
(
beta
)
/
2.0
)
);
// First triangle
GLfloat
newVertex1
[]
=
{
v0
.
x
,
v0
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
GLfloat
newVertex2
[]
=
{
v1
.
x
,
v1
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
GLfloat
newVertex3
[]
=
{
v2
.
x
,
v2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
// Second triangle
GLfloat
newVertex4
[]
=
{
v0
.
x
,
v0
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
GLfloat
newVertex5
[]
=
{
v2
.
x
,
v2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
GLfloat
newVertex6
[]
=
{
v3
.
x
,
v3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertex
(
newVertex1
);
curVboItem
->
PushVertex
(
newVertex2
);
curVboItem
->
PushVertex
(
newVertex3
);
curVboItem
->
PushVertex
(
newVertex4
);
curVboItem
->
PushVertex
(
newVertex5
);
curVboItem
->
PushVertex
(
newVertex6
);
// Two triangles
GLfloat
newVertices
[]
=
{
v0
.
x
,
v0
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v1
.
x
,
v1
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
.
x
,
v2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v0
.
x
,
v0
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
.
x
,
v2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v3
.
x
,
v3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
6
);
}
if
(
isFillEnabled
)
...
...
common/gal/opengl/vbo_item.cpp
View file @
32784ea1
...
...
@@ -61,7 +61,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
if
(
m_vertices
)
{
// Copy all previous vertices data
memcpy
(
newVertices
,
m_vertices
,
(
m_size
)
*
VertSize
);
memcpy
(
newVertices
,
m_vertices
,
m_size
*
VertSize
);
delete
m_vertices
;
}
m_vertices
=
newVertices
;
...
...
@@ -73,7 +73,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
if
(
m_indices
)
{
// Copy all previous vertices data
memcpy
(
newIndices
,
m_indices
,
(
m_size
)
*
IndSize
);
memcpy
(
newIndices
,
m_indices
,
m_size
*
IndSize
);
delete
m_indices
;
}
m_indices
=
newIndices
;
...
...
@@ -88,7 +88,36 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
void
VBO_ITEM
::
PushVertices
(
const
GLfloat
*
aVertex
,
GLuint
aSize
)
{
// FIXME to be done
int
newSize
=
m_size
+
aSize
;
GLfloat
*
newVertices
=
new
GLfloat
[
newSize
*
VertStride
];
GLuint
*
newIndices
=
new
GLuint
[
newSize
*
IndStride
];
// Handle new vertices
if
(
m_vertices
)
{
// Copy all previous vertices data
memcpy
(
newVertices
,
m_vertices
,
(
m_size
)
*
VertSize
);
delete
m_vertices
;
}
m_vertices
=
newVertices
;
// Add the new vertex
memcpy
(
&
newVertices
[
m_size
*
VertStride
],
aVertex
,
aSize
*
VertSize
);
// Handle new indices
if
(
m_indices
)
{
// Copy all previous vertices data
memcpy
(
newIndices
,
m_indices
,
(
m_size
)
*
IndSize
);
delete
m_indices
;
}
m_indices
=
newIndices
;
// Add the new vertex
for
(
int
i
=
m_size
;
i
<
newSize
;
++
i
)
m_indices
[
i
]
=
m_offset
+
i
;
m_size
+=
aSize
;
m_isDirty
=
true
;
}
...
...
include/gal/opengl/vbo_item.h
View file @
32784ea1
...
...
@@ -96,6 +96,7 @@ private:
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
GLfloat
*
m_vertices
;
///< Indices of vertices
GLuint
*
m_indices
;
///< Offset and size of data in VBO.
...
...
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