-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscreen.h
337 lines (288 loc) · 10.8 KB
/
screen.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
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
/*
* $Id: screen.h,v 1.4 2003/04/26 03:24:16 kenta Exp $
*
* Copyright 2003 Kenta Cho. All rights reserved.
*/
/**
* Opengl screen functions header file.
*
* @version $Revision: 1.4 $
*/
#ifndef SCREEN_H
#define SCREEN_H
// For GL type defines:
#include "GLES/gl.h"
#include "GLES/egl.h"
// For joystick
#include "SDL.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_BPP 16
#define SCREEN_FLAGS (SDL_FULLSCREEN)
//#define LOWRES_SCREEN_WIDTH 320
//#define LOWRES_SCREEN_HEIGHT 240
//Original rrootage code:
#define PAD_UP 1
#define PAD_DOWN 2
#define PAD_LEFT 4
#define PAD_RIGHT 8
#define PAD_BUTTON1 16
#define PAD_BUTTON2 32
#if defined(WIZ) || defined(GP2X)
//GP2X mappings
#define GP2X_BUTTON_UP (0)
#define GP2X_BUTTON_DOWN (4)
#define GP2X_BUTTON_LEFT (2)
#define GP2X_BUTTON_RIGHT (6)
#define GP2X_BUTTON_UPLEFT (1)
#define GP2X_BUTTON_UPRIGHT (7)
#define GP2X_BUTTON_DOWNLEFT (3)
#define GP2X_BUTTON_DOWNRIGHT (5)
#define GP2X_BUTTON_CLICK (18)
#define GP2X_BUTTON_A (12)
#define GP2X_BUTTON_B (13)
#define GP2X_BUTTON_X (14)
#define GP2X_BUTTON_Y (15)
#define GP2X_BUTTON_L (10)
#define GP2X_BUTTON_R (11)
#define GP2X_BUTTON_START (8)
#define GP2X_BUTTON_SELECT (9)
#define GP2X_BUTTON_VOLUP (16)
#define GP2X_BUTTON_VOLDOWN (17)
#endif
#define DEFAULT_BRIGHTNESS 224
//#define glColor4hack(r,g,b,a) (glColor4x(r * Q(0, 1, 255), g * Q(0, 1, 255), b * Q(0, 1, 255), a * Q(0, 1, 255)))
//#define glColor4hack(r,g,b,a) glColor4x(255 * (Q(0,1,255)), 255 * (Q(0,1,255)), 255 * (Q(0,1,255)), 255 * (Q(0,1,255)))
extern float eyeX, eyeY, eyeZ;
extern float pitch, roll;
extern float zoom;
//senquack
//extern Uint8 *keys;
//extern SDL_Joystick *stick;
#ifdef GCW
extern SDL_Joystick *joy_analog;
#endif
extern int buttonReversed;
extern int lowres;
extern int windowMode;
extern int brightness;
/* senquack - added these structs to aid vertice/color interleaving for batch-drawing: */
typedef struct {
#ifdef FIXEDMATH
GLfixed x,y;
#else
GLfloat x,y;
#endif //FIXEDMATH
union {
uint32_t color_rgba;
struct { GLubyte r, g, b, a; };
// GLubyte r,g,b,a;
};
} gl_vertex;
typedef struct {
#ifdef FIXEDMATH
GLfixed x,y;
#else
GLfloat x,y,tx,ty; // tx & ty hold the texture coordinates
#endif //FIXEDMATH
union {
uint32_t color_rgba;
struct { GLubyte r, g, b, a; };
// GLubyte r,g,b,a;
};
} gl_textured_vertex;
typedef struct {
#ifdef FIXEDMATH
GLfixed x,y,z;
#else
GLfloat x,y,z;
#endif //FIXEDMATH
union {
uint32_t color_rgba;
struct { GLubyte r, g, b, a; };
// GLubyte r,g,b,a;
};
} gl_vertex_3d;
//senquack - returns FPS as integer. Called once per frame.
int fps();
int getPadState ();
int getButtonState ();
void loadModel (char *fileName, GLuint * model);
void loadGLTexture (char *, GLuint *);
void generateTexture (GLuint *);
void deleteTexture (GLuint *);
void initSDL ();
void closeSDL ();
void resized (int, int);
void drawGLSceneStart ();
void drawGLSceneEnd ();
void swapGLScene ();
int initGLES();
int closeGLES();
//senquack - added our own copy of gluPerspective
#ifdef FIXEDMATH
void gluPerspective (GLfixed fovy, GLfixed ratio, GLfixed near, GLfixed far);
#else
void gluPerspective (GLfloat fovy, GLfloat ratio, GLfloat near, GLfloat far);
#endif //FIXEDMATH
void setScreenShake (int type, int cnt);
void moveScreenShake ();
//senquack - both fixed and float versions now:
#ifdef FIXEDMATH
void drawBox(GLfixed fx, GLfixed fy, GLfixed fwidth, GLfixed fheight, int r, int g, int b);
#else
void drawBox(GLfloat x, GLfloat y, GLfloat width, GLfloat height, int r, int g, int b);
#endif //FIXEDMATH
//senquack - new function to draw boxes with no outline, i.e. for tiny text on handhelds
#ifdef FIXEDMATH
void drawBoxNoOutline(GLfixed x, GLfixed y, GLfixed width, GLfixed height, int r, int g, int b);
#else
void drawBoxNoOutline(GLfloat x, GLfloat y, GLfloat width, GLfloat height, int r, int g, int b);
#endif
//senquack - converted to 2D (no need for z coordinate)
//void drawLine(GLfloat x1, GLfloat y1, GLfloat z1,
// GLfloat x2, GLfloat y2, GLfloat z2, int r, int g, int b, int a);
#ifdef FIXEDMATH
void drawLine (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2, int r, int g, int b, int a);
#else
void drawLine (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, int r, int g, int b, int a);
#endif //FIXEDMATH
//senquack - converted to 2D (no need for z coordinate)
//void drawLinePart (GLfloat x1, GLfloat y1, GLfloat z1,
// GLfloat x2, GLfloat y2, GLfloat z2, int r, int g, int b,
// int a, int len);
#ifdef FIXEDMATH
void drawLinePart (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2, int r,
int g, int b, int a, int len);
#else
void drawLinePart (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, int r,
int g, int b, int a, int len);
#endif //FIXEDMATH
//senquack - these were for drawing the background lines, and I directly draw the lines there now, no need for this anymore:
//#ifdef FIXEDMATH
//void drawRollLineAbs (GLfixed x1, GLfixed y1, GLfixed z1,
// GLfixed x2, GLfixed y2, GLfixed z2, int r, int g, int b,
// int a, int d1)
//#else
//void drawRollLineAbs (GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2,
// GLfloat y2, GLfloat z2, int r, int g, int b, int a,
// int d1);
//#endif //FIXEDMATH
//void drawRollLine (GLfloat x, GLfloat y, GLfloat z, GLfloat width, int r,
// int g, int b, int a, int d1, int d2);
//senquack - these are now batch-drawn through these two functions:
void prepareDrawRollLines();
void finishDrawRollLines();
//senquack - (only called from frag.c)
// note: we dropped the a parameter (always 255 it turns out)
#ifdef FIXEDMATH
void drawRollLine (GLfixed x, GLfixed y, GLfixed z, GLfixed width,
int r, int g, int b, int d1, int d2);
#else
void drawRollLine (GLfloat x, GLfloat y, GLfloat z, GLfloat width,
int r, int g, int b, int d1, int d2);
#endif //FIXEDMATH
////senquack - this allows us to avoid a few hundred unnecessary calls to two functions:
//void prepareDrawRollLines (void);
//void finishDrawRollLines (void);
#ifdef FIXEDMATH
void drawSquare (GLfixed x1, GLfixed y1, GLfixed z1,
GLfixed x2, GLfixed y2, GLfixed z2,
GLfixed x3, GLfixed y3, GLfixed z3,
GLfixed x4, GLfixed y4, GLfixed z4, int r, int g, int b);
#else
void drawSquare (GLfloat x1, GLfloat y1, GLfloat z1,
GLfloat x2, GLfloat y2, GLfloat z2,
GLfloat x3, GLfloat y3, GLfloat z3,
GLfloat x4, GLfloat y4, GLfloat z4, int r, int g, int b);
#endif //FIXEDMATH
//senquack - stars/smoke are now batch-drawn, and I got rid of the unused z parameter
void prepareDrawStars();
void finishDrawStars();
//void drawStar(int f, GLfloat x, GLfloat y, GLfloat z, int r, int g, int b, float size);
#ifdef FIXEDMATH
void drawStar (int f, GLfixed x, GLfixed y, int r, int g, int b, GLfixed size);
#else
void drawStar (int f, GLfloat x, GLfloat y, int r, int g, int b, GLfloat size);
#endif //FIXEDMATH
//senquack - converted to fixed point, only one color passed
//void drawLaser(GLfloat x, GLfloat y, GLfloat width, GLfloat height,
// int cc1, int cc2, int cc3, int cc4, int cnt, int type);
//void drawLaserx(GLfixed fx, GLfixed fy, GLfixed fwidth, GLfixed fheight,
// int cc1, int cc2, int cc3, int cc4, int cnt, int type);
#ifdef FIXEDMATH
void drawLaser (GLfixed x, GLfixed y, GLfixed width, GLfixed height,
int cc1, int cnt, int type);
#else
void drawLaser (GLfloat x, GLfloat y, GLfloat width, GLfloat height,
int cc1, int cnt, int type);
#endif //FIXEDMATH
//senquack - two new functions :
void prepareDrawLaser (void);
void finishDrawLaser (void);
#ifdef FIXEDMATH
void drawCore(GLfixed x, GLfixed y, int cnt, int r, int g, int b);
#else
void drawCore(GLfloat x, GLfloat y, int cnt, int r, int g, int b);
#endif //FIXEDMATH
#ifdef FIXEDMATH
void drawShipShape(GLfixed x, GLfixed y, float d, int inv);
#else
void drawShipShape(GLfloat x, GLfloat y, float d, int inv);
#endif //FIXEDMATH
#ifdef FIXEDMATH
void drawBomb(GLfixed x, GLfixed y, GLfixed width, int cnt);
#else
void drawBomb(GLfloat x, GLfloat y, GLfloat width, int cnt);
#endif //FIXEDMATH
#ifdef FIXEDMATH
void drawCircle(GLfixed x, GLfixed y, GLfixed width, int cnt,
int r1, int g1, int b1, int r2, int b2, int g2);
#else
void drawCircle(GLfloat x, GLfloat y, GLfloat width, int cnt,
int r1, int g1, int b1, int r2, int b2, int g2);
#endif //FIXEDMATH
//senquack - conversion to fixed point
#ifdef FIXEDMATH
void drawShape (GLfixed x, GLfixed y, GLfixed size, int d, int cnt, int type, int r, int g, int b);
void drawShapeIka (GLfixed x, GLfixed y, GLfixed size, int d, int cnt, int type, int c);
#else
void drawShape(GLfloat x, GLfloat y, GLfloat size, int d, int cnt, int type, int r, int g, int b);
void drawShapeIka(GLfloat x, GLfloat y, GLfloat size, int d, int cnt, int type, int c);
#endif //FIXEDMATH
//senquack - new functions called before and after massive batch drawing
void prepareDrawBatch (void);
void finishDrawBatch (void);
//void prepareDrawShapes (void);
//void finishDrawShapes (void);
// senquack - moved drawing shots back to 100% float
//#ifdef FIXEDMATH
//void drawShot(GLfixed x, GLfixed y, GLfixed d, int c, GLfixed width, GLfixed height);
//#else
void drawShot(GLfloat x, GLfloat y, GLfloat d, int c, float width, float height);
//#endif //FIXEDMATH
void startDrawBoards ();
void endDrawBoards ();
void drawSideBoards ();
void drawTitleBoard ();
int drawNum (int n, int x, int y, int s, int r, int g, int b);
//senquack made a new function to draw horizontally:
int drawNumHoriz (int n, int x, int y, int s, int r, int g, int b);
int drawNumRight (int n, int x, int y, int s, int r, int g, int b);
int drawNumCenter (int n, int x, int y, int s, int r, int g, int b);
int drawTimeCenter (int n, int x, int y, int s, int r, int g, int b);
//void CrossProd(float x1, float y1, float z1, float x2, float y2, float z2, float res[3]);
//senquack - no need for this:
//void FadiGluLookAt(float eyeX, float eyeY, float eyeZ, float lookAtX, float lookAtY, float lookAtZ, float upX, float upY, float upZ);
#ifdef FIXEDMATH
void gluLookAt(GLfixed eyex, GLfixed eyey, GLfixed eyez,
GLfixed centerx, GLfixed centery, GLfixed centerz,
GLfixed upx, GLfixed upy, GLfixed upz);
#else
void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
GLfloat centerx, GLfloat centery, GLfloat centerz,
GLfloat upx, GLfloat upy, GLfloat upz);
#endif //FIXEDMATH
//senquack - Albert had added this I think
//void drawTestPoly();
#endif //SCREEN_H