[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/map map_fog.c
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src/map map_fog.c |
Date: |
15 Jan 2004 06:02:09 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/15 06:02:09
Modified files:
src/map : map_fog.c
Log message:
Faster sdl fog?
Patches:
Index: stratagus/src/map/map_fog.c
diff -u stratagus/src/map/map_fog.c:1.136 stratagus/src/map/map_fog.c:1.137
--- stratagus/src/map/map_fog.c:1.136 Thu Jan 15 01:06:40 2004
+++ stratagus/src/map/map_fog.c Thu Jan 15 06:02:08 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: map_fog.c,v 1.136 2004/01/14 14:06:40 nobody_ Exp $
+// $Id: map_fog.c,v 1.137 2004/01/14 19:02:08 nobody_ Exp $
//@{
@@ -122,9 +122,10 @@
local unsigned char* VisibleTable;
#ifdef USE_SDL_SURFACE
+local SDL_Surface* OnlyFogSurface;
local void (*VideoDrawUnexplored)(const int, int, int);
local void (*VideoDrawFog)(const int, int, int);
-local void (*VideoDrawOnlyFog)(int x, int y);
+local void (*VideoDrawOnlyFog)(int, int);
#else
/**
** Draw unexplored area function pointer. (display and video mode
independ)
@@ -507,7 +508,7 @@
drect.x = x;
drect.y = y;
- SDL_SetAlpha(TheMap.TileGraphic->Surface, SDL_SRCALPHA | SDL_RLEACCEL,
128);
+ SDL_SetAlpha(TheMap.TileGraphic->Surface, SDL_SRCALPHA | SDL_RLEACCEL,
FogOfWarOpacity);
SDL_BlitSurface(TheMap.TileGraphic->Surface, &srect, TheScreen, &drect);
SDL_SetAlpha(TheMap.TileGraphic->Surface, SDL_RLEACCEL, 0);
}
@@ -533,7 +534,13 @@
global void VideoDrawOnlyFogSDL(int x, int y)
{
- VideoFillTransRectangleClip(ColorBlack, x, y, TileSizeX, TileSizeY,
128);
+ SDL_Rect drect;
+
+ drect.x = x;
+ drect.y = y;
+
+ SDL_BlitSurface(OnlyFogSurface, NULL, TheScreen, &drect);
+ //VideoFillTransRectangleClip(ColorBlack, x, y, TileSizeX, TileSizeY,
FogOfWarOpacity);
}
#else
@@ -1938,6 +1945,24 @@
VideoDrawUnexplored = VideoDrawUnexploredSolidOpenGL;
#else
#ifdef USE_SDL_SURFACE
+ //
+ // Generate Only Fog surface.
+ //
+ {
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ Uint32 color;
+
+ // FIXME: optimize
+ OnlyFogSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, TileSizeX,
TileSizeY,
+ 32, RMASK, GMASK, BMASK, AMASK);
+
+ SDL_GetRGB(ColorBlack, TheScreen->format, &r, &g, &b);
+ color = SDL_MapRGBA(OnlyFogSurface->format, r, g, b,
FogOfWarOpacity);
+
+ SDL_FillRect(OnlyFogSurface, NULL, color);
+ }
VideoDrawUnexplored = VideoDrawUnexploredSDL;
VideoDrawFog = VideoDrawFogSDL;
VideoDrawOnlyFog = VideoDrawOnlyFogSDL;
@@ -2023,6 +2048,7 @@
free(VisibleTable);
VisibleTable = NULL;
}
+ SDL_FreeSurface(OnlyFogSurface);
}
/**
- [Stratagus-CVS] stratagus/src/map map_fog.c,
address@hidden <=