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:
@@ -31,7 +31,8 @@ static struct
|
||||
} tc;
|
||||
} TaskControl;
|
||||
|
||||
static int cur = FADE_NORMAL_INTENSITY, end, XForming;
|
||||
volatile int FadeAmount = FADE_NORMAL_INTENSITY;
|
||||
static volatile int end, XForming;
|
||||
|
||||
DWORD* _varPLUTs;
|
||||
static unsigned int varPLUTsize = VARPLUTS_SIZE;
|
||||
@@ -41,22 +42,17 @@ static TFB_Palette cmap_rgb[256];
|
||||
static int cmap_type = 0;
|
||||
|
||||
|
||||
int TFB_GetFadeAmount ()
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
|
||||
BOOLEAN TFB_HasColorMap ()
|
||||
BOOLEAN TFB_HasColorMap (void)
|
||||
{
|
||||
return has_colormap;
|
||||
}
|
||||
|
||||
int TFB_GetColorMapType ()
|
||||
int TFB_GetColorMapType (void)
|
||||
{
|
||||
return cmap_type;
|
||||
}
|
||||
|
||||
void TFB_ReleaseColorMap ()
|
||||
void TFB_ReleaseColorMap (void)
|
||||
{
|
||||
//fprintf (stderr, "TFB_ReleaseColorMap()\n");
|
||||
has_colormap = FALSE;
|
||||
@@ -172,8 +168,8 @@ SetColorMap (COLORMAPPTR map, int type)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
int xform_clut_task (void *data)
|
||||
static int
|
||||
xform_clut_task (void *data)
|
||||
{
|
||||
SIZE TDelta, TTotal;
|
||||
DWORD CurTime;
|
||||
@@ -197,8 +193,8 @@ int xform_clut_task (void *data)
|
||||
if (!XForming || (TDelta = (SIZE)(CurTime - StartTime)) > TTotal)
|
||||
TDelta = TTotal;
|
||||
|
||||
cur += (end - cur) * TDelta / TTotal;
|
||||
//fprintf (stderr, "xform_clut_task cur %d\n", cur);
|
||||
FadeAmount += (end - FadeAmount) * TDelta / TTotal;
|
||||
//fprintf (stderr, "xform_clut_task FadeAmount %d\n", FadeAmount);
|
||||
} while (TTotal -= TDelta && (!Task_ReadState (task, TASK_EXIT)));
|
||||
}
|
||||
|
||||
@@ -243,7 +239,7 @@ XFormColorMap (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
|
||||
(TaskControl.tc.XFormTask = AssignTask (xform_clut_task,
|
||||
1024, "transform colormap")) == 0)
|
||||
{
|
||||
cur = end;
|
||||
FadeAmount = end;
|
||||
TimeOut = GetTimeCounter ();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -51,8 +51,8 @@ enum
|
||||
};
|
||||
|
||||
extern DWORD* _varPLUTs;
|
||||
extern volatile int FadeAmount;
|
||||
|
||||
int TFB_GetFadeAmount (void);
|
||||
BOOLEAN TFB_HasColorMap (void);
|
||||
int TFB_GetColorMapType (void);
|
||||
void TFB_ReleaseColorMap (void);
|
||||
|
||||
@@ -19,9 +19,13 @@
|
||||
#ifdef GFXMODULE_SDL
|
||||
|
||||
#include "sdl_common.h"
|
||||
#include "pure.h"
|
||||
#include "opengl.h"
|
||||
|
||||
int batch_depth = 0;
|
||||
|
||||
static Task transition_task;
|
||||
|
||||
|
||||
//Status: Not entirely unimplemented!
|
||||
BOOLEAN
|
||||
@@ -79,11 +83,13 @@ FlushGraphics (void)
|
||||
void
|
||||
SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :)
|
||||
{
|
||||
//fprintf(stderr, "SetGraphicUseOtherExtra %d\n", other);
|
||||
}
|
||||
|
||||
void
|
||||
SetGraphicGrabOther (int grab_other)
|
||||
{
|
||||
//fprintf(stderr, "SetGraphicGrabOther %d\n", grab_other);
|
||||
}
|
||||
|
||||
// Status: Unimplemented
|
||||
@@ -91,14 +97,72 @@ void
|
||||
SetGraphicStrength (int numerator, int 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
|
||||
void
|
||||
ScreenTransition (int TransType, PRECT pRect) //TransType==3
|
||||
static int
|
||||
transition_task_func (void *data)
|
||||
{
|
||||
//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
|
||||
|
||||
@@ -24,7 +24,9 @@ static SDL_Surface *format_conv_surf;
|
||||
|
||||
static int ScreenFilterMode;
|
||||
static unsigned int DisplayTexture;
|
||||
static unsigned int TransitionTexture;
|
||||
static BOOLEAN tveffect;
|
||||
static BOOLEAN upload_transitiontexture = FALSE;
|
||||
|
||||
|
||||
int
|
||||
@@ -55,33 +57,33 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||
ScreenWidthActual = width;
|
||||
ScreenHeightActual = height;
|
||||
|
||||
switch(bpp) {
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
fprintf (stderr, "bpp of 8 not supported under OpenGL\n");
|
||||
exit(-1);
|
||||
|
||||
case 15:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 6);
|
||||
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8);
|
||||
break;
|
||||
|
||||
case 32:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8);
|
||||
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",
|
||||
ScreenWidthActual, ScreenHeightActual, bpp,
|
||||
SDL_GetError ());
|
||||
exit(-1);
|
||||
exit (-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,27 +111,34 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||
SDL_GetVideoSurface()->format->BitsPerPixel);
|
||||
|
||||
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);
|
||||
|
||||
if (SDL_Screen == NULL)
|
||||
{
|
||||
fprintf (stderr, "Couldn't create back buffer: %s\n",
|
||||
SDL_GetError());
|
||||
exit(-1);
|
||||
fprintf (stderr, "Couldn't create back buffer: %s\n", SDL_GetError());
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
ExtraScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
|
||||
ExtraScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24,
|
||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
|
||||
|
||||
if (ExtraScreen == NULL)
|
||||
{
|
||||
fprintf (stderr, "Couldn't create workspace buffer: %s\n",
|
||||
SDL_GetError());
|
||||
exit(-1);
|
||||
fprintf (stderr, "Couldn't create workspace buffer: %s\n", SDL_GetError());
|
||||
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,
|
||||
@@ -137,8 +146,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||
|
||||
if (format_conv_surf == NULL)
|
||||
{
|
||||
fprintf (stderr, "Couldn't create format_conv_surf: %s\n",
|
||||
SDL_GetError());
|
||||
fprintf (stderr, "Couldn't create format_conv_surf: %s\n", SDL_GetError());
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@@ -160,84 +168,134 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||
glDisable (GL_DITHER);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glGenTextures(1,&DisplayTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, DisplayTexture);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glGenTextures (1, &DisplayTexture);
|
||||
glBindTexture (GL_TEXTURE_2D, DisplayTexture);
|
||||
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_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;
|
||||
}
|
||||
|
||||
void TFB_GL_UploadTransitionScreen (void)
|
||||
{
|
||||
upload_transitiontexture = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
TFB_GL_TVEffect()
|
||||
TFB_GL_TVEffect (void)
|
||||
{
|
||||
int y;
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_DST_COLOR, GL_ONE);
|
||||
glColor3f(0.5, 0.5, 0.5);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_DST_COLOR, GL_ONE);
|
||||
glColor3f (0.5, 0.5, 0.5);
|
||||
|
||||
for (y = 0; y < ScreenHeightActual; y += 2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(0, y);
|
||||
glVertex2i(ScreenWidthActual, y);
|
||||
glEnd();
|
||||
glBegin (GL_LINES);
|
||||
glVertex2i (0, y);
|
||||
glVertex2i (ScreenWidthActual, y);
|
||||
glEnd ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TFB_GL_DrawQuad ()
|
||||
TFB_GL_DrawQuad (void)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glBegin (GL_TRIANGLE_FAN);
|
||||
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 0);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2i (0, 0);
|
||||
|
||||
glTexCoord2f(ScreenWidth / 512.0f, 0);
|
||||
glVertex2i(ScreenWidthActual, 0);
|
||||
glTexCoord2f (ScreenWidth / 512.0f, 0);
|
||||
glVertex2i (ScreenWidthActual, 0);
|
||||
|
||||
glTexCoord2f(ScreenWidth / 512.0f, ScreenHeight / 256.0f);
|
||||
glVertex2i(ScreenWidthActual, ScreenHeightActual);
|
||||
glTexCoord2f (ScreenWidth / 512.0f, ScreenHeight / 256.0f);
|
||||
glVertex2i (ScreenWidthActual, ScreenHeightActual);
|
||||
|
||||
glTexCoord2f(0, ScreenHeight / 256.0f);
|
||||
glVertex2i(0, ScreenHeightActual);
|
||||
glTexCoord2f (0, ScreenHeight / 256.0f);
|
||||
glVertex2i (0, ScreenHeightActual);
|
||||
|
||||
glEnd();
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
void
|
||||
TFB_GL_SwapBuffers ()
|
||||
TFB_GL_SwapBuffers (void)
|
||||
{
|
||||
int fade_amount;
|
||||
int transition_amount;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glOrtho (0,ScreenWidthActual,ScreenHeightActual, 0, -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
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);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth,ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, SDL_Screen->pixels);
|
||||
SDL_UnlockSurface(SDL_Screen);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glDisable (GL_BLEND);
|
||||
glColor4f (1, 1, 1, 1);
|
||||
|
||||
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);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glColor4f(1,1,1,1);
|
||||
SDL_LockSurface (SDL_Screen);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, SDL_Screen->pixels);
|
||||
SDL_UnlockSurface (SDL_Screen);
|
||||
|
||||
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)
|
||||
{
|
||||
float c;
|
||||
@@ -245,27 +303,25 @@ TFB_GL_SwapBuffers ()
|
||||
if (fade_amount < 255)
|
||||
{
|
||||
c = fade_amount / 255.0f;
|
||||
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
||||
glBlendFunc (GL_DST_COLOR, GL_ZERO);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = (fade_amount - 255) / 255.0f;
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendFunc (GL_ONE, GL_ONE);
|
||||
}
|
||||
|
||||
glColor3f(c, c, c);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
//fprintf (stderr, "fade_amount %d c %f\n",fade_amount, c);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glEnable (GL_BLEND);
|
||||
glColor4f (c, c, c, 1);
|
||||
|
||||
TFB_GL_DrawQuad ();
|
||||
}
|
||||
|
||||
if (tveffect)
|
||||
TFB_GL_TVEffect();
|
||||
TFB_GL_TVEffect ();
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
SDL_GL_SwapBuffers ();
|
||||
}
|
||||
|
||||
SDL_Surface*
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
#include "libs/graphics/sdl/sdl_common.h"
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||
|
||||
SDL_Screen = SDL_DisplayFormat (test_extra);
|
||||
ExtraScreen = SDL_DisplayFormat (test_extra);
|
||||
TransitionScreen = SDL_DisplayFormat (test_extra);
|
||||
|
||||
fade_white = SDL_DisplayFormat (test_extra);
|
||||
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
|
||||
@@ -132,13 +133,26 @@ void
|
||||
TFB_Pure_SwapBuffers ()
|
||||
{
|
||||
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;
|
||||
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)
|
||||
{
|
||||
SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount);
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
SDL_Surface *SDL_Video;
|
||||
SDL_Surface *SDL_Screen;
|
||||
SDL_Surface *ExtraScreen;
|
||||
SDL_Surface *TransitionScreen;
|
||||
|
||||
|
||||
volatile int TransitionAmount = -1;
|
||||
SDL_Rect TransitionClipRect;
|
||||
|
||||
BOOLEAN ShowFPS = FALSE;
|
||||
volatile int continuity_break;
|
||||
@@ -319,13 +324,22 @@ TFB_FlushGraphics () // Only call from main thread!!
|
||||
if (DrawCommandQueue == 0 || DrawCommandQueue->Size == 0)
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
SDL_Delay(5);
|
||||
{
|
||||
SDL_Delay(1);
|
||||
}
|
||||
|
||||
last_fade = current_fade;
|
||||
last_transition = current_transition;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
extern SDL_Surface *SDL_Video;
|
||||
extern SDL_Surface *SDL_Screen;
|
||||
extern SDL_Surface *ExtraScreen;
|
||||
extern SDL_Surface *TransitionScreen;
|
||||
|
||||
extern volatile int TransitionAmount;
|
||||
extern SDL_Rect TransitionClipRect;
|
||||
|
||||
extern volatile int continuity_break;
|
||||
extern BOOLEAN ShowFPS;
|
||||
|
||||
Reference in New Issue
Block a user