-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrawing.cpp
76 lines (58 loc) · 1.78 KB
/
drawing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* drawing.cpp - contains functions for drawing primitives */
#include "app.h"
void PSX_App::setBgColor(u_char r, u_char g, u_char b)
{
bgcolor[0] = r;
bgcolor[1] = g;
bgcolor[2] = b;
return;
}
void PSX_App::drawLine(const int x0, const int y0,
const int x1, const int y1,
const int r, const int g, const int b)
{
LINE_F2 line;
SetLineF2(&line);
setXY2(&line, x0, y0, x1, y1);
setRGB0(&line, r, g, b);
DrawPrim(&line);
return;
}
void PSX_App::drawPixel(const int x, const int y,
const int r, const int g, const int b)
{
LINE_F2 line;
SetLineF2(&line);
setXY2(&line, x, y, x, y); // line where both coords are the same
setRGB0(&line, r, g, b);
DrawPrim(&line);
return;
}
void PSX_App::drawRect(const int topLeftX, const int topLeftY,
const int bottomRightX, const int bottomRightY,
const int r, const int g, const int b)
{
POLY_F4 rect;
SetPolyF4(&rect);
setXY4(&rect, topLeftX, topLeftY,
bottomRightX, topLeftY,
topLeftX, bottomRightY,
bottomRightX, bottomRightY);
setRGB0(&rect, r, g, b);
DrawPrim(&rect);
return;
}
void PSX_App::drawTriangle(const int bottomLeftX, const int bottomLeftY,
const int middleX, const int middleY,
const int bottomRightX, const int bottomRightY,
const int r, const int g, const int b)
{
POLY_F3 tri;
SetPolyF3(&tri);
setXY3(&tri, bottomLeftX, bottomLeftY,
middleX, middleY,
bottomRightX, bottomRightY );
setRGB0(&tri, r, g, b);
DrawPrim(&tri);
return;
}