summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rend2/tr_cmds.c97
-rw-r--r--src/rend2/tr_init.c89
-rw-r--r--src/rend2/tr_local.h3
-rw-r--r--src/renderer/tr_init.c1
4 files changed, 101 insertions, 89 deletions
diff --git a/src/rend2/tr_cmds.c b/src/rend2/tr_cmds.c
index 2f67d221..fe4d33d8 100644
--- a/src/rend2/tr_cmds.c
+++ b/src/rend2/tr_cmds.c
@@ -291,9 +291,9 @@ Passing NULL will set the color to white
void RE_SetColor( const float *rgba ) {
setColorCommand_t *cmd;
- if ( !tr.registered ) {
- return;
- }
+ if ( !tr.registered ) {
+ return;
+ }
cmd = R_GetCommandBuffer( sizeof( *cmd ) );
if ( !cmd ) {
return;
@@ -311,6 +311,88 @@ void RE_SetColor( const float *rgba ) {
cmd->color[3] = rgba[3];
}
+/*
+=============
+R_ClipRegion
+=============
+*/
+static qboolean R_ClipRegion ( float *x, float *y, float *w, float *h,
+ float *s1, float *t1, float *s2, float *t2 ) {
+ float left, top, right, bottom;
+ float _s1, _t1, _s2, _t2;
+ float clipLeft, clipTop, clipRight, clipBottom;
+
+ if (tr.clipRegion[2] <= tr.clipRegion[0] ||
+ tr.clipRegion[3] <= tr.clipRegion[1] ) {
+ return qfalse;
+ }
+
+ left = *x;
+ top = *y;
+ right = *x + *w;
+ bottom = *y + *h;
+
+ _s1 = *s1;
+ _t1 = *t1;
+ _s2 = *s2;
+ _t2 = *t2;
+
+ clipLeft = tr.clipRegion[0];
+ clipTop = tr.clipRegion[1];
+ clipRight = tr.clipRegion[2];
+ clipBottom = tr.clipRegion[3];
+
+ // Completely clipped away
+ if ( right <= clipLeft || left >= clipRight ||
+ bottom <= clipTop || top >= clipBottom ) {
+ return qtrue;
+ }
+
+ // Clip left edge
+ if ( left < clipLeft ) {
+ float f = ( clipLeft - left ) / ( right - left );
+ *s1 = ( f * ( _s2 - _s1 ) ) + _s1;
+ *x = clipLeft;
+ *w -= ( clipLeft - left );
+ }
+
+ // Clip right edge
+ if ( right > clipRight ) {
+ float f = ( clipRight - right ) / ( left - right );
+ *s2 = ( f * ( _s1 - _s2 ) ) + _s2;
+ *w = clipRight - *x;
+ }
+
+ // Clip top edge
+ if ( top < clipTop ) {
+ float f = ( clipTop - top ) / ( bottom - top );
+ *t1 = ( f * ( _t2 - _t1 ) ) + _t1;
+ *y = clipTop;
+ *h -= ( clipTop - top );
+ }
+
+ // Clip bottom edge
+ if ( bottom > clipBottom ) {
+ float f = ( clipBottom - bottom ) / ( top - bottom );
+ *t2 = ( f * ( _t1 - _t2 ) ) + _t2;
+ *h = clipBottom - *y;
+ }
+
+ return qfalse;
+}
+
+/*
+=============
+RE_SetClipRegion
+=============
+*/
+void RE_SetClipRegion( const float *region ) {
+ if ( region == NULL ) {
+ Com_Memset( tr.clipRegion, 0, sizeof( vec4_t ) );
+ } else {
+ Vector4Copy( region, tr.clipRegion );
+ }
+}
/*
=============
@@ -321,9 +403,12 @@ void RE_StretchPic ( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader ) {
stretchPicCommand_t *cmd;
- if (!tr.registered) {
- return;
- }
+ if (!tr.registered) {
+ return;
+ }
+ if (R_ClipRegion(&x, &y, &w, &h, &s1, &t1, &s2, &t2)) {
+ return;
+ }
cmd = R_GetCommandBuffer( sizeof( *cmd ) );
if ( !cmd ) {
return;
diff --git a/src/rend2/tr_init.c b/src/rend2/tr_init.c
index 94b97f8b..30062bb9 100644
--- a/src/rend2/tr_init.c
+++ b/src/rend2/tr_init.c
@@ -195,9 +195,9 @@ cvar_t *r_lodCurveError;
cvar_t *r_fullscreen;
cvar_t *r_noborder;
-cvar_t *r_customwidth;
-cvar_t *r_customheight;
-cvar_t *r_customPixelAspect;
+cvar_t *r_width;
+cvar_t *r_height;
+cvar_t *r_pixelAspect;
cvar_t *r_overBrightBits;
cvar_t *r_mapOverBrightBits;
@@ -319,77 +319,6 @@ void GL_CheckErrs( char *file, int line ) {
}
-/*
-** R_GetModeInfo
-*/
-typedef struct vidmode_s
-{
- const char *description;
- int width, height;
- float pixelAspect; // pixel width / height
-} vidmode_t;
-
-vidmode_t r_vidModes[] =
-{
- { "Mode 0: 320x240", 320, 240, 1 },
- { "Mode 1: 400x300", 400, 300, 1 },
- { "Mode 2: 512x384", 512, 384, 1 },
- { "Mode 3: 640x480", 640, 480, 1 },
- { "Mode 4: 800x600", 800, 600, 1 },
- { "Mode 5: 960x720", 960, 720, 1 },
- { "Mode 6: 1024x768", 1024, 768, 1 },
- { "Mode 7: 1152x864", 1152, 864, 1 },
- { "Mode 8: 1280x1024", 1280, 1024, 1 },
- { "Mode 9: 1600x1200", 1600, 1200, 1 },
- { "Mode 10: 2048x1536", 2048, 1536, 1 },
- { "Mode 11: 856x480 (wide)",856, 480, 1 }
-};
-static int s_numVidModes = ARRAY_LEN( r_vidModes );
-
-qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) {
- vidmode_t *vm;
- float pixelAspect;
-
- if ( mode < -1 ) {
- return qfalse;
- }
- if ( mode >= s_numVidModes ) {
- return qfalse;
- }
-
- if ( mode == -1 ) {
- *width = r_customwidth->integer;
- *height = r_customheight->integer;
- pixelAspect = r_customPixelAspect->value;
- } else {
- vm = &r_vidModes[mode];
-
- *width = vm->width;
- *height = vm->height;
- pixelAspect = vm->pixelAspect;
- }
-
- *windowAspect = (float)*width / ( *height * pixelAspect );
-
- return qtrue;
-}
-
-/*
-** R_ModeList_f
-*/
-static void R_ModeList_f( void )
-{
- int i;
-
- ri.Printf( PRINT_ALL, "\n" );
- for ( i = 0; i < s_numVidModes; i++ )
- {
- ri.Printf( PRINT_ALL, "%s\n", r_vidModes[i].description );
- }
- ri.Printf( PRINT_ALL, "\n" );
-}
-
-
/*
==============================================================================
@@ -1135,9 +1064,9 @@ void R_Register( void )
r_mode = ri.Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH );
r_fullscreen = ri.Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE );
r_noborder = ri.Cvar_Get("r_noborder", "0", CVAR_ARCHIVE);
- r_customwidth = ri.Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH );
- r_customheight = ri.Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH );
- r_customPixelAspect = ri.Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH );
+ r_width = ri.Cvar_Get( "r_width", "640", CVAR_ARCHIVE | CVAR_LATCH );
+ r_height = ri.Cvar_Get( "r_height", "480", CVAR_ARCHIVE | CVAR_LATCH );
+ r_pixelAspect = ri.Cvar_Get( "r_pixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_simpleMipMaps = ri.Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0);
@@ -1297,7 +1226,6 @@ void R_Register( void )
ri.Cmd_AddCommand( "shaderlist", R_ShaderList_f );
ri.Cmd_AddCommand( "skinlist", R_SkinList_f );
ri.Cmd_AddCommand( "modellist", R_Modellist_f );
- ri.Cmd_AddCommand( "modelist", R_ModeList_f );
ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f );
ri.Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f );
ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f );
@@ -1342,9 +1270,6 @@ void R_Init( void ) {
Com_Memset( &backEnd, 0, sizeof( backEnd ) );
Com_Memset( &tess, 0, sizeof( tess ) );
- if(sizeof(glconfig_t) != 11332)
- ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t));
-
// Swap_Init();
if ( (intptr_t)tess.xyz & 15 ) {
@@ -1455,7 +1380,6 @@ void RE_Shutdown( qboolean destroyWindow ) {
ri.Cmd_RemoveCommand ("skinlist");
ri.Cmd_RemoveCommand ("gfxinfo");
ri.Cmd_RemoveCommand("minimize");
- ri.Cmd_RemoveCommand( "modelist" );
ri.Cmd_RemoveCommand( "shaderstate" );
ri.Cmd_RemoveCommand( "gfxmeminfo" );
@@ -1550,6 +1474,7 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) {
re.RenderScene = RE_RenderScene;
re.SetColor = RE_SetColor;
+ re.SetClipRegion = RE_SetClipRegion;
re.DrawStretchPic = RE_StretchPic;
re.DrawStretchRaw = RE_StretchRaw;
re.UploadCinematic = RE_UploadCinematic;
diff --git a/src/rend2/tr_local.h b/src/rend2/tr_local.h
index 3abe5d3d..6730f5c1 100644
--- a/src/rend2/tr_local.h
+++ b/src/rend2/tr_local.h
@@ -1917,6 +1917,8 @@ typedef struct {
frontEndCounters_t pc;
int frontEndMsec; // not in pc due to clearing issue
+ vec4_t clipRegion; // 2D clipping region
+
//
// put large tables at the end, so most elements will be
// within the +/32K indexed range on risc processors
@@ -2864,6 +2866,7 @@ void R_AddCapShadowmapCmd( int dlight, int cubeSide );
void R_AddPostProcessCmd (void);
void RE_SetColor( const float *rgba );
+void RE_SetClipRegion( const float *region );
void RE_StretchPic ( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader );
void RE_BeginFrame( stereoFrame_t stereoFrame );
diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c
index 52c0f45c..3795d97d 100644
--- a/src/renderer/tr_init.c
+++ b/src/renderer/tr_init.c
@@ -1290,7 +1290,6 @@ void RE_Shutdown( qboolean destroyWindow ) {
ri.Cmd_RemoveCommand ("skinlist");
ri.Cmd_RemoveCommand ("gfxinfo");
ri.Cmd_RemoveCommand("minimize");
- ri.Cmd_RemoveCommand( "modelist" );
ri.Cmd_RemoveCommand( "shaderstate" );