View Single Post
Re: quake 2 screen effect
Old
  (#3)
hl_backdoor
Member
 
Status: Offline
Posts: 2
Join Date: Jul 2010
Default Re: quake 2 screen effect - 27-07-2010

I did a quick search and found that the screen resizement is handled by some internal variables (cvars) ... I was looking into the quake2 source code since it is the basesrc for hl1 src code. I am 100% sure that this can be done in CS1.6 apart of those disabled commands (sizeup and down). so I still ask if anyone knows how this can be done.

Code:
vid_dll.c
// Global variables used internally by this module
viddef_t viddef;    // global video state; used by other modules

/*
** VID_NewWindow
*/
void VID_NewWindow ( int width, int height)
{
 viddef.width  = width;
 viddef.height = height;
 cl.force_refdef = true;  // can't use a paused refdef
}
/*
============
VID_Init
============
*/
void VID_Init (void)
{
 /* Create the video variables so we know how to start the graphics drivers */
 vid_ref = Cvar_Get ("vid_ref", "soft", CVAR_ARCHIVE);
 vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE);
 vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
 vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
 vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
 win_noalttab = Cvar_Get( "win_noalttab", "0", CVAR_ARCHIVE );
 /* Add some console commands that we want to handle */
 Cmd_AddCommand ("vid_restart", VID_Restart_f);
 Cmd_AddCommand ("vid_front", VID_Front_f);
 /*
 ** this is a gross hack but necessary to clamp the mode for 3Dfx
 */
#if 0
 {
  cvar_t *gl_driver = Cvar_Get( "gl_driver", "opengl32", 0 );
  cvar_t *gl_mode = Cvar_Get( "gl_mode", "3", 0 );
  if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 )
  {
   Cvar_SetValue( "gl_mode", 3 );
   viddef.width  = 640;
   viddef.height = 480;
  }
 }
#endif
 /* Disable the 3Dfx splash screen */
 putenv("FX_GLIDE_NO_SPLASH=0");
  
 /* Start the graphics mode and load refresh DLL */
 VID_CheckChanges();
}
 
/*////////////////////*/

cl_scrn.c
 

vrect_t  scr_vrect;  // position of render window on screen

cvar_t  *scr_viewsize;
 
/*
=================
SCR_CalcVrect
Sets scr_vrect, the coordinates of the rendered window
=================
*/
static void SCR_CalcVrect (void)
{
 int  size;
 // bound viewsize
 if (scr_viewsize->value < 40)
  Cvar_Set ("viewsize","40");
 if (scr_viewsize->value > 100)
  Cvar_Set ("viewsize","100");
 size = scr_viewsize->value;
 scr_vrect.width = viddef.width*size/100;
 scr_vrect.width &= ~7;
 scr_vrect.height = viddef.height*size/100;
 scr_vrect.height &= ~1;
 scr_vrect.x = (viddef.width - scr_vrect.width)/2;
 scr_vrect.y = (viddef.height - scr_vrect.height)/2;
}

/*
=================
SCR_SizeUp_f
Keybinding command
=================
*/
void SCR_SizeUp_f (void)
{
 Cvar_SetValue ("viewsize",scr_viewsize->value+10);
}

/*
=================
SCR_SizeDown_f
Keybinding command
=================
*/
void SCR_SizeDown_f (void)
{
 Cvar_SetValue ("viewsize",scr_viewsize->value-10);
}
 

/*
==================
SCR_Init
==================
*/
void SCR_Init (void)
{
 
        scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE);

//
// register our commands
//
 Cmd_AddCommand ("timerefresh",SCR_TimeRefresh_f);
 Cmd_AddCommand ("loading",SCR_Loading_f);
 Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
 Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
 scr_initialized = true;
}
 
/*///////////////*/

/*
============
Cvar_Get
If the variable already exists, the value will not be set
The flags will be or'ed in if the variable exists.
============
*/
cvar_t *Cvar_Get (char *var_name, char *var_value, int flags);

/*
============
Cvar_SetValue
============
*/
void Cvar_SetValue (char *var_name, float value)
{
 char val[32];
 if (value == (int)value)
  Com_sprintf (val, sizeof(val), "%i",(int)value);
 else
  Com_sprintf (val, sizeof(val), "%f",value);
 Cvar_Set (var_name, val);
}
  
Reply With Quote