[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video graphic.c video.c
From: |
Nehal Mistry |
Subject: |
[Stratagus-CVS] stratagus/src/video graphic.c video.c |
Date: |
Thu, 27 Nov 2003 17:00:01 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Nehal Mistry <address@hidden> 03/11/27 17:00:01
Modified files:
src/video : graphic.c video.c
Log message:
add color cycling support for new video code
Patches:
Index: stratagus/src/video/graphic.c
diff -u stratagus/src/video/graphic.c:1.54 stratagus/src/video/graphic.c:1.55
--- stratagus/src/video/graphic.c:1.54 Sat Nov 22 17:58:27 2003
+++ stratagus/src/video/graphic.c Thu Nov 27 17:00:01 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: graphic.c,v 1.54 2003/11/22 22:58:27 nehalmistry Exp $
+// $Id: graphic.c,v 1.55 2003/11/27 22:00:01 nehalmistry Exp $
//@{
@@ -889,6 +889,7 @@
// graphic->Surface->format->palette =
// VideoCreateSharedPalette(graphic->Surface->format->palette);
graphic->NumFrames = 1;
+ VideoPaletteListAdd(graphic->Surface);
#else
graphic->Pixels = VideoCreateSharedPalette(graphic->Palette);
//free(graphic->Palette);
Index: stratagus/src/video/video.c
diff -u stratagus/src/video/video.c:1.75 stratagus/src/video/video.c:1.76
--- stratagus/src/video/video.c:1.75 Sun Nov 23 15:08:48 2003
+++ stratagus/src/video/video.c Thu Nov 27 17:00:01 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.c,v 1.75 2003/11/23 20:08:48 jsalmon3 Exp $
+// $Id: video.c,v 1.76 2003/11/27 22:00:01 nehalmistry Exp $
//@{
@@ -506,7 +506,28 @@
** @return A palette in hardware dependend format.
*/
#ifdef USE_SDL_SURFACE
+global void VideoPaletteListAdd(SDL_Surface* surface)
+{
+ PaletteLink* curlink;
+
+ curlink = malloc(sizeof(PaletteLink));
+
+ curlink->Surface = surface;
+ curlink->Prev = PaletteList;
+
+ PaletteList = curlink;
+}
+
+global void VideoPaletteListClean()
+{
+ PaletteLink* curlink;
+ while (PaletteList) {
+ curlink = PaletteList->Prev;
+ free(PaletteList);
+ PaletteList = curlink;
+ }
+}
#else
global VMemType* VideoCreateSharedPalette(const Palette* palette)
{
@@ -703,16 +724,84 @@
// 205-207 cycle (lights on christmas tree)
// 240-244 cycle (water around ships, Runestone, Dark Portal)
+#ifdef USE_SDL_SURFACE
/**
-** Color cycle for 8 bpp video mode.
+** Color cycle.
**
** FIXME: Also icons and some units use color cycling.
-** FIXME: must be configured by the tileset or global.
*/
-#ifdef USE_SDL_SURFACE
+// FIXME: cpu intensive to go through the whole PaletteList
local void ColorCycle(void)
{
- // FIXME: todo
+ int i;
+ SDL_Palette* pal;
+ SDL_Color c;
+
+ if (ColorCycleAll) {
+ PaletteLink* curlink;
+
+ curlink = PaletteList;
+ while (curlink != NULL) {
+ pal = curlink->Surface->format->palette;
+
+ c = pal->colors[ColorWaterCycleStart];
+ for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd; ++i) {
+ SDL_SetPalette(curlink->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &pal->colors[i + 1], i, 1);
+ }
+ SDL_SetPalette(curlink->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &c, ColorWaterCycleEnd, 1);
+
+ c = pal->colors[ColorIconCycleStart];
+ for (i = ColorIconCycleStart; i < ColorIconCycleEnd; ++i) {
+ SDL_SetPalette(curlink->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &pal->colors[i + 1], i, 1);
+ }
+ SDL_SetPalette(curlink->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &c, ColorIconCycleEnd, 1);
+
+ c = pal->colors[ColorBuildingCycleStart];
+ for (i = ColorBuildingCycleStart; i < ColorBuildingCycleEnd; ++i) {
+ SDL_SetPalette(curlink->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &pal->colors[i + 1], i, 1);
+ }
+ SDL_SetPalette(curlink->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &c, ColorBuildingCycleEnd, 1);
+
+ curlink = curlink->Prev;
+ }
+ } else {
+ //
+ // Color cycle tileset palette
+ //
+ pal = TheMap.TileGraphic->Surface->format->palette;
+
+ c = pal->colors[ColorWaterCycleStart];
+ for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd; ++i) {
+ SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL |
SDL_PHYSPAL,
+ &pal->colors[i + 1], i, 1);
+ }
+ SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &c, ColorWaterCycleEnd, 1);
+
+ c = pal->colors[ColorIconCycleStart];
+ for (i = ColorIconCycleStart; i < ColorIconCycleEnd; ++i) {
+ SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL |
SDL_PHYSPAL,
+ &pal->colors[i + 1], i, 1);
+ }
+ SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &c, ColorIconCycleEnd, 1);
+
+ c = pal->colors[ColorBuildingCycleStart];
+ for (i = ColorBuildingCycleStart; i < ColorBuildingCycleEnd; ++i) {
+ SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL |
SDL_PHYSPAL,
+ &pal->colors[i + 1], i, 1);
+ }
+ SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL | SDL_PHYSPAL,
+ &c, ColorBuildingCycleEnd, 1);
+ }
+
+ MapColorCycle(); // FIXME: could be little more informative
MustRedraw |= RedrawColorCycle;
}
#else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/video graphic.c video.c,
Nehal Mistry <=