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
7a1718d0
Commit
7a1718d0
authored
May 16, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed functions for adding vertices in VBO mode to make code easier to read and understand.
parent
2579fd52
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
349 deletions
+149
-349
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+115
-342
vbo_item.cpp
common/gal/opengl/vbo_item.cpp
+9
-5
opengl_gal.h
include/gal/opengl/opengl_gal.h
+20
-0
vbo_item.h
include/gal/opengl/vbo_item.h
+5
-2
No files found.
common/gal/opengl/opengl_gal.cpp
View file @
7a1718d0
...
@@ -625,31 +625,15 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2
...
@@ -625,31 +625,15 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2
VECTOR2D
v2
=
aEndPoint
+
perpendicularVector
;
VECTOR2D
v2
=
aEndPoint
+
perpendicularVector
;
VECTOR2D
v3
=
aEndPoint
-
perpendicularVector
;
VECTOR2D
v3
=
aEndPoint
-
perpendicularVector
;
if
(
isGrouping
)
begin
(
GL_TRIANGLES
);
{
vertex3
(
v0
.
x
,
v0
.
y
,
layerDepth
);
const
GLfloat
newVertices
[]
=
vertex3
(
v1
.
x
,
v1
.
y
,
layerDepth
);
{
vertex3
(
v3
.
x
,
v3
.
y
,
layerDepth
);
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
,
vertex3
(
v0
.
x
,
v0
.
y
,
layerDepth
);
v3
.
x
,
v3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
v3
.
x
,
v3
.
y
,
layerDepth
);
v0
.
x
,
v0
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
v2
.
x
,
v2
.
y
,
layerDepth
);
v3
.
x
,
v3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
end
();
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
(
v0
.
x
,
v0
.
y
,
layerDepth
);
glVertex3d
(
v3
.
x
,
v3
.
y
,
layerDepth
);
glVertex3d
(
v2
.
x
,
v2
.
y
,
layerDepth
);
glEnd
();
}
}
}
...
@@ -721,6 +705,34 @@ inline void OPENGL_GAL::drawLineCap( const VECTOR2D& aStartPoint, const VECTOR2D
...
@@ -721,6 +705,34 @@ inline void OPENGL_GAL::drawLineCap( const VECTOR2D& aStartPoint, const VECTOR2D
}
}
void
OPENGL_GAL
::
begin
(
GLenum
aMode
)
{
if
(
!
isGrouping
)
glBegin
(
aMode
);
}
void
OPENGL_GAL
::
end
()
{
if
(
!
isGrouping
)
glEnd
();
}
void
OPENGL_GAL
::
vertex3
(
double
aX
,
double
aY
,
double
aZ
)
{
if
(
isGrouping
)
{
const
GLfloat
vertex
[]
=
{
aX
,
aY
,
aZ
};
curVboItem
->
PushVertex
(
vertex
);
}
else
{
glVertex3d
(
aX
,
aY
,
aZ
);
}
}
void
OPENGL_GAL
::
translate3
(
double
aX
,
double
aY
,
double
aZ
)
void
OPENGL_GAL
::
translate3
(
double
aX
,
double
aY
,
double
aZ
)
{
{
if
(
isGrouping
)
if
(
isGrouping
)
...
@@ -738,8 +750,7 @@ void OPENGL_GAL::color4( double aRed, double aGreen, double aBlue, double aAlpha
...
@@ -738,8 +750,7 @@ void OPENGL_GAL::color4( double aRed, double aGreen, double aBlue, double aAlpha
{
{
if
(
isGrouping
)
if
(
isGrouping
)
{
{
// TODO not used - may be it is not useful at all, to be checked
curVboItem
->
UseColor
(
COLOR4D
(
aRed
,
aGreen
,
aBlue
,
aAlpha
)
);
// curVboItem->UseColor( COLOR4D( aRed, aGreen, aBlue, aAlpha ) );
}
}
else
else
{
{
...
@@ -752,8 +763,7 @@ void OPENGL_GAL::color4( const COLOR4D& aColor )
...
@@ -752,8 +763,7 @@ void OPENGL_GAL::color4( const COLOR4D& aColor )
{
{
if
(
isGrouping
)
if
(
isGrouping
)
{
{
// TODO not used - may be it is not useful at all, to be checked
curVboItem
->
UseColor
(
aColor
);
// curVboItem->UseColor( aColor );
}
}
else
else
{
{
...
@@ -871,54 +881,24 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
...
@@ -871,54 +881,24 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
// Now draw the fan
// Now draw the fan
SWAP
(
angle1
,
>
,
angle2
);
SWAP
(
angle1
,
>
,
angle2
);
if
(
!
isGrouping
)
begin
(
GL_TRIANGLES
);
glBegin
(
GL_TRIANGLES
);
for
(
double
a
=
angle1
;
a
<
angle2
;
)
for
(
double
a
=
angle1
;
a
<
angle2
;
)
{
{
// Compute vertices
// Compute vertices
double
v0
[]
=
{
lastPoint
.
x
,
lastPoint
.
y
};
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
double
v1
[]
=
vertex3
(
lastPoint
.
x
+
adjust
*
sin
(
a
),
{
lastPoint
.
y
-
adjust
*
cos
(
a
),
layerDepth
);
lastPoint
.
x
+
adjust
*
sin
(
a
),
lastPoint
.
y
-
adjust
*
cos
(
a
)
};
a
+=
M_PI
/
32
;
a
+=
M_PI
/
32
;
if
(
a
>
angle2
)
if
(
a
>
angle2
)
a
=
angle2
;
a
=
angle2
;
double
v2
[]
=
vertex3
(
lastPoint
.
x
+
adjust
*
sin
(
a
),
{
lastPoint
.
y
-
adjust
*
cos
(
a
),
layerDepth
);
lastPoint
.
x
+
adjust
*
sin
(
a
),
lastPoint
.
y
-
adjust
*
cos
(
a
)
};
if
(
isGrouping
)
{
const
GLfloat
newVertices
[]
=
{
v0
[
0
],
v0
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v1
[
0
],
v1
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
[
0
],
v2
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
};
curVboItem
->
PushVertices
(
newVertices
,
3
);
}
else
{
glVertex3d
(
v0
[
0
],
v0
[
1
],
layerDepth
);
glVertex3d
(
v1
[
0
],
v1
[
1
],
layerDepth
);
glVertex3d
(
v2
[
0
],
v2
[
1
],
layerDepth
);
}
}
}
if
(
!
isGrouping
)
end
();
glEnd
();
break
;
break
;
}
}
...
@@ -942,29 +922,11 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
...
@@ -942,29 +922,11 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
}
}
// Insert a triangle at the joint to close the gap
// Insert a triangle at the joint to close the gap
if
(
isGrouping
)
begin
(
GL_TRIANGLES
);
{
vertex3
(
edgePoint1
.
x
,
edgePoint1
.
y
,
layerDepth
);
const
GLfloat
newVertices
[]
=
vertex3
(
edgePoint2
.
x
,
edgePoint2
.
y
,
layerDepth
);
{
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
edgePoint1
.
x
,
edgePoint1
.
y
,
layerDepth
,
end
();
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
edgePoint2
.
x
,
edgePoint2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
};
curVboItem
->
PushVertices
(
newVertices
,
3
);
}
else
{
glBegin
(
GL_TRIANGLES
);
glVertex3d
(
edgePoint1
.
x
,
edgePoint1
.
y
,
layerDepth
);
glVertex3d
(
edgePoint2
.
x
,
edgePoint2
.
y
,
layerDepth
);
glVertex3d
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
glEnd
();
}
break
;
break
;
}
}
...
@@ -1002,95 +964,32 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
...
@@ -1002,95 +964,32 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
VECTOR2D
mp1
=
point1
+
(
limit
/
lineLengthA
)
*
lastStartEndVector
;
VECTOR2D
mp1
=
point1
+
(
limit
/
lineLengthA
)
*
lastStartEndVector
;
VECTOR2D
mp2
=
point3
-
(
limit
/
lineLengthB
)
*
startEndVector
;
VECTOR2D
mp2
=
point3
-
(
limit
/
lineLengthB
)
*
startEndVector
;
if
(
isGrouping
)
begin
(
GL_TRIANGLES
);
{
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
const
GLfloat
newVertices
[]
=
vertex3
(
point1
.
x
,
point1
.
y
,
layerDepth
);
{
vertex3
(
mp1
.
x
,
mp1
.
y
,
layerDepth
);
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
point1
.
x
,
point1
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
mp1
.
x
,
mp1
.
y
,
layerDepth
,
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
mp1
.
x
,
mp1
.
y
,
layerDepth
);
vertex3
(
mp2
.
x
,
mp2
.
y
,
layerDepth
);
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
,
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
mp2
.
x
,
mp2
.
y
,
layerDepth
);
vertex3
(
point3
.
x
,
point3
.
y
,
layerDepth
);
mp1
.
x
,
mp1
.
y
,
layerDepth
,
end
();
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
mp2
.
x
,
mp2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
mp2
.
x
,
mp2
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
point3
.
x
,
point3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
9
);
}
else
{
glBegin
(
GL_TRIANGLES
);
glVertex3d
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
glVertex3d
(
point1
.
x
,
point1
.
y
,
layerDepth
);
glVertex3d
(
mp1
.
x
,
mp1
.
y
,
layerDepth
);
glVertex3d
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
glVertex3d
(
mp1
.
x
,
mp1
.
y
,
layerDepth
);
glVertex3d
(
mp2
.
x
,
mp2
.
y
,
layerDepth
);
glVertex3d
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
glVertex3d
(
mp2
.
x
,
mp2
.
y
,
layerDepth
);
glVertex3d
(
point3
.
x
,
point3
.
y
,
layerDepth
);
glEnd
();
}
}
}
else
else
{
{
if
(
isGrouping
)
// Insert two triangles for the mitered edge
{
begin
(
GL_TRIANGLES
);
const
GLfloat
newVertices
[]
=
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
{
vertex3
(
point1
.
x
,
point1
.
y
,
layerDepth
);
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
,
vertex3
(
miterPoint
.
x
,
miterPoint
.
y
,
layerDepth
);
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
point1
.
x
,
point1
.
y
,
layerDepth
,
vertex3
(
miterPoint
.
x
,
miterPoint
.
y
,
layerDepth
);
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
point3
.
x
,
point3
.
y
,
layerDepth
);
end
();
miterPoint
.
x
,
miterPoint
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
miterPoint
.
x
,
miterPoint
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
point3
.
x
,
point3
.
y
,
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
6
);
}
else
{
// Insert two triangles for the mitered edge
glBegin
(
GL_TRIANGLES
);
glVertex3d
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
glVertex3d
(
point1
.
x
,
point1
.
y
,
layerDepth
);
glVertex3d
(
miterPoint
.
x
,
miterPoint
.
y
,
layerDepth
);
glVertex3d
(
lastPoint
.
x
,
lastPoint
.
y
,
layerDepth
);
glVertex3d
(
miterPoint
.
x
,
miterPoint
.
y
,
layerDepth
);
glVertex3d
(
point3
.
x
,
point3
.
y
,
layerDepth
);
glEnd
();
}
}
}
break
;
break
;
}
}
...
@@ -1175,42 +1074,15 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn
...
@@ -1175,42 +1074,15 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn
{
{
color4
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
color4
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
if
(
isGrouping
)
begin
(
GL_TRIANGLES
);
{
vertex3
(
aStartPoint
.
x
,
aStartPoint
.
y
,
layerDepth
);
const
GLfloat
newVertices
[]
=
vertex3
(
diagonalPointA
.
x
,
diagonalPointA
.
y
,
layerDepth
);
{
vertex3
(
aEndPoint
.
x
,
aEndPoint
.
y
,
layerDepth
);
aStartPoint
.
x
,
aStartPoint
.
y
,
layerDepth
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
diagonalPointA
.
x
,
diagonalPointA
.
y
,
layerDepth
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
aEndPoint
.
x
,
aEndPoint
.
y
,
layerDepth
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
aStartPoint
.
x
,
aStartPoint
.
y
,
layerDepth
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
aEndPoint
.
x
,
aEndPoint
.
y
,
layerDepth
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
diagonalPointB
.
x
,
diagonalPointB
.
y
,
layerDepth
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
6
);
}
else
{
glBegin
(
GL_TRIANGLES
);
glVertex3d
(
aStartPoint
.
x
,
aStartPoint
.
y
,
layerDepth
);
glVertex3d
(
diagonalPointA
.
x
,
diagonalPointA
.
y
,
layerDepth
);
glVertex3d
(
aEndPoint
.
x
,
aEndPoint
.
y
,
layerDepth
);
glVertex3d
(
aStartPoint
.
x
,
aStartPoint
.
y
,
layerDepth
);
vertex3
(
aStartPoint
.
x
,
aStartPoint
.
y
,
layerDepth
);
glVertex3d
(
aEndPoint
.
x
,
aEndPoint
.
y
,
layerDepth
);
vertex3
(
aEndPoint
.
x
,
aEndPoint
.
y
,
layerDepth
);
glVertex3d
(
diagonalPointB
.
x
,
diagonalPointB
.
y
,
layerDepth
);
vertex3
(
diagonalPointB
.
x
,
diagonalPointB
.
y
,
layerDepth
);
glEnd
();
end
();
}
}
}
// Restore the stroke color
// Restore the stroke color
...
@@ -1257,8 +1129,7 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
...
@@ -1257,8 +1129,7 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
translate3
(
aCenterPoint
.
x
,
aCenterPoint
.
y
,
0.0
);
translate3
(
aCenterPoint
.
x
,
aCenterPoint
.
y
,
0.0
);
Scale
(
VECTOR2D
(
aRadius
,
aRadius
)
);
Scale
(
VECTOR2D
(
aRadius
,
aRadius
)
);
if
(
!
isGrouping
)
begin
(
GL_TRIANGLES
);
glBegin
(
GL_TRIANGLES
);
for
(
std
::
deque
<
VECTOR2D
>::
const_iterator
it
=
unitCirclePoints
.
begin
();
for
(
std
::
deque
<
VECTOR2D
>::
const_iterator
it
=
unitCirclePoints
.
begin
();
it
!=
unitCirclePoints
.
end
();
it
++
)
it
!=
unitCirclePoints
.
end
();
it
++
)
...
@@ -1268,44 +1139,16 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
...
@@ -1268,44 +1139,16 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
double
v2
[]
=
{
(
it
+
1
)
->
x
*
innerScale
,
(
it
+
1
)
->
y
*
innerScale
};
double
v2
[]
=
{
(
it
+
1
)
->
x
*
innerScale
,
(
it
+
1
)
->
y
*
innerScale
};
double
v3
[]
=
{
(
it
+
1
)
->
x
*
outerScale
,
(
it
+
1
)
->
y
*
outerScale
};
double
v3
[]
=
{
(
it
+
1
)
->
x
*
outerScale
,
(
it
+
1
)
->
y
*
outerScale
};
if
(
isGrouping
)
vertex3
(
v0
[
0
],
v0
[
1
],
layerDepth
);
{
vertex3
(
v1
[
0
],
v1
[
1
],
layerDepth
);
const
GLfloat
newVertices
[]
=
vertex3
(
v2
[
0
],
v2
[
1
],
layerDepth
);
{
v0
[
0
],
v0
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v1
[
0
],
v1
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
[
0
],
v2
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v1
[
0
],
v1
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v3
[
0
],
v3
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
[
0
],
v2
[
1
],
layerDepth
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
6
);
}
else
{
glVertex3d
(
v0
[
0
],
v0
[
1
],
layerDepth
);
glVertex3d
(
v1
[
0
],
v1
[
1
],
layerDepth
);
glVertex3d
(
v2
[
0
],
v2
[
1
],
layerDepth
);
glVertex3d
(
v1
[
0
],
v1
[
1
],
layerDepth
);
vertex3
(
v1
[
0
],
v1
[
1
],
layerDepth
);
glVertex3d
(
v3
[
0
],
v3
[
1
],
layerDepth
);
vertex3
(
v3
[
0
],
v3
[
1
],
layerDepth
);
glVertex3d
(
v2
[
0
],
v2
[
1
],
layerDepth
);
vertex3
(
v2
[
0
],
v2
[
1
],
layerDepth
);
}
}
}
if
(
!
isGrouping
)
end
();
glEnd
();
Restore
();
Restore
();
}
}
...
@@ -1323,7 +1166,6 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
...
@@ -1323,7 +1166,6 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
if
(
isGrouping
)
if
(
isGrouping
)
{
{
verticesCircle
.
ChangeColor
(
fillColor
);
curVboItem
->
PushVertices
(
verticesCircle
.
GetVertices
(),
verticesCircle
.
GetSize
()
);
curVboItem
->
PushVertices
(
verticesCircle
.
GetVertices
(),
verticesCircle
.
GetSize
()
);
}
}
else
else
...
@@ -1336,7 +1178,6 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
...
@@ -1336,7 +1178,6 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
}
}
// This method is used for round line caps
void
OPENGL_GAL
::
drawSemiCircle
(
const
VECTOR2D
&
aCenterPoint
,
double
aRadius
,
double
aAngle
,
void
OPENGL_GAL
::
drawSemiCircle
(
const
VECTOR2D
&
aCenterPoint
,
double
aRadius
,
double
aAngle
,
double
aDepthOffset
)
double
aDepthOffset
)
{
{
...
@@ -1347,8 +1188,6 @@ void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, d
...
@@ -1347,8 +1188,6 @@ void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, d
if
(
isGrouping
)
if
(
isGrouping
)
{
{
// Add vertices with a proper color
verticesSemiCircle
.
ChangeColor
(
strokeColor
);
curVboItem
->
PushVertices
(
verticesSemiCircle
.
GetVertices
(),
verticesSemiCircle
.
GetSize
()
);
curVboItem
->
PushVertices
(
verticesSemiCircle
.
GetVertices
(),
verticesSemiCircle
.
GetSize
()
);
}
}
else
else
...
@@ -1427,8 +1266,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
...
@@ -1427,8 +1266,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
double
alphaIncrement
=
2
*
M_PI
/
CIRCLE_POINTS
;
double
alphaIncrement
=
2
*
M_PI
/
CIRCLE_POINTS
;
color4
(
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
);
color4
(
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
);
if
(
!
isGrouping
)
begin
(
GL_TRIANGLES
);
glBegin
(
GL_TRIANGLES
);
for
(
double
alpha
=
aStartAngle
;
alpha
<
aEndAngle
;
)
for
(
double
alpha
=
aStartAngle
;
alpha
<
aEndAngle
;
)
{
{
...
@@ -1443,44 +1281,16 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
...
@@ -1443,44 +1281,16 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
double
v2
[]
=
{
cos
(
alpha
)
*
innerScale
,
sin
(
alpha
)
*
innerScale
};
double
v2
[]
=
{
cos
(
alpha
)
*
innerScale
,
sin
(
alpha
)
*
innerScale
};
double
v3
[]
=
{
cos
(
alpha
)
*
outerScale
,
sin
(
alpha
)
*
outerScale
};
double
v3
[]
=
{
cos
(
alpha
)
*
outerScale
,
sin
(
alpha
)
*
outerScale
};
if
(
isGrouping
)
vertex3
(
v0
[
0
],
v0
[
1
],
0.0
);
{
vertex3
(
v1
[
0
],
v1
[
1
],
0.0
);
const
GLfloat
newVertices
[]
=
vertex3
(
v2
[
0
],
v2
[
1
],
0.0
);
{
v0
[
0
],
v0
[
1
],
0.0
f
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v1
[
0
],
v1
[
1
],
0.0
f
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
[
0
],
v2
[
1
],
0.0
f
,
vertex3
(
v1
[
0
],
v1
[
1
],
0.0
);
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
vertex3
(
v3
[
0
],
v3
[
1
],
0.0
);
vertex3
(
v2
[
0
],
v2
[
1
],
0.0
);
v1
[
0
],
v1
[
1
],
0.0
f
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v3
[
0
],
v3
[
1
],
0.0
f
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
,
v2
[
0
],
v2
[
1
],
0.0
f
,
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
6
);
}
else
{
glVertex2d
(
v0
[
0
],
v0
[
1
]
);
glVertex2d
(
v1
[
0
],
v1
[
1
]
);
glVertex2d
(
v2
[
0
],
v2
[
1
]
);
glVertex2d
(
v1
[
0
],
v1
[
1
]
);
glVertex2d
(
v3
[
0
],
v3
[
1
]
);
glVertex2d
(
v2
[
0
],
v2
[
1
]
);
}
}
}
if
(
!
isGrouping
)
end
();
glEnd
();
if
(
lineCap
==
LINE_CAP_ROUND
)
if
(
lineCap
==
LINE_CAP_ROUND
)
{
{
...
@@ -1496,57 +1306,20 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
...
@@ -1496,57 +1306,20 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
double
alpha
;
double
alpha
;
color4
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
color4
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
if
(
!
isGrouping
)
begin
(
GL_TRIANGLES
);
{
glBegin
(
GL_TRIANGLES
);
for
(
alpha
=
aStartAngle
;
(
alpha
+
alphaIncrement
)
<
aEndAngle
;
)
{
glVertex2d
(
middlePoint
.
x
,
middlePoint
.
y
);
glVertex2d
(
cos
(
alpha
),
sin
(
alpha
)
);
alpha
+=
alphaIncrement
;
glVertex2d
(
cos
(
alpha
),
sin
(
alpha
)
);
}
glVertex2d
(
middlePoint
.
x
,
middlePoint
.
y
);
for
(
alpha
=
aStartAngle
;
(
alpha
+
alphaIncrement
)
<
aEndAngle
;
)
glVertex2d
(
cos
(
alpha
),
sin
(
alpha
)
);
glVertex2d
(
endPoint
.
x
,
endPoint
.
y
);
glEnd
();
}
else
{
{
for
(
alpha
=
aStartAngle
;
(
alpha
+
alphaIncrement
)
<
aEndAngle
;
)
vertex3
(
middlePoint
.
x
,
middlePoint
.
y
,
0.0
);
{
vertex3
(
cos
(
alpha
),
sin
(
alpha
),
0.0
);
const
GLfloat
v0
[]
=
alpha
+=
alphaIncrement
;
{
vertex3
(
cos
(
alpha
),
sin
(
alpha
),
0.0
);
middlePoint
.
x
,
middlePoint
.
y
,
0.0
f
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
};
const
GLfloat
v1
[]
=
{
cos
(
alpha
),
sin
(
alpha
),
0.0
f
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
};
alpha
+=
alphaIncrement
;
const
GLfloat
v2
[]
=
{
cos
(
alpha
),
sin
(
alpha
),
0.0
f
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
};
curVboItem
->
PushVertex
(
v0
);
curVboItem
->
PushVertex
(
v1
);
curVboItem
->
PushVertex
(
v2
);
}
const
GLfloat
newVertices
[]
=
{
middlePoint
.
x
,
middlePoint
.
y
,
0.0
f
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
cos
(
alpha
),
sin
(
alpha
),
0.0
f
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
,
endPoint
.
x
,
endPoint
.
y
,
0.0
f
,
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
};
curVboItem
->
PushVertices
(
newVertices
,
3
);
}
}
vertex3
(
middlePoint
.
x
,
middlePoint
.
y
,
0.0
);
vertex3
(
cos
(
alpha
),
sin
(
alpha
),
0.0
);
vertex3
(
endPoint
.
x
,
endPoint
.
y
,
0.0
);
end
();
}
}
Restore
();
Restore
();
...
@@ -1897,18 +1670,18 @@ void OPENGL_GAL::computeUnitCircle()
...
@@ -1897,18 +1670,18 @@ void OPENGL_GAL::computeUnitCircle()
// Insert in a display list and a vector
// Insert in a display list and a vector
for
(
int
i
=
0
;
i
<
CIRCLE_POINTS
;
i
++
)
for
(
int
i
=
0
;
i
<
CIRCLE_POINTS
;
i
++
)
{
{
GLfloat
v0
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
};
const
GLfloat
v0
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
};
GLfloat
v1
[]
=
const
GLfloat
v1
[]
=
{
{
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// x
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// x
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// y
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// y
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
// z & color
0.0
f
// z
};
};
GLfloat
v2
[]
=
const
GLfloat
v2
[]
=
{
{
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// x
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// x
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// y
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// y
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
// z & color
0.0
f
// z
};
};
glVertex2d
(
0
,
0
);
glVertex2d
(
0
,
0
);
...
@@ -1938,18 +1711,18 @@ void OPENGL_GAL::computeUnitSemiCircle()
...
@@ -1938,18 +1711,18 @@ void OPENGL_GAL::computeUnitSemiCircle()
for
(
int
i
=
0
;
i
<
CIRCLE_POINTS
/
2
;
++
i
)
for
(
int
i
=
0
;
i
<
CIRCLE_POINTS
/
2
;
++
i
)
{
{
GLfloat
v0
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
};
GLfloat
v0
[]
=
{
0.0
f
,
0.0
f
,
0.0
f
};
GLfloat
v1
[]
=
GLfloat
v1
[]
=
{
{
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// x
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// x
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// y
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
i
),
// y
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
// z & color
0.0
f
// z
};
};
GLfloat
v2
[]
=
GLfloat
v2
[]
=
{
{
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// x
cos
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// x
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// y
sin
(
2.0
*
M_PI
/
CIRCLE_POINTS
*
(
i
+
1
)
),
// y
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
// z & color
0.0
f
// z
};
};
glVertex2d
(
0
,
0
);
glVertex2d
(
0
,
0
);
...
...
common/gal/opengl/vbo_item.cpp
View file @
7a1718d0
...
@@ -72,9 +72,6 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
...
@@ -72,9 +72,6 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
if
(
m_spaceLeft
==
0
)
if
(
m_spaceLeft
==
0
)
useNewBlock
();
useNewBlock
();
// Add the new vertex
memcpy
(
m_vertPtr
,
aVertex
,
VertSize
);
if
(
m_transform
!=
NULL
)
if
(
m_transform
!=
NULL
)
{
{
// Apply transformations
// Apply transformations
...
@@ -83,9 +80,17 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
...
@@ -83,9 +80,17 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
glm
::
vec4
transVertex
=
*
m_transform
*
origVertex
;
glm
::
vec4
transVertex
=
*
m_transform
*
origVertex
;
// Replace only coordinates, leave color as it is
// Replace only coordinates, leave color as it is
memcpy
(
m_vertPtr
,
&
transVertex
[
0
],
3
*
sizeof
(
GLfloat
)
);
memcpy
(
m_vertPtr
,
&
transVertex
[
0
],
CoordSize
);
}
else
{
// Add the new vertex
memcpy
(
m_vertPtr
,
aVertex
,
CoordSize
);
}
}
// Apply currently used color
memcpy
(
m_vertPtr
+
ColorOffset
,
m_color
,
ColorSize
);
// Move to the next free space
// Move to the next free space
m_vertPtr
+=
VertStride
;
m_vertPtr
+=
VertStride
;
...
@@ -180,7 +185,6 @@ void VBO_ITEM::ChangeColor( const COLOR4D& aColor )
...
@@ -180,7 +185,6 @@ void VBO_ITEM::ChangeColor( const COLOR4D& aColor )
}
}
// TODO it is not used yet
void
VBO_ITEM
::
UseColor
(
const
COLOR4D
&
aColor
)
void
VBO_ITEM
::
UseColor
(
const
COLOR4D
&
aColor
)
{
{
m_color
[
0
]
=
aColor
.
r
;
m_color
[
0
]
=
aColor
.
r
;
...
...
include/gal/opengl/opengl_gal.h
View file @
7a1718d0
...
@@ -506,6 +506,26 @@ private:
...
@@ -506,6 +506,26 @@ private:
inline
void
drawLineCap
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
inline
void
drawLineCap
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aDepthOffset
);
double
aDepthOffset
);
///< OpenGL replacement functions (that are working both in immediate and VBO modes)
/**
* @brief Starts drawing in immediate mode or does nothing if an item's caching has started.
* @param aMode specifies the primitive or primitives that will be created.
*/
inline
void
begin
(
GLenum
aMode
);
/**
* @brief Ends drawing in immediate mode or does nothing if an item's caching has started.
*/
inline
void
end
();
/**
* @brief Adds vertex to the current item or draws it in immediate mode.
* @param aX is X coordinate.
* @param aY is Y coordinate.
* @param aZ is Z coordinate.
*/
inline
void
vertex3
(
double
aX
,
double
aY
,
double
aZ
);
/**
/**
* @brief Function that replaces glTranslate and behaves according to isGrouping variable.
* @brief Function that replaces glTranslate and behaves according to isGrouping variable.
* In case isGrouping==false, it is simply glTranslate, in other case it
* In case isGrouping==false, it is simply glTranslate, in other case it
...
...
include/gal/opengl/vbo_item.h
View file @
7a1718d0
...
@@ -130,8 +130,8 @@ public:
...
@@ -130,8 +130,8 @@ public:
static
const
int
VertStride
=
7
;
static
const
int
VertStride
=
7
;
static
const
int
VertSize
=
VertStride
*
sizeof
(
GLfloat
);
static
const
int
VertSize
=
VertStride
*
sizeof
(
GLfloat
);
static
const
int
IndStride
=
1
;
static
const
int
CoordStride
=
3
;
static
const
int
IndSize
=
IndStride
*
sizeof
(
GLuin
t
);
static
const
int
CoordSize
=
CoordStride
*
sizeof
(
GLfloa
t
);
// Offset of color data from the beginning of each vertex data
// Offset of color data from the beginning of each vertex data
static
const
int
ColorOffset
=
3
;
static
const
int
ColorOffset
=
3
;
...
@@ -139,6 +139,9 @@ public:
...
@@ -139,6 +139,9 @@ public:
static
const
int
ColorStride
=
4
;
static
const
int
ColorStride
=
4
;
static
const
int
ColorSize
=
ColorStride
*
sizeof
(
GLfloat
);
static
const
int
ColorSize
=
ColorStride
*
sizeof
(
GLfloat
);
static
const
int
IndStride
=
1
;
static
const
int
IndSize
=
IndStride
*
sizeof
(
GLuint
);
private
:
private
:
///< VBO ids in which the item is stored.
///< VBO ids in which the item is stored.
//int m_vboId; // not used yet
//int m_vboId; // not used yet
...
...
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