mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-03-13 22:23:04 +00:00
added screenshotnc and screenshotncJPEG
This commit is contained in:
parent
caaa8e4e47
commit
e26163aa79
10 changed files with 96 additions and 10 deletions
|
@ -1,6 +1,11 @@
|
|||
|
||||
DD Mmm 17 - 1.49
|
||||
|
||||
add: new commands to take screenshots with the console hidden
|
||||
screenshotnc for TARGA (.tga) images
|
||||
screenshotncJPEG for JPEG (.jpg) images
|
||||
they will be used for end-game screenshots by CPMA 1.50+ with compatible engines
|
||||
|
||||
add: in_noGrab <0|1> (default: 0) disables input grabbing
|
||||
|
||||
add: bindkeylist command to print all bindable key names
|
||||
|
|
|
@ -299,13 +299,17 @@ static qbool CL_CG_GetValue( char* value, int valueSize, const char* key )
|
|||
{
|
||||
struct syscall_t { const char* name; int number; };
|
||||
static const syscall_t syscalls[] = {
|
||||
// syscalls
|
||||
{ "trap_LocateInteropData", CG_EXT_LOCATEINTEROPDATA },
|
||||
{ "trap_R_AddRefEntityToScene2", CG_EXT_R_ADDREFENTITYTOSCENE2 },
|
||||
{ "trap_R_ForceFixedDLights", CG_EXT_R_FORCEFIXEDDLIGHTS },
|
||||
{ "trap_SetInputForwarding", CG_EXT_SETINPUTFORWARDING },
|
||||
{ "trap_Cvar_SetRange", CG_EXT_CVAR_SETRANGE },
|
||||
{ "trap_Cvar_SetHelp", CG_EXT_CVAR_SETHELP },
|
||||
{ "trap_Cmd_SetHelp", CG_EXT_CMD_SETHELP }
|
||||
{ "trap_Cmd_SetHelp", CG_EXT_CMD_SETHELP },
|
||||
// commands
|
||||
{ "screenshotnc", 1 },
|
||||
{ "screenshotncJPEG", 1 }
|
||||
};
|
||||
|
||||
for ( int i = 0; i < ARRAY_LEN( syscalls ); ++i ) {
|
||||
|
|
|
@ -58,6 +58,8 @@ struct console_t {
|
|||
|
||||
int times[CON_NOTIFYLINES]; // cls.realtime time the line was generated
|
||||
// for transparent notify lines
|
||||
|
||||
qbool wasActive; // was active before Con_PushConsoleInvisible was called?
|
||||
};
|
||||
|
||||
static console_t con;
|
||||
|
@ -69,6 +71,13 @@ static console_t con;
|
|||
int g_console_field_width = CONSOLE_WIDTH;
|
||||
|
||||
|
||||
float Con_SetConsoleVisibility( float fraction )
|
||||
{
|
||||
const float oldValue = con.displayFrac;
|
||||
con.displayFrac = fraction;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
void Con_ToggleConsole_f()
|
||||
{
|
||||
g_consoleField.acOffset = 0;
|
||||
|
|
|
@ -1679,6 +1679,7 @@ static void CL_InitRef()
|
|||
{
|
||||
refimport_t ri;
|
||||
|
||||
ri.SetConsoleVisibility = Con_SetConsoleVisibility;
|
||||
ri.Cmd_RegisterTable = RI_Cmd_RegisterTable;
|
||||
ri.Cmd_UnregisterModule = RI_Cmd_UnregisterModule;
|
||||
ri.Cmd_Argc = Cmd_Argc;
|
||||
|
|
|
@ -401,6 +401,7 @@ qbool CL_UpdateVisiblePings_f( int source );
|
|||
//
|
||||
void CL_ConInit();
|
||||
void CL_ConShutdown();
|
||||
float Con_SetConsoleVisibility( float fraction );
|
||||
void Con_ToggleConsole_f();
|
||||
void Con_ClearNotify();
|
||||
void Con_RunConsole();
|
||||
|
|
|
@ -45,3 +45,11 @@ extern dllSyscall_t syscall;
|
|||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define GET_CMD(Name) \
|
||||
do { \
|
||||
if (trap_GetValue(syscallStr, sizeof(syscallStr), #Name) && \
|
||||
syscallStr[0] == '1') { \
|
||||
cpma_ext.Name = qtrue; \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
|
@ -202,6 +202,19 @@ void RE_BeginFrame( stereoFrame_t stereoFrame )
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// delayed screenshot
|
||||
//
|
||||
if ( r_delayedScreenshotPending ) {
|
||||
r_delayedScreenshotFrame++;
|
||||
if ( r_delayedScreenshotFrame >= 2 ) {
|
||||
R_CMD( screenshotCommand_t, RC_SCREENSHOT );
|
||||
*cmd = r_delayedScreenshot;
|
||||
r_delayedScreenshotPending = qfalse;
|
||||
r_delayedScreenshotFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// draw buffer stuff
|
||||
//
|
||||
|
|
|
@ -29,6 +29,10 @@ glinfo_t glInfo;
|
|||
|
||||
glstate_t glState;
|
||||
|
||||
screenshotCommand_t r_delayedScreenshot;
|
||||
qbool r_delayedScreenshotPending = qfalse;
|
||||
int r_delayedScreenshotFrame = 0;
|
||||
|
||||
static void GfxInfo_f( void );
|
||||
|
||||
cvar_t *r_verbose;
|
||||
|
@ -331,6 +335,9 @@ static void RB_TakeScreenshotJPG( int x, int y, int width, int height, const cha
|
|||
|
||||
const void* RB_TakeScreenshotCmd( const screenshotCommand_t* cmd )
|
||||
{
|
||||
// NOTE: the current read buffer is the last FBO color attachment texture that was written to
|
||||
// therefore, qglReadPixels will get the latest data even with double/triple buffering enabled
|
||||
|
||||
switch (cmd->type) {
|
||||
case screenshotCommand_t::SS_JPG:
|
||||
RB_TakeScreenshotJPG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName );
|
||||
|
@ -339,6 +346,13 @@ const void* RB_TakeScreenshotCmd( const screenshotCommand_t* cmd )
|
|||
RB_TakeScreenshotTGA( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName );
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd->conVis > 0.0f) {
|
||||
ri.SetConsoleVisibility( cmd->conVis );
|
||||
r_delayedScreenshotPending = qfalse;
|
||||
r_delayedScreenshotFrame = 0;
|
||||
}
|
||||
|
||||
return (const void*)(cmd + 1);
|
||||
}
|
||||
|
||||
|
@ -346,13 +360,21 @@ const void* RB_TakeScreenshotCmd( const screenshotCommand_t* cmd )
|
|||
// screenshot filename is YYYY_MM_DD-HH_MM_SS-TTT
|
||||
// so you can find the damn things and you never run out of them for movies :)
|
||||
|
||||
static void R_TakeScreenshot( const char* ext, screenshotCommand_t::ss_type type )
|
||||
static void R_TakeScreenshot( const char* ext, screenshotCommand_t::ss_type type, qbool hideConsole )
|
||||
{
|
||||
static char s[MAX_OSPATH]; // bad things may happen if we somehow manage to take 2 ss in 1 frame
|
||||
|
||||
screenshotCommand_t* cmd = (screenshotCommand_t*)R_GetCommandBuffer( sizeof(*cmd) );
|
||||
if ( !cmd )
|
||||
return;
|
||||
const float conVis = hideConsole ? ri.SetConsoleVisibility( 0.0f ) : 0.0f;
|
||||
screenshotCommand_t* cmd;
|
||||
if ( conVis > 0.0f ) {
|
||||
cmd = &r_delayedScreenshot;
|
||||
r_delayedScreenshotPending = qtrue;
|
||||
r_delayedScreenshotFrame = 0;
|
||||
} else {
|
||||
cmd = (screenshotCommand_t*)R_GetCommandBuffer( sizeof(screenshotCommand_t) );
|
||||
if ( !cmd )
|
||||
return;
|
||||
}
|
||||
|
||||
if (ri.Cmd_Argc() == 2) {
|
||||
Com_sprintf( s, sizeof(s), "screenshots/%s.%s", ri.Cmd_Argv(1), ext );
|
||||
|
@ -372,18 +394,31 @@ static void R_TakeScreenshot( const char* ext, screenshotCommand_t::ss_type type
|
|||
cmd->height = glConfig.vidHeight;
|
||||
cmd->fileName = s;
|
||||
cmd->type = type;
|
||||
cmd->conVis = conVis;
|
||||
}
|
||||
|
||||
|
||||
static void R_ScreenShotTGA_f(void)
|
||||
static void R_ScreenShotTGA_f()
|
||||
{
|
||||
R_TakeScreenshot( "tga", screenshotCommand_t::SS_TGA );
|
||||
R_TakeScreenshot( "tga", screenshotCommand_t::SS_TGA, qfalse );
|
||||
}
|
||||
|
||||
|
||||
static void R_ScreenShotJPG_f(void)
|
||||
static void R_ScreenShotJPG_f()
|
||||
{
|
||||
R_TakeScreenshot( "jpg", screenshotCommand_t::SS_JPG );
|
||||
R_TakeScreenshot( "jpg", screenshotCommand_t::SS_JPG, qfalse );
|
||||
}
|
||||
|
||||
|
||||
static void R_ScreenShotNoConTGA_f()
|
||||
{
|
||||
R_TakeScreenshot( "tga", screenshotCommand_t::SS_TGA, qtrue );
|
||||
}
|
||||
|
||||
|
||||
static void R_ScreenShotNoConJPG_f()
|
||||
{
|
||||
R_TakeScreenshot( "jpg", screenshotCommand_t::SS_JPG, qtrue );
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,7 +499,9 @@ static const cmdTableItem_t r_cmds[] =
|
|||
{ "skinlist", R_SkinList_f, NULL, "prints loaded skins" },
|
||||
{ "modellist", R_Modellist_f, NULL, "prints loaded models" },
|
||||
{ "screenshot", R_ScreenShotTGA_f, NULL, "takes a TARGA (.tga) screenshot" },
|
||||
{ "screenshotJPEG", R_ScreenShotJPG_f, NULL, "takes a JPEG (.jpg) screenshot" }
|
||||
{ "screenshotJPEG", R_ScreenShotJPG_f, NULL, "takes a JPEG (.jpg) screenshot" },
|
||||
{ "screenshotnc", R_ScreenShotNoConTGA_f, NULL, "takes a TARGA screenshot w/o the console" },
|
||||
{ "screenshotncJPEG", R_ScreenShotNoConJPG_f, NULL, "takes a JPEG screenshot w/o the console" }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1412,6 +1412,8 @@ typedef struct {
|
|||
int height;
|
||||
const char* fileName;
|
||||
enum ss_type { SS_TGA, SS_JPG } type;
|
||||
float conVis; // if > 0, this is a delayed screenshot and we need to
|
||||
// restore the console visibility to that value
|
||||
} screenshotCommand_t;
|
||||
|
||||
const void* RB_TakeScreenshotCmd( const screenshotCommand_t* cmd );
|
||||
|
@ -1526,5 +1528,9 @@ void GL2_EndFrame();
|
|||
|
||||
extern int re_cameraMatrixTime;
|
||||
|
||||
extern screenshotCommand_t r_delayedScreenshot;
|
||||
extern qbool r_delayedScreenshotPending;
|
||||
extern int r_delayedScreenshotFrame;
|
||||
|
||||
|
||||
#endif //TR_LOCAL_H
|
||||
|
|
|
@ -167,6 +167,8 @@ typedef struct {
|
|||
// these are the functions imported by the refresh module
|
||||
//
|
||||
typedef struct {
|
||||
float (*SetConsoleVisibility)( float fraction );
|
||||
|
||||
// print message on the local console
|
||||
void (QDECL *Printf)( printParm_t printLevel, const char *fmt, ... );
|
||||
|
||||
|
|
Loading…
Reference in a new issue