stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src map/map_fog.c video/linedraw.c


From: Nehal Mistry
Subject: [Stratagus-CVS] stratagus/src map/map_fog.c video/linedraw.c
Date: Tue, 18 Nov 2003 13:37:52 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Nehal Mistry <address@hidden>   03/11/18 13:37:52

Modified files:
        src/map        : map_fog.c 
        src/video      : linedraw.c 

Log message:
        add preliminary in-game support for USE_SDL_SURFACE

Patches:
Index: stratagus/src/map/map_fog.c
diff -u stratagus/src/map/map_fog.c:1.115 stratagus/src/map/map_fog.c:1.116
--- stratagus/src/map/map_fog.c:1.115   Tue Nov 18 01:58:03 2003
+++ stratagus/src/map/map_fog.c Tue Nov 18 13:37:50 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: map_fog.c,v 1.115 2003/11/18 06:58:03 nehalmistry Exp $
+//     $Id: map_fog.c,v 1.116 2003/11/18 18:37:50 nehalmistry Exp $
 
 //@{
 
@@ -520,9 +520,65 @@
     SDL_BlitSurface(TheMap.TileGraphic->Surface, &srect, TheScreen, &drect);
 }
 
+global void VideoDrawOnlyFogSolid(const int tile, int x, int y)
+{
+    int tilepitch;
+    SDL_Rect srect;
+    SDL_Rect drect;
+
+    tilepitch = TheMap.TileGraphic->Width / TileSizeX;
+
+    srect.x = TileSizeX * (tile % tilepitch);
+    srect.y = TileSizeY * (tile / tilepitch);
+    srect.w = TileSizeX;
+    srect.h = TileSizeY;
+
+    drect.x = x;
+    drect.y = y;
+
+    SDL_BlitSurface(TheMap.TileGraphic->Surface, &srect, TheScreen, &drect);
+}
+
+global void VideoDrawOnlyFogAlpha(const int tile, int x, int y)
+{
+    int tilepitch;
+    int alpha;
+    SDL_Rect srect;
+    SDL_Rect drect;
+
+    tilepitch = TheMap.TileGraphic->Width / TileSizeX;
+
+    srect.x = TileSizeX * (tile % tilepitch);
+    srect.y = TileSizeY * (tile / tilepitch);
+    srect.w = TileSizeX;
+    srect.h = TileSizeY;
+
+    drect.x = x;
+    drect.y = y;
+
+    alpha = TheMap.TileGraphic->Surface->format->alpha;
+    SDL_SetAlpha(TheMap.TileGraphic->Surface, SDL_SRCALPHA, 128);
+    SDL_BlitSurface(TheMap.TileGraphic->Surface, &srect, TheScreen, &drect);
+    SDL_SetAlpha(TheMap.TileGraphic->Surface, SDL_SRCALPHA, alpha);
+}
+
 global void VideoDrawUnexploredSolid(const int tile, int x, int y)
 {
+    int tilepitch;
+    SDL_Rect srect;
+    SDL_Rect drect;
 
+    tilepitch = TheMap.TileGraphic->Width / TileSizeX;
+
+    srect.x = TileSizeX * (tile % tilepitch);
+    srect.y = TileSizeY * (tile / tilepitch);
+    srect.w = TileSizeX;
+    srect.h = TileSizeY;
+
+    drect.x = x;
+    drect.y = y;
+
+    SDL_BlitSurface(TheMap.TileGraphic->Surface, &srect, TheScreen, &drect);
 }
 #else
 // Routines for 8 bit displays .. --------------------------------------------
@@ -2853,6 +2909,15 @@
 #else
 
 #ifdef USE_SDL_SURFACE
