-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrafmac.h
101 lines (88 loc) · 2.76 KB
/
grafmac.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
// Pablo Hugo Reda <[email protected]>
// rutinas graficas
#ifndef GRAF_H
#define GRAF_H
#ifdef __cplusplus
extern "C" {
#endif
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
#include <SDL2/SDL_thread.h>
#include <SDL2/SDL_syswm.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_audio.h>
#include <SDL2/SDL_mixer.h>
#ifdef __cplusplus
}
#endif
extern SDL_Window *window;
//extern SDL_Renderer *renderer;
//extern SDL_Texture *texture;
extern Uint32 *gr_buffer; // buffer de pantalla
extern int gr_ancho,gr_alto;
extern Uint32 gr_color1,gr_color2,col1,col2;
extern int MA,MB,MTX,MTY; // matrix de transformacion
extern int *mTex; // textura
int gr_init(char *title,int XRES,int YRES,int f,Uint32 *buff);
void gr_fin(void);
void gr_cls(int color);
void gr_redraw(void);
//---- lineas rectas
void gr_hline(int x1,int y1,int x2);
void gr_vline(int x1,int y1,int y2);
//---- basicas
void gr_setpixel(int x,int y);
void gr_setpixela(int x,int y);
void gr_line(int x1,int y1,int x2,int y2);
void gr_spline(int x1,int y1,int x2,int y2,int x3,int y3);
void gr_spline3(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4);
//---- ALPHA
void gr_solid(void);
void gr_alpha(int a);
//---- FILL POLY
void fillSol(void);
void fillLin(void);
void fillRad(void);
void fillTex(void);
//---- matriz transf
inline void fillcent(int mx,int my) { MTX=mx;MTY=my; }
inline void fillmat(int a,int b) { MA=a;MB=b; }
inline void fillcol(Uint32 c1,Uint32 c2) { col1=c1;col2=c2; }
//---- poligono
void gr_psegmento(int x1,int y1,int x2,int y2);
void gr_pspline(int x1,int y1,int x2,int y2,int x3,int y3);
void gr_pspline3(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4);
//#define LLQ
//#define LOWQ
#define MEDQ
//#define HIQ
//////////////////////////////////////////////////////////////
#ifdef HIQ
#define BPP 4
#define TOLERANCE 24
#define QALPHA(a) (a)
#elif defined(MEDQ)
#define BPP 3
#define TOLERANCE 12
#define QALPHA(a) ((a)&0x3|(a)<<2)
#elif defined(LOWQ)
#define BPP 2
#define TOLERANCE 8
#define QALPHA(a) ((a)<<4|(a))
#else
#define BPP 1
#define TOLERANCE 4
#define QALPHA(a) ((a)<<6|(a)<<4|(a)<<2|(a))
#endif
#define VALUES (1<<BPP)
#define QFULL VALUES*VALUES
#define MASK (VALUES-1)
#define FTOI(v) (v<<BPP)
inline void gr_pline(int x1,int y1,int x2,int y2)
{ gr_psegmento(FTOI(x1),FTOI(y1),FTOI(x2),FTOI(y2)); }
inline void gr_pcurve(int x1,int y1,int x2,int y2,int x3,int y3)
{ gr_pspline(FTOI(x1),FTOI(y1),FTOI(x2),FTOI(y2),FTOI(x3),FTOI(y3)); }
inline void gr_pcurve3(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
{ gr_pspline3(FTOI(x1),FTOI(y1),FTOI(x2),FTOI(y2),FTOI(x3),FTOI(y3),FTOI(x4),FTOI(y4)); }
void gr_drawPoli(void);
#endif