stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src include/video.h map/map_draw.c vi...


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src include/video.h map/map_draw.c vi...
Date: 2 Feb 2004 17:29:59 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/02/02 17:29:59

Modified files:
        src/include    : video.h 
        src/map        : map_draw.c 
        src/video      : sdl.c video.c 

Log message:
        Fix for 8 and 24 bpp, clean up

Patches:
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.118 stratagus/src/include/video.h:1.119
--- stratagus/src/include/video.h:1.118 Sun Jan 25 09:17:46 2004
+++ stratagus/src/include/video.h       Mon Feb  2 17:29:57 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: video.h,v 1.118 2004/01/24 22:17:46 jsalmon3 Exp $
+//      $Id: video.h,v 1.119 2004/02/02 06:29:57 jsalmon3 Exp $
 
 #ifndef __VIDEO_H__
 #define __VIDEO_H__
@@ -143,9 +143,6 @@
 
 extern volatile int VideoInterrupts;
 
-       // 1 if mouse cursor is inside main window, else 0
-extern int InMainWindow;
-
        ///             Wanted videomode, fullscreen or windowed.
 extern char VideoFullScreen;
 
@@ -159,9 +156,6 @@
        ///             Unlock the screen for display
 extern void VideoUnlockScreen(void);
 
-       // 1 if mouse cursor is inside main window, else 0
-extern int InMainWindow;
-
        ///             Wanted videomode, fullscreen or windowed.
 extern char VideoFullScreen;
 