+    if (!OriginalFogOfWar) {
+       VideoDrawFog = VideoDrawFogAlpha;
+       VideoDrawOnlyFog = VideoDrawOnlyFogAlpha;
+       VideoDrawUnexplored = VideoDrawUnexploredSolid;
+    } else {
+       VideoDrawFog = VideoDrawFogSolid;
+       VideoDrawOnlyFog = VideoDrawOnlyFogSolid;
+       VideoDrawUnexplored = VideoDrawUnexploredSolid;
+    }
 
 #else
     if (!OriginalFogOfWar) {
Index: stratagus/src/video/linedraw.c
diff -u stratagus/src/video/linedraw.c:1.42 stratagus/src/video/linedraw.c:1.43
--- stratagus/src/video/linedraw.c:1.42 Mon Nov 17 20:50:15 2003
+++ stratagus/src/video/linedraw.c      Tue Nov 18 13:37:51 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: linedraw.c,v 1.42 2003/11/18 01:50:15 nehalmistry Exp $
+//     $Id: linedraw.c,v 1.43 2003/11/18 18:37:51 nehalmistry Exp $
 
 //@{
 
@@ -470,12 +470,34 @@
 
 global void VideoDrawTransPixel(SDL_Color color, int x, int y, unsigned char 
alpha)
 {
-    DebugCheck(1);
+    int bpp;
+    int ofs;
+    unsigned int c;
+
+    c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
+    bpp = TheScreen->format->BytesPerPixel;
+    ofs = TheScreen->pitch * y + x * bpp;
+
+    SDL_LockSurface(TheScreen);
+    memcpy(TheScreen->pixels + ofs, &c, bpp);
+    SDL_UnlockSurface(TheScreen);
 }
+
 global void VideoDrawPixelClip(SDL_Color color, int x, int y)
 {
-    DebugCheck(1);
+    int bpp;
+    int ofs;
+    unsigned int c;
+
+    c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
+    bpp = TheScreen->format->BytesPerPixel;
+    ofs = TheScreen->pitch * y + x * bpp;
+
+    SDL_LockSurface(TheScreen);
+    memcpy(TheScreen->pixels + ofs, &c, bpp);
+    SDL_UnlockSurface(TheScreen);
 }
+
 global void VideoDrawVLine(SDL_Color color, int x, int y, int height)
 {
     int i;
@@ -484,14 +506,24 @@
        VideoDrawPixel(color, x, y + i);
     }
 }
+
 global void VideoDrawTransVLine(SDL_Color color, int x, int y,
     int height, unsigned char alpha)
 {
-    DebugCheck(1);
+    int i;
+
+    for (i = 1; i < height; ++i) {
+       VideoDrawPixel(color, x, y + i);
+    }
 }
-global void VideoDrawVLineClip(SDL_Color color, int x, int y, int width)
+
+global void VideoDrawVLineClip(SDL_Color color, int x, int y, int height)
 {
-    DebugCheck(1);
+    int i;
+
+    for (i = 1; i < height; ++i) {
+       VideoDrawPixel(color, x, y + i);
+    }
 }
 
 global void VideoDrawHLine(SDL_Color color, int x, int y, int width)
@@ -502,30 +534,40 @@
        VideoDrawPixel(color, x + i, y);
     }
 }
+
 global void VideoDrawHLineClip(SDL_Color color, int x, int y, int width)
 {
-    DebugCheck(1);
+    int i;
+
+    for (i = 1; i < width; ++i) {
+       VideoDrawPixel(color, x + i, y);
+    }
 }
 
 global void VideoDrawTransHLine(SDL_Color color, int x, int y,
     int width, unsigned char alpha)
 {
-    DebugCheck(1);
+    int i;
+
+    for (i = 1; i < width; ++i) {
+       VideoDrawPixel(color, x + i, y);
+    }
 }
+
 global void VideoDrawLine(SDL_Color color, int sx, int sy, int dx, int dy)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoDrawLineClip(SDL_Color color, int sx, int sy, int dx, int dy)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoDrawTransLine(SDL_Color color, int sx, int sy,
     int dx, int dy, unsigned char alpha)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoDrawRectangle(SDL_Color color, int x, int y,
@@ -601,6 +643,7 @@
 global void VideoFillTransRectangle(SDL_Color color, int x, int y,
     int w, int h, unsigned char alpha)
 {
+    // FIXME: alpha
     // FIXME: do clipping
 
     SDL_Rect drect;
@@ -617,42 +660,52 @@
 global void VideoFillRectangleClip(SDL_Color color, int x, int y,
     int w, int h)
 {
-    DebugCheck(1);
+    // FIXME: do clipping
+
+    SDL_Rect drect;
+    Uint32 c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
+
+    drect.x = x;
+    drect.y = y;
+    drect.w = w;
+    drect.h = h;
+
+    SDL_FillRect(TheScreen, &drect, c);
 }
 
 global void VideoFillTransRectangleClip(SDL_Color color, int x, int y,
     int w, int h, unsigned char alpha)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoDrawCircleClip(SDL_Color color, int x, int y,
     int w)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoDrawTransCircleClip(SDL_Color color, int x, int y,
     int w, unsigned char alpha)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoFillCircleClip(SDL_Color color, int x, int y,
     int w)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void VideoFillTransCircleClip(SDL_Color color, int x, int y,
     int w, unsigned char alpha)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 
 global void DebugTestDisplayLines(void)
 {
-    DebugCheck(1);
+//    DebugCheck(1);
 }
 #else
 /**




reply via email to

[Prev in Thread] Current Thread [Next in Thread]