diff --git a/src/font.c b/src/font.c index d87523a..a18681a 100644 --- a/src/font.c +++ b/src/font.c @@ -64,7 +64,7 @@ void gl_print(const glFont* ft_font, const double x, const double y, glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Translation matrix. - glTranslated(x - (double)gl_screen.w/2., y - (double)gl_screen.h/2., 0); + glTranslated(x - (double)SCREEN_W/2., y - (double)SCREEN_H/2., 0); if(c == NULL) glColor4d(1., 1., 1., 1.); else COLOUR(*c); @@ -113,7 +113,7 @@ int gl_printMax(const glFont* ft_font, const int max, glMatrixMode(GL_MODELVIEW); // Projection gets full fast using modelview. glPushMatrix(); // Translation matrix. - glTranslated(x - (double)gl_screen.w/2., y - (double)gl_screen.h/2., 0); + glTranslated(x - (double)SCREEN_W/2., y - (double)SCREEN_H/2., 0); if(c == NULL) glColor4d(1., 1., 1., 1.); else COLOUR(*c); @@ -168,7 +168,7 @@ int gl_printMid(const glFont* ft_font, const int width, double x, const double y glMatrixMode(GL_MODELVIEW); // Projection gets full fast using modelview. glPushMatrix(); // Translation matrix. - glTranslated(x - (double)gl_screen.w/2., y - (double)gl_screen.h/2., 0); + glTranslated(x - (double)SCREEN_W/2., y - (double)SCREEN_H/2., 0); if(c == NULL) glColor4d(1., 1., 1., 1.); else COLOUR(*c); @@ -204,8 +204,8 @@ int gl_printText(const glFont* ft_font, const int width, const int height, vsprintf(txt, fmt, ap); va_end(ap); } - bx -= (double)gl_screen.w/2.; - by -= (double)gl_screen.h/2.; + bx -= (double)SCREEN_W/2.; + by -= (double)SCREEN_H/2.; x = bx; y = by + height - (double)ft_font->h; // y is top left corner. diff --git a/src/land.c b/src/land.c index 5fe5de4..0f6f53d 100644 --- a/src/land.c +++ b/src/land.c @@ -439,8 +439,8 @@ static void outfits_renderMod(double bx, double by, double w, double h) { snprintf(buf, 8, "%dx", q); gl_printMid(&gl_smallFont, w, - bx + (double)gl_screen.w/2., - by + (double)gl_screen.h/2., + bx + (double)SCREEN_W/2., + by + (double)SCREEN_H/2., &cBlack, buf); } diff --git a/src/map.c b/src/map.c index 3941e90..271e06f 100644 --- a/src/map.c +++ b/src/map.c @@ -185,7 +185,7 @@ static void map_render(double bx, double by, double w, double h) { tx = x + 7. + sys->pos.x * map_zoom; ty = y - 5. + sys->pos.y * map_zoom; gl_print(&gl_smallFont, - tx + gl_screen.w/2., ty + gl_screen.h/2., + tx + SCREEN_W/2., ty + SCREEN_H/2., &cWhite, sys->name); // Draw the hyperspace paths. diff --git a/src/menu.c b/src/menu.c index f3b5b74..0387754 100644 --- a/src/menu.c +++ b/src/menu.c @@ -67,11 +67,11 @@ void menu_main(void) { unsigned int bwid, wid; glTexture* tex; - tex = pf_genFractal(gl_screen.w, gl_screen.h, 5.); + tex = pf_genFractal(SCREEN_W, SCREEN_H, 5.); // Create background image window. - bwid = window_create("BG", -1, -1, gl_screen.w, gl_screen.h); - window_addRect(bwid, 0, 0, gl_screen.w, gl_screen.h, "rctBG", &cBlack, 0); + bwid = window_create("BG", -1, -1, SCREEN_W, SCREEN_H); + window_addRect(bwid, 0, 0, SCREEN_W, SCREEN_H, "rctBG", &cBlack, 0); window_addImage(bwid, 0, 0, "imgBG", tex, 0); window_imgColour(bwid, "imgBG", &cPurple); diff --git a/src/opengl.c b/src/opengl.c index 8fc3cff..a89d2e9 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -274,7 +274,7 @@ glTexture* gl_newImage(const char* path) { SDL_FreeSurface(tmp); // Free the temp surface. - + // We have to flip our surfaces to match the ortho. if(SDL_VFlipSurface(surface)) { WARN("Error flipping surface"); return NULL; @@ -325,8 +325,8 @@ void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir) { // Make sure the sprite is "in range". if(s > (sy*sx-1)) s = s % (sy*sx); - *x = s % sx; - *y = s / sx; + (*x) = s % sx; + (*y) = s / sx; } // ================ @@ -763,7 +763,7 @@ int gl_init(void) { // Clean up our mess. void gl_exit(void) { - + SDL_QuitSubSystem(SDL_INIT_VIDEO); } // Saves a png. diff --git a/src/player.c b/src/player.c index 1b63d35..00a396e 100644 --- a/src/player.c +++ b/src/player.c @@ -543,11 +543,11 @@ void player_render(void) { glMatrixMode(GL_PROJECTION); glPushMatrix(); if(gui.radar.shape == RADAR_RECT) - glTranslated(gui.radar.x - gl_screen.w/2. + gui.radar.w/2., - gui.radar.y - gl_screen.h/2. - gui.radar.h/2., 0.); + glTranslated(gui.radar.x - SCREEN_W/2. + gui.radar.w/2., + gui.radar.y - SCREEN_H/2. - gui.radar.h/2., 0.); else if(gui.radar.shape == RADAR_CIRCLE) - glTranslated(gui.radar.x - gl_screen.w/2., - gui.radar.y - gl_screen.h/2., 0.); + glTranslated(gui.radar.x - SCREEN_W/2., + gui.radar.y - SCREEN_H/2., 0.); // Planets. planets_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape); @@ -741,10 +741,10 @@ void player_render(void) { x = (double)(j-i) / HYPERSPACE_FADEOUT; glColor4d(1.,1.,1., x); // We'll | I'll, make this more effiecent later. glBegin(GL_QUADS); - glVertex2d(-gl_screen.w/2., -gl_screen.h/2.); - glVertex2d(-gl_screen.w/2., gl_screen.h/2.); - glVertex2d( gl_screen.w/2., gl_screen.h/2.); - glVertex2d( gl_screen.w/2., -gl_screen.h/2.); + glVertex2d(-SCREEN_W/2., -SCREEN_H/2.); + glVertex2d(-SCREEN_W/2., SCREEN_H/2.); + glVertex2d( SCREEN_W/2., SCREEN_H/2.); + glVertex2d( SCREEN_W/2., -SCREEN_H/2.); glEnd(); } } @@ -797,8 +797,8 @@ static void gui_renderBar(const glColour* c, const Rect* r, const double w) { glBegin(GL_QUADS); COLOUR(*c); - x = r->x - gl_screen.w/2.; - y = r->y - gl_screen.h/2.; + x = r->x - SCREEN_W/2.; + y = r->y - SCREEN_H/2.; sx = w * r->w; sy = r->h; glVertex2d(x, y); @@ -959,8 +959,8 @@ static int gui_parse(const xmlNodePtr parent, const char* name) { // Frame (based on gfx). vect_csetmin(&gui.frame, - gl_screen.w - gui.gfx_frame->w, // x. - gl_screen.h - gui.gfx_frame->h); // h. + SCREEN_W - gui.gfx_frame->w, // x. + SCREEN_H - gui.gfx_frame->h); // h. // Let's parse the data now. node = parent->children; diff --git a/src/space.c b/src/space.c index 6b02e4e..a346858 100644 --- a/src/space.c +++ b/src/space.c @@ -586,13 +586,13 @@ void space_init(const char* sysname) { free(lt); // Set up stars. - nstars = (cur_system->stars*gl_screen.w*gl_screen.h+STAR_BUF*STAR_BUF)/(800*640); + nstars = (cur_system->stars*SCREEN_W*SCREEN_H+STAR_BUF*STAR_BUF)/(800*640); if(mstars < nstars) stars = realloc(stars, sizeof(Star)*nstars); // should realloc not malloc. for(i = 0; i < nstars; i++) { stars[i].brightness = (double)RNG(50, 200)/256.; - stars[i].x = (double)RNG(-STAR_BUF, gl_screen.w + STAR_BUF); - stars[i].y = (double)RNG(-STAR_BUF, gl_screen.h + STAR_BUF); + stars[i].x = (double)RNG(-STAR_BUF, SCREEN_W + STAR_BUF); + stars[i].y = (double)RNG(-STAR_BUF, SCREEN_H + STAR_BUF); } } // Set up fleets -> pilots. @@ -969,7 +969,7 @@ void space_render(double dt) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Translation matrix. - glTranslated(-(double)gl_screen.w/2., -(double)gl_screen.h/2., 0); + glTranslated(-(double)SCREEN_W/2., -(double)SCREEN_H/2., 0); t = SDL_GetTicks(); if(!player_isFlag(PLAYER_DESTROYED) && !player_isFlag(PLAYER_CREATING) && @@ -1008,10 +1008,10 @@ void space_render(double dt) { stars[i].y -= player->solid->vel.y/b*dt; // Check for boundaries. - if(stars[i].x > gl_screen.w + STAR_BUF) stars[i].x = -STAR_BUF; - else if(stars[i].x < -STAR_BUF) stars[i].x = gl_screen.w + STAR_BUF; - if(stars[i].y > gl_screen.h + STAR_BUF) stars[i].y = -STAR_BUF; - else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF; + if(stars[i].x > SCREEN_W + STAR_BUF) stars[i].x = -STAR_BUF; + else if(stars[i].x < -STAR_BUF) stars[i].x = SCREEN_W + STAR_BUF; + if(stars[i].y > SCREEN_H + STAR_BUF) stars[i].y = -STAR_BUF; + else if(stars[i].y < -STAR_BUF) stars[i].y = SCREEN_H + STAR_BUF; // Render. if((stars[i].x < SCREEN_W) && (stars[i].x > 0) && diff --git a/src/spfx.c b/src/spfx.c index ecd1370..66d6ac5 100644 --- a/src/spfx.c +++ b/src/spfx.c @@ -232,18 +232,18 @@ void spfx_shake(double mod) { void spfx_cinematic(void) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Translation matrix. - glTranslated(-(double)gl_screen.w/2., -(double)gl_screen.h/2., 0); + glTranslated(-(double)SCREEN_W/2., -(double)SCREEN_H/2., 0); COLOUR(cBlack); glBegin(GL_QUADS); - glVertex2d(0., 0.); - glVertex2d(0., gl_screen.h*0.2); - glVertex2d(gl_screen.w, gl_screen.h*0.2); - glVertex2d(gl_screen.w, 0.); - glVertex2d(0., gl_screen.h); - glVertex2d(gl_screen.w, gl_screen.h); - glVertex2d(gl_screen.w, gl_screen.h*0.8); - glVertex2d(0., gl_screen.h*0.8); + glVertex2d(0., 0.); + glVertex2d(0., SCREEN_H*0.2); + glVertex2d(SCREEN_W, SCREEN_H*0.2); + glVertex2d(SCREEN_W, 0.); + glVertex2d(0., SCREEN_H); + glVertex2d(SCREEN_W, SCREEN_H); + glVertex2d(SCREEN_W, SCREEN_H*0.8); + glVertex2d(0., SCREEN_H*0.8); glEnd(); glPopMatrix(); // Translation matrix. diff --git a/src/toolkit.c b/src/toolkit.c index b73fcac..6906610 100644 --- a/src/toolkit.c +++ b/src/toolkit.c @@ -476,16 +476,16 @@ unsigned int window_create(char* name, const int x, const int y, // x pos. if(x == -1) // Center. - wdw->x = gl_screen.w/2. - windows[nwindows].w/2.; + wdw->x = SCREEN_W/2. - windows[nwindows].w/2.; else if(x < 0) - wdw->x = gl_screen.w - windows[nwindows].w + (double)x; + wdw->x = SCREEN_W - windows[nwindows].w + (double)x; else windows[nwindows].x = (double)x; // y pos. if(y == -1) // Center. - wdw->y = gl_screen.h/2. - windows[nwindows].h/2.; + wdw->y = SCREEN_H/2. - windows[nwindows].h/2.; else if(y < 0) - wdw->x = gl_screen.h - windows[nwindows].h + (double)y; + wdw->x = SCREEN_H - windows[nwindows].h + (double)y; else wdw->y = (double)y; wdw->widgets = NULL; @@ -666,8 +666,8 @@ static void window_render(Window* w) { glColour *lc, *c, *dc, *oc; // Position. - x = w->x - (double)gl_screen.w/2.; - y = w->y - (double)gl_screen.h/2.; + x = w->x - (double)SCREEN_W/2.; + y = w->y - (double)SCREEN_H/2.; // Colours. lc = &cGrey90; @@ -808,8 +808,8 @@ static void window_render(Window* w) { // Render the window name. gl_printMid(&gl_defFont, w->w, - x + (double)gl_screen.w/2., - y + w->h - 20. + (double)gl_screen.h/2., + x + (double)SCREEN_W/2., + y + w->h - 20. + (double)SCREEN_H/2., &cBlack, w->name); // Widgets. @@ -901,8 +901,8 @@ static void toolkit_renderButton(Widget* btn, double bx, double by) { toolkit_drawOutline(x, y, btn->w, btn->h, 1., &cBlack, NULL); gl_printMid(NULL, (int)btn->w, - bx + (double)gl_screen.w/2. + btn->x, - by + (double)gl_screen.h/2. + btn->y + (btn->h - gl_defFont.h)/2., + bx + (double)SCREEN_W/2. + btn->x, + by + (double)SCREEN_H/2. + btn->y + (btn->h - gl_defFont.h)/2., &cDarkRed, btn->dat.btn.display); } @@ -911,13 +911,13 @@ static void toolkit_renderText(Widget* txt, double bx, double by) { if(txt->dat.txt.centered) gl_printMid(txt->dat.txt.font, txt->w, - bx + (double)gl_screen.w/2. + txt->x, - by + (double)gl_screen.h/2. + txt->y, + bx + (double)SCREEN_W/2. + txt->x, + by + (double)SCREEN_H/2. + txt->y, txt->dat.txt.colour, txt->dat.txt.text); else gl_printText(txt->dat.txt.font, txt->w, txt->h, - bx + (double)gl_screen.w/2. + txt->x, - by + (double)gl_screen.h/2. + txt->y, + bx + (double)SCREEN_W/2. + txt->x, + by + (double)SCREEN_H/2. + txt->y, txt->dat.txt.colour, txt->dat.txt.text); } @@ -932,8 +932,8 @@ static void toolkit_renderImage(Widget* img, double bx, double by) { // Image. gl_blitStatic(img->dat.img.image, - x + (double)gl_screen.w/2., - y + (double)gl_screen.h/2., + x + (double)SCREEN_W/2., + y + (double)SCREEN_H/2., img->dat.img.colour); if(img->dat.img.border) { @@ -969,8 +969,8 @@ static void toolkit_renderList(Widget* lst, double bx, double by) { lst->w, gl_defFont.h+2., &cHilight, NULL); // Draw content. - tx = (double)gl_screen.w/2. + x+2.; - ty = (double)gl_screen.h/2. + y+lst->h - 2. - gl_defFont.h; + tx = (double)SCREEN_W/2. + x+2.; + ty = (double)SCREEN_H/2. + y+lst->h - 2. - gl_defFont.h; y = ty-2.; for(i = lst->dat.lst.pos; i < lst->dat.lst.noptions; i++) { @@ -1036,7 +1036,7 @@ static void toolkit_renderInput(Widget* inp, double bx, double by) { if(inp->dat.inp.oneline) ty = y - (inp->h - gl_smallFont.h)/2.; gl_printText(&gl_smallFont, inp->w-10., inp->h, - x+5. + gl_screen.w/2., ty + gl_screen.h/2., + x+5. + SCREEN_W/2., ty + SCREEN_H/2., &cBlack, inp->dat.inp.input+inp->dat.inp.view); // Inner outline. @@ -1136,11 +1136,11 @@ static void toolkit_mouseEvent(SDL_Event* event) { // Absolute positions. if(event->type == SDL_MOUSEMOTION) { x = (double)event->motion.x; - y = gl_screen.h - (double)event->motion.y; + y = SCREEN_H - (double)event->motion.y; } else if((event->type == SDL_MOUSEBUTTONDOWN) || (event->type == SDL_MOUSEBUTTONUP)) { x = (double)event->button.x; - y = gl_screen.h - (double)event->motion.y; + y = SCREEN_H - (double)event->motion.y; } w = &windows[nwindows-1];