-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtextures.h
206 lines (173 loc) · 6.03 KB
/
textures.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
/* --------------------------------------------------------------------
EXTREME TUXRACER
Copyright (C) 1999-2001 Jasmin F. Patry (Tuxracer)
Copyright (C) 2010 Extreme Tuxracer Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
---------------------------------------------------------------------*/
#ifndef TEXTURES_H
#define TEXTURES_H
#include "bh.h"
#define MAX_COMMON_TEX 128
#define TEXLOGO 0
#define SNOW_START 1
#define SNOW_TRACK 2
#define SNOW_STOP 3
#define T_TITLE 4
#define T_TITLE_SMALL 5
#define HERRING_ICON 7
#define GAUGE_OUTLINE 8
#define GAUGE_ENERGY 9
#define GAUGE_SPEED 10
#define LB_ARROWS 11
#define SPEEDMETER 12
#define LIGHT_BUTT 14
#define SNOW_BUTT 15
#define WIND_BUTT 16
#define BOTTOM_LEFT 17
#define BOTTOM_RIGHT 18
#define TOP_LEFT 19
#define TOP_RIGHT 20
#define TUXBONUS 21
#define MOUSECURSOR 22
#define SNOW_PART 23
#define ENV_MAP 24
#define T_ENERGY_MASK 25
#define T_MASK_OUTLINE 26
#define NUMERIC_FONT 27
#define MIRROR_BUTT 28
#define CHAR_BUTT 29
#define RANDOM_BUTT 30
#define T_YELLHERRING 31
#define T_TIME 32
#define STARS 33
#define HERRING_ICON2 34
#define SPEED_KNOB 35
#define CUPICON 36
#define CHECKBOX 37
#define CHECKMARK_SMALL 38
#define CHECKMARK 39
#define T_WIDGETS 40
#define T_SNOW1 41
#define T_SNOW2 42
#define T_SNOW3 43
#define WORD_SPACE 6
#define LETTER_SPACE -3
#define BF_TYPE 0x4D42 // "MB"
typedef struct {
char tfType;
char tfColorMapType;
char tfImageType;
char tfColorMapSpec[5];
short tfOrigX;
short tfOrigY;
short tfWidth;
short tfHeight;
char tfBpp;
char tfImageDes;
} TTgaHeader;
typedef struct {
unsigned short bfType; // identifier of bmp formae
unsigned long bfSize; // size of file, including the headers
unsigned short bfReserved1; // reserved, always 0
unsigned short bfReserved2; // reserved, always 0
unsigned long bfOffBits; // offset to bitmap data
} TBmpHeader;
typedef struct {
unsigned long biSize; // size of info header, normally 40
long biWidth; // width
long biHeight; // height
unsigned short biPlanes; // number of color planes, normally 1
unsigned short biBitCount; // Number of bits per pixel (8 * depth)
unsigned long biCompression; // type of compression, normally 0 = no compr.
unsigned long biSizeImage; // size of data
long biXPelsPerMeter; // normally 0
long biYPelsPerMeter; // normally 0
unsigned long biClrUsed; // normally 0
unsigned long biClrImportant; // normally 0
} TBmpInfo;
// --------------------------------------------------------------------
// class CImage
// --------------------------------------------------------------------
class CImage {
private:
public:
CImage ();
~CImage ();
unsigned char *data;
int nx;
int ny;
int depth;
int pitch;
int format;
void DisposeData ();
// load:
bool LoadPng (const char *filepath, bool mirroring, bool texture);
bool LoadPng (const char *dir, const char *filepath, bool mirroring, bool texture);
// write:
bool ReadFrameBuffer_PPM ();
bool ReadFrameBuffer_TGA ();
bool ReadFrameBuffer_BMP ();
void WritePPM (const char *filepath);
void WritePPM (const char *dir, const char *filename);
void WriteTGA (const char *filepath);
void WriteTGA (const char *dir, const char *filename);
// versions with explicite header
void WriteTGA_H (const char *filepath);
void WriteTGA_H (const char *dir, const char *filename);
void WriteBMP (const char *filepath);
void WriteBMP (const char *dir, const char *filename);
};
// --------------------------------------------------------------------
// class CTexture
// --------------------------------------------------------------------
#define TEX_WIDGETS 0
#define TEX_NUMERIC_FONT 1
#define TEX_LOGO 2
class CTexture {
private:
struct Details {
GLuint id, width, height;
};
Details CommonTex [MAX_COMMON_TEX];
int numTextures;
string TextureIndex;
int forientation;
void DrawNumChr (char c, int x, int y, int w, int h, TColor col);
public:
CTexture ();
~CTexture ();
int LoadTexture (const char *filename, GLuint *width = NULL, GLuint *height = NULL);
int LoadTexture (const char *dir, const char *filename, GLuint *width = NULL, GLuint *height = NULL);
int LoadTexture (const string dir, const string filename, GLuint *width = NULL, GLuint *height = NULL);
int LoadMipmapTexture (const char *filename, bool repeatable, GLuint *width = NULL, GLuint *height = NULL);
int LoadMipmapTexture (const char *dir, const char *filename, bool repeatable, GLuint *width = NULL, GLuint *height = NULL);
void LoadTextureList ();
void FreeTextureList ();
GLuint TexWidth (int idx);
GLuint TexHeight (int idx);
GLuint TexID (int idx);
GLuint TexID (string name);
bool BindTex (int idx);
bool BindTex (string name);
void DrawDirect (GLuint texid, int x, int y, float width, float height);
void Draw (int idx, int x, int y, float size);
void Draw (int idx, int x, int y, int width, int height);
void Draw (string name, int x, int y, int width, int height);
void DrawDirectFrame (GLuint texid, int x, int y, double w, double h, int frame, TColor col);
void DrawFrame (int idx, int x, int y, double w, double h, int frame, TColor col);
void DrawFrame (string name, int x, int y, double w, double h, int frame, TColor col);
void SetOrientation (int orientation);
void DrawNumStr (const char *s, int x, int y, float size, TColor col);
};
extern CTexture Tex;
void ScreenshotN ();
void TGAScreenshot2 (const char *destFile);
void BMPScreenshot (const char *destFile);
#endif