// backend
void R_ClearScreen(void);
+// color tag printing
+static vec4_t string_colors[] =
+{
+ // Quake3 colors
+ // LordHavoc: why on earth is cyan before magenta in Quake3?
+ // LordHavoc: note: Doom3 uses white for [0] and [7]
+ {0.0, 0.0, 0.0, 1.0}, // black
+ {1.0, 0.0, 0.0, 1.0}, // red
+ {0.0, 1.0, 0.0, 1.0}, // green
+ {1.0, 1.0, 0.0, 1.0}, // yellow
+ {0.0, 0.0, 1.0, 1.0}, // blue
+ {0.0, 1.0, 1.0, 1.0}, // cyan
+ {1.0, 0.0, 1.0, 1.0}, // magenta
+ {1.0, 1.0, 1.0, 1.0}, // white
+ // [515]'s BX_COLOREDTEXT extension
+ {1.0, 1.0, 1.0, 0.5}, // half transparent
+ {0.5, 0.5, 0.5, 1.0} // half brightness
+ // Black's color table
+ //{1.0, 1.0, 1.0, 1.0},
+ //{1.0, 0.0, 0.0, 1.0},
+ //{0.0, 1.0, 0.0, 1.0},
+ //{0.0, 0.0, 1.0, 1.0},
+ //{1.0, 1.0, 0.0, 1.0},
+ //{0.0, 1.0, 1.0, 1.0},
+ //{1.0, 0.0, 1.0, 1.0},
+ //{0.1, 0.1, 0.1, 1.0}
+};
+
+#define STRING_COLORS_COUNT (sizeof(string_colors) / sizeof(vec4_t))
+
+// color is read and changed in the end
+void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor )
+{
+ vec_t *color;
+ int len;
+ int colorindex;
+ const char *start, *current;
+
+ if( !outcolor || *outcolor == -1 ) {
+ colorindex = STRING_COLOR_DEFAULT;
+ } else {
+ colorindex = *outcolor;
+ }
+ color = string_colors[colorindex];
+
+ if( maxlen < 1)
+ len = (int)strlen( text );
+ else
+ len = min( maxlen, (int) strlen( text ) );
+
+ start = current = text;
+ while( len > 0 ) {
+ // check for color control char
+ if( *current == STRING_COLOR_TAG ) {
+ // get next char
+ current++;
+ len--;
+ if( len == 0 ) {
+ break;
+ }
+ // display the tag char?
+ if( *current == STRING_COLOR_TAG ) {
+ // only display one of the two
+ start = current;
+ // get the next char
+ current++;
+ len--;
+ } else if( '0' <= *current && *current <= '9' ) {
+ colorindex = 0;
+ do {
+ colorindex = colorindex * 10 + (*current - '0');
+ // only read as long as it makes a valid index
+ if( colorindex >= STRING_COLORS_COUNT ) {
+ // undo the last operation
+ colorindex /= 10;
+ break;
+ }
+ current++;
+ len--;
+ } while( len > 0 && '0' <= *current && *current <= '9' );
+ // set the color
+ color = string_colors[colorindex];
+ // we jump over the color tag
+ start = current;
+ }
+ }
+ // go on and read normal text in until the next control char
+ while( len > 0 && *current != STRING_COLOR_TAG ) {
+ current++;
+ len--;
+ }
+ // display the text
+ if( start != current ) {
+ // draw the string
+ DrawQ_String( x, y, start, current - start, scalex, scaley, basered * color[0], basegreen * color[1], baseblue * color[2], basealpha * color[3], flags );
+ // update x to be at the new start position
+ x += (current - start) * scalex;
+ // set start accordingly
+ start = current;
+ }
+ }
+
+ // return the last colorindex
+ if( outcolor ) {
+ *outcolor = colorindex;
+ }
+}
+
/*
===============================================================================
start = scr_centerstring;
if (scr_center_lines <= 4)
- y = vid.conheight*0.35;
+ y = vid_conheight.integer*0.35;
else
y = 48;
do
{
// scan the width of the line
- for (l=0 ; l<vid.conwidth/8 ; l++)
+ for (l=0 ; l<vid_conwidth.integer/8 ; l++)
if (start[l] == '\n' || !start[l])
break;
- x = (vid.conwidth - l*8)/2;
+ x = (vid_conwidth.integer - l*8)/2;
if (l > 0)
{
if (remaining < l)
return;
pic = Draw_CachePic ("gfx/pause", true);
- DrawQ_Pic ((vid.conwidth - pic->width)/2, (vid.conheight - pic->height)/2, "gfx/pause", 0, 0, 1, 1, 1, 1, 0);
+ DrawQ_Pic ((vid_conwidth.integer - pic->width)/2, (vid_conheight.integer - pic->height)/2, "gfx/pause", 0, 0, 1, 1, 1, 1, 0);
}
// decide on the height of the console
if (key_consoleactive & KEY_CONSOLEACTIVE_USER)
- conlines = vid.conheight/2; // half screen
+ conlines = vid_conheight.integer/2; // half screen
else
conlines = 0; // none visible
if (key_consoleactive & KEY_CONSOLEACTIVE_FORCED)
{
// full screen
- Con_DrawConsole (vid.conheight);
+ Con_DrawConsole (vid_conheight.integer);
}
else if (scr_con_current)
Con_DrawConsole (scr_con_current);
r_timereport_current = Sys_DoubleTime();
t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0);
- sprintf(tempbuf, "%8i %s", t, desc);
- length = strlen(tempbuf);
+ dpsnprintf(tempbuf, sizeof(tempbuf), "%8i %s", t, desc);
+ length = (int)strlen(tempbuf);
while (length < 20)
tempbuf[length++] = ' ';
tempbuf[length] = 0;
- if (speedstringcount + length > (vid.conwidth / 8))
+ if (speedstringcount + length > (vid_conwidth.integer / 8))
{
- strcat(r_speeds_string, "\n");
+ strlcat(r_speeds_string, "\n", sizeof(r_speeds_string));
speedstringcount = 0;
}
// skip the space at the beginning if it's the first on the line
if (speedstringcount == 0)
{
- strcat(r_speeds_string, tempbuf + 1);
+ strlcat(r_speeds_string, tempbuf + 1, sizeof(r_speeds_string));
speedstringcount = length - 1;
}
else
{
- strcat(r_speeds_string, tempbuf);
+ strlcat(r_speeds_string, tempbuf, sizeof(r_speeds_string));
speedstringcount += length;
}
}
for (i = 0;r_speeds_string[i];i++)
if (r_speeds_string[i] == '\n')
lines++;
- y = vid.conheight - sb_lines - lines * 8;
+ y = vid_conheight.integer - sb_lines - lines * 8;
i = j = 0;
- DrawQ_Fill(0, y, vid.conwidth, lines * 8, 0, 0, 0, 0.5, 0);
+ DrawQ_Fill(0, y, vid_conwidth.integer, lines * 8, 0, 0, 0, 0.5, 0);
while (r_speeds_string[i])
{
j = i;
if (alpha < (1.0f / 255.0f))
return;
if (maxlen < 1)
- len = strlen(string);
+ len = (int)strlen(string);
else
for (len = 0;len < maxlen && string[len];len++);
for (;len > 0 && string[0] == ' ';string++, x += scalex, len--);
for (;len > 0 && string[len - 1] == ' ';len--);
if (len < 1)
return;
- if (x >= vid.conwidth || y >= vid.conheight || x < (-scalex * len) || y < (-scaley))
+ if (x >= vid_conwidth.integer || y >= vid_conheight.integer || x < (-scalex * len) || y < (-scaley))
return;
size = sizeof(*dq) + ((len + 1 + 3) & ~3);
if (r_refdef.drawqueuesize + size > r_refdef.maxdrawqueuesize)
DrawQ_String_Real(x,y,string,maxlen,scalex,scaley,red,green,blue,alpha,flags);
}
+
+
void DrawQ_Fill (float x, float y, float w, float h, float red, float green, float blue, float alpha, int flags)
{
DrawQ_SuperPic(x,y,NULL,w,h,0,0,red,green,blue,alpha,1,0,red,green,blue,alpha,0,1,red,green,blue,alpha,1,1,red,green,blue,alpha,flags);
sprintf(filename, "%s%06d.%s", base, shotnumber, jpeg ? "jpg" : "tga");
- buffer1 = Mem_Alloc(tempmempool, vid.realwidth * vid.realheight * 3);
- buffer2 = Mem_Alloc(tempmempool, vid.realwidth * vid.realheight * 3);
- buffer3 = Mem_Alloc(tempmempool, vid.realwidth * vid.realheight * 3 + 18);
+ buffer1 = Mem_Alloc(tempmempool, vid.width * vid.height * 3);
+ buffer2 = Mem_Alloc(tempmempool, vid.width * vid.height * 3);
+ buffer3 = Mem_Alloc(tempmempool, vid.width * vid.height * 3 + 18);
- if (SCR_ScreenShot (filename, buffer1, buffer2, buffer3, vid.realx, vid.realy, vid.realwidth, vid.realheight, false, false, false, jpeg, true))
+ if (SCR_ScreenShot (filename, buffer1, buffer2, buffer3, 0, 0, vid.width, vid.height, false, false, false, jpeg, true))
Con_Printf("Wrote %s\n", filename);
else
Con_Printf("unable to write %s\n", filename);
cl_capturevideo_framerate = bound(1, cl_capturevideo_fps.value, 1000);
cl_capturevideo_soundrate = 0;
cl_capturevideo_frame = 0;
- cl_capturevideo_buffer = Mem_Alloc(tempmempool, vid.realwidth * vid.realheight * (3+3+3) + 18);
+ cl_capturevideo_buffer = Mem_Alloc(tempmempool, vid.width * vid.height * (3+3+3) + 18);
gamma = 1.0/scr_screenshot_gamma.value;
/*
qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
{
- int x = vid.realx, y = vid.realy, width = vid.realwidth, height = vid.realheight;
+ int x = 0, y = 0, width = vid.width, height = vid.height;
unsigned char *b, *out;
char filename[32];
int outoffset = (width/2)*(height/2);
- //return SCR_ScreenShot(filename, cl_capturevideo_buffer, cl_capturevideo_buffer + vid.realwidth * vid.realheight * 3, cl_capturevideo_buffer + vid.realwidth * vid.realheight * 6, vid.realx, vid.realy, vid.realwidth, vid.realheight, false, false, false, jpeg, true);
+ //return SCR_ScreenShot(filename, cl_capturevideo_buffer, cl_capturevideo_buffer + vid.width * vid.height * 3, cl_capturevideo_buffer + vid.width * vid.height * 6, 0, 0, vid.width, vid.height, false, false, false, jpeg, true);
// speed is critical here, so do saving as directly as possible
switch (cl_capturevideo_format)
{
}
return true;
case CAPTUREVIDEOFORMAT_TARGA:
- //return Image_WriteTGARGB_preflipped (filename, width, height, cl_capturevideo_buffer, cl_capturevideo_buffer + vid.realwidth * vid.realheight * 3, );
+ //return Image_WriteTGARGB_preflipped (filename, width, height, cl_capturevideo_buffer, cl_capturevideo_buffer + vid.width * vid.height * 3, );
memset (cl_capturevideo_buffer, 0, 18);
cl_capturevideo_buffer[2] = 2; // uncompressed type
cl_capturevideo_buffer[12] = (width >> 0) & 0xFF;
Con_Print("envmap: size must be one of 128, 256, 512, or 1024\n");
return;
}
- if (size > vid.realwidth || size > vid.realheight)
+ if (size > vid.width || size > vid.height)
{
Con_Print("envmap: your resolution is not big enough to render that size\n");
return;
R_Mesh_Start();
R_RenderView();
R_Mesh_Finish();
- SCR_ScreenShot(filename, buffer1, buffer2, buffer3, vid.realx, vid.realy + vid.realheight - (r_refdef.y + r_refdef.height), size, size, envmapinfo[j].flipx, envmapinfo[j].flipy, envmapinfo[j].flipdiagonaly, false, false);
+ SCR_ScreenShot(filename, buffer1, buffer2, buffer3, 0, vid.height - (r_refdef.y + r_refdef.height), size, size, envmapinfo[j].flipx, envmapinfo[j].flipy, envmapinfo[j].flipdiagonaly, false, false);
}
Mem_Free (buffer1);
{
float conwidth, conheight;
- VID_GetWindowSize (&vid.realx, &vid.realy, &vid.realwidth, &vid.realheight);
-
VID_UpdateGamma(false);
conwidth = bound(320, vid_conwidth.value, 2048);
if (vid_conheight.value != conheight)
Cvar_SetValue("vid_conheight", conheight);
- vid.conwidth = vid_conwidth.integer;
- vid.conheight = vid_conheight.integer;
-
-/* if (vid.realheight > 240)
- {
- vid.conheight = (vid.realheight - 240) * scr_2dresolution.value + 240;
- vid.conheight = bound(240, vid.conheight, vid.realheight);
- }
- else
- vid.conheight = 240;*/
+ vid_conwidth.integer = vid_conwidth.integer;
+ vid_conheight.integer = vid_conheight.integer;
SCR_SetUpToDrawConsole();
}