X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fvideo%2Fscreen.cpp;h=4cef057038160262958265a334d826b6c91c4cee;hb=a5e66c8aec9b24595006c52499c926807cc7118b;hp=70b1d5b2851499fd368f861d2025ba075ab37b6f;hpb=edaacb3651cf0560314dd008d7243be4b3b2f8c6;p=supertux.git diff --git a/lib/video/screen.cpp b/lib/video/screen.cpp index 70b1d5b28..4cef05703 100644 --- a/lib/video/screen.cpp +++ b/lib/video/screen.cpp @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include + #include #include #include @@ -33,15 +35,45 @@ #include #endif -#include "video/screen.h" +#include "screen.h" #include "app/globals.h" #include "video/drawing_context.h" -#include "special/base.h" #include "math/vector.h" using namespace SuperTux; /* 'Stolen' from the SDL documentation. + * Return the pixel value at (x, y) + * NOTE: The surface must be locked before calling this! + */ +Uint32 SuperTux::getpixel(SDL_Surface *surface, int x, int y) +{ + int bpp = surface->format->BytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch(bpp) { + case 1: + return *p; + + case 2: + return *(Uint16 *)p; + + case 3: + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; + else + return p[0] | p[1] << 8 | p[2] << 16; + + case 4: + return *(Uint32 *)p; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } +} + +/* 'Stolen' from the SDL documentation. * Set the pixel at (x, y) to the given value * NOTE: The surface must be locked before calling this! */ @@ -264,11 +296,7 @@ void SuperTux::fadeout(int fade_time) } fillrect(0, 0, screen->w, screen->h, 0, 0, 0, 255); - - DrawingContext context; - context.draw_text_center(white_text, "Loading...", - Vector(0, screen->h/2), LAYER_FOREGROUND1); - context.do_drawing(); + } void SuperTux::shrink_fade(const Vector& point, int fade_time)