[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/video.h stratagus/constru...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/video.h stratagus/constru... |
Date: |
22 Jan 2004 07:01:32 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/22 07:01:31
Modified files:
src/include : video.h
src/stratagus : construct.c
src/unit : unit_draw.c unittype.c
src/video : sprite.c
Log message:
Fixed shadows
Patches:
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.116 stratagus/src/include/video.h:1.117
--- stratagus/src/include/video.h:1.116 Thu Jan 15 17:44:24 2004
+++ stratagus/src/include/video.h Thu Jan 22 07:01:28 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.h,v 1.116 2004/01/15 06:44:24 jsalmon3 Exp $
+// $Id: video.h,v 1.117 2004/01/21 20:01:28 jsalmon3 Exp $
#ifndef __VIDEO_H__
#define __VIDEO_H__
@@ -271,6 +271,9 @@
/// Load sprite
extern Graphic* LoadSprite(const char* file, int w, int h);
+ /// Make shadow sprite
+extern void MakeShadowSprite(Graphic* graphic);
+
/// Draw part of a graphic clipped and faded.
extern void VideoDrawSubClipFaded(Graphic* graphic, int gx, int gy,
int w, int h, int x, int y, unsigned char fade);
@@ -505,13 +508,6 @@
#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)
VideoDrawClipTransX((o), (f), (x), (y), 128)
-
- /// Draw a shadow graphic object clipped to the current
clipping.
-extern void VideoDrawShadowClip(const Graphic*, unsigned frame,
- int x, int y);
- /// Draw a shadow graphic object clipped and flipped in X
direction.
-extern void VideoDrawShadowClipX(const Graphic*, unsigned frame,
- int x, int y);
/// Free a graphic object.
extern void VideoFree(Graphic* o);
Index: stratagus/src/stratagus/construct.c
diff -u stratagus/src/stratagus/construct.c:1.48
stratagus/src/stratagus/construct.c:1.49
--- stratagus/src/stratagus/construct.c:1.48 Sat Jan 17 18:26:09 2004
+++ stratagus/src/stratagus/construct.c Thu Jan 22 07:01:29 2004
@@ -5,12 +5,12 @@
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
-// 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 construct.c - The constructions. */
+/address@hidden construct.c - The constructions. */
//
-// (c) Copyright 1998-2003 by Lutz Sammer and Jimmy Salmon
+// (c) Copyright 1998-2004 by Lutz Sammer 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
@@ -26,12 +26,12 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: construct.c,v 1.48 2004/01/17 07:26:09 jsalmon3 Exp $
+// $Id: construct.c,v 1.49 2004/01/21 20:01:29 jsalmon3 Exp $
//@{
/*----------------------------------------------------------------------------
--- Includes
+-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
@@ -46,7 +46,7 @@
#include "script.h"
/*----------------------------------------------------------------------------
--- Variables
+-- Variables
----------------------------------------------------------------------------*/
/**
@@ -129,6 +129,7 @@
(*cop)->ShadowSprite = LoadSprite(file,
(*cop)->ShadowWidth,
(*cop)->ShadowHeight);
FlipGraphic((*cop)->ShadowSprite);
+ MakeShadowSprite((*cop)->ShadowSprite);
}
++cop;
}
@@ -150,7 +151,7 @@
ConstructionFrame* cframe;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: constructions $Id: construct.c,v 1.48
2004/01/17 07:26:09 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: constructions $Id: construct.c,v 1.49
2004/01/21 20:01:29 jsalmon3 Exp $\n\n");
// FIXME: needed?
Index: stratagus/src/unit/unit_draw.c
diff -u stratagus/src/unit/unit_draw.c:1.212
stratagus/src/unit/unit_draw.c:1.213
--- stratagus/src/unit/unit_draw.c:1.212 Sat Jan 17 18:26:10 2004
+++ stratagus/src/unit/unit_draw.c Thu Jan 22 07:01:29 2004
@@ -26,12 +26,12 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit_draw.c,v 1.212 2004/01/17 07:26:10 jsalmon3 Exp $
+// $Id: unit_draw.c,v 1.213 2004/01/21 20:01:29 jsalmon3 Exp $
//@{
/*----------------------------------------------------------------------------
--- Includes
+-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
@@ -616,6 +616,7 @@
ShowLoadProgress("Decorations `%s'", ShadowSprite.File);
ShadowSprite.Sprite = LoadSprite(ShadowSprite.File,
ShadowSprite.Width, ShadowSprite.Height);
+ MakeShadowSprite(ShadowSprite.Sprite);
}
if (SpellSprite.File) {
ShowLoadProgress("Decorations `%s'", SpellSprite.File);
@@ -631,7 +632,7 @@
{
#if 0
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.212
2004/01/17 07:26:10 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.213
2004/01/21 20:01:29 jsalmon3 Exp $\n\n");
CLprintf(file, "(mana-sprite \"%s\" %d %d %d %d)\n",
ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,
@@ -1199,9 +1200,9 @@
y += type->ShadowOffsetY;
if (type->Flip) {
if (frame < 0) {
-
VideoDrawShadowClipX(type->ShadowSprite, -frame - 1, x, y);
+ VideoDrawClipX(type->ShadowSprite,
-frame - 1, x, y);
} else {
- VideoDrawShadowClip(type->ShadowSprite,
frame, x, y);
+ VideoDrawClip(type->ShadowSprite,
frame, x, y);
}
} else {
int row;
@@ -1212,7 +1213,7 @@
} else {
frame = (frame / row) *
type->NumDirections + frame % row;
}
- VideoDrawShadowClip(type->ShadowSprite, frame,
x, y);
+ VideoDrawClip(type->ShadowSprite, frame, x, y);
}
}
return;
@@ -1233,9 +1234,9 @@
if (type->Flip) {
if (frame < 0) {
- VideoDrawShadowClipX(type->ShadowSprite, -frame
- 1, x, y);
+ VideoDrawClipX(type->ShadowSprite, -frame - 1,
x, y);
} else {
- VideoDrawShadowClip(type->ShadowSprite, frame,
x, y);
+ VideoDrawClip(type->ShadowSprite, frame, x, y);
}
} else {
int row;
@@ -1246,7 +1247,7 @@
} else {
frame = (frame / row) * type->NumDirections +
frame % row;
}
- VideoDrawShadowClip(type->ShadowSprite, frame, x, y);
+ VideoDrawClip(type->ShadowSprite, frame, x, y);
}
return;
}
@@ -1776,10 +1777,10 @@
// y += type->ShadowOffsetY;
if (unit->Type->Flip) {
if (frame < 0) {
-
VideoDrawShadowClipX(unit->Type->Construction->ShadowSprite,
+
VideoDrawClipX(unit->Type->Construction->ShadowSprite,
-frame - 1, x, y);
} else {
-
VideoDrawShadowClip(unit->Type->Construction->ShadowSprite,
+
VideoDrawClip(unit->Type->Construction->ShadowSprite,
frame, x, y);
}
} else {
@@ -1791,7 +1792,7 @@
} else {
frame = (frame / row) *
unit->Type->NumDirections + frame % row;
}
-
VideoDrawShadowClip(unit->Type->Construction->ShadowSprite, frame,
+
VideoDrawClip(unit->Type->Construction->ShadowSprite, frame,
x, y);
}
}
@@ -1803,9 +1804,9 @@
y += unit->Type->ShadowOffsetY;
if (unit->Type->Flip) {
if (frame < 0) {
-
VideoDrawShadowClipX(unit->Type->ShadowSprite, -frame - 1, x, y);
+
VideoDrawClipX(unit->Type->ShadowSprite, -frame - 1, x, y);
} else {
-
VideoDrawShadowClip(unit->Type->ShadowSprite, frame, x, y);
+ VideoDrawClip(unit->Type->ShadowSprite,
frame, x, y);
}
} else {
int row;
@@ -1816,7 +1817,7 @@
} else {
frame = (frame / row) *
unit->Type->NumDirections + frame % row;
}
- VideoDrawShadowClip(unit->Type->ShadowSprite,
frame, x, y);
+ VideoDrawClip(unit->Type->ShadowSprite, frame,
x, y);
}
}
}
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.148 stratagus/src/unit/unittype.c:1.149
--- stratagus/src/unit/unittype.c:1.148 Wed Jan 21 03:44:57 2004
+++ stratagus/src/unit/unittype.c Thu Jan 22 07:01:30 2004
@@ -26,12 +26,12 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unittype.c,v 1.148 2004/01/20 16:44:57 nobody_ Exp $
+// $Id: unittype.c,v 1.149 2004/01/21 20:01:30 jsalmon3 Exp $
//@{
/*----------------------------------------------------------------------------
--- Includes
+-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
@@ -57,7 +57,7 @@
#include "myendian.h"
/*----------------------------------------------------------------------------
--- Variables
+-- Variables
----------------------------------------------------------------------------*/
/**
@@ -1187,7 +1187,7 @@
// char** sp;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: unittypes $Id: unittype.c,v 1.148
2004/01/20 16:44:57 nobody_ Exp $\n\n");
+ CLprintf(file, "--- MODULE: unittypes $Id: unittype.c,v 1.149
2004/01/21 20:01:30 jsalmon3 Exp $\n\n");
#if 0
// Original number to internal unit-type name.
@@ -1371,6 +1371,7 @@
type->ShadowSprite = LoadSprite(file, type->ShadowWidth,
type->ShadowHeight);
FlipGraphic(type->ShadowSprite);
+ MakeShadowSprite(type->ShadowSprite);
}
if (type->Harvester) {
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.66 stratagus/src/video/sprite.c:1.67
--- stratagus/src/video/sprite.c:1.66 Wed Jan 21 17:14:07 2004
+++ stratagus/src/video/sprite.c Thu Jan 22 07:01:31 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sprite.c,v 1.66 2004/01/21 06:14:07 jsalmon3 Exp $
+// $Id: sprite.c,v 1.67 2004/01/21 20:01:31 jsalmon3 Exp $
//@{
@@ -330,63 +330,6 @@
#endif
#ifndef USE_OPENGL
-global void VideoDrawShadowClip(const Graphic* sprite, unsigned frame, int x,
int y)
-{
- SDL_Rect srect;
- SDL_Rect drect;
- int oldx;
- int oldy;
- unsigned char alpha;
-
- 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;
-
- alpha = sprite->Surface->format->alpha;
- SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, 128);
- SDL_BlitSurface(sprite->Surface, &srect, TheScreen, &drect);
- SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA | SDL_RLEACCEL, alpha);
-}
-
-global void VideoDrawShadowClipX(const Graphic* sprite, unsigned frame, int x,
int y)
-{
- SDL_Rect srect;
- SDL_Rect drect;
- int oldx;
- int oldy;
- unsigned char alpha;
-
- 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;
-
- alpha = sprite->SurfaceFlip->format->alpha;
- SDL_SetAlpha(sprite->SurfaceFlip, SDL_SRCALPHA | SDL_RLEACCEL, 128);
- SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
- SDL_SetAlpha(sprite->SurfaceFlip, SDL_SRCALPHA | SDL_RLEACCEL, alpha);
-}
-
global void VideoDrawTrans(const Graphic* sprite, unsigned frame, int x, int
y, int alpha)
{
SDL_Rect srect;
@@ -485,12 +428,6 @@
SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
}
#else
-global void VideoDrawShadowClip(const Graphic* sprite, unsigned frame, int x,
int y)
-{
-}
-global void VideoDrawShadowClipX(const Graphic* sprite, unsigned frame, int x,
int y)
-{
-}
global void VideoDrawTrans(const Graphic* sprite, unsigned frame, int x, int
y, int alpha)
{
}
@@ -595,7 +532,28 @@
}
/**
-** Init sprite
+** Make shadow sprite
+**
+** @param graphic pointer to object
+*/
+global void MakeShadowSprite(Graphic* graphic)
+{
+ SDL_Color colors[256];
+
+ // Set all colors in the palette to black and use 50% alpha
+ memset(colors, 0, sizeof(colors));
+
+ SDL_SetPalette(graphic->Surface, SDL_LOGPAL | SDL_PHYSPAL, colors, 0,
256);
+ SDL_SetAlpha(graphic->Surface, SDL_SRCALPHA | SDL_RLEACCEL, 128);
+
+ if (graphic->SurfaceFlip) {
+ SDL_SetPalette(graphic->SurfaceFlip, SDL_LOGPAL | SDL_PHYSPAL,
colors, 0, 256);
+ SDL_SetAlpha(graphic->SurfaceFlip, SDL_SRCALPHA | SDL_RLEACCEL,
128);
+ }
+}
+
+/**
+** Init sprite
*/
global void InitSprite(void)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/video.h stratagus/constru...,
address@hidden <=