Jypeli
9
The simple game programming library
LineBatch.cs
Siirry tämän tiedoston dokumentaatioon.
1
using
System
.Diagnostics;
2
using
Microsoft
.
Xna
.
Framework
;
3
using
Microsoft
.
Xna
.
Framework
.Graphics;
4
5
namespace
Jypeli
6
{
7
internal
class
LineBatch
8
{
9
VertexPositionColor[]
vertexBuffer
=
new
VertexPositionColor[512];
10
Effect
effect
;
11
Matrix
matrix
;
12
int
iVertexBuffer
= 0;
13
bool
beginHasBeenCalled
=
false
;
14
public
bool
LightingEnabled
=
true
;
15
16
17
public
void
Begin
( ref
Matrix
matrix
)
18
{
19
Debug.Assert( !
beginHasBeenCalled
);
20
beginHasBeenCalled
=
true
;
21
22
this.matrix =
matrix
;
23
iVertexBuffer
= 0;
24
}
25
26
public
void
End
()
27
{
28
Debug.Assert(
beginHasBeenCalled
);
29
Flush
();
30
beginHasBeenCalled
=
false
;
31
}
32
33
private
void
Flush
()
34
{
35
if
(
iVertexBuffer
> 0 )
36
{
37
effect
=
Graphics
.
GetColorEffect
(ref
matrix
,
LightingEnabled
);
38
for
(
int
i = 0; i <
effect
.CurrentTechnique.Passes.Count; i++ )
39
effect
.CurrentTechnique.Passes[i].Apply();
40
41
Game
.
GraphicsDevice
.DrawUserPrimitives<VertexPositionColor>(
42
PrimitiveType.LineList,
vertexBuffer
, 0,
iVertexBuffer
/ 2);
43
}
44
45
iVertexBuffer
= 0;
46
}
47
48
public
void
Draw
(
Vector
startPoint,
Vector
endPoint,
Color
color)
49
{
50
if
((
iVertexBuffer
+ 2) >
vertexBuffer
.Length)
51
{
52
Flush
();
53
}
54
55
vertexBuffer
[
iVertexBuffer
++] =
new
VertexPositionColor(
56
new
Vector3((
float
)startPoint.
X
, (
float
)startPoint.
Y
, 0f),
57
color.
AsXnaColor
());
58
vertexBuffer
[
iVertexBuffer
++] =
new
VertexPositionColor(
59
new
Vector3((
float
)endPoint.
X
, (
float
)endPoint.
Y
, 0f),
60
color.
AsXnaColor
());
61
}
62
}
63
}
Jypeli.Graphics.GetColorEffect
static Effect GetColorEffect(ref Matrix worldMatrix, bool lightingEnabled)
Definition:
Graphics.cs:164
Jypeli.LineBatch.End
void End()
Definition:
LineBatch.cs:26
Jypeli.Matrix
Microsoft.Xna.Framework.Matrix Matrix
Definition:
Mouse.cs:36
Microsoft.Xna
Definition:
JypeliContentManager.cs:6
Jypeli.LineBatch.Flush
void Flush()
Definition:
LineBatch.cs:33
Jypeli.Vector.X
double X
Definition:
Vector.cs:312
Jypeli
Definition:
Automobile.cs:5
Microsoft
Definition:
JypeliContentManager.cs:6
Microsoft.Xna.Framework
Definition:
JypeliContentManager.cs:6
Jypeli.LineBatch.matrix
Matrix matrix
Definition:
LineBatch.cs:11
Jypeli.LineBatch.beginHasBeenCalled
bool beginHasBeenCalled
Definition:
LineBatch.cs:13
Jypeli.Color
Väri.
Definition:
Color.cs:13
Jypeli.LineBatch.iVertexBuffer
int iVertexBuffer
Definition:
LineBatch.cs:12
Jypeli.Graphics
Contains graphics resources.
Definition:
Graphics.cs:36
Jypeli.Vector
2D-vektori.
Definition:
Vector.cs:59
System
Definition:
CFFauxAttributes.cs:29
Jypeli.LineBatch.LightingEnabled
bool LightingEnabled
Definition:
LineBatch.cs:14
Jypeli.LineBatch.effect
Effect effect
Definition:
LineBatch.cs:10
Jypeli.LineBatch.Draw
void Draw(Vector startPoint, Vector endPoint, Color color)
Definition:
LineBatch.cs:48
Jypeli.Game.GraphicsDevice
static new GraphicsDevice GraphicsDevice
XNA:n grafiikkakortti.
Definition:
Graphics.cs:49
Jypeli.LineBatch.Begin
void Begin(ref Matrix matrix)
Definition:
LineBatch.cs:17
Jypeli.LineBatch
Definition:
LineBatch.cs:8
Jypeli.LineBatch.vertexBuffer
VertexPositionColor[] vertexBuffer
Definition:
LineBatch.cs:9
Jypeli.Game
Definition:
Content.cs:46
Jypeli.Color.AsXnaColor
XnaColor AsXnaColor()
Definition:
Color.cs:46
Jypeli.Vector.Y
double Y
Definition:
Vector.cs:313
Jypeli
Graphics
LineBatch.cs
Generoinut projektille Jypeli Sat Oct 17 2020 19:03:15
1.8.20