about summary refs log tree commit diff
path: root/src/engine/e_if_gfx.h
blob: d49a3cda6e9f35bec8162d211e7bd2b89a68fa6c (plain)
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
#ifndef ENGINE_IF_GFX_H
#define ENGINE_IF_GFX_H

/*
	Section: Structures
*/

/*
	Structure: IMAGE_INFO
*/
typedef struct
{
	/* Variable: width
		Contains the width of the image */
	int width;
	
	/* Variable: height
		Contains the height of the image */
	int height;
	
	/* Variable: format
		Contains the format of the image. See <Image Formats> for more information. */
	int format;

	/* Variable: data
		Pointer to the image data. */
	void *data;
} IMAGE_INFO;

/*
	Structure: VIDEO_MODE
*/
typedef struct 
{
	int width, height;
	int red, green, blue;
} VIDEO_MODE;

/*
	Section: Functions
*/

/*
	Group: Quads
*/

/*
	Function: gfx_quads_begin
		Begins a quad drawing session.
		
	Remarks:
		This functions resets the rotation, color and subset.
		End the session by using <gfx_quads_end>.
		You can't change texture or blending mode during a session.
		
	See Also:
		<gfx_quads_end>
*/
void gfx_quads_begin();

/*
	Function: gfx_quads_end
		Ends a quad session.
		
	See Also:
		<gfx_quads_begin>
*/
void gfx_quads_end();

/*
	Function: gfx_quads_setrotation
		Sets the rotation to use when drawing a quad.
		
	Arguments:
		angle - Angle in radians.
		
	Remarks:
		The angle is reset when <gfx_quads_begin> is called.
*/
void gfx_quads_setrotation(float angle);

/*
	Function: gfx_quads_setsubset
		Sets the uv coordinates to use.
		
	Arguments:
		tl_u - Top-left U value.
		tl_v - Top-left V value.
		br_u - Bottom-right U value.
		br_v - Bottom-right V value.
		
	Remarks:
		O,0 is top-left of the texture and 1,1 is bottom-right.
		The color is reset when <gfx_quads_begin> is called.
*/
void gfx_quads_setsubset(float tl_u, float tl_v, float br_u, float br_v);

/*
	Function: gfx_quads_setsubset_free
		TODO
		
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_quads_setsubset_free(
	float x0, float y0,
	float x1, float y1,
	float x2, float y2,
	float x3, float y3);

/*
	Function: gfx_quads_drawTL
		Draws a quad by specifying the top-left point.
		
	Arguments:
		x - X coordinate of the top-left corner.
		y - Y coordinate of the top-left corner.
		width - Width of the quad.
		height - Height of the quad.
		
	Remarks:
		Rotation still occurs from the center of the quad.
		You must call <gfx_quads_begin> before calling this function.

	See Also:
		<gfx_quads_draw, gfx_quads_draw_freeform>
*/
void gfx_quads_drawTL(float x, float y, float width, float height);

/*
	Function: gfx_quads_draw
		Draws a quad by specifying the center point.
		
	Arguments:
		x - X coordinate of the center.
		y - Y coordinate of the center.
		width - Width of the quad.
		height - Height of the quad.

	Remarks:
		You must call <gfx_quads_begin> before calling this function.

	See Also:
		<gfx_quads_drawTL, gfx_quads_draw_freeform>
*/
void gfx_quads_draw(float x, float y, float w, float h);

/*
	Function: gfx_quads_draw_freeform
		Draws a quad by specifying the corner points.
	
	Arguments:
		x0, y0 - Coordinates of the upper left corner.
		x1, y1 - Coordinates of the upper right corner.
		x2, y2 - Coordinates of the lower left corner. // TODO: DOUBLE CHECK!!!
		x3, y3 - Coordinates of the lower right corner. // TODO: DOUBLE CHECK!!!
	
	See Also:
		<gfx_quads_draw, gfx_quads_drawTL>
*/
void gfx_quads_draw_freeform(
	float x0, float y0,
	float x1, float y1,
	float x2, float y2,
	float x3, float y3);

/*
	Function: gfx_quads_text
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_quads_text(float x, float y, float size, const char *text);

/*
	Group: Lines
*/

/*
	Function: gfx_lines_begin
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_lines_begin();

/*
	Function: gfx_lines_draw
		TODO
		
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_lines_draw(float x0, float y0, float x1, float y1);

/*
	Function: gfx_lines_end
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_lines_end();

/*
	Group: Text
*/


/*
	Function: gfx_text
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_text(void *font, float x, float y, float size, const char *text, int max_width);

/*
	Function: gfx_text_width
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
float gfx_text_width(void *font, float size, const char *text, int length);

/*
	Function: gfx_text_color
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_text_color(float r, float g, float b, float a);

/*
	Function: gfx_text_set_default_font
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_text_set_default_font(void *font);

/*
	Group: Other
*/

/*
	Function: gfx_get_video_modes
		Fetches a list of all the available video modes.
		
	Arguments:
		list - An array to recive the modes. Must be able to contain maxcount number of modes.
		maxcount - The maximum number of modes to fetch.
	
	Returns:
		The number of video modes that was fetched.
*/
int gfx_get_video_modes(VIDEO_MODE *list, int maxcount);

