stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src video/sprite.c include/video.h


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src video/sprite.c include/video.h
Date: 10 Jan 2004 08:57:19 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/10 08:57:19

Modified files:
        src/video      : sprite.c 
        src/include    : video.h 

Log message:
        Added transparent functions

Patches:
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.107 stratagus/src/include/video.h:1.108
--- stratagus/src/include/video.h:1.107 Fri Jan  9 16:44:37 2004
+++ stratagus/src/include/video.h       Sat Jan 10 08:57:18 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: video.h,v 1.107 2004/01/09 05:44:37 jsalmon3 Exp $
+//     $Id: video.h,v 1.108 2004/01/09 21:57:18 jsalmon3 Exp $
 
 #ifndef __VIDEO_H__
 #define __VIDEO_H__
@@ -504,13 +504,22 @@
 
        /// Translucent Functions
        ///             Draw a graphic object unclipped.
-#define VideoDrawTrans50(o, f, x, y)           VideoDraw((o), (f), (x), (y))
+extern void VideoDrawTrans(const Graphic*, unsigned, int, int, int);
+       ///             Draw a graphic object clipped to the current clipping.
+extern void VideoDrawClipTrans(const Graphic*, unsigned frame, int x, int y, 
int);
+       ///             Draw a graphic object unclipped and flipped in X 
direction.
+extern void VideoDrawTransX(const Graphic*, unsigned frame, int x, int y, int 
alpha);
+       ///             Draw a graphic object clipped and flipped in X 
direction.
+extern void VideoDrawClipTransX(const Graphic*, unsigned frame, int x, int y, 
int alpha);
+
+       ///             Draw a graphic object unclipped.
+#define VideoDrawTrans50(o, f, x, y)           VideoDrawTrans((o), (f), (x), 
(y), 128)
        ///             Draw a graphic object unclipped and flipped in X 
direction.
-#define VideoDrawXTrans50(o, f, x, y)          VideoDrawX((o), (f), (x), (y))
+#define VideoDrawXTrans50(o, f, x, y)          VideoDrawTransX((o), (f), (x), 
(y), 128)
        ///             Draw a graphic object clipped to the current clipping.
-#define VideoDrawClipTrans50(o, f, x, y)               VideoDrawClip((o), (f), 
(x), (y))
+#define VideoDrawClipTrans50(o, f, x, y)               VideoDrawClipTrans((o), 
(f), (x), (y), 128)
        ///             Draw a graphic object clipped and flipped in X 
direction.
-#define VideoDrawClipXTrans50(o, f, x, y)              VideoDrawClipX((o), 
(f), (x), (y))
+#define VideoDrawClipXTrans50(o, f, x, y)              
VideoDrawClipTransX((o), (f), (x), (y), 128)
 
        ///             Draw a shadow graphic object clipped to the current 
clipping.
 extern void VideoDrawShadowClip(const Graphic*, unsigned frame,
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.59 stratagus/src/video/sprite.c:1.60
--- stratagus/src/video/sprite.c:1.59   Sat Dec 20 18:22:30 2003
+++ stratagus/src/video/sprite.c        Sat Jan 10 08:57:17 2004
@@ -5,13 +5,13 @@
 //     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
 //             \/                  \/          \//_____/            \/
 //  ______________________                           ______________________
-//                       T H E   W A R   B E G I N S
-//        Stratagus - A free fantasy real time strategy game engine
+//                        T H E   W A R   B E G I N S
+//         Stratagus - A free fantasy real time strategy game engine
 //
-/address@hidden sprite.c       -       The general sprite functions. */
+/address@hidden sprite.c - The general sprite functions. */
 //
-//     (c) Copyright 2000-2002 by Lutz Sammer, Stephan Rasenberg,
-//     Nehal Mistry
+//      (c) Copyright 2000-2004 by Lutz Sammer, Stephan Rasenberg,
+//                                 Nehal Mistry, and Jimmy Salmon
 //
 //      This program is free software; you can redistribute it and/or modify
 //      it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: sprite.c,v 1.59 2003/12/20 07:22:30 wizzard Exp $
+//      $Id: sprite.c,v 1.60 2004/01/09 21:57:17 jsalmon3 Exp $
 
 //@{
 
@@ -211,6 +211,104 @@
        SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, 128);
        SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
        SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, alpha);
+}
+
+global void VideoDrawTrans(const Graphic* sprite, unsigned frame, int x, int 
y, int alpha)
+{
+       SDL_Rect srect;
+       SDL_Rect drect;
+       int oldalpha;
+
+       srect.x = (frame % (sprite->Surface->w / sprite->Width)) * 
sprite->Width;
+       srect.y = (frame / (sprite->Surface->w / sprite->Width)) * 
sprite->Height;
+       srect.w = sprite->Width;
+       srect.h = sprite->Height;
+
+       drect.x = x;
+       drect.y = y;
+
+       oldalpha = sprite->Surface->format->alpha;
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, alpha);
+       SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
+}
+
+global void VideoDrawClipTrans(const Graphic* sprite, unsigned frame, int x, 
int y, int alpha)
+{
+       SDL_Rect srect;
+       SDL_Rect drect;
+       int oldx;
+       int oldy;
+       int oldalpha;
+
+       srect.x = (frame % (sprite->Surface->w / sprite->Width)) * 
sprite->Width;
+       srect.y = (frame / (sprite->Surface->w / sprite->Width)) * 
sprite->Height;
+       srect.w = sprite->Width;
+       srect.h = sprite->Height;
+
+       oldx = x;
+       oldy = y;
+       CLIP_RECTANGLE(x, y, srect.w, srect.h);
+       srect.x += x - oldx;
+       srect.y += y - oldy;
+
+       drect.x = x;
+       drect.y = y;
+
+       oldalpha = sprite->Surface->format->alpha;
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, alpha);
+       SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
+}
+
+global void VideoDrawTransX(const Graphic* sprite, unsigned frame, int x, int 
y, int alpha)
+{
+       SDL_Rect srect;
+       SDL_Rect drect;
+       int oldalpha;
+
+       srect.x = (sprite->SurfaceFlip->w - (frame % (sprite->SurfaceFlip->w /
+                       sprite->Width)) * sprite->Width) - sprite->Width;
+       srect.y = (frame / (sprite->SurfaceFlip->w / sprite->Width)) * 
sprite->Height;
+       srect.w = sprite->Width;
+       srect.h = sprite->Height;
+
+       drect.x = x;
+       drect.y = y;
+
+       oldalpha = sprite->Surface->format->alpha;
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, alpha);
+       SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
+}
+
+global void VideoDrawClipTransX(const Graphic* sprite, unsigned frame, int x, 
int y, int alpha)
+{
+       SDL_Rect srect;
+       SDL_Rect drect;
+       int oldx;
+       int oldy;
+       int oldalpha;
+
+       srect.x = (sprite->SurfaceFlip->w - (frame % (sprite->SurfaceFlip->w /
+                       sprite->Width)) * sprite->Width) - sprite->Width;
+       srect.y = (frame / (sprite->SurfaceFlip->w / sprite->Width)) * 
sprite->Height;
+       srect.w = sprite->Width;
+       srect.h = sprite->Height;
+
+       oldx = x;
+       oldy = y;
+       CLIP_RECTANGLE(x, y, srect.w, srect.h);
+       srect.x += x - oldx;
+       srect.y += y - oldy;
+
+       drect.x = x;
+       drect.y = y;
+
+       oldalpha = sprite->Surface->format->alpha;
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, alpha);
+       SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
+       SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
 }
 #else
 //




reply via email to

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