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
a6c8beb7
Commit
a6c8beb7
authored
May 14, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drawing tracks using PushVertices, added some comments, fixed formatting.
parent
32784ea1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
51 deletions
+83
-51
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+54
-36
round.vert
common/gal/opengl/shader/round.vert
+1
-1
vbo_item.cpp
common/gal/opengl/vbo_item.cpp
+4
-4
vbo_item.h
include/gal/opengl/vbo_item.h
+24
-10
No files found.
common/gal/opengl/opengl_gal.cpp
View file @
a6c8beb7
...
...
@@ -68,7 +68,7 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
isFrameBufferInitialized
=
false
;
isUseShader
=
isUseShaders
;
isShaderInitialized
=
false
;
isGrouping
=
false
;
isGrouping
=
false
;
shaderPath
=
"../../common/gal/opengl/shader/"
;
wxSize
parentSize
=
aParent
->
GetSize
();
...
...
@@ -615,20 +615,35 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2
VECTOR2D
perpendicularVector
(
-
startEndVector
.
y
*
scale
,
startEndVector
.
x
*
scale
);
// Compute the edge points of the line
VECTOR2D
point1
=
aStartPoint
+
perpendicularVector
;
VECTOR2D
point2
=
aStartPoint
-
perpendicularVector
;
VECTOR2D
point3
=
aEndPoint
+
perpendicularVector
;
VECTOR2D
point4
=
aEndPoint
-
perpendicularVector
;
VECTOR2D
v0
=
aStartPoint
+
perpendicularVector
;
VECTOR2D
v1
=
aStartPoint
-
perpendicularVector
;
VECTOR2D
v2
=
aEndPoint
+
perpendicularVector
;
VECTOR2D
v3
=
aEndPoint
-
perpendicularVector
;
glBegin
(
GL_TRIANGLES
);
glVertex3d
(
point1
.
x
,
point1
.
y
,
layerDepth
);
glVertex3d
(
point2
.
x
,
point2
.
y
,
layerDepth
);
glVertex3d
(
point4
.
x
,
point4
.
y
,
layerDepth
);
if
(
isGrouping
)
{
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
,
v3
.
x
,
v3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v0
.
x
,
v0
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v3
.
x
,
v3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
.
x
,
v2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
6
);
}
else
{
glBegin
(
GL_TRIANGLES
);
glVertex3d
(
v0
.
x
,
v0
.
y
,
layerDepth
);
glVertex3d
(
v1
.
x
,
v1
.
y
,
layerDepth
);
glVertex3d
(
v3
.
x
,
v3
.
y
,
layerDepth
);
glVertex3d
(
point1
.
x
,
point1
.
y
,
layerDepth
);
glVertex3d
(
point4
.
x
,
point4
.
y
,
layerDepth
);
glVertex3d
(
point3
.
x
,
point3
.
y
,
layerDepth
);
glEnd
();
glVertex3d
(
v0
.
x
,
v0
.
y
,
layerDepth
);
glVertex3d
(
v3
.
x
,
v3
.
y
,
layerDepth
);
glVertex3d
(
v2
.
x
,
v2
.
y
,
layerDepth
);
glEnd
();
}
}
...
...
@@ -637,7 +652,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
double
lineAngle
=
atan2
(
startEndVector
.
y
,
startEndVector
.
x
);
if
(
isGrouping
)
/*
if ( isGrouping )
{
// Angle of a line perpendicular to the segment being drawn
double beta = ( M_PI / 2.0 ) - lineAngle;
...
...
@@ -662,37 +677,40 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
};
curVboItem->PushVertices( newVertices, 6 );
}
if
(
isFillEnabled
)
else*/
{
glColor4d
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
if
(
isFillEnabled
)
{
if
(
!
isGrouping
)
glColor4d
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
SetLineWidth
(
aWidth
);
drawSemiCircle
(
aStartPoint
,
aWidth
/
2
,
lineAngle
+
M_PI
/
2
,
layerDepth
);
drawSemiCircle
(
aEndPoint
,
aWidth
/
2
,
lineAngle
-
M_PI
/
2
,
layerDepth
);
drawLineQuad
(
aStartPoint
,
aEndPoint
);
}
else
{
double
lineLength
=
startEndVector
.
EuclideanNorm
();
SetLineWidth
(
aWidth
);
drawSemiCircle
(
aStartPoint
,
aWidth
/
2
,
lineAngle
+
M_PI
/
2
,
layerDepth
);
drawSemiCircle
(
aEndPoint
,
aWidth
/
2
,
lineAngle
-
M_PI
/
2
,
layerDepth
);
drawLineQuad
(
aStartPoint
,
aEndPoint
);
}
else
{
double
lineLength
=
startEndVector
.
EuclideanNorm
();
glColor4d
(
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
);
glColor4d
(
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
);
glPushMatrix
();
glPushMatrix
();
glTranslated
(
aStartPoint
.
x
,
aStartPoint
.
y
,
0.0
);
glRotated
(
lineAngle
*
(
360
/
(
2
*
M_PI
)
),
0
,
0
,
1
);
glTranslated
(
aStartPoint
.
x
,
aStartPoint
.
y
,
0.0
);
glRotated
(
lineAngle
*
(
360
/
(
2
*
M_PI
)
),
0
,
0
,
1
);
drawLineQuad
(
VECTOR2D
(
0.0
,
aWidth
/
2.0
),
VECTOR2D
(
lineLength
,
aWidth
/
2.0
)
);
drawLineQuad
(
VECTOR2D
(
0.0
,
aWidth
/
2.0
),
VECTOR2D
(
lineLength
,
aWidth
/
2.0
)
);
drawLineQuad
(
VECTOR2D
(
0.0
,
-
aWidth
/
2.0
),
VECTOR2D
(
lineLength
,
-
aWidth
/
2.0
)
);
drawLineQuad
(
VECTOR2D
(
0.0
,
-
aWidth
/
2.0
),
VECTOR2D
(
lineLength
,
-
aWidth
/
2.0
)
);
DrawArc
(
VECTOR2D
(
0.0
,
0.0
),
aWidth
/
2.0
,
M_PI
/
2.0
,
3.0
*
M_PI
/
2.0
);
DrawArc
(
VECTOR2D
(
lineLength
,
0.0
),
aWidth
/
2.0
,
M_PI
/
2.0
,
-
M_PI
/
2.0
);
DrawArc
(
VECTOR2D
(
0.0
,
0.0
),
aWidth
/
2.0
,
M_PI
/
2.0
,
3.0
*
M_PI
/
2.0
);
DrawArc
(
VECTOR2D
(
lineLength
,
0.0
),
aWidth
/
2.0
,
M_PI
/
2.0
,
-
M_PI
/
2.0
);
glPopMatrix
();
glPopMatrix
();
}
}
}
...
...
common/gal/opengl/shader/round.vert
View file @
a6c8beb7
...
...
@@ -25,7 +25,7 @@
#version 120
varying
float
aspect
;
varying
float
aspect
;
void
main
()
{
...
...
common/gal/opengl/vbo_item.cpp
View file @
a6c8beb7
...
...
@@ -86,7 +86,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
}
void
VBO_ITEM
::
PushVertices
(
const
GLfloat
*
aVert
ex
,
GLuint
aSize
)
void
VBO_ITEM
::
PushVertices
(
const
GLfloat
*
aVert
ices
,
GLuint
aSize
)
{
int
newSize
=
m_size
+
aSize
;
GLfloat
*
newVertices
=
new
GLfloat
[
newSize
*
VertStride
];
...
...
@@ -101,8 +101,8 @@ void VBO_ITEM::PushVertices( const GLfloat* aVertex, GLuint aSize )
}
m_vertices
=
newVertices
;
// Add
the new vertex
memcpy
(
&
newVertices
[
m_size
*
VertStride
],
aVert
ex
,
aSize
*
VertSize
);
// Add
new vertices
memcpy
(
&
newVertices
[
m_size
*
VertStride
],
aVert
ices
,
aSize
*
VertSize
);
// Handle new indices
if
(
m_indices
)
...
...
@@ -160,7 +160,7 @@ void SetVbo( int aVboId )
}
int GetVbo()
int GetVbo()
const
{
}
*/
include/gal/opengl/vbo_item.h
View file @
a6c8beb7
...
...
@@ -43,9 +43,23 @@ public:
VBO_ITEM
();
~
VBO_ITEM
();
// TODO comments
/**
* Function PushVertex()
* Adds a single vertex to the VBO_ITEM. Vertex contains information about coordinates and
* colors and has to follow the specified format {X,Y,Z,R,G,B,A}.
* @param aVertex is a vertex to be added.
*/
void
PushVertex
(
const
GLfloat
*
aVertex
);
void
PushVertices
(
const
GLfloat
*
aVertex
,
GLuint
aSize
);
/**
* Function PushVertices()
* Adds multiple vertices to the VBO_ITEM. This function is recommended over multiple calls to
* PushVertex, as it does less memory reallocations. Vertices contain information about
* coordinates and colors and has to follow the specified format {X,Y,Z,R,G,B,A}.
* @param aVertices are vertices to be added.
* @param aSize is an amount of vertices to be added.
*/
void
PushVertices
(
const
GLfloat
*
aVertices
,
GLuint
aSize
);
/**
* Function GetVertices()
...
...
@@ -79,7 +93,7 @@ public:
///< Functions for getting VBO ids.
//void SetVbo( int aVboId );
//int GetVbo();
//int GetVbo()
const
;
///< Data organization information for vertices.
static
const
int
VertStride
=
7
;
...
...
@@ -94,21 +108,21 @@ private:
///< Contains vertices coordinates and colors.
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
GLfloat
*
m_vertices
;
GLfloat
*
m_vertices
;
///< Indices of vertices
GLuint
*
m_indices
;
GLuint
*
m_indices
;
///< Offset and size of data in VBO.
int
m_offset
;
int
m_size
;
int
m_offset
;
int
m_size
;
///< Shader data used for rendering.
int
m_shader
;
int
m_shaderAttrib
;
int
m_shader
;
int
m_shaderAttrib
;
///< Flag telling if the item should be recached in VBO or not.
bool
m_isDirty
;
bool
m_isDirty
;
};
}
// 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