Implemented screen transitions aka. crossfading

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@72 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-09-23 22:49:56 +00:00
parent fe329193b7
commit 337b750b43
8 changed files with 250 additions and 101 deletions
+10 -14
View File
@@ -31,7 +31,8 @@ static struct
} tc; } tc;
} TaskControl; } TaskControl;
static int cur = FADE_NORMAL_INTENSITY, end, XForming; volatile int FadeAmount = FADE_NORMAL_INTENSITY;
static volatile int end, XForming;
DWORD* _varPLUTs; DWORD* _varPLUTs;
static unsigned int varPLUTsize = VARPLUTS_SIZE; static unsigned int varPLUTsize = VARPLUTS_SIZE;
@@ -41,22 +42,17 @@ static TFB_Palette cmap_rgb[256];
static int cmap_type = 0; static int cmap_type = 0;
int TFB_GetFadeAmount () BOOLEAN TFB_HasColorMap (void)
{
return cur;
}
BOOLEAN TFB_HasColorMap ()
{ {
return has_colormap; return has_colormap;
} }
int TFB_GetColorMapType () int TFB_GetColorMapType (void)
{ {
return cmap_type; return cmap_type;
} }
void TFB_ReleaseColorMap () void TFB_ReleaseColorMap (void)
{ {
//fprintf (stderr, "TFB_ReleaseColorMap()\n"); //fprintf (stderr, "TFB_ReleaseColorMap()\n");
has_colormap = FALSE; has_colormap = FALSE;
@@ -172,8 +168,8 @@ SetColorMap (COLORMAPPTR map, int type)
return TRUE; return TRUE;
} }
static static int
int xform_clut_task (void *data) xform_clut_task (void *data)
{ {
SIZE TDelta, TTotal; SIZE TDelta, TTotal;
DWORD CurTime; DWORD CurTime;
@@ -197,8 +193,8 @@ int xform_clut_task (void *data)
if (!XForming || (TDelta = (SIZE)(CurTime - StartTime)) > TTotal) if (!XForming || (TDelta = (SIZE)(CurTime - StartTime)) > TTotal)
TDelta = TTotal; TDelta = TTotal;
cur += (end - cur) * TDelta / TTotal; FadeAmount += (end - FadeAmount) * TDelta / TTotal;
//fprintf (stderr, "xform_clut_task cur %d\n", cur); //fprintf (stderr, "xform_clut_task FadeAmount %d\n", FadeAmount);
} while (TTotal -= TDelta && (!Task_ReadState (task, TASK_EXIT))); } while (TTotal -= TDelta && (!Task_ReadState (task, TASK_EXIT)));
} }
@@ -243,7 +239,7 @@ XFormColorMap (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
(TaskControl.tc.XFormTask = AssignTask (xform_clut_task, (TaskControl.tc.XFormTask = AssignTask (xform_clut_task,
1024, "transform colormap")) == 0) 1024, "transform colormap")) == 0)
{ {
cur = end; FadeAmount = end;
TimeOut = GetTimeCounter (); TimeOut = GetTimeCounter ();
} }
else else
+1 -1
View File
@@ -51,8 +51,8 @@ enum
}; };
extern DWORD* _varPLUTs; extern DWORD* _varPLUTs;
extern volatile int FadeAmount;
int TFB_GetFadeAmount (void);
BOOLEAN TFB_HasColorMap (void); BOOLEAN TFB_HasColorMap (void);
int TFB_GetColorMapType (void); int TFB_GetColorMapType (void);
void TFB_ReleaseColorMap (void); void TFB_ReleaseColorMap (void);
+69 -5
View File
@@ -19,9 +19,13 @@
#ifdef GFXMODULE_SDL #ifdef GFXMODULE_SDL
#include "sdl_common.h" #include "sdl_common.h"
#include "pure.h"
#include "opengl.h"
int batch_depth = 0; int batch_depth = 0;
static Task transition_task;
//Status: Not entirely unimplemented! //Status: Not entirely unimplemented!
BOOLEAN BOOLEAN
@@ -79,11 +83,13 @@ FlushGraphics (void)
void void
SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :) SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :)
{ {
//fprintf(stderr, "SetGraphicUseOtherExtra %d\n", other);
} }
void void
SetGraphicGrabOther (int grab_other) SetGraphicGrabOther (int grab_other)
{ {
//fprintf(stderr, "SetGraphicGrabOther %d\n", grab_other);
} }
// Status: Unimplemented // Status: Unimplemented
@@ -91,14 +97,72 @@ void
SetGraphicStrength (int numerator, int denominator) SetGraphicStrength (int numerator, int denominator)
// I just hope numerator always = denominator... // I just hope numerator always = denominator...
{ {
//fprintf (stderr, "Unimplemented function activated: SetGraphicsStrength(), %d %d\n",numerator,denominator); //fprintf (stderr, "SetGraphicsStrength, %d %d\n",numerator, denominator);
} }
//Status: Unimplemented static int
void transition_task_func (void *data)
ScreenTransition (int TransType, PRECT pRect) //TransType==3
{ {
//fprintf (stderr, "Unimplemented function activated: ScreenTransition()\n"); const float TRANSITION_SPEED = 2.5f;
Uint32 last_time = 0, current_time, delta_time, add_amount;
Task task = (Task)data;
last_time = SDL_GetTicks ();
TransitionAmount = 0;
for (;;)
{
SleepThread (10);
current_time = SDL_GetTicks ();
delta_time = current_time - last_time;
last_time = current_time;
add_amount = (Uint32)(delta_time / TRANSITION_SPEED);
if (TransitionAmount + add_amount >= 255)
break;
TransitionAmount += add_amount;
}
TransitionAmount = -1;
FinishTask (task);
return 0;
}
// Status: Implemented
void
ScreenTransition (int TransType, PRECT pRect)
{
//fprintf(stderr, "ScreenTransition %d\n", TransType);
if (TransitionAmount == -1)
{
if (pRect)
{
TransitionClipRect.x = pRect->corner.x;
TransitionClipRect.y = pRect->corner.y;
TransitionClipRect.w = pRect->extent.width;
TransitionClipRect.h = pRect->extent.height;
}
else
{
TransitionClipRect.x = TransitionClipRect.y = 0;
TransitionClipRect.w = ScreenWidth;
TransitionClipRect.h = ScreenHeight;
}
SDL_BlitSurface (SDL_Screen, &TransitionClipRect, TransitionScreen, &TransitionClipRect);
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
{
TFB_GL_UploadTransitionScreen ();
}
#endif
transition_task = AssignTask (transition_task_func, 1024, "screen transition");
}
} }
void void
+131 -75
View File
@@ -24,7 +24,9 @@ static SDL_Surface *format_conv_surf;
static int ScreenFilterMode; static int ScreenFilterMode;
static unsigned int DisplayTexture; static unsigned int DisplayTexture;
static unsigned int TransitionTexture;
static BOOLEAN tveffect; static BOOLEAN tveffect;
static BOOLEAN upload_transitiontexture = FALSE;
int int
@@ -55,33 +57,33 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
ScreenWidthActual = width; ScreenWidthActual = width;
ScreenHeightActual = height; ScreenHeightActual = height;
switch(bpp) { switch (bpp) {
case 8: case 8:
fprintf (stderr, "bpp of 8 not supported under OpenGL\n"); fprintf (stderr, "bpp of 8 not supported under OpenGL\n");
exit(-1); exit(-1);
case 15: case 15:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
break; break;
case 16: case 16:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 6);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
break; break;
case 24: case 24:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8);
break; break;
case 32: case 32:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8);
break; break;
} }
@@ -100,7 +102,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
fprintf (stderr, "Couldn't set OpenGL %ix%ix%i video mode: %s\n", fprintf (stderr, "Couldn't set OpenGL %ix%ix%i video mode: %s\n",
ScreenWidthActual, ScreenHeightActual, bpp, ScreenWidthActual, ScreenHeightActual, bpp,
SDL_GetError ()); SDL_GetError ());
exit(-1); exit (-1);
} }
else else
{ {
@@ -109,27 +111,34 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
SDL_GetVideoSurface()->format->BitsPerPixel); SDL_GetVideoSurface()->format->BitsPerPixel);
fprintf (stderr, "OpenGL renderer: %s version: %s\n", fprintf (stderr, "OpenGL renderer: %s version: %s\n",
glGetString(GL_RENDERER), glGetString(GL_VERSION)); glGetString (GL_RENDERER), glGetString (GL_VERSION));
} }
SDL_Screen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32, SDL_Screen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24,
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
if (SDL_Screen == NULL) if (SDL_Screen == NULL)
{ {
fprintf (stderr, "Couldn't create back buffer: %s\n", fprintf (stderr, "Couldn't create back buffer: %s\n", SDL_GetError());
SDL_GetError()); exit (-1);
exit(-1);
} }
ExtraScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32, ExtraScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24,
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
if (ExtraScreen == NULL) if (ExtraScreen == NULL)
{ {
fprintf (stderr, "Couldn't create workspace buffer: %s\n", fprintf (stderr, "Couldn't create workspace buffer: %s\n", SDL_GetError());
SDL_GetError()); exit (-1);
exit(-1); }
TransitionScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24,
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
if (TransitionScreen == NULL)
{
fprintf (stderr, "Couldn't create transition buffer: %s\n", SDL_GetError());
exit (-1);
} }
format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32, format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32,
@@ -137,8 +146,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
if (format_conv_surf == NULL) if (format_conv_surf == NULL)
{ {
fprintf (stderr, "Couldn't create format_conv_surf: %s\n", fprintf (stderr, "Couldn't create format_conv_surf: %s\n", SDL_GetError());
SDL_GetError());
exit(-1); exit(-1);
} }
@@ -160,84 +168,134 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
glDisable (GL_DITHER); glDisable (GL_DITHER);
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glGenTextures(1,&DisplayTexture); glGenTextures (1, &DisplayTexture);
glBindTexture(GL_TEXTURE_2D, DisplayTexture); glBindTexture (GL_TEXTURE_2D, DisplayTexture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 512, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 512, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
glGenTextures (1, &TransitionTexture);
glBindTexture (GL_TEXTURE_2D, TransitionTexture);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 512, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
return 0; return 0;
} }
void TFB_GL_UploadTransitionScreen (void)
{
upload_transitiontexture = TRUE;
}
void void
TFB_GL_TVEffect() TFB_GL_TVEffect (void)
{ {
int y; int y;
glDisable(GL_TEXTURE_2D); glDisable (GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable (GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ONE); glBlendFunc (GL_DST_COLOR, GL_ONE);
glColor3f(0.5, 0.5, 0.5); glColor3f (0.5, 0.5, 0.5);
for (y = 0; y < ScreenHeightActual; y += 2) for (y = 0; y < ScreenHeightActual; y += 2)
{ {
glBegin(GL_LINES); glBegin (GL_LINES);
glVertex2i(0, y); glVertex2i (0, y);
glVertex2i(ScreenWidthActual, y); glVertex2i (ScreenWidthActual, y);
glEnd(); glEnd ();
} }
} }
void void
TFB_GL_DrawQuad () TFB_GL_DrawQuad (void)
{ {
glBegin(GL_TRIANGLE_FAN); glBegin (GL_TRIANGLE_FAN);
glTexCoord2f(0, 0); glTexCoord2f (0, 0);
glVertex2i(0, 0); glVertex2i (0, 0);
glTexCoord2f(ScreenWidth / 512.0f, 0); glTexCoord2f (ScreenWidth / 512.0f, 0);
glVertex2i(ScreenWidthActual, 0); glVertex2i (ScreenWidthActual, 0);
glTexCoord2f(ScreenWidth / 512.0f, ScreenHeight / 256.0f); glTexCoord2f (ScreenWidth / 512.0f, ScreenHeight / 256.0f);
glVertex2i(ScreenWidthActual, ScreenHeightActual); glVertex2i (ScreenWidthActual, ScreenHeightActual);
glTexCoord2f(0, ScreenHeight / 256.0f); glTexCoord2f (0, ScreenHeight / 256.0f);
glVertex2i(0, ScreenHeightActual); glVertex2i (0, ScreenHeightActual);
glEnd(); glEnd ();
} }
void void
TFB_GL_SwapBuffers () TFB_GL_SwapBuffers (void)
{ {
int fade_amount; int fade_amount;
int transition_amount;
glMatrixMode(GL_PROJECTION); glMatrixMode (GL_PROJECTION);
glLoadIdentity(); glLoadIdentity ();
glOrtho (0,ScreenWidthActual,ScreenHeightActual, 0, -1, 1); glOrtho (0,ScreenWidthActual,ScreenHeightActual, 0, -1, 1);
glMatrixMode(GL_MODELVIEW); glMatrixMode (GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity ();
glBindTexture(GL_TEXTURE_2D, DisplayTexture); glBindTexture (GL_TEXTURE_2D, DisplayTexture);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ScreenFilterMode);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ScreenFilterMode);
SDL_LockSurface(SDL_Screen); glEnable (GL_TEXTURE_2D);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth,ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, SDL_Screen->pixels); glDisable (GL_BLEND);
SDL_UnlockSurface(SDL_Screen); glColor4f (1, 1, 1, 1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); SDL_LockSurface (SDL_Screen);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ScreenFilterMode); glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ScreenFilterMode); GL_RGB, GL_UNSIGNED_BYTE, SDL_Screen->pixels);
SDL_UnlockSurface (SDL_Screen);
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glColor4f(1,1,1,1);
TFB_GL_DrawQuad (); TFB_GL_DrawQuad ();
fade_amount = TFB_GetFadeAmount (); transition_amount = TransitionAmount;
if (transition_amount != -1)
{
float scale_x = (ScreenWidthActual / (float)ScreenWidth);
float scale_y = (ScreenHeightActual / (float)ScreenHeight);
glBindTexture(GL_TEXTURE_2D, TransitionTexture);
if (upload_transitiontexture)
{
SDL_LockSurface (TransitionScreen);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight,
GL_RGB, GL_UNSIGNED_BYTE, TransitionScreen->pixels);
SDL_UnlockSurface (TransitionScreen);
upload_transitiontexture = FALSE;
}
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ScreenFilterMode);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ScreenFilterMode);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f (1, 1, 1, (255 - transition_amount) / 255.0f);
glScissor (
(GLint) (TransitionClipRect.x * scale_x),
(GLint) ((ScreenHeight - (TransitionClipRect.y + TransitionClipRect.h)) * scale_y),
(GLsizei) (TransitionClipRect.w * scale_x),
(GLsizei) (TransitionClipRect.h * scale_y)
);
glEnable (GL_SCISSOR_TEST);
TFB_GL_DrawQuad ();
glDisable (GL_SCISSOR_TEST);
}
fade_amount = FadeAmount;
if (fade_amount != 255) if (fade_amount != 255)
{ {
float c; float c;
@@ -245,27 +303,25 @@ TFB_GL_SwapBuffers ()
if (fade_amount < 255) if (fade_amount < 255)
{ {
c = fade_amount / 255.0f; c = fade_amount / 255.0f;
glBlendFunc(GL_DST_COLOR, GL_ZERO); glBlendFunc (GL_DST_COLOR, GL_ZERO);
} }
else else
{ {
c = (fade_amount - 255) / 255.0f; c = (fade_amount - 255) / 255.0f;
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc (GL_ONE, GL_ONE);
} }
glColor3f(c, c, c); glDisable (GL_TEXTURE_2D);
glDisable(GL_TEXTURE_2D); glEnable (GL_BLEND);
glEnable(GL_BLEND); glColor4f (c, c, c, 1);
//fprintf (stderr, "fade_amount %d c %f\n",fade_amount, c);
TFB_GL_DrawQuad (); TFB_GL_DrawQuad ();
} }
if (tveffect) if (tveffect)
TFB_GL_TVEffect(); TFB_GL_TVEffect ();
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers ();
} }
SDL_Surface* SDL_Surface*
+2 -1
View File
@@ -22,7 +22,8 @@
#include "libs/graphics/sdl/sdl_common.h" #include "libs/graphics/sdl/sdl_common.h"
int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp); int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp);
void TFB_GL_SwapBuffers (); void TFB_GL_UploadTransitionScreen (void);
void TFB_GL_SwapBuffers (void);
SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface); SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface);
+16 -2
View File
@@ -107,6 +107,7 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
SDL_Screen = SDL_DisplayFormat (test_extra); SDL_Screen = SDL_DisplayFormat (test_extra);
ExtraScreen = SDL_DisplayFormat (test_extra); ExtraScreen = SDL_DisplayFormat (test_extra);
TransitionScreen = SDL_DisplayFormat (test_extra);
fade_white = SDL_DisplayFormat (test_extra); fade_white = SDL_DisplayFormat (test_extra);
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255)); SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
@@ -132,13 +133,26 @@ void
TFB_Pure_SwapBuffers () TFB_Pure_SwapBuffers ()
{ {
SDL_Surface *backbuffer = SDL_Screen; SDL_Surface *backbuffer = SDL_Screen;
int fade_amount = TFB_GetFadeAmount (); int fade_amount = FadeAmount;
int transition_amount = TransitionAmount;
if (fade_amount != 255) if (transition_amount != -1)
{ {
backbuffer = fade_temp; backbuffer = fade_temp;
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL); SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
SDL_SetAlpha (TransitionScreen, SDL_SRCALPHA, 255 - transition_amount);
SDL_BlitSurface (TransitionScreen, &TransitionClipRect, backbuffer, &TransitionClipRect);
}
if (fade_amount != 255)
{
if (transition_amount == -1)
{
backbuffer = fade_temp;
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
}
if (fade_amount < 255) if (fade_amount < 255)
{ {
SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount); SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount);
+17 -3
View File
@@ -29,6 +29,11 @@
SDL_Surface *SDL_Video; SDL_Surface *SDL_Video;
SDL_Surface *SDL_Screen; SDL_Surface *SDL_Screen;
SDL_Surface *ExtraScreen; SDL_Surface *ExtraScreen;
SDL_Surface *TransitionScreen;
volatile int TransitionAmount = -1;
SDL_Rect TransitionClipRect;
BOOLEAN ShowFPS = FALSE; BOOLEAN ShowFPS = FALSE;
volatile int continuity_break; volatile int continuity_break;
@@ -319,13 +324,22 @@ TFB_FlushGraphics () // Only call from main thread!!
if (DrawCommandQueue == 0 || DrawCommandQueue->Size == 0) if (DrawCommandQueue == 0 || DrawCommandQueue->Size == 0)
{ {
static int last_fade = 255; static int last_fade = 255;
int current_fade = TFB_GetFadeAmount(); static int last_transition = -1;
int current_fade = FadeAmount;
int current_transition = TransitionAmount;
if (current_fade != 255 && current_fade != last_fade) if ((current_fade != 255 && current_fade != last_fade) ||
(current_transition != -1 && current_transition != last_transition))
{
TFB_SwapBuffers(); // if fading, redraw every frame TFB_SwapBuffers(); // if fading, redraw every frame
}
else else
SDL_Delay(5); {
SDL_Delay(1);
}
last_fade = current_fade; last_fade = current_fade;
last_transition = current_transition;
return; return;
} }
@@ -31,6 +31,10 @@
extern SDL_Surface *SDL_Video; extern SDL_Surface *SDL_Video;
extern SDL_Surface *SDL_Screen; extern SDL_Surface *SDL_Screen;
extern SDL_Surface *ExtraScreen; extern SDL_Surface *ExtraScreen;
extern SDL_Surface *TransitionScreen;
extern volatile int TransitionAmount;
extern SDL_Rect TransitionClipRect;
extern volatile int continuity_break; extern volatile int continuity_break;
extern BOOLEAN ShowFPS; extern BOOLEAN ShowFPS;