/* image loaders */

/*
	Function: gfx_load_png
		Loads a PNG image from disk.
	
	Arguments:
		img - Pointer to an structure to be filled out with the image information.
		filename - Filename of the image to load.
	
	Returns:
		Returns non-zero on success and zero on error.
	
	Remarks:
		The caller are responsible for cleaning up the allocated memory in the IMAGE_INFO structure.
	
	See Also:
		<gfx_load_texture>
*/
int gfx_load_png(IMAGE_INFO *img, const char *filename);

/* textures */
/*
	Function: gfx_load_texture
		Loads a texture from a file. TGA and PNG supported.
	
	Arguments:
		filename - Null terminated string to the file to load.
		store_format - What format to store on gfx card as.
	
	Returns:
		An ID to the texture. -1 on failure.

	See Also:
		<gfx_unload_texture, gfx_load_png>
*/
int gfx_load_texture(const char *filename, int store_format);

/*
	Function: gfx_load_texture_raw
		Loads a texture from memory.
	
	Arguments:
		w - Width of the texture.
		h - Height of the texture.
		data - Pointer to the pixel data.
		format - Format of the pixel data.
		store_format - The format to store the texture on the graphics card.
	
	Returns:
		An ID to the texture. -1 on failure.
		
	Remarks:
		The pixel data should be in RGBA format with 8 bit per component.
		So the total size of the data should be w*h*4.
		
	See Also:
		<gfx_unload_texture>
*/
int gfx_load_texture_raw(int w, int h, int format, const void *data, int store_format);

/*
	Function: gfx_texture_set
		Sets the active texture.
	
	Arguments:
		id - ID to the texture to set.
*/
void gfx_texture_set(int id);

/*
	Function: gfx_unload_texture
		Unloads a texture.
	
	Arguments:
		id - ID to the texture to unload.
		
	See Also:
		<gfx_load_texture_tga>, <gfx_load_texture_raw>
		
	Remarks:
		NOT IMPLEMENTED
*/
int gfx_unload_texture(int id);

/*
	Function: gfx_clear
		Clears the screen with the specified color.
	
	Arguments:
		r - Red component.
		g - Green component.
		b - Red component.
	
	Remarks:
		The value of the components are given in 0.0 - 1.0 ranges.
*/
void gfx_clear(float r, float g, float b);

/*
	Function: gfx_screenaspect
		Returns the aspect ratio between width and height.

	See Also:
		<gfx_screenwidth>, <gfx_screenheight>
*/
float gfx_screenaspect();

/*
	Function: gfx_screenwidth
		Returns the screen width.
	
	See Also:
		<gfx_screenheight>
*/
int gfx_screenwidth();

/*
	Function: gfx_screenheight
		Returns the screen height.
	
	See Also:
		<gfx_screenwidth>
*/
int gfx_screenheight();

/*
	Function: gfx_mapscreen
		Specifies the coordinate system for the screen.
		
	Arguments:
		tl_x - Top-left X
		tl_y - Top-left Y
		br_x - Bottom-right X
		br_y - Bottom-right y
*/
void gfx_mapscreen(float tl_x, float tl_y, float br_x, float br_y);

/*
	Function: gfx_blend_normal
		Set the active blending mode to normal (src, 1-src).

	Remarks:
		This must be used before calling <gfx_quads_begin>.
		This is equal to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
	
	See Also:
		<gfx_blend_additive>
*/
void gfx_blend_normal();

/*
	Function: gfx_blend_additive
		Set the active blending mode to additive (src, one).

	Remarks:
		This must be used before calling <gfx_quads_begin>.
		This is equal to glBlendFunc(GL_SRC_ALPHA, GL_ONE).
	
	See Also:
		<gfx_blend_normal>
*/
void gfx_blend_additive();

/*
	Function: gfx_setcolorvertex
		Sets the color of a vertex.
		
	Arguments:
		i - Index to the vertex.
		r - Red value.
		g - Green value.
		b - Blue value.
		a - Alpha value.
		
	Remarks:
		The color values are from 0.0 to 1.0.
		The color is reset when <gfx_quads_begin> is called.
*/
void gfx_setcolorvertex(int i, float r, float g, float b, float a);

/*
	Function: gfx_setcolor
		Sets the color of all the vertices.
		
	Arguments:
		r - Red value.
		g - Green value.
		b - Blue value.
		a - Alpha value.
		
	Remarks:
		The color values are from 0.0 to 1.0.
		The color is reset when <gfx_quads_begin> is called.
*/
void gfx_setcolor(float r, float g, float b, float a);

/*
	Function: gfx_getscreen
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_getscreen(float *tl_x, float *tl_y, float *br_x, float *br_y);

/*
	Function: gfx_memory_usage
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
int gfx_memory_usage();

/*
	Function: gfx_screenshot
		TODO		
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_screenshot();

/*
	Function: gfx_clip_enable
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_clip_enable(int x, int y, int w, int h);

/*
	Function: gfx_clip_disable
		TODO	
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void gfx_clip_disable();

#endif