mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-16 01:31:30 +00:00
Merge branch 'next' into 2.1.24-prep
This commit is contained in:
commit
c0c1e5416f
5 changed files with 47 additions and 30 deletions
|
@ -1082,21 +1082,24 @@ UINT8 *HWR_GetScreenshot(void)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean HWR_Screenshot(const char *lbmname)
|
boolean HWR_Screenshot(const char *pathname)
|
||||||
{
|
{
|
||||||
boolean ret;
|
boolean ret;
|
||||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// returns 24bit 888 RGB
|
// returns 24bit 888 RGB
|
||||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||||
|
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
ret = M_SavePNG(lbmname, buf, vid.width, vid.height, NULL);
|
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||||
#else
|
#else
|
||||||
ret = saveTGA(lbmname, buf, vid.width, vid.height);
|
ret = saveTGA(pathname, buf, vid.width, vid.height);
|
||||||
#endif
|
#endif
|
||||||
free(buf);
|
free(buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -38,8 +38,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player);
|
||||||
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
|
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
|
||||||
void HWR_DrawViewBorder(INT32 clearlines);
|
void HWR_DrawViewBorder(INT32 clearlines);
|
||||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
||||||
UINT8 *HWR_GetScreenshot(void);
|
|
||||||
boolean HWR_Screenshot(const char *lbmname);
|
|
||||||
void HWR_InitTextureMapping(void);
|
void HWR_InitTextureMapping(void);
|
||||||
void HWR_SetViewSize(void);
|
void HWR_SetViewSize(void);
|
||||||
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
|
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
|
||||||
|
@ -54,6 +52,9 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
|
||||||
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right.
|
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right.
|
||||||
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
|
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
|
||||||
|
|
||||||
|
UINT8 *HWR_GetScreenshot(void);
|
||||||
|
boolean HWR_Screenshot(const char *pathname);
|
||||||
|
|
||||||
void HWR_AddCommands(void);
|
void HWR_AddCommands(void);
|
||||||
void HWR_CorrectSWTricks(void);
|
void HWR_CorrectSWTricks(void);
|
||||||
void transform(float *cx, float *cy, float *cz);
|
void transform(float *cx, float *cy, float *cz);
|
||||||
|
|
60
src/m_misc.c
60
src/m_misc.c
|
@ -30,6 +30,7 @@
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
#include "m_misc.h"
|
#include "m_misc.h"
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
|
#include "st_stuff.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "g_input.h"
|
#include "g_input.h"
|
||||||
|
@ -586,6 +587,21 @@ void M_SaveConfig(const char *filename)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==========================================================================
|
||||||
|
// SCREENSHOTS
|
||||||
|
// ==========================================================================
|
||||||
|
static UINT8 screenshot_palette[768];
|
||||||
|
static void M_CreateScreenShotPalette(void)
|
||||||
|
{
|
||||||
|
size_t i, j;
|
||||||
|
for (i = 0, j = 0; i < 768; i += 3, j++)
|
||||||
|
{
|
||||||
|
RGBA_t locpal = pLocalPalette[(max(st_palette,0)*256)+j];
|
||||||
|
screenshot_palette[i] = locpal.s.red;
|
||||||
|
screenshot_palette[i+1] = locpal.s.green;
|
||||||
|
screenshot_palette[i+2] = locpal.s.blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if NUMSCREENS > 2
|
#if NUMSCREENS > 2
|
||||||
static const char *Newsnapshotfile(const char *pathname, const char *ext)
|
static const char *Newsnapshotfile(const char *pathname, const char *ext)
|
||||||
|
@ -1016,6 +1032,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
||||||
static inline moviemode_t M_StartMovieAPNG(const char *pathname)
|
static inline moviemode_t M_StartMovieAPNG(const char *pathname)
|
||||||
{
|
{
|
||||||
#ifdef USE_APNG
|
#ifdef USE_APNG
|
||||||
|
UINT8 *palette;
|
||||||
const char *freename = NULL;
|
const char *freename = NULL;
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
|
|
||||||
|
@ -1031,10 +1048,8 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname)
|
||||||
return MM_OFF;
|
return MM_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft) M_CreateScreenShotPalette();
|
||||||
ret = M_SetupaPNG(va(pandf,pathname,freename), W_CacheLumpName(GetPalette(), PU_CACHE));
|
ret = M_SetupaPNG(va(pandf,pathname,freename), (palette = screenshot_palette));
|
||||||
else
|
|
||||||
ret = M_SetupaPNG(va(pandf,pathname,freename), NULL);
|
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
|
@ -1237,7 +1252,7 @@ void M_StopMovie(void)
|
||||||
* \param data The image data.
|
* \param data The image data.
|
||||||
* \param width Width of the picture.
|
* \param width Width of the picture.
|
||||||
* \param height Height of the picture.
|
* \param height Height of the picture.
|
||||||
* \param palette Palette of image data
|
* \param palette Palette of image data.
|
||||||
* \note if palette is NULL, BGR888 format
|
* \note if palette is NULL, BGR888 format
|
||||||
*/
|
*/
|
||||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette)
|
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette)
|
||||||
|
@ -1259,8 +1274,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
|
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
|
||||||
PNG_error, PNG_warn);
|
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n");
|
CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n");
|
||||||
|
@ -1414,9 +1428,8 @@ void M_ScreenShot(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Takes a screenshot.
|
/** Takes a screenshot.
|
||||||
* The screenshot is saved as "srb2xxxx.pcx" (or "srb2xxxx.tga" in hardware
|
* The screenshot is saved as "srb2xxxx.png" where xxxx is the lowest
|
||||||
* rendermode) where xxxx is the lowest four-digit number for which a file
|
* four-digit number for which a file does not already exist.
|
||||||
* does not already exist.
|
|
||||||
*
|
*
|
||||||
* \sa HWR_ScreenShot
|
* \sa HWR_ScreenShot
|
||||||
*/
|
*/
|
||||||
|
@ -1430,6 +1443,10 @@ void M_DoScreenShot(void)
|
||||||
// Don't take multiple screenshots, obviously
|
// Don't take multiple screenshots, obviously
|
||||||
takescreenshot = false;
|
takescreenshot = false;
|
||||||
|
|
||||||
|
// how does one take a screenshot without a render system?
|
||||||
|
if (rendermode == render_none)
|
||||||
|
return;
|
||||||
|
|
||||||
if (cv_screenshot_option.value == 0)
|
if (cv_screenshot_option.value == 0)
|
||||||
pathname = usehome ? srb2home : srb2path;
|
pathname = usehome ? srb2home : srb2path;
|
||||||
else if (cv_screenshot_option.value == 1)
|
else if (cv_screenshot_option.value == 1)
|
||||||
|
@ -1440,16 +1457,13 @@ void M_DoScreenShot(void)
|
||||||
pathname = cv_screenshot_folder.string;
|
pathname = cv_screenshot_folder.string;
|
||||||
|
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
if (rendermode != render_none)
|
freename = Newsnapshotfile(pathname,"png");
|
||||||
freename = Newsnapshotfile(pathname,"png");
|
|
||||||
#else
|
#else
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
freename = Newsnapshotfile(pathname,"pcx");
|
freename = Newsnapshotfile(pathname,"pcx");
|
||||||
else if (rendermode != render_none)
|
else if (rendermode == render_opengl)
|
||||||
freename = Newsnapshotfile(pathname,"tga");
|
freename = Newsnapshotfile(pathname,"tga");
|
||||||
#endif
|
#endif
|
||||||
else
|
|
||||||
I_Error("Can't take a screenshot without a render system");
|
|
||||||
|
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
{
|
{
|
||||||
|
@ -1463,18 +1477,16 @@ void M_DoScreenShot(void)
|
||||||
|
|
||||||
// save the pcx file
|
// save the pcx file
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode != render_soft)
|
if (rendermode == render_opengl)
|
||||||
ret = HWR_Screenshot(va(pandf,pathname,freename));
|
ret = HWR_Screenshot(va(pandf,pathname,freename));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (rendermode != render_none)
|
|
||||||
{
|
{
|
||||||
|
M_CreateScreenShotPalette();
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height,
|
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||||
W_CacheLumpName(GetPalette(), PU_CACHE));
|
|
||||||
#else
|
#else
|
||||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height,
|
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||||
W_CacheLumpName(GetPalette(), PU_CACHE));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1482,14 +1494,14 @@ failure:
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (moviemode != MM_SCREENSHOT)
|
if (moviemode != MM_SCREENSHOT)
|
||||||
CONS_Printf(M_GetText("screen shot %s saved in %s\n"), freename, pathname);
|
CONS_Printf(M_GetText("Screen shot %s saved in %s\n"), freename, pathname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (freename)
|
if (freename)
|
||||||
CONS_Printf(M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname);
|
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname);
|
||||||
else
|
else
|
||||||
CONS_Printf(M_GetText("Couldn't create screen shot (all 10000 slots used!) in %s\n"), pathname);
|
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname);
|
||||||
|
|
||||||
if (moviemode == MM_SCREENSHOT)
|
if (moviemode == MM_SCREENSHOT)
|
||||||
M_StopMovie();
|
M_StopMovie();
|
||||||
|
|
|
@ -197,7 +197,7 @@ void ST_Ticker(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 is default, any others are special palettes.
|
// 0 is default, any others are special palettes.
|
||||||
static INT32 st_palette = 0;
|
INT32 st_palette = 0;
|
||||||
|
|
||||||
void ST_doPaletteStuff(void)
|
void ST_doPaletteStuff(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@ boolean ST_SameTeam(player_t *a, player_t *b);
|
||||||
//--------------------
|
//--------------------
|
||||||
|
|
||||||
extern boolean st_overlay; // sb overlay on or off when fullscreen
|
extern boolean st_overlay; // sb overlay on or off when fullscreen
|
||||||
|
extern INT32 st_palette; // 0 is default, any others are special palettes.
|
||||||
|
|
||||||
extern lumpnum_t st_borderpatchnum;
|
extern lumpnum_t st_borderpatchnum;
|
||||||
// patches, also used in intermission
|
// patches, also used in intermission
|
||||||
|
|
Loading…
Reference in a new issue