Thread: [Super-tux-commit] supertux/lib/video drawing_context.cpp,1.11,1.12 surface.cpp,1.16,1.17 surface.h,
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-23 16:48:05
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29597/lib/video Modified Files: drawing_context.cpp surface.cpp surface.h Log Message: added jam build system, please try it out - the advantage would be that it already supports all the stuff we need Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- drawing_context.cpp 23 Nov 2004 02:00:32 -0000 1.11 +++ drawing_context.cpp 23 Nov 2004 16:47:24 -0000 1.12 @@ -79,6 +79,22 @@ surfacepartrequest->size = size; surfacepartrequest->source = source; surfacepartrequest->surface = surface; + + // clip on screen borders + if(request.pos.x < 0) { + surfacepartrequest->size.x += request.pos.x; + if(surfacepartrequest->size.x <= 0) + return; + surfacepartrequest->source.x -= request.pos.x; + request.pos.x = 0; + } + if(request.pos.y < 0) { + surfacepartrequest->size.y += request.pos.y; + if(surfacepartrequest->size.y <= 0) + return; + surfacepartrequest->source.y -= request.pos.y; + request.pos.y = 0; + } request.request_data = surfacepartrequest; drawingrequests.push_back(request); Index: surface.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/surface.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- surface.h 20 Oct 2004 21:08:50 -0000 1.8 +++ surface.h 23 Nov 2004 16:47:24 -0000 1.9 @@ -17,7 +17,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. - #ifndef SUPERTUX_TEXTURE_H #define SUPERTUX_TEXTURE_H @@ -25,7 +24,7 @@ #include <list> #ifndef NOOPENGL -#include "SDL_opengl.h" +#include <SDL_opengl.h> #endif #include "SDL.h" @@ -122,8 +121,6 @@ /** Reload the surface, which is necesarry in case of a mode swich */ void reload(); - void resize(int widht, int height); - void apply_filter(int filter, Color color = Color(0,0,0)); }; @@ -148,8 +145,6 @@ virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0; - int resize(int w_, int h_); - SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function virtual void apply_filter(int filter, Color color = Color(0,0,0)) = 0; Index: surface.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/surface.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- surface.cpp 23 Nov 2004 02:00:32 -0000 1.16 +++ surface.cpp 23 Nov 2004 16:47:24 -0000 1.17 @@ -37,7 +37,8 @@ Surface::Surfaces Surface::surfaces; SurfaceData::SurfaceData(SDL_Surface* temp, bool use_alpha_) - : type(SURFACE), surface(0), use_alpha(use_alpha_) + : type(SURFACE), surface(0), use_alpha(use_alpha_), + x(0), y(0), w(0), h(0) { // Copy the given surface and make sure that it is not stored in // video memory @@ -254,58 +255,41 @@ } void -Surface::resize(int w_, int h_) -{ - if (impl) - { - w = w_; - h = h_; - if (impl->resize(w_,h_) == -2) - reload(); - } -} - -void apply_filter_to_surface(SDL_Surface* surface, int filter, Color color) { -if(filter == HORIZONTAL_FLIP_FILTER) - { - SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true); - SDL_BlitSurface(surface, NULL, sur_copy, NULL); - SDL_SetAlpha(sur_copy,0,0); + if(filter == HORIZONTAL_FLIP_FILTER) { + SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true); + SDL_BlitSurface(surface, NULL, sur_copy, NULL); + SDL_SetAlpha(sur_copy,0,0); - SDL_Rect src, dst; - src.y = dst.y = 0; - src.w = dst.w = 1; - src.h = dst.h = sur_copy->h; - for(int x = 0; x < sur_copy->w; x++) + SDL_Rect src, dst; + src.y = dst.y = 0; + src.w = dst.w = 1; + src.h = dst.h = sur_copy->h; + for(int x = 0; x < sur_copy->w; x++) { - src.x = x; dst.x = sur_copy->w-1 - x; - SDL_BlitSurface(sur_copy, &src, surface, &dst); + src.x = x; dst.x = sur_copy->w-1 - x; + SDL_BlitSurface(sur_copy, &src, surface, &dst); } - SDL_FreeSurface(sur_copy); - } -else if(filter == MASK_FILTER) - { - SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true); + SDL_FreeSurface(sur_copy); + } else if(filter == MASK_FILTER) { + SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true); - Uint8 r,g,b,a; + Uint8 r,g,b,a; - SDL_LockSurface(sur_copy); - for(int x = 0; x < sur_copy->w; x++) - for(int y = 0; y < sur_copy->h; y++) - { - SDL_GetRGBA(getpixel(sur_copy,x,y), sur_copy->format, &r,&g,&b,&a); - if(a != 0) - { - putpixel(sur_copy, x,y, color.map_rgba(sur_copy)); + SDL_LockSurface(sur_copy); + for(int x = 0; x < sur_copy->w; x++) + for(int y = 0; y < sur_copy->h; y++) { + SDL_GetRGBA(getpixel(sur_copy,x,y), sur_copy->format, &r,&g,&b,&a); + if(a != 0) { + putpixel(sur_copy, x,y, color.map_rgba(sur_copy)); } } - SDL_UnlockSurface(sur_copy); + SDL_UnlockSurface(sur_copy); - SDL_BlitSurface(sur_copy, NULL, surface, NULL); - SDL_FreeSurface(sur_copy); + SDL_BlitSurface(sur_copy, NULL, surface, NULL); + SDL_FreeSurface(sur_copy); } } @@ -329,19 +313,12 @@ src.w = w; src.h = h; - conv = SDL_CreateRGBSurface(temp->flags, w, h, temp->format->BitsPerPixel, + conv = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, temp->format->BitsPerPixel, temp->format->Rmask, temp->format->Gmask, temp->format->Bmask, temp->format->Amask); - /* #if SDL_BYTEORDER == SDL_BIG_ENDIAN - 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); - #else - - 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); - #endif*/ - SDL_SetAlpha(temp,0,0); SDL_BlitSurface(temp, &src, conv, NULL); @@ -480,20 +457,6 @@ return sdl_surface; } -int SurfaceImpl::resize(int w_, int h_) -{ - w = w_; - h = h_; - SDL_Rect dest; - dest.x = 0; - dest.y = 0; - dest.w = w; - dest.h = h; - int ret = SDL_SoftStretch(sdl_surface, NULL, - sdl_surface, &dest); - return ret; -} - #ifndef NOOPENGL SurfaceOpenGL::SurfaceOpenGL(SDL_Surface* surf, bool use_alpha) { @@ -1089,4 +1052,3 @@ SurfaceSDL::~SurfaceSDL() {} -/* EOF */ |