stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src movie/movie.c video/sdl.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src movie/movie.c video/sdl.c
Date: Wed, 19 Nov 2003 22:05:48 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/11/19 22:05:48

Modified files:
        src/movie      : movie.c 
        src/video      : sdl.c 

Log message:
        Renamed Screen to TheScreen, merged with USE_SDL_SURFACE

Patches:
Index: stratagus/src/movie/movie.c
diff -u stratagus/src/movie/movie.c:1.18 stratagus/src/movie/movie.c:1.19
--- stratagus/src/movie/movie.c:1.18    Mon Nov 17 14:14:37 2003
+++ stratagus/src/movie/movie.c Wed Nov 19 22:05:47 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: movie.c,v 1.18 2003/11/17 19:14:37 nehalmistry Exp $
+//     $Id: movie.c,v 1.19 2003/11/20 03:05:47 jsalmon3 Exp $
 
 //@{
 
@@ -57,11 +57,7 @@
 
 #ifdef USE_SDL                         /// Only supported with SDL for now
 
-#ifdef USE_SDL_SURFACE
 extern SDL_Surface* TheScreen; /// internal screen
-#else
-extern SDL_Surface* Screen;    /// internal screen
-#endif
 
 /*----------------------------------------------------------------------------
 --     Defines
@@ -250,13 +246,8 @@
     if (flags & PlayMovieFullScreen) {
        DebugLevel0Fn("FIXME: full screen switch not supported\n");
     }
-#ifdef USE_SDL_SURFACE
     overlay = SDL_CreateYUVOverlay(avi->Width, avi->Height,
        SDL_YV12_OVERLAY, TheScreen);
-#else
-    overlay = SDL_CreateYUVOverlay(avi->Width, avi->Height,
-       SDL_YV12_OVERLAY, Screen);
-#endif
     if (!overlay) {
        fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
        exit(1);
Index: stratagus/src/video/sdl.c
diff -u stratagus/src/video/sdl.c:1.104 stratagus/src/video/sdl.c:1.105
--- stratagus/src/video/sdl.c:1.104     Mon Nov 17 14:35:25 2003
+++ stratagus/src/video/sdl.c   Wed Nov 19 22:05:48 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: sdl.c,v 1.104 2003/11/17 19:35:25 nehalmistry Exp $
+//     $Id: sdl.c,v 1.105 2003/11/20 03:05:48 jsalmon3 Exp $
 
 //@{
 
@@ -82,11 +82,7 @@
 --     Variables
 ----------------------------------------------------------------------------*/
 
-#ifdef USE_SDL_SURFACE
 global SDL_Surface* TheScreen;         /// Internal screen
-#else
-global SDL_Surface* Screen;            /// Internal screen
-#endif
 global int InMainWindow = 1;           /// Cursor inside stratagus window
 
 local int FrameTicks;                  /// Frame length in ms
@@ -207,46 +203,30 @@
     flags |= SDL_OPENGL;
 #endif
 
-#ifdef USE_SDL_SURFACE
     TheScreen = SDL_SetVideoMode(VideoWidth, VideoHeight, VideoDepth, flags);
-#else
-    Screen = SDL_SetVideoMode(VideoWidth, VideoHeight, VideoDepth, flags);
-
-    if (Screen == NULL) {
+    if (TheScreen == NULL) {
        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
            VideoWidth, VideoHeight, VideoDepth, SDL_GetError());
        exit(1);
     }
-#endif
 
 #ifdef USE_SDL_SURFACE
-//    TheScreen = TheScreen;
-    if (VideoDepth == 8)
-    TheScreen->format->palette = &GlobalPalette;
+    if (VideoDepth == 8) {
+       TheScreen->format->palette = &GlobalPalette;
+    }
 #endif
 
 #ifdef DEBUG
-#ifdef USE_SDL_SURFACE
     if (SDL_MUSTLOCK(TheScreen)) {
        DebugLevel0Fn("Must locksurface!\n");
     }