@@ -174,14 +168,6 @@
 extern int VideoDepth;
 
        /**
-       **              Architecture-dependant video bpp (bits pro pixel).
-       **              Set by InitVideoXXX. (8,16,24,32)
-       **              @see InitVideo @see InitVideoSdl
-       **              @see main
-       */
-extern int VideoBpp;
-
-       /**
        **              Architecture-dependant videomemory. Set by InitVideoXXX.
        **              FIXME: need a new function to set it, see #ifdef SDL 
code
        **              @see InitVideo @see InitVideoSdl
@@ -201,12 +187,8 @@
 #define AMASK 0xff000000
 #endif
 
-typedef unsigned char GraphicData;             /// generic graphic data type
-
        /// initialize the video part
 extern void InitVideo(void);
-
-extern void RealizeScreen(void);
 
        /// Resize a graphic
 extern void ResizeGraphic(Graphic* g, int w, int h);
Index: stratagus/src/map/map_draw.c
diff -u stratagus/src/map/map_draw.c:1.62 stratagus/src/map/map_draw.c:1.63
--- stratagus/src/map/map_draw.c:1.62   Wed Jan 21 05:41:59 2004
+++ stratagus/src/map/map_draw.c        Mon Feb  2 17:29:57 2004
@@ -29,7 +29,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//             $Id: map_draw.c,v 1.62 2004/01/20 18:41:59 nobody_ Exp $
+//             $Id: map_draw.c,v 1.63 2004/02/02 06:29:57 jsalmon3 Exp $
 
 //@{
 
@@ -1960,8 +1960,6 @@
 /**
 **             Initialize the fog of war.
 **             Build tables, setup functions.
-**
-**             @see VideoBpp
 */
 global void InitMap(void)
 {
@@ -1969,8 +1967,8 @@
        // StephanR: Using the decoration mechanism we need to support drawing 
tiles
        // clipped, as by only updating a small part of the tile, we don't have 
to
        // redraw items overlapping the remaining part of the tile.. it might 
need
-       // some performance increase though, but atleast the video dependent 
depth is
-       // not done here, making the switch(VideoBpp) obsolete..
+       // some performance increase though, but at least the video dependent 
depth is
+       // not done here..
        MapDrawTile = MapDrawXXTileClip;
        VideoDrawTile = VideoDrawXXTileClip;
        DebugLevel0Fn("Adding a big deco %d,%d - %d %d\n" _C_
Index: stratagus/src/video/sdl.c
diff -u stratagus/src/video/sdl.c:1.116 stratagus/src/video/sdl.c:1.117
--- stratagus/src/video/sdl.c:1.116     Thu Jan 15 17:44:29 2004
+++ stratagus/src/video/sdl.c   Mon Feb  2 17:29:58 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: sdl.c,v 1.116 2004/01/15 06:44:29 jsalmon3 Exp $
+//      $Id: sdl.c,v 1.117 2004/02/02 06:29:58 jsalmon3 Exp $
 
 //@{
 
@@ -87,7 +87,6 @@
 ----------------------------------------------------------------------------*/
 
 global SDL_Surface* TheScreen;                         /// Internal screen
-global int InMainWindow = 1;                           /// Cursor inside 
stratagus window
 
 local int FrameTicks;                                          /// Frame 
length in ms
 local int FrameRemainder;                              /// Frame remainder 0.1 
ms
@@ -168,30 +167,26 @@
 
 
 /**
-**             Initialize the video part for SDL.
+**  Initialize the video part for SDL.
 */
 global void InitVideoSdl(void)
 {
        Uint32 flags;
 
-       //              Initialize the SDL library
-
-
        if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
-
                if (SDL_Init(
 #ifdef USE_SDLA
-                       SDL_INIT_AUDIO |
+                               SDL_INIT_AUDIO |
 #endif
 #ifdef DEBUG
-                       SDL_INIT_NOPARACHUTE|
+                               SDL_INIT_NOPARACHUTE |
 #endif
-                       SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) {
-                       fprintf(stderr,"Couldn't initialize SDL: %s\n", 
SDL_GetError());
+                               SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) {
+                       fprintf(stderr, "Couldn't initialize SDL: %s\n", 
SDL_GetError());
                        exit(1);
                }
 
-               //              Clean up on exit
+               // Clean up on exit
 
                atexit(SDL_Quit);
 
@@ -203,10 +198,6 @@
 #endif
                // Set WindowManager Title
                SDL_WM_SetCaption("Stratagus", "Stratagus");
-       } else {
-               if (VideoBpp == 32 && VideoDepth == 24) {
-                       VideoDepth = 0;
-               }
        }
 
        // Initialize the display
@@ -227,31 +218,23 @@
 #endif
 
        TheScreen = SDL_SetVideoMode(VideoWidth, VideoHeight, VideoDepth, 
flags);
+       if (TheScreen && (TheScreen->format->BitsPerPixel == 8 ||
+                       TheScreen->format->BitsPerPixel == 24)) {
+               // Only support 16 and 32 bpp, default to 16
+               TheScreen = SDL_SetVideoMode(VideoWidth, VideoHeight, 16, 
flags);
+       }
        if (TheScreen == NULL) {
                fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
                        VideoWidth, VideoHeight, VideoDepth, SDL_GetError());
                exit(1);
        }
 
-#ifdef DEBUG
-       if (SDL_MUSTLOCK(TheScreen)) {
-               DebugLevel0Fn("Must locksurface!\n");
-       }
-#endif
+       VideoFullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0;
+       VideoDepth = TheScreen->format->BitsPerPixel;
 
        // Turn cursor off, we use our own.
        SDL_ShowCursor(0);
 
-       VideoBpp = TheScreen->format->BitsPerPixel;
-       VideoFullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0;
-
-       //
-       //              I need the used bits per pixel.
-       //              You see it's better making all self, than using wired 
libaries :)
-       //  And with the win32 version this also doesn't work
-       //
-       VideoDepth = TheScreen->format->BitsPerPixel;
-
        // Make default character translation easier
        SDL_EnableUNICODE(1);
 
@@ -271,7 +254,7 @@
 
        DebugLevel3Fn("Video init ready %d %d\n" _C_ VideoDepth _C_ VideoBpp);
 
-       // FIXME: Setup InMainWindow correct.
+       TheUI.MouseWarpX = TheUI.MouseWarpY = -1;
 }
 
 /**
@@ -516,10 +499,10 @@
 }
 
 /**
-**             Handle interactive input event.
+**  Handle interactive input event.
 **
-**             @param callbacks                Callback structure for events.
-**             @param event                            SDL event structure 
pointer.
+**  @param callbacks  Callback structure for events.
+**  @param event      SDL event structure pointer.
 */
 local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
 {
@@ -542,17 +525,17 @@
                                event->button.button);
                        break;
 
-                       // FIXME SDL: check if this is only usefull for the 
cursor
-                       //                      if this is the case we don't 
need this.
+                       // FIXME: check if this is only useful for the cursor
+                       // FIXME: if this is the case we don't need this.
                case SDL_MOUSEMOTION:
                        DebugLevel3("\tmotion notify %d,%d\n" _C_ 
event->motion.x _C_
                                event->motion.y);
                        InputMouseMove(callbacks, SDL_GetTicks(),
                                event->motion.x, event->motion.y);
                        // FIXME: Same bug fix from X11
