mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-25 23:11:20 +00:00
GIF recording
(cherry picked from commit d467d2b2295a9660631774b9edb29555cc5c30fe)
This commit is contained in:
parent
3c2adbb7d1
commit
1a759a4904
7 changed files with 91 additions and 19 deletions
|
|
@ -582,7 +582,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
if (nrPlaneVerts < 3) //not even a triangle ?
|
||||
return;
|
||||
|
||||
if ((UINT32)nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size
|
||||
if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "polygon size of %d exceeds max value of %d vertices\n", nrPlaneVerts, UINT16_MAX);
|
||||
return;
|
||||
|
|
@ -3229,7 +3229,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
if (nrPlaneVerts < 3) //not even a triangle ?
|
||||
return;
|
||||
|
||||
if (nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size
|
||||
if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "polygon size of %s exceeds max value of %d vertices\n", sizeu1(nrPlaneVerts), UINT16_MAX);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@
|
|||
#include "i_video.h"
|
||||
#include "m_misc.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h"
|
||||
#endif
|
||||
|
||||
// GIFs are always little-endian
|
||||
#include "byteptr.h"
|
||||
|
||||
|
|
@ -457,6 +461,32 @@ const UINT8 gifframe_gchead[4] = {0x21,0xF9,0x04,0x04}; // GCE, bytes, packed by
|
|||
static UINT8 *gifframe_data = NULL;
|
||||
static size_t gifframe_size = 8192;
|
||||
|
||||
#ifdef HWRENDER
|
||||
static void hwrconvert(void)
|
||||
{
|
||||
UINT8 *linear = HWR_GetScreenshot();
|
||||
UINT8 *dest = screens[2];
|
||||
UINT8 r, g, b;
|
||||
INT32 x, y;
|
||||
size_t i = 0;
|
||||
|
||||
InitColorLUT();
|
||||
|
||||
for (y = 0; y < vid.height; y++)
|
||||
{
|
||||
for (x = 0; x < vid.width; x++, i += 3)
|
||||
{
|
||||
r = (UINT8)linear[i];
|
||||
g = (UINT8)linear[i + 1];
|
||||
b = (UINT8)linear[i + 2];
|
||||
dest[(y * vid.width) + x] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS];
|
||||
}
|
||||
}
|
||||
|
||||
free(linear);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// GIF_framewrite
|
||||
// writes a frame into the file.
|
||||
|
|
@ -482,7 +512,12 @@ static void GIF_framewrite(void)
|
|||
GIF_optimizeregion(cur_screen, movie_screen, &blitx, &blity, &blitw, &blith);
|
||||
|
||||
// blit to temp screen
|
||||
I_ReadScreen(movie_screen);
|
||||
if (rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen);
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
hwrconvert();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -491,7 +526,18 @@ static void GIF_framewrite(void)
|
|||
blith = vid.height;
|
||||
|
||||
if (gif_frames == 0)
|
||||
I_ReadScreen(movie_screen);
|
||||
{
|
||||
if (rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen);
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
hwrconvert();
|
||||
VID_BlitLinearScreen(screens[2], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
movie_screen = screens[0];
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +626,7 @@ static void GIF_framewrite(void)
|
|||
//
|
||||
INT32 GIF_open(const char *filename)
|
||||
{
|
||||
#ifdef HWRENDER
|
||||
#if 0
|
||||
if (rendermode != render_soft)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("GIFs cannot be taken in non-software modes!\n"));
|
||||
|
|
|
|||
|
|
@ -1120,12 +1120,8 @@ void M_StartMovie(void)
|
|||
switch (cv_moviemode.value)
|
||||
{
|
||||
case MM_GIF:
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
moviemode = M_StartMovieGIF(pathname);
|
||||
break;
|
||||
}
|
||||
/* FALLTHRU */
|
||||
moviemode = M_StartMovieGIF(pathname);
|
||||
break;
|
||||
case MM_APNG:
|
||||
moviemode = M_StartMovieAPNG(pathname);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ void R_MakeInvertmap(void);
|
|||
#endif
|
||||
const char *R_ColormapNameForNum(INT32 num);
|
||||
|
||||
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1647,6 +1647,7 @@ INT32 VID_SetMode(INT32 modeNum)
|
|||
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
|
||||
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||
Impl_VideoSetupBuffer();
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
|
|
@ -1655,8 +1656,6 @@ INT32 VID_SetMode(INT32 modeNum)
|
|||
SDL_FreeSurface(bufSurface);
|
||||
bufSurface = NULL;
|
||||
}
|
||||
|
||||
Impl_VideoSetupBuffer();
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
|
|
@ -1779,7 +1778,7 @@ static void Impl_VideoSetupSDLBuffer(void)
|
|||
static void Impl_VideoSetupBuffer(void)
|
||||
{
|
||||
// Set up game's software render buffer
|
||||
if (rendermode == render_soft)
|
||||
//if (rendermode == render_soft)
|
||||
{
|
||||
vid.rowbytes = vid.width * vid.bpp;
|
||||
vid.direct = NULL;
|
||||
|
|
|
|||
|
|
@ -2867,6 +2867,27 @@ Unoptimized version
|
|||
#endif
|
||||
}
|
||||
|
||||
// Taken from my videos-in-SRB2 project
|
||||
// Generates a color look-up table
|
||||
// which has up to 64 colors at each channel
|
||||
// (see the defines in v_video.h)
|
||||
|
||||
UINT8 colorlookup[CLUTSIZE][CLUTSIZE][CLUTSIZE];
|
||||
|
||||
void InitColorLUT(void)
|
||||
{
|
||||
UINT8 r, g, b;
|
||||
static boolean clutinit = false;
|
||||
if (!clutinit)
|
||||
{
|
||||
for (r = 0; r < CLUTSIZE; r++)
|
||||
for (g = 0; g < CLUTSIZE; g++)
|
||||
for (b = 0; b < CLUTSIZE; b++)
|
||||
colorlookup[r][g][b] = NearestColor(r << SHIFTCOLORBITS, g << SHIFTCOLORBITS, b << SHIFTCOLORBITS);
|
||||
clutinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
// V_Init
|
||||
// old software stuff, buffers are allocated at video mode setup
|
||||
// here we set the screens[x] pointers accordingly
|
||||
|
|
@ -2878,13 +2899,9 @@ void V_Init(void)
|
|||
const INT32 screensize = vid.rowbytes * vid.height;
|
||||
|
||||
LoadMapPalette();
|
||||
// hardware modes do not use screens[] pointers
|
||||
|
||||
for (i = 0; i < NUMSCREENS; i++)
|
||||
screens[i] = NULL;
|
||||
if (rendermode != render_soft)
|
||||
{
|
||||
return; // be sure to cause a NULL read/write error so we detect it, in case of..
|
||||
}
|
||||
|
||||
// start address of NUMSCREENS * width*height vidbuffers
|
||||
if (base)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,18 @@ cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation,
|
|||
// Allocates buffer screens, call before R_Init.
|
||||
void V_Init(void);
|
||||
|
||||
// Taken from my videos-in-SRB2 project
|
||||
// Generates a color look-up table
|
||||
// which has up to 64 colors at each channel
|
||||
|
||||
#define COLORBITS 6
|
||||
#define SHIFTCOLORBITS (8-COLORBITS)
|
||||
#define CLUTSIZE (1<<COLORBITS)
|
||||
|
||||
extern UINT8 colorlookup[CLUTSIZE][CLUTSIZE][CLUTSIZE];
|
||||
|
||||
void InitColorLUT(void);
|
||||
|
||||
// Set the current RGB palette lookup to use for palettized graphics
|
||||
void V_SetPalette(INT32 palettenum);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue