-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphics.h
298 lines (255 loc) · 7.33 KB
/
graphics.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#ifndef __GRAPHICS_H__
#define __GRAPHICS_H__
#define far
#define huge
#define random(range) (rand() % (range))
#ifndef __COLORS
#define __COLORS
enum colors {
BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
};
#endif
enum write_modes {
COPY_PUT, XOR_PUT, OR_PUT, AND_PUT, NOT_PUT
};
enum line_styles {
SOLID_LINE, DOTTED_LINE, CENTER_LINE, DASHED_LINE, USERBIT_LINE
};
enum fill_styles {
EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL, SLASH_FILL, BKSLASH_FILL,
LTBKSLASH_FILL, HATCH_FILL, XHATCH_FILL, INTERLEAVE_FILL, WIDE_DOT_FILL,
CLOSE_DOT_FILL, USER_FILL
};
enum text_directions {
HORIZ_DIR, VERT_DIR
};
enum font_types {
DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANSSERIF_FONT, GOTHIC_FONT
};
#define LEFT_TEXT 0
#define CENTER_TEXT 1
#define RIGHT_TEXT 2
#define BOTTOM_TEXT 0
#define TOP_TEXT 2
#define NORM_WIDTH 1
#define THICK_WIDTH 3
#define DOTTEDLINE_LENGTH 2
#define CENTRELINE_LENGTH 4
#define USER_CHAR_SIZE 0
#define MAXCOLORS 15
#define CLIP_ON 1
#define CLIP_OFF 0
#define TOP_ON 1
#define TOP_OFF 0
enum graphics_errors {
grOk = 0,
grNoInitGraph = -1,
grNotDetected = -2,
grFileNotFound = -3,
grInvalidDriver = -4,
grNoLoadMem = -5,
grNoScanMem = -6,
grNoFloodMem = -7,
grFontNotFound = -8,
grNoFontMem = -9,
grInvalidMode = -10,
grError = -11,
grIOerror = -12,
grInvalidFont = -13,
grInvalidFontNum = -14,
grInvalidDeviceNum = -15,
grInvalidVersion = -18
};
/* Graphics drivers constants, includes X11 which is particular to XBGI. */
#define DETECT 0
#define CGA 1
#define MCGA 2
#define EGA 3
#define EGA64 4
#define EGAMONO 5
#define IBM8514 6
#define HERCMONO 7
#define ATT400 8
#define VGA 9
#define PC3270 10
/* Graphics modes constants. */
#define CGAC0 0
#define CGAC1 1
#define CGAC2 2
#define CGAC3 3
#define CGAHI 4
#define MCGAC0 0
#define MCGAC1 1
#define MCGAC2 2
#define MCGAC3 3
#define MCGAMED 4
#define MCGAHI 5
#define EGALO 0
#define EGAHI 1
#define EGA64LO 0
#define EGA64HI 1
#define EGAMONOHI 3
#define HERCMONOHI 0
#define ATT400C0 0
#define ATT400C1 1
#define ATT400C2 2
#define ATT400C3 3
#define ATT400MED 4
#define ATT400HI 5
#define VGALO 0
#define VGAMED 1
#define VGAHI 2
#define VGAMAX 3
#define PC3270HI 0
#define IBM8514LO 0
#define IBM8514HI 1
typedef struct arccoordstype {
int x;
int y;
int xstart;
int ystart;
int xend;
int yend;
} arccoordstype;
typedef char fillpatterntype[8];
typedef struct fillsettingstype {
int pattern;
int color;
} fillsettingstype;
typedef struct linesettingstype {
int linestyle;
unsigned int upattern;
int thickness;
} linesettingstype;
typedef struct palettetype {
unsigned char size;
signed char colors[16];
} palettetype;
typedef struct textsettingstype {
int font;
int direction;
int charsize;
int horiz;
int vert;
} textsettingstype;
typedef struct viewporttype {
int left;
int top;
int right;
int bottom;
int clip;
} viewporttype;
#if defined(__cplusplus)
extern "C" {
#endif
//
// Setting this variable to 0 increase speed of drawing but
// correct redraw is not possible. By default this variable is initialized by 1
//
extern int bgiemu_handle_redraw;
//
// Default mode choosed by WinBGI if DETECT value is specified for
// device parameter of initgraoh(). Default value is VGAMAX which
// cause creation of maximized window (resolution depends on display mode)
//
extern int bgiemu_default_mode;
void _graphfreemem (void *ptr, unsigned int size);
void* _graphgetmem (unsigned int size);
void arc (int x, int y, int start_angle, int end_angle, int radius);
void bar (int left, int top, int right, int bottom);
void bar3d (int left, int top, int right, int bottom, int depth, int topflag);
void circle (int x, int y, int radius);
void cleardevice (void);
void clearviewport (void);
void closegraph (void);
void detectgraph (int *, int *);
void drawpoly (int, int *);
void ellipse (int x, int y, int start_angle, int end_angle, int rx, int ry);
void fillellipse (int x, int y, int rx, int ry);
void fillpoly (int, int *);
void floodfill (int x, int y, int border);
void getarccoords (arccoordstype *);
void getaspectratio (int *, int *);
int getbkcolor (void);
int getcolor (void);
palettetype* getdefaultpalette (void);
const char* getdrivername (void);
void getfillpattern (char const *);
void getfillsettings (fillsettingstype *);
int getgraphmode (void);
void getimage (int, int, int, int, void *);
void getlinesettings (linesettingstype *);
int getmaxcolor (void);
int getmaxmode (void);
int getmaxx (void);
int getmaxy (void);
char* getmodename (int);
void getmoderange (int, int *, int *);
void getpalette (palettetype *);
int getpalettesize (void);
unsigned int getpixel (int x, int y);
void gettextsettings (textsettingstype *);
void getviewsettings (viewporttype *);
int getx (void);
int gety (void);
void graphdefaults (void);
char* grapherrormsg (int);
int graphresult (void);
unsigned int imagesize (int, int, int, int);
void initgraph (int *, int *, char const *);
int installuserdriver (char const *, int *);
int installuserfont (char const *);
void line (int x0, int y0, int x1, int y1);
void linerel (int dx, int dy);
void lineto (int x, int y);
void moverel (int dx, int dy);
void moveto (int x, int y);
void outtext (char const *);
void outtextxy (int, int, char const *);
void pieslice (int x, int y, int start_angle, int end_angle, int radius);
void putimage (int, int, void *, int);
void putpixel (int x, int y, int c);
void plot (int x, int y);
void rectangle (int left, int top, int right, int bottom);
int registerbgidriver (void *);
int registerbgifont (void *);
void restorecrtmode (void);
void sector (int x, int y, int start_angle, int end_angle, int rx, int ry);
void setactivepage (int);
void setallpalette (palettetype *);
void setaspectratio (int ax, int ay);
void setbkcolor (int color);
void setcolor (int c);
void setfillpattern (char const *, int);
void setfillstyle (int, int);
unsigned int setgraphbufsize (unsigned int);
void setgraphmode (int);
void setlinestyle (int, unsigned int, int);
void setpalette (int, int);
void setrgbpalette (int, int, int, int);
void settextjustify (int, int);
void settextstyle (int, int, int);
void setusercharsize (int, int, int, int);
void setviewport (int, int, int, int, int);
void setvisualpage (int);
void setwritemode (int);
int textheight (char const *);
int textwidth (char const *);
int getch (void);
int kbhit (void);
void delay (unsigned msec);
void restorecrtmode (void);
// ajout
void opengraph (void);
void opengraphsize (int width,int height);
int keypressed (void);
int buttonhit (void);
void getmouse (int& x,int& y);
int buttonpressed (void);
void waituntilkeypressed();
void waituntilbuttonpressed();
#if defined(__cplusplus)
}
#endif
#endif