[Change] Now we can get confused as to when to use Color and Colour. Won't that be fun?

This commit is contained in:
Allanis 2013-02-15 02:57:51 +00:00
parent dc9f089abe
commit 627240c5a4
4 changed files with 53 additions and 53 deletions

View File

@ -19,8 +19,8 @@
#define FONT_DEF "../gfx/fonts/FreeSans.ttf" #define FONT_DEF "../gfx/fonts/FreeSans.ttf"
// Default colors. // Default colors.
glColor cGrey = { .r = 0.75, .g = 0.75, .b = 0.75, .a = 1 }; glColour cGrey = { .r = 0.75, .g = 0.75, .b = 0.75, .a = 1 };
glColor cGreen = { .r = 0.20, .g = 0.80, .b = 0.20, .a = 1 }; glColour cGreen = { .r = 0.20, .g = 0.80, .b = 0.20, .a = 1 };
// offsets to Adjust the pilot's place onscreen to be in the middle, even with the GUI. // offsets to Adjust the pilot's place onscreen to be in the middle, even with the GUI.
extern double gui_xoff; extern double gui_xoff;
@ -45,7 +45,7 @@ static GLuint gl_loadSurface(SDL_Surface* surface, int* rw, int* rh);
// Gl font. // Gl font.
static void gl_fontMakeDList(FT_Face face, char ch, GLuint list_base, GLuint* tex_base, int* width_base); static void gl_fontMakeDList(FT_Face face, char ch, GLuint list_base, GLuint* tex_base, int* width_base);
// PNG. // PNG.
int write_png(const char* file_name, png_bytep* rows, int w, int h, int colortype, int bitdepth); int write_png(const char* file_name, png_bytep* rows, int w, int h, int colourtype, int bitdepth);
// ================ // ================
// MISC! // MISC!
@ -91,28 +91,28 @@ static int SDL_IsTrans(SDL_Surface* s, int x, int y) {
// p is the address to the pixel we want to retrieve. // p is the address to the pixel we want to retrieve.
Uint8* p = (Uint8*)s->pixels + y * s->pitch + x*bpp; Uint8* p = (Uint8*)s->pixels + y * s->pitch + x*bpp;
Uint32 pixelcolor = 0; Uint32 pixelcolour = 0;
switch(bpp) { switch(bpp) {
case 1: case 1:
pixelcolor = *p; pixelcolour = *p;
break; break;
case 2: case 2:
pixelcolor = *(Uint16*)p; pixelcolour = *(Uint16*)p;
break; break;
case 3: case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
pixelcolor = p[0] << 16 | p[1] << 8 | p[2]; pixelcolour = p[0] << 16 | p[1] << 8 | p[2];
else else
pixelcolor = p[0] | p[1] << 8 | p[2] << 16; pixelcolour = p[0] | p[1] << 8 | p[2] << 16;
break; break;
case 4: case 4:
pixelcolor = *(Uint32*)p; pixelcolour = *(Uint32*)p;
break; break;
} }
// Test whetehr the pixels color is equal to color of // Test whetehr the pixels color is equal to color of
//transparent pixels for that surface. //transparent pixels for that surface.
return (pixelcolor == s->format->colorkey); return (pixelcolour == s->format->colorkey);
} }
// Map the surface transparancy. // Map the surface transparancy.
@ -349,7 +349,7 @@ void gl_getSpriteFromDir(int* x, int* y, const gl_texture* t, const double dir)
// ================ // ================
// Blit the sprite at given position. // Blit the sprite at given position.
void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, const int sx, const int sy, const glColor* c) { void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, const int sx, const int sy, const glColour* c) {
// Don't bother drawing if offscreen -- waste of cycles. // Don't bother drawing if offscreen -- waste of cycles.
if(fabs(VX(*pos) -VX(*gl_camera)+gui_xoff) > gl_screen.w / 2 + sprite->sw / 2 || if(fabs(VX(*pos) -VX(*gl_camera)+gui_xoff) > gl_screen.w / 2 + sprite->sw / 2 ||
fabs(VY(*pos) -VY(*gl_camera)+gui_yoff) > gl_screen.h / 2 + sprite->sh / 2) fabs(VY(*pos) -VY(*gl_camera)+gui_yoff) > gl_screen.h / 2 + sprite->sh / 2)
@ -371,7 +371,7 @@ void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, const int sx, cons
glBindTexture(GL_TEXTURE_2D, sprite->texture); glBindTexture(GL_TEXTURE_2D, sprite->texture);
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
if(c == NULL) glColor4d(1., 1., 1., 1.); if(c == NULL) glColor4d(1., 1., 1., 1.);
else COLOR(*c); else COLOUR(*c);
glTexCoord2d(0., 0.); glTexCoord2d(0., 0.);
glVertex2d(0., 0.); glVertex2d(0., 0.);
glTexCoord2d(sprite->sw/sprite->rw, 0.); glTexCoord2d(sprite->sw/sprite->rw, 0.);
@ -391,7 +391,7 @@ void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, const int sx, cons
} }
// Just straight out blit the thing at position. // Just straight out blit the thing at position.
void gl_blitStatic(const gl_texture* texture, const Vec2* pos, const glColor* c) { void gl_blitStatic(const gl_texture* texture, const Vec2* pos, const glColour* c) {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); // Set up translation matrix. glPushMatrix(); // Set up translation matrix.
@ -402,7 +402,7 @@ void gl_blitStatic(const gl_texture* texture, const Vec2* pos, const glColor* c)
glBindTexture(GL_TEXTURE_2D, texture->texture); glBindTexture(GL_TEXTURE_2D, texture->texture);
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
if(c == NULL) glColor4d(1., 1., 1., 1.); if(c == NULL) glColor4d(1., 1., 1., 1.);
else COLOR(*c); else COLOUR(*c);
glTexCoord2d(0., 0.); glTexCoord2d(0., 0.);
glVertex2d(0., 0.); glVertex2d(0., 0.);
glTexCoord2d(texture->sw/texture->rw, 0.); glTexCoord2d(texture->sw/texture->rw, 0.);
@ -425,7 +425,7 @@ void gl_bindCamera(const Vec2* pos) {
// Print text on screen! YES!!!! Just like printf! But different! // Print text on screen! YES!!!! Just like printf! But different!
// Defaults ft_font to gl_defFont if NULL. // Defaults ft_font to gl_defFont if NULL.
void gl_print(const gl_font* ft_font, const Vec2* pos, const glColor* c, const char* fmt, ...) { void gl_print(const gl_font* ft_font, const Vec2* pos, const glColour* c, const char* fmt, ...) {
//float h = ft_font->h / .63; // Slightly increases font size. //float h = ft_font->h / .63; // Slightly increases font size.
char text[256]; char text[256];
va_list ap; va_list ap;
@ -450,7 +450,7 @@ void gl_print(const gl_font* ft_font, const Vec2* pos, const glColor* c, const c
glTranslated(VX(*pos) - (double)gl_screen.w/2., VY(*pos) - (double)gl_screen.h/2., 0); glTranslated(VX(*pos) - (double)gl_screen.w/2., VY(*pos) - (double)gl_screen.h/2., 0);
if(c == NULL) glColor4d(1., 1., 1., 1.); if(c == NULL) glColor4d(1., 1., 1., 1.);
else COLOR(*c); else COLOUR(*c);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, &text); glCallLists(strlen(text), GL_UNSIGNED_BYTE, &text);
glPopMatrix(); // Translation matrix. glPopMatrix(); // Translation matrix.
@ -725,7 +725,7 @@ void gl_exit(void) {
} }
// Saves a png. // Saves a png.
int write_png(const char* file_name, png_bytep* rows, int w, int h, int colortype, int bitdepth) { int write_png(const char* file_name, png_bytep* rows, int w, int h, int colourtype, int bitdepth) {
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
FILE* fp = NULL; FILE* fp = NULL;
@ -742,7 +742,7 @@ int write_png(const char* file_name, png_bytep* rows, int w, int h, int colortyp
doing = "Init IO"; doing = "Init IO";
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, w, h, bitdepth, colortype, PNG_INTERLACE_NONE, png_set_IHDR(png_ptr, info_ptr, w, h, bitdepth, colourtype, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
doing = "Write info"; doing = "Write info";

View File

@ -27,15 +27,15 @@ typedef struct {
} gl_info; } gl_info;
extern gl_info gl_screen; // Local structure set with gl_init etc. extern gl_info gl_screen; // Local structure set with gl_init etc.
// Colors. // Colours.
typedef struct { typedef struct {
double r, g, b, a; double r, g, b, a;
} glColor; } glColour;
#define COLOR(x) glColor4d((x).r, (x).g, (x).b, (x).a) #define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
// Default colors. // Default colors.
extern glColor cGrey; extern glColour cGrey;
extern glColor cGreen; extern glColour cGreen;
// Spritesheet info. // Spritesheet info.
typedef struct { typedef struct {
@ -69,11 +69,11 @@ void gl_freeTexture(gl_texture* texture);
// Rendering. // Rendering.
void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, void gl_blitSprite(const gl_texture* sprite, const Vec2* pos,
const int sx, const int sy, const glColor* c); const int sx, const int sy, const glColour* c);
void gl_blitStatic(const gl_texture* texture, const Vec2* pos, const glColor* c); void gl_blitStatic(const gl_texture* texture, const Vec2* pos, const glColour* c);
void gl_bindCamera(const Vec2* pos); void gl_bindCamera(const Vec2* pos);
void gl_print(const gl_font* ft_font, const Vec2* pos, const glColor* c, const char* fmt, ...); void gl_print(const gl_font* ft_font, const Vec2* pos, const glColour* c, const char* fmt, ...);
int gl_printWidth(const gl_font* ft_font, const char* fmt, ...); int gl_printWidth(const gl_font* ft_font, const char* fmt, ...);
// Initialize/cleanup. // Initialize/cleanup.

View File

@ -66,22 +66,22 @@ extern int pilots;
// GUI crap. // GUI crap.
// -- Colors. // -- Colours.
// Standard colors. // Standard colors.
glColor cConsole = { .r = 0.5, .g = 0.8, .b = 0.5, .a = 1. }; glColour cConsole = { .r = 0.5, .g = 0.8, .b = 0.5, .a = 1. };
glColor cInert = { .r = 0.6, .g = 0.6, .b = 0.6, .a = 1. }; glColour cInert = { .r = 0.6, .g = 0.6, .b = 0.6, .a = 1. };
glColor cNeutral = { .r = 0.9, .g = 1.0, .b = 0.3, .a = 1. }; glColour cNeutral = { .r = 0.9, .g = 1.0, .b = 0.3, .a = 1. };
glColor cFriend = { .r = 0.0, .g = 1.0, .b = 0.0, .a = 1. }; glColour cFriend = { .r = 0.0, .g = 1.0, .b = 0.0, .a = 1. };
glColor cHostile = { .r = 0.9, .g = 0.2, .b = 0.2, .a = 1. }; glColour cHostile = { .r = 0.9, .g = 0.2, .b = 0.2, .a = 1. };
glColor cRadar_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. }; glColour cRadar_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. };
glColor cRadar_targ = { .r = 0.0, .g = 0.7, .b = 1.0, .a = 1. }; glColour cRadar_targ = { .r = 0.0, .g = 0.7, .b = 1.0, .a = 1. };
glColor cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. }; glColour cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. };
// Bars. // Bars.
glColor cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. }; glColour cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. };
glColor cArmor = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. }; glColour cArmor = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. };
glColor cEnergy = { .r = 0.2, .g = 0.8, .b = 0.2, .a = 1. }; glColour cEnergy = { .r = 0.2, .g = 0.8, .b = 0.2, .a = 1. };
typedef struct { typedef struct {
double w,h; // Dimensions. double w,h; // Dimensions.
@ -144,7 +144,7 @@ extern void planets_minimap(const double res, const double w, const double h, co
static void rect_parse(const xmlNodePtr parent, double* x, double* y, double* w, double* h); static void rect_parse(const xmlNodePtr parent, double* x, double* y, double* w, double* h);
static int gui_parse(const xmlNodePtr parent, const char* name); static int gui_parse(const xmlNodePtr parent, const char* name);
static void gui_renderPilot(const Pilot* p); static void gui_renderPilot(const Pilot* p);
static void gui_renderBar(const glColor* c, const Vec2* p, const Rect* r, const double w); static void gui_renderBar(const glColour* c, const Vec2* p, const Rect* r, const double w);
// Keybinds. // Keybinds.
static void player_board(void); static void player_board(void);
@ -248,7 +248,7 @@ void player_render(void) {
char str[10]; char str[10];
Pilot* p; Pilot* p;
Vec2 v; Vec2 v;
glColor* c; glColour* c;
// Render the player target graphics. // Render the player target graphics.
if(player_target != PLAYER_ID) { if(player_target != PLAYER_ID) {
@ -286,12 +286,12 @@ void player_render(void) {
VY(gui.pos_radar) - gl_screen.h/2., 0.); VY(gui.pos_radar) - gl_screen.h/2., 0.);
// Planets. // Planets.
COLOR(cFriend); COLOUR(cFriend);
planets_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape); planets_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape);
// Weapons. // Weapons.
glBegin(GL_POINTS); glBegin(GL_POINTS);
COLOR(cRadar_weap); COLOUR(cRadar_weap);
weapon_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape); weapon_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape);
glEnd(); glEnd();
@ -307,7 +307,7 @@ void player_render(void) {
// Player. // Player.
glBegin(GL_POINTS); glBegin(GL_POINTS);
// Player. -- Drawn last. // Player. -- Drawn last.
COLOR(cRadar_player); COLOUR(cRadar_player);
glVertex2d( 0., 2. ); // We represent the player with a small '+' glVertex2d( 0., 2. ); // We represent the player with a small '+'
glVertex2d( 0., 1. ); glVertex2d( 0., 1. );
glVertex2d( 0., 0. ); glVertex2d( 0., 0. );
@ -431,11 +431,11 @@ static void gui_renderPilot(const Pilot* p) {
} }
glBegin(GL_QUADS); glBegin(GL_QUADS);
// Colors. // Colours.
if(p->id == player_target) COLOR(cRadar_targ); if(p->id == player_target) COLOUR(cRadar_targ);
else if(pilot_isFlag(p, PILOT_DISABLED)) COLOR(cInert); else if(pilot_isFlag(p, PILOT_DISABLED)) COLOUR(cInert);
else if(pilot_isFlag(p, PILOT_HOSTILE)) COLOR(cHostile); else if(pilot_isFlag(p, PILOT_HOSTILE)) COLOUR(cHostile);
else COLOR(cNeutral); else COLOUR(cNeutral);
// Image. // Image.
glVertex2d(MAX(x-sx, -w), MIN(y+sy, h)); // Top left. glVertex2d(MAX(x-sx, -w), MIN(y+sy, h)); // Top left.
@ -446,11 +446,11 @@ static void gui_renderPilot(const Pilot* p) {
} }
// Render a bar. // Render a bar.
static void gui_renderBar(const glColor* c, const Vec2* p, const Rect* r, const double w) { static void gui_renderBar(const glColour* c, const Vec2* p, const Rect* r, const double w) {
int x, y, sx, sy; int x, y, sx, sy;
glBegin(GL_QUADS); glBegin(GL_QUADS);
COLOR(*c); COLOUR(*c);
x = VX(*p) - gl_screen.w/2.; x = VX(*p) - gl_screen.w/2.;
y = VY(*p) - gl_screen.h/2.; y = VY(*p) - gl_screen.h/2.;
sx = w * r->w; sx = w * r->w;

View File

@ -28,7 +28,7 @@
#define HS 6 #define HS 6
static int save_png(SDL_Surface* surface, const char* file); static int save_png(SDL_Surface* surface, const char* file);
static int write_png(const char* file_name, png_bytep* rows, int w, int h, int colortype, int bitdepth); static int write_png(const char* file_name, png_bytep* rows, int w, int h, int colourtype, int bitdepth);
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int i, ws, hs; int i, ws, hs;
@ -189,7 +189,7 @@ static int save_png(SDL_Surface* surface, const char* file) {
return r; return r;
} }
static int write_png(const char* file_name, png_bytep* rows, int w, int h, int colortype, int bitdepth) { static int write_png(const char* file_name, png_bytep* rows, int w, int h, int colourtype, int bitdepth) {
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
FILE* fp = NULL; FILE* fp = NULL;
@ -203,7 +203,7 @@ static int write_png(const char* file_name, png_bytep* rows, int w, int h, int c
doing = "Init IO"; doing = "Init IO";
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, w, h, bitdepth, colortype, PNG_INTERLACE_NONE, png_set_IHDR(png_ptr, info_ptr, w, h, bitdepth, colourtype, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
doing = "Write info"; doing = "Write info";