-#else
-    if (SDL_MUSTLOCK(Screen)) {
-       DebugLevel0Fn("Must locksurface!\n");
-    }
-#endif
 #endif
 
     // Turn cursor off, we use our own.
     SDL_ShowCursor(0);
 
-#ifdef USE_SDL_SURFACE
     VideoBpp = TheScreen->format->BitsPerPixel;
     VideoFullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0;
-#else
-    VideoBpp = Screen->format->BitsPerPixel;
-    VideoFullScreen = (Screen->flags & SDL_FULLSCREEN) ? 1 : 0;
-#endif
 
     //
     // I need the used bits per pixel.
@@ -261,19 +241,19 @@
        int j;
 
        DebugLevel3Fn("Mask R%x G%x B%x\n" _C_
-           Screen->format->Rmask _C_
-           Screen->format->Gmask _C_
-           Screen->format->Bmask);
-
-       if (Screen->format->BitsPerPixel > 8) {
-           j = Screen->format->Rmask | Screen->format->Gmask |
-               Screen->format->Bmask;
+           TheScreen->format->Rmask _C_
+           TheScreen->format->Gmask _C_
+           TheScreen->format->Bmask);
+
+       if (TheScreen->format->BitsPerPixel > 8) {
+           j = TheScreen->format->Rmask | TheScreen->format->Gmask |
+               TheScreen->format->Bmask;
 
            for (i = 0; j & (1 << i); ++i) {
            }
            VideoDepth = i;
        } else {
-           VideoDepth = Screen->format->BitsPerPixel;
+           VideoDepth = TheScreen->format->BitsPerPixel;
        }
     }
 #endif
@@ -310,9 +290,6 @@
 */
 global void InvalidateArea(int x, int y, int w, int h)
 {
-#ifdef USE_SDL_SURFACE
-    SDL_UpdateRect(TheScreen, x, y, w, h);
-#else
 #ifndef USE_OPENGL
     // FIXME: This checks should be done at higher level
     // FIXME: did SDL version >1.1, check this now also?
@@ -336,8 +313,7 @@
     if (h <= 0) {
        return;
     }
-    SDL_UpdateRect(Screen, x, y, w, h);
-#endif
+    SDL_UpdateRect(TheScreen, x, y, w, h);
 #endif
 }
 
@@ -347,11 +323,7 @@
 global void Invalidate(void)
 {
 #ifndef USE_OPENGL
-#ifdef USE_SDL_SURFACE
     SDL_UpdateRect(TheScreen, 0, 0, VideoWidth, VideoHeight);
-#else
-    SDL_UpdateRect(Screen, 0, 0, VideoWidth, VideoHeight);
-#endif
 #endif
 }
 
