[Change] Now we can get confused as to when to use Color and Colour. Won't that be fun?
This commit is contained in:
parent
dc9f089abe
commit
627240c5a4
36
src/opengl.c
36
src/opengl.c
@ -19,8 +19,8 @@
|
||||
#define FONT_DEF "../gfx/fonts/FreeSans.ttf"
|
||||
|
||||
// Default colors.
|
||||
glColor 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 cGrey = { .r = 0.75, .g = 0.75, .b = 0.75, .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.
|
||||
extern double gui_xoff;
|
||||
@ -45,7 +45,7 @@ static GLuint gl_loadSurface(SDL_Surface* surface, int* rw, int* rh);
|
||||
// Gl font.
|
||||
static void gl_fontMakeDList(FT_Face face, char ch, GLuint list_base, GLuint* tex_base, int* width_base);
|
||||
// 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!
|
||||
@ -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.
|
||||
Uint8* p = (Uint8*)s->pixels + y * s->pitch + x*bpp;
|
||||
|
||||
Uint32 pixelcolor = 0;
|
||||
Uint32 pixelcolour = 0;
|
||||
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
pixelcolor = *p;
|
||||
pixelcolour = *p;
|
||||
break;
|
||||
case 2:
|
||||
pixelcolor = *(Uint16*)p;
|
||||
pixelcolour = *(Uint16*)p;
|
||||
break;
|
||||
case 3:
|
||||
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
|
||||
pixelcolor = p[0] | p[1] << 8 | p[2] << 16;
|
||||
pixelcolour = p[0] | p[1] << 8 | p[2] << 16;
|
||||
break;
|
||||
case 4:
|
||||
pixelcolor = *(Uint32*)p;
|
||||
pixelcolour = *(Uint32*)p;
|
||||
break;
|
||||
}
|
||||
// Test whetehr the pixels color is equal to color of
|
||||
//transparent pixels for that surface.
|
||||
return (pixelcolor == s->format->colorkey);
|
||||
return (pixelcolour == s->format->colorkey);
|
||||
}
|
||||
|
||||
// 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.
|
||||
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.
|
||||
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)
|
||||
@ -371,7 +371,7 @@ void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, const int sx, cons
|
||||
glBindTexture(GL_TEXTURE_2D, sprite->texture);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
if(c == NULL) glColor4d(1., 1., 1., 1.);
|
||||
else COLOR(*c);
|
||||
else COLOUR(*c);
|
||||
glTexCoord2d(0., 0.);
|
||||
glVertex2d(0., 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.
|
||||
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);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
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);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
if(c == NULL) glColor4d(1., 1., 1., 1.);
|
||||
else COLOR(*c);
|
||||
else COLOUR(*c);
|
||||
glTexCoord2d(0., 0.);
|
||||
glVertex2d(0., 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!
|
||||
// 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.
|
||||
char text[256];
|
||||
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);
|
||||
|
||||
if(c == NULL) glColor4d(1., 1., 1., 1.);
|
||||
else COLOR(*c);
|
||||
else COLOUR(*c);
|
||||
glCallLists(strlen(text), GL_UNSIGNED_BYTE, &text);
|
||||
|
||||
glPopMatrix(); // Translation matrix.
|
||||
@ -725,7 +725,7 @@ void gl_exit(void) {
|
||||
}
|
||||
|
||||
// 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_infop info_ptr;
|
||||
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";
|
||||
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);
|
||||
|
||||
doing = "Write info";
|
||||
|
16
src/opengl.h
16
src/opengl.h
@ -27,15 +27,15 @@ typedef struct {
|
||||
} gl_info;
|
||||
extern gl_info gl_screen; // Local structure set with gl_init etc.
|
||||
|
||||
// Colors.
|
||||
// Colours.
|
||||
typedef struct {
|
||||
double r, g, b, a;
|
||||
} glColor;
|
||||
#define COLOR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
|
||||
} glColour;
|
||||
#define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
|
||||
|
||||
// Default colors.
|
||||
extern glColor cGrey;
|
||||
extern glColor cGreen;
|
||||
extern glColour cGrey;
|
||||
extern glColour cGreen;
|
||||
|
||||
// Spritesheet info.
|
||||
typedef struct {
|
||||
@ -69,11 +69,11 @@ void gl_freeTexture(gl_texture* texture);
|
||||
|
||||
// Rendering.
|
||||
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_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, ...);
|
||||
|
||||
// Initialize/cleanup.
|
||||
|
48
src/player.c
48
src/player.c
@ -66,22 +66,22 @@ extern int pilots;
|
||||
|
||||
// GUI crap.
|
||||
|
||||
// -- Colors.
|
||||
// -- Colours.
|
||||
// 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. };
|
||||
glColor 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. };
|
||||
glColor cHostile = { .r = 0.9, .g = 0.2, .b = 0.2, .a = 1. };
|
||||
glColour cInert = { .r = 0.6, .g = 0.6, .b = 0.6, .a = 1. };
|
||||
glColour cNeutral = { .r = 0.9, .g = 1.0, .b = 0.3, .a = 1. };
|
||||
glColour cFriend = { .r = 0.0, .g = 1.0, .b = 0.0, .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. };
|
||||
glColor 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_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. };
|
||||
glColour cRadar_targ = { .r = 0.0, .g = 0.7, .b = 1.0, .a = 1. };
|
||||
glColour cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. };
|
||||
// Bars.
|
||||
glColor 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. };
|
||||
glColor cEnergy = { .r = 0.2, .g = 0.8, .b = 0.2, .a = 1. };
|
||||
glColour cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. };
|
||||
glColour cArmor = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. };
|
||||
glColour cEnergy = { .r = 0.2, .g = 0.8, .b = 0.2, .a = 1. };
|
||||
|
||||
typedef struct {
|
||||
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 int gui_parse(const xmlNodePtr parent, const char* name);
|
||||
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.
|
||||
static void player_board(void);
|
||||
@ -248,7 +248,7 @@ void player_render(void) {
|
||||
char str[10];
|
||||
Pilot* p;
|
||||
Vec2 v;
|
||||
glColor* c;
|
||||
glColour* c;
|
||||
|
||||
// Render the player target graphics.
|
||||
if(player_target != PLAYER_ID) {
|
||||
@ -286,12 +286,12 @@ void player_render(void) {
|
||||
VY(gui.pos_radar) - gl_screen.h/2., 0.);
|
||||
|
||||
// Planets.
|
||||
COLOR(cFriend);
|
||||
COLOUR(cFriend);
|
||||
planets_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape);
|
||||
|
||||
// Weapons.
|
||||
glBegin(GL_POINTS);
|
||||
COLOR(cRadar_weap);
|
||||
COLOUR(cRadar_weap);
|
||||
weapon_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape);
|
||||
glEnd();
|
||||
|
||||
@ -307,7 +307,7 @@ void player_render(void) {
|
||||
// Player.
|
||||
glBegin(GL_POINTS);
|
||||
// Player. -- Drawn last.
|
||||
COLOR(cRadar_player);
|
||||
COLOUR(cRadar_player);
|
||||
glVertex2d( 0., 2. ); // We represent the player with a small '+'
|
||||
glVertex2d( 0., 1. );
|
||||
glVertex2d( 0., 0. );
|
||||
@ -431,11 +431,11 @@ static void gui_renderPilot(const Pilot* p) {
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
// Colors.
|
||||
if(p->id == player_target) COLOR(cRadar_targ);
|
||||
else if(pilot_isFlag(p, PILOT_DISABLED)) COLOR(cInert);
|
||||
else if(pilot_isFlag(p, PILOT_HOSTILE)) COLOR(cHostile);
|
||||
else COLOR(cNeutral);
|
||||
// Colours.
|
||||
if(p->id == player_target) COLOUR(cRadar_targ);
|
||||
else if(pilot_isFlag(p, PILOT_DISABLED)) COLOUR(cInert);
|
||||
else if(pilot_isFlag(p, PILOT_HOSTILE)) COLOUR(cHostile);
|
||||
else COLOUR(cNeutral);
|
||||
|
||||
// Image.
|
||||
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.
|
||||
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;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
COLOR(*c);
|
||||
COLOUR(*c);
|
||||
x = VX(*p) - gl_screen.w/2.;
|
||||
y = VY(*p) - gl_screen.h/2.;
|
||||
sx = w * r->w;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define HS 6
|
||||
|
||||
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 i, ws, hs;
|
||||
@ -189,7 +189,7 @@ static int save_png(SDL_Surface* surface, const char* file) {
|
||||
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_infop info_ptr;
|
||||
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";
|
||||
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);
|
||||
|
||||
doing = "Write info";
|
||||
|
Loading…
Reference in New Issue
Block a user