-                       if ((TheUI.MouseWarpX != -1 || TheUI.MouseWarpY != -1)
-                               && (event->motion.x != TheUI.MouseWarpX ||
-                                       event->motion.y != TheUI.MouseWarpY)) {
+                       if ((TheUI.MouseWarpX != -1 || TheUI.MouseWarpY != -1) 
&&
+                                       (event->motion.x != TheUI.MouseWarpX ||
+                                               event->motion.y != 
TheUI.MouseWarpY)) {
                                int xw;
                                int yw;
 
@@ -566,12 +549,27 @@
                        break;
 
                case SDL_ACTIVEEVENT:
-                       DebugLevel3("\tFocus changed\n");
-                       // FIXME: Johns: I think this was not correct?
-                       // FIXME: InMainWindow = !InMainWindow;
-                       InMainWindow = event->active.gain;
-                       if (!InMainWindow) {
-                               InputMouseExit(callbacks,SDL_GetTicks());
+                       if (event->active.state & SDL_APPMOUSEFOCUS) {
+                               static int InMainWindow = 1;
+
+                               DebugLevel3("\tMouse focus changed\n");
+                               if (InMainWindow && !event->active.gain) {
+                                       InputMouseExit(callbacks, 
SDL_GetTicks());
+                               }
+                               InMainWindow = event->active.gain;
+                       }
+                       if (event->active.state & SDL_APPACTIVE) {
+                               static int IsVisible = 1;
+
+                               DebugLevel3("\tApp focus changed\n");
+                               if (IsVisible && !event->active.gain) {
+                                       IsVisible = 0;
+                                       UiTogglePause();
+                               } else if (!IsVisible && event->active.gain) {
+                                       IsVisible = 1;
+                                       UiTogglePause();
+                                       MustRedraw = RedrawEverything & 
~RedrawMinimap;
+                               }
                        }
                        break;
 
@@ -590,28 +588,6 @@
        }
 }
 
-#ifdef USE_WIN32
-/**
-**             Check if the user alt-tabbed away from the game and redraw
-**             everyhing when the user comes back.
-*/
-local void CheckScreenVisible()
-{
-       static int IsVisible = 1;
-       Uint8 state;
-
-       state = SDL_GetAppState();
-       if (IsVisible && !(state & SDL_APPACTIVE)) {
-               IsVisible = 0;
-               UiTogglePause();
-       } else if (!IsVisible && (state & SDL_APPACTIVE)) {
-               IsVisible = 1;
-               UiTogglePause();
-               MustRedraw = RedrawEverything & ~RedrawMinimap;
-       }
-}
-#endif
-
 /**
 **             Wait for interactive input event for one frame.
 **
@@ -770,10 +746,6 @@
        if (!SkipGameCycle--) {
                SkipGameCycle = SkipFrames;
        }
-
-#ifdef USE_WIN32
-       CheckScreenVisible();
-#endif
 }
 
 /**
Index: stratagus/src/video/video.c
diff -u stratagus/src/video/video.c:1.88 stratagus/src/video/video.c:1.89
--- stratagus/src/video/video.c:1.88    Thu Jan 15 13:14:08 2004
+++ stratagus/src/video/video.c Mon Feb  2 17:29:58 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: video.c,v 1.88 2004/01/15 02:14:08 jsalmon3 Exp $
+//      $Id: video.c,v 1.89 2004/02/02 06:29:58 jsalmon3 Exp $
 
 //@{
 
@@ -164,21 +164,6 @@
 global int VideoDepth;
 
        /**
-       **              Architecture-dependant video bpp (bits pro pixel).
-       **              Set by InitVideoXXX. (8,16,24,32)
-       **              @see InitVideo @see InitVideoSdl
-       **              @see main
-       */
-global int VideoBpp;
-
-       /**
-       **  Architecture-dependant video memory-size (byte pro pixel).
-       **  Set by InitVideo. (1,2,3,4 equals VideoBpp/8)
-       **  @see InitVideo
-       */
-global int VideoTypeSize;
-
-       /**
        **              Architecture-dependant videomemory. Set by InitVideoXXX.
        **              FIXME: need a new function to set it, see #ifdef SDL 
code
        **              @see InitVideo @see InitVideoSdl
@@ -186,27 +171,8 @@
        */
 global SDL_Surface* TheScreen;
 
-global int VideoSyncSpeed = 100;               /// 0 disable interrupts
-global volatile int VideoInterrupts;           /// be happy, were are quicker
-
-       /**
-       ** FIXME: this docu is added only to the first variable!
-       **
-       **  As a video 8bpp pixel color doesn't have RGB encoded, but denote 
some
-       **  index (a value from contents Pixels) in a system pallete, the
-       **  following precalculated arrays deliver a shortcut.
-       **  NOTE: all array pointers are NULL in a non 8bpp mode
-       **
-       **  lookup25trans8:
-       **  Array to get from two system colors as unsigned int 
(color1<<8)|color2
-       **  to a new system color which is aproximately 75% color1 and 25% 
color2.
-       **  lookup50trans8:
-       **  The same for 50% color1 and 50% color2.
-       */
-       // FIXME: docu
-global SDL_Color* lookup25trans8;
-       // FIXME: docu
-global SDL_Color* lookup50trans8;
+global int VideoSyncSpeed = 100;            /// 0 disable interrupts
+global volatile int VideoInterrupts;        /// be happy, were are quicker
 
 global int ColorWaterCycleStart;
 global int ColorWaterCycleEnd;




reply via email to

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