@@ -638,8 +610,7 @@
     if (IsVisible && !(state & SDL_APPACTIVE)) {
        IsVisible = 0;
        UiTogglePause();
-    }
-    else if (!IsVisible && (state & SDL_APPACTIVE)) {
+    } else if (!IsVisible && (state & SDL_APPACTIVE)) {
        IsVisible = 1;
        UiTogglePause();
        MustRedraw = RedrawEverything & ~RedrawMinimap;
@@ -801,7 +772,7 @@
     // Prepare return, time for one frame is over.
     //
     VideoInterrupts = 0;
-    
+
     if (!SkipGameCycle--) {
        SkipGameCycle = SkipFrames;
     }
@@ -837,13 +808,8 @@
     VMemType c;
     unsigned long map;
 
-#ifdef USE_SDL_SURFACE
     DebugCheck(!TheScreen);
     map = SDL_MapRGB(TheScreen->format, r, g, b);
-#else
-    DebugCheck(!Screen);
-    map = SDL_MapRGB(Screen->format, r, g, b);
-#endif
 
     memcpy(&c, &map, sizeof(c));
     return c;
@@ -872,7 +838,7 @@
     int i;
     void* pixels;
 
-    if (!Screen) {                     // no init
+    if (!TheScreen) {                  // no init
        return NULL;
     }
 
@@ -929,24 +895,24 @@
        // -> Video
        switch (VideoBpp) {
            case 8:
-               ((VMemType8 *) pixels)[i] =
-                   SDL_MapRGB(Screen->format, r, g, b);
+               ((VMemType8*)pixels)[i] =
+                   SDL_MapRGB(TheScreen->format, r, g, b);
                break;
            case 15:
            case 16:
-               ((VMemType16 *) pixels)[i] =
-                   SDL_MapRGB(Screen->format, r, g, b);
+               ((VMemType16*)pixels)[i] =
+                   SDL_MapRGB(TheScreen->format, r, g, b);
                break;
            case 24:
-               v = SDL_MapRGB(Screen->format, r, g, b);
+               v = SDL_MapRGB(TheScreen->format, r, g, b);
                vp = (char *)(&v);
-               ((VMemType24 *) pixels)[i].a = vp[0];   // endian safe ?
-               ((VMemType24 *) pixels)[i].b = vp[1];
-               ((VMemType24 *) pixels)[i].c = vp[2];
+               ((VMemType24*)pixels)[i].a = vp[0];     // endian safe ?
+               ((VMemType24*)pixels)[i].b = vp[1];
+               ((VMemType24*)pixels)[i].c = vp[2];
                break;
            case 32:
-               ((VMemType32 *) pixels)[i] =
-                   SDL_MapRGB(Screen->format, r, g, b);
+               ((VMemType32*)pixels)[i] =
+                   SDL_MapRGB(TheScreen->format, r, g, b);
                break;
        }
     }
@@ -982,11 +948,9 @@
 global void SdlLockScreen(void)
 {
 #ifndef USE_OPENGL
-#ifdef USE_SDL_SURFACE
     SDL_LockSurface(TheScreen);
-#else
-    SDL_LockSurface(Screen);
-    VideoMemory = Screen->pixels;
+#ifndef USE_SDL_SURFACE
+    VideoMemory = TheScreen->pixels;
 #endif
 #endif
 }
@@ -997,14 +961,12 @@
 global void SdlUnlockScreen(void)
 {
 #ifndef USE_OPENGL
-#ifdef USE_SDL_SURFACE
     SDL_UnlockSurface(TheScreen);
-#else
-    SDL_UnlockSurface(Screen);
+#ifndef USE_SDL_SURFACE
 #ifdef DEBUG
     VideoMemory = NULL;                        // Catch errors!
 #else
-    VideoMemory = Screen->pixels;      // Be kind
+    VideoMemory = TheScreen->pixels;   // Be kind
 #endif
 #endif
 #endif
@@ -1050,58 +1012,32 @@
     int ncolors;
 #endif
 
-#ifdef USE_SDL_SURFACE
     if (!TheScreen) {                  // don't bother if there's no surface.
        return;
     }
-#else
-    if (!Screen) {                     // don't bother if there's no surface.
-       return;
-    }
-#endif
 
-#ifdef USE_SDL_SURFACE
     flags = TheScreen->flags;
     w = TheScreen->w;
     h = TheScreen->h;
     bpp = TheScreen->format->BitsPerPixel;
 
     SDL_GetClipRect(TheScreen, &clip);
-#else
-    flags = Screen->flags;
-    w = Screen->w;
-    h = Screen->h;
-    bpp = Screen->format->BitsPerPixel;
-
-    SDL_GetClipRect(Screen, &clip);
-#endif
 
     // save the contents of the screen.
-#ifdef USE_SDL_SURFACE
     framesize = w * h * TheScreen->format->BytesPerPixel;
-#else
-    framesize = w * h * Screen->format->BytesPerPixel;
-#endif
 
 #ifndef USE_OPENGL
     if (!(pixels = malloc(framesize))) {       // out of memory
        return;
     }
-#ifdef USE_SDL_SURFACE
     SDL_LockSurface(TheScreen);
     memcpy(pixels, TheScreen->pixels, framesize);
-#else
-    SDL_LockSurface(Screen);
-    memcpy(pixels, Screen->pixels, framesize);
-#endif
-#else
 
 #ifdef DEBUG
     // shut up compiler
     palette = NULL;
     ncolors=0;
 #endif
-#ifdef USE_SDL_SURFACE
     if (TheScreen->format->palette) {
        ncolors = TheScreen->format->palette->ncolors;
        if (!(palette = malloc(ncolors * sizeof(SDL_Color)))) {
@@ -1112,21 +1048,8 @@
            ncolors * sizeof(SDL_Color));
     }
     SDL_UnlockSurface(TheScreen);
-#else
-    if (Screen->format->palette) {
-       ncolors = Screen->format->palette->ncolors;
-       if (!(palette = malloc(ncolors * sizeof(SDL_Color)))) {
-           free(pixels);
-           return;
-       }
-       memcpy(palette, Screen->format->palette->colors,
-           ncolors * sizeof(SDL_Color));
-    }
-    SDL_UnlockSurface(Screen);
-#endif
 #endif
 
-#ifdef USE_SDL_SURFACE
     TheScreen = SDL_SetVideoMode(w, h, bpp, flags ^ SDL_FULLSCREEN);
     if (!TheScreen) {
        TheScreen = SDL_SetVideoMode(w, h, bpp, flags);
@@ -1141,22 +1064,6 @@
            Exit(-1);
        }
     }
-#else
-    Screen = SDL_SetVideoMode(w, h, bpp, flags ^ SDL_FULLSCREEN);
-    if (!Screen) {
-       Screen = SDL_SetVideoMode(w, h, bpp, flags);
-       if (!Screen) {          // completely screwed.
-#ifndef USE_OPENGL
-           free(pixels);
-           if (Screen->format->palette) {
-               free(palette);
-           }
-#endif
-           fprintf(stderr, "Toggle to fullscreen, crashed all\n");
-           Exit(-1);
-       }
-    }
-#endif
 
     // Windows shows the SDL cursor when starting in fullscreen mode
     // then switching to window mode.  This hides the cursor again.
@@ -1166,7 +1073,6 @@
 #ifdef USE_OPENGL
     InitOpenGL();
 #else
-#ifdef USE_SDL_SURFACE
     SDL_LockSurface(TheScreen);
     memcpy(TheScreen->pixels, pixels, framesize);
     free(pixels);
@@ -1177,42 +1083,16 @@
        free(palette);
     }
     SDL_UnlockSurface(TheScreen);
-#else
-    SDL_LockSurface(Screen);
-    memcpy(Screen->pixels, pixels, framesize);
-    free(pixels);
-
-    if (Screen->format->palette) {
-       // !!! FIXME : No idea if that flags param is right.
-       SDL_SetPalette(Screen, SDL_LOGPAL, palette, 0, ncolors);
-       free(palette);
-    }
-    SDL_UnlockSurface(Screen);
-#endif
 #endif
 
-#ifdef USE_SDL_SURFACE
     SDL_SetClipRect(TheScreen, &clip);
-#else
-    SDL_SetClipRect(Screen, &clip);
-#endif
 
     Invalidate();                      // Update display
-#else
-#ifdef USE_SDL_SURFACE
+#else  // !USE_WIN32
     SDL_WM_ToggleFullScreen(TheScreen);
-#else
-    SDL_WM_ToggleFullScreen(Screen);
 #endif
 
-#endif
-#ifdef USE_SDL_SURFACE
     VideoFullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0;
-#else
-    VideoFullScreen = (Screen->flags & SDL_FULLSCREEN) ? 1 : 0;
-#endif
-
-
 }
 
 #endif // } USE_SDL




reply via email to

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