[video] Use views instead of conwidth and conheight

conwidth and conheight have been moved into vid.conview (probably change
the name at some time), and scr_vrect has been replaced by a view as
well. This makes it much easier to create 2d elements that follow the
screen size (taking advantage of a view's gravity) which will, in the
end, make changing the window size easier.
This commit is contained in:
Bill Currie 2021-07-10 18:04:34 +09:00
parent a75c027b7f
commit 755ef524e4
29 changed files with 344 additions and 247 deletions

View file

@ -176,7 +176,7 @@ typedef struct vid_render_funcs_s {
typedef struct vid_render_data_s {
viddef_t *vid;
refdef_t *refdef;
vrect_t *scr_vrect;
struct view_s *scr_view;
int scr_copytop;
int scr_copyeverything;
int scr_fullupdate; // set to 0 to force full redraw

View file

@ -56,8 +56,7 @@ typedef struct {
quat_t cshift_color;
void *conbuffer;
int conrowbytes;
int conwidth;
int conheight;
struct view_s *conview;
byte *direct; // direct drawing to framebuffer, if not
// NULL
struct vid_internal_s *vid_internal;

View file

@ -257,7 +257,6 @@ extern float r_skyspeed;
extern float r_skytime;
extern int c_surf;
extern vrect_t scr_vrect;
extern byte *r_warpbuffer;

View file

@ -64,7 +64,6 @@ extern int clearconsole;
extern int clearnotify;
extern vrect_t *pconupdate;
extern vrect_t scr_vrect;
extern qboolean scr_skipupdate;

View file

@ -180,7 +180,7 @@ Resize (old_console_t *con)
char tbuf[CON_TEXTSIZE];
int width, oldwidth, oldtotallines, numlines, numchars, i, j;
width = (r_data->vid->conwidth >> 3) - 2;
width = (r_data->vid->conview->xlen >> 3) - 2;
if (width < 1) { // video hasn't been initialized yet
width = 38;
@ -234,7 +234,8 @@ C_CheckResize (void)
Resize (&con_main);
Resize (&con_chat);
view_resize (con_data.view, r_data->vid->conwidth, r_data->vid->conheight);
view_resize (con_data.view, r_data->vid->conview->xlen,
r_data->vid->conview->ylen);
}
static void
@ -671,7 +672,7 @@ draw_console (view_t *view)
if (con_data.force_commandline) {
alpha = 255;
} else {
float y = r_data->vid->conheight * con_size->value;
float y = r_data->vid->conview->ylen * con_size->value;
alpha = 255 * con_alpha->value * view->ylen / y;
alpha = min (alpha, 255);
}
@ -732,9 +733,9 @@ setup_console (void)
float lines;
if (con_data.force_commandline) {
lines = con_data.lines = r_data->vid->conheight;
lines = con_data.lines = r_data->vid->conview->ylen;
} else if (con_keydest == key_console) {
lines = r_data->vid->conheight * bound (0.2, con_size->value, 1);
lines = r_data->vid->conview->ylen * bound (0.2, con_size->value, 1);
} else {
lines = 0;
}
@ -750,7 +751,7 @@ setup_console (void)
} else {
con_data.lines = lines;
}
if (con_data.lines >= r_data->vid->conheight - r_data->lineadj)
if (con_data.lines >= r_data->vid->conview->ylen - r_data->lineadj)
r_data->scr_copyeverything = 1;
}

View file

@ -59,6 +59,7 @@
#include "QF/GL/qf_textures.h"
#include "QF/GL/qf_vid.h"
#include "QF/GL/types.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
@ -682,8 +683,8 @@ gl_Draw_Crosshair (void)
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = vid.conwidth / 2 + cl_crossx->int_val;
y = vid.conheight / 2 + cl_crossy->int_val;
x = vid.conview->xlen / 2 + cl_crossx->int_val;
y = vid.conview->ylen / 2 + cl_crossy->int_val;
crosshair_func[ch] (x, y);
}
@ -808,7 +809,7 @@ gl_Draw_ConsoleBackground (int lines, byte alpha)
if (gl_constretch->int_val) {
ofs = 0;
} else
ofs = (vid.conheight - lines) / (float) vid.conheight;
ofs = (vid.conview->ylen - lines) / (float) vid.conview->ylen;
color_0_8[3] = alpha;
qfglColor4ubv (color_0_8);
@ -819,9 +820,9 @@ gl_Draw_ConsoleBackground (int lines, byte alpha)
qfglTexCoord2f (0, 0 + ofs);
qfglVertex2f (0, 0);
qfglTexCoord2f (1, 0 + ofs);
qfglVertex2f (vid.conwidth, 0);
qfglVertex2f (vid.conview->xlen, 0);
qfglTexCoord2f (1, 1);
qfglVertex2f (vid.conwidth, lines);
qfglVertex2f (vid.conview->xlen, lines);
qfglTexCoord2f (0, 1);
qfglVertex2f (0, lines);
qfglEnd ();
@ -837,8 +838,9 @@ gl_Draw_ConsoleBackground (int lines, byte alpha)
qfglPopMatrix ();
}
gl_Draw_AltString (vid.conwidth - strlen (cl_verstring->string) * 8 - 11,
lines - 14, cl_verstring->string);
int len = strlen (cl_verstring->string);
gl_Draw_AltString (vid.conview->xlen - len * 8 - 11, lines - 14,
cl_verstring->string);
qfglColor3ubv (color_white);
}
@ -901,9 +903,9 @@ gl_Draw_FadeScreen (void)
qfglBegin (GL_QUADS);
qfglVertex2f (0, 0);
qfglVertex2f (vid.conwidth, 0);
qfglVertex2f (vid.conwidth, vid.conheight);
qfglVertex2f (0, vid.conheight);
qfglVertex2f (vid.conview->xlen, 0);
qfglVertex2f (vid.conview->xlen, vid.conview->ylen);
qfglVertex2f (0, vid.conview->ylen);
qfglEnd ();
qfglColor3ubv (color_white);
@ -943,7 +945,7 @@ GL_Set2D (void)
void
GL_Set2DScaled (void)
{
set_2d (vid.conwidth, vid.conheight);
set_2d (vid.conview->xlen, vid.conview->ylen);
}
void
@ -974,9 +976,9 @@ gl_Draw_BlendScreen (quat_t color)
qfglColor4fv (color);
qfglVertex2f (0, 0);
qfglVertex2f (vid.conwidth, 0);
qfglVertex2f (vid.conwidth, vid.conheight);
qfglVertex2f (0, vid.conheight);
qfglVertex2f (vid.conview->xlen, 0);
qfglVertex2f (vid.conview->xlen, vid.conview->ylen);
qfglVertex2f (0, vid.conview->ylen);
qfglEnd ();

View file

@ -55,6 +55,7 @@
#include "QF/GL/qf_draw.h"
#include "QF/GL/qf_rmain.h"
#include "QF/GL/qf_vid.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
@ -238,6 +239,7 @@ gl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
GL_Set2DScaled ();
view_draw (vr_data.scr_view);
while (*scr_funcs) {
(*scr_funcs)();
scr_funcs++;

View file

@ -48,6 +48,7 @@
#include "QF/quakefs.h"
#include "QF/sys.h"
#include "QF/vid.h"
#include "QF/ui/view.h"
#include "QF/GLSL/defines.h"
#include "QF/GLSL/funcs.h"
@ -570,8 +571,8 @@ glsl_Draw_Crosshair (void)
{
int x, y;
x = vid.conwidth / 2 + cl_crossx->int_val;
y = vid.conheight / 2 + cl_crossy->int_val;
x = vid.conview->xlen / 2 + cl_crossx->int_val;
y = vid.conview->ylen / 2 + cl_crossy->int_val;
glsl_Draw_CrosshairAt (crosshair->int_val, x, y);
}
@ -603,14 +604,14 @@ glsl_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
void
glsl_Draw_ConsoleBackground (int lines, byte alpha)
{
float ofs = (vid.conheight - lines) / (float) vid.conheight;
float ofs = (vid.conview->ylen - lines) / (float) vid.conview->ylen;
quat_t color = {1, 1, 1, bound (0, alpha, 255) / 255.0};
drawvert_t verts[] = {
{{ 0, 0, 0, ofs}},
{{vid.conwidth, 0, 1, ofs}},
{{vid.conwidth, lines, 1, 1}},
{{vid.conview->xlen, 0, 1, ofs}},
{{vid.conview->xlen, lines, 1, 1}},
{{ 0, 0, 0, ofs}},
{{vid.conwidth, lines, 1, 1}},
{{vid.conview->xlen, lines, 1, 1}},
{{ 0, lines, 0, 1}},
};
@ -684,7 +685,8 @@ glsl_Draw_Fill (int x, int y, int w, int h, int c)
static inline void
draw_blendscreen (quat_t color)
{
draw_pic (0, 0, vid.conwidth, vid.conheight, white_pic, 0, 0, 8, 8, color);
draw_pic (0, 0, vid.conview->xlen, vid.conview->ylen, white_pic,
0, 0, 8, 8, color);
}
void
@ -757,7 +759,7 @@ GLSL_Set2D (void)
void
GLSL_Set2DScaled (void)
{
set_2d (vid.conwidth, vid.conheight);
set_2d (vid.conview->xlen, vid.conview->ylen);
}
void

View file

@ -58,6 +58,7 @@
#include "QF/GLSL/qf_draw.h"
#include "QF/GLSL/qf_textures.h"
#include "QF/GLSL/qf_vid.h"
#include "QF/ui/view.h"
#include "r_internal.h"
#include "vid_gl.h"
@ -184,6 +185,8 @@ glsl_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
GLSL_DrawReset ();
SCR_TileClear ();
GLSL_Set2DScaled ();
view_draw (vr_data.scr_view);
while (*scr_funcs) {
(*scr_funcs)();
scr_funcs++;

View file

@ -44,6 +44,8 @@
#include "QF/screen.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
#include "sbar.h"
@ -105,7 +107,6 @@ qpic_t *scr_turtle;
int clearconsole;
vrect_t *pconupdate;
vrect_t scr_vrect;
qboolean scr_skipupdate;
@ -179,9 +180,10 @@ SCR_CalcRefdef (void)
vrect.width = r_data->vid->width;
vrect.height = r_data->vid->height;
R_SetVrect (&vrect, &scr_vrect, r_data->lineadj);
R_SetVrect (&vrect, &refdef->vrect, r_data->lineadj);
refdef->vrect = scr_vrect;
view_setgeometry (vr_data.scr_view, refdef->vrect.x, refdef->vrect.y,
refdef->vrect.width, refdef->vrect.height);
// notify the refresh of the change
r_funcs->R_ViewChanged ();
@ -262,7 +264,9 @@ SCR_DrawRam (void)
if (!r_cache_thrash)
return;
r_funcs->Draw_Pic (scr_vrect.x + 32, scr_vrect.y, scr_ram);
//FIXME view
r_funcs->Draw_Pic (vr_data.scr_view->xpos + 32, vr_data.scr_view->ypos,
scr_ram);
}
void
@ -282,7 +286,9 @@ SCR_DrawTurtle (void)
if (count < 3)
return;
r_funcs->Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle);
//FIXME view
r_funcs->Draw_Pic (vr_data.scr_view->xpos, vr_data.scr_view->ypos,
scr_turtle);
}
void
@ -296,9 +302,11 @@ SCR_DrawPause (void)
if (!r_data->paused)
return;
//FIXME view conwidth
pic = r_funcs->Draw_CachePic ("gfx/pause.lmp", true);
r_funcs->Draw_Pic ((r_data->vid->conwidth - pic->width) / 2,
(r_data->vid->conheight - 48 - pic->height) / 2, pic);
r_funcs->Draw_Pic ((r_data->vid->conview->xlen - pic->width) / 2,
(r_data->vid->conview->ylen - 48 - pic->height) / 2,
pic);
}
void

View file

@ -29,6 +29,7 @@
#endif
#include "QF/render.h"
#include "QF/ui/view.h"
#include "d_local.h"
#include "r_internal.h"
@ -50,6 +51,10 @@ D_WarpScreen (void)
{
int w, h;
int u, v;
int scr_x = vr_data.scr_view->xpos;
int scr_y = vr_data.scr_view->ypos;
int scr_w = vr_data.scr_view->xlen;
int scr_h = vr_data.scr_view->ylen;
byte *dest;
int *turb;
int *col;
@ -63,26 +68,26 @@ D_WarpScreen (void)
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
wratio = w / (float) scr_vrect.width;
hratio = h / (float) scr_vrect.height;
wratio = w / (float) scr_w;
hratio = h / (float) scr_h;
for (v = 0; v < scr_vrect.height + AMP2 * 2; v++) {
for (v = 0; v < scr_h + AMP2 * 2; v++) {
rowptr[v] = d_viewbuffer + (r_refdef.vrect.y * screenwidth) +
(screenwidth * (int) ((float) v * hratio * h / (h + AMP2 * 2)));
}
for (u = 0; u < scr_vrect.width + AMP2 * 2; u++) {
for (u = 0; u < scr_w + AMP2 * 2; u++) {
column[u] = r_refdef.vrect.x +
(int) ((float) u * wratio * w / (w + AMP2 * 2));
}
turb = intsintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
dest = ((byte*)vid.buffer) + scr_vrect.y * vid.rowbytes + scr_vrect.x;
dest = ((byte*)vid.buffer) + scr_y * vid.rowbytes + scr_x;
for (v = 0; v < scr_vrect.height; v++, dest += vid.rowbytes) {
for (v = 0; v < scr_h; v++, dest += vid.rowbytes) {
col = &column[turb[v]];
row = &rowptr[v];
for (u = 0; u < scr_vrect.width; u += 4) {
for (u = 0; u < scr_w; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]];
dest[u + 2] = row[turb[u + 2]][col[u + 2]];

View file

@ -42,6 +42,7 @@
#include "QF/quakefs.h"
#include "QF/sound.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "d_iface.h"
#include "r_internal.h"
@ -263,7 +264,7 @@ Draw_Character (int x, int y, unsigned int chr)
if (y <= -8)
return; // totally off screen
if (y > vid.conheight - 8 || x < 0 || x > vid.conwidth - 8)
if (y > vid.conview->ylen - 8 || x < 0 || x > vid.conview->xlen - 8)
return;
if (chr > 255)
return;
@ -461,8 +462,8 @@ Draw_Crosshair (void)
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = vid.conwidth / 2 + cl_crossx->int_val;
y = vid.conheight / 2 + cl_crossy->int_val;
x = vid.conview->xlen / 2 + cl_crossx->int_val;
y = vid.conview->ylen / 2 + cl_crossy->int_val;
crosshair_func[ch] (x, y);
}
@ -484,8 +485,8 @@ Draw_Pic (int x, int y, qpic_t *pic)
byte *dest, *source, tbyte;
int v, u;
if (x < 0 || (x + pic->width) > vid.conwidth
|| y < 0 || (y + pic->height) > vid.conheight) {
if (x < 0 || (x + pic->width) > vid.conview->xlen
|| y < 0 || (y + pic->height) > vid.conview->ylen) {
Sys_MaskPrintf (SYS_vid, "Draw_Pic: bad coordinates");
Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height);
return;
@ -543,8 +544,8 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
byte *dest, *source, tbyte;
int u, v;
if ((x < 0) || (x + width > vid.conwidth)
|| (y < 0) || (y + height > vid.conheight)) {
if ((x < 0) || (x + width > vid.conview->xlen)
|| (y < 0) || (y + height > vid.conview->ylen)) {
Sys_MaskPrintf (SYS_vid, "Draw_SubPic: bad coordinates");
}
// first, clip to screen
@ -623,14 +624,14 @@ Draw_ConsoleBackground (int lines, byte alpha)
dest = vid.conbuffer;
for (y = 0; y < lines; y++, dest += vid.conrowbytes) {
v = (vid.conheight - lines + y) * 200 / vid.conheight;
v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen;
src = conback->data + v * 320;
if (vid.conwidth == 320)
memcpy (dest, src, vid.conwidth);
if (vid.conview->xlen == 320)
memcpy (dest, src, vid.conview->xlen);
else {
f = 0;
fstep = 320 * 0x10000 / vid.conwidth;
for (x = 0; x < vid.conwidth; x += 4) {
fstep = 320 * 0x10000 / vid.conview->xlen;
for (x = 0; x < vid.conview->xlen; x += 4) {
dest[x] = src[f >> 16];
f += fstep;
dest[x + 1] = src[f >> 16];
@ -643,7 +644,7 @@ Draw_ConsoleBackground (int lines, byte alpha)
}
}
Draw_AltString (vid.conwidth - strlen (cl_verstring->string) * 8 - 11,
Draw_AltString (vid.conview->xlen - strlen (cl_verstring->string) * 8 - 11,
lines - 14, cl_verstring->string);
}
@ -759,8 +760,8 @@ Draw_Fill (int x, int y, int w, int h, int c)
byte *dest;
int u, v;
if (x < 0 || x + w > vid.conwidth
|| y < 0 || y + h > vid.conheight) {
if (x < 0 || x + w > vid.conview->xlen
|| y < 0 || y + h > vid.conview->ylen) {
Sys_MaskPrintf (SYS_vid, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
x, y, w, h, c);
}
@ -777,8 +778,8 @@ void
Draw_FadeScreen (void)
{
int x, y;
int height = vid.conheight;
int width = vid.conwidth / 4;
int height = vid.conview->ylen;
int width = vid.conview->xlen / 4;
uint32_t *pbuf;
VID_UnlockBuffer ();

View file

@ -47,6 +47,7 @@
#include "QF/screen.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
@ -207,6 +208,7 @@ R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
D_EnableBackBufferAccess (); // of all overlay stuff if drawing
// directly
view_draw (vr_data.scr_view);
while (*scr_funcs) {
(*scr_funcs)();
scr_funcs++;
@ -232,10 +234,10 @@ R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
vrect.height = vid.height - vr_data.lineadj;
vrect.next = 0;
} else {
vrect.x = scr_vrect.x;
vrect.y = scr_vrect.y;
vrect.width = scr_vrect.width;
vrect.height = scr_vrect.height;
vrect.x = vr_data.scr_view->xpos;
vrect.y = vr_data.scr_view->ypos;
vrect.width = vr_data.scr_view->xlen;
vrect.height = vr_data.scr_view->ylen;
vrect.next = 0;
}
sw_ctx->update (&vrect);

View file

@ -33,6 +33,7 @@
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
@ -290,7 +291,10 @@ R_SetupFrame (void)
R_ViewChanged ();
}
} else {
r_refdef.vrect = scr_vrect;
r_refdef.vrect.x = vr_data.scr_view->xpos;
r_refdef.vrect.y = vr_data.scr_view->ypos;
r_refdef.vrect.width = vr_data.scr_view->xlen;
r_refdef.vrect.height = vr_data.scr_view->ylen;
R_ViewChanged ();
}

View file

@ -34,6 +34,7 @@
#include "QF/qendian.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "d_local.h"
@ -60,6 +61,10 @@ sw32_D_WarpScreen (void)
{
int w, h;
int u, v;
int scr_x = vr_data.scr_view->xpos;
int scr_y = vr_data.scr_view->ylen;
int scr_w = vr_data.scr_view->xpos;
int scr_h = vr_data.scr_view->ylen;
byte *dest;
int *turb;
int *col;
@ -71,29 +76,28 @@ sw32_D_WarpScreen (void)
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
wratio = w / (float) scr_vrect.width;
hratio = h / (float) scr_vrect.height;
wratio = w / (float) scr_w;
hratio = h / (float) scr_h;
for (v = 0; v < scr_vrect.height + AMP2 * 2; v++) {
for (v = 0; v < scr_h + AMP2 * 2; v++) {
rowptr[v] = (byte *) sw32_d_viewbuffer + (r_refdef.vrect.y *
sw32_screenwidth) +
(sw32_screenwidth * (int) ((float) v * hratio * h /
(h + AMP2 * 2)));
}
for (u = 0; u < scr_vrect.width + AMP2 * 2; u++) {
for (u = 0; u < scr_w + AMP2 * 2; u++) {
column[u] = r_refdef.vrect.x +
(int) ((float) u * wratio * w / (w + AMP2 * 2));
}
turb = sw32_intsintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
dest = (byte *)vid.buffer + scr_vrect.y * vid.rowbytes +
scr_vrect.x;
dest = (byte *)vid.buffer + scr_y * vid.rowbytes + scr_x;
for (v = 0; v < scr_vrect.height; v++, dest += vid.rowbytes) {
for (v = 0; v < scr_h; v++, dest += vid.rowbytes) {
col = &column[turb[v]];
row = &rowptr[v];
for (u = 0; u < scr_vrect.width; u += 4) {
for (u = 0; u < scr_w; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]];
dest[u + 2] = row[turb[u + 2]][col[u + 2]];
@ -106,6 +110,10 @@ sw32_D_WarpScreen (void)
{
int w, h;
int u, v;
int scr_x = vr_data.scr_view->xpos;
int scr_y = vr_data.scr_view->ylen;
int scr_w = vr_data.scr_view->xpos;
int scr_h = vr_data.scr_view->ylen;
short *dest;
int *turb;
int *col;
@ -117,29 +125,28 @@ sw32_D_WarpScreen (void)
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
wratio = w / (float) scr_vrect.width;
hratio = h / (float) scr_vrect.height;
wratio = w / (float) scr_w;
hratio = h / (float) scr_h;
for (v = 0; v < scr_vrect.height + AMP2 * 2; v++) {
for (v = 0; v < scr_h + AMP2 * 2; v++) {
rowptr[v] = (short *) sw32_d_viewbuffer +
(r_refdef.vrect.y * sw32_screenwidth) +
(sw32_screenwidth * (int) ((float) v * hratio * h /
(h + AMP2 * 2)));
}
for (u = 0; u < scr_vrect.width + AMP2 * 2; u++) {
for (u = 0; u < scr_w + AMP2 * 2; u++) {
column[u] = r_refdef.vrect.x +
(int) ((float) u * wratio * w / (w + AMP2 * 2));
}
turb = sw32_intsintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
dest = (short *) vid.buffer + scr_vrect.y * (vid.rowbytes >> 1) +
scr_vrect.x;
dest = (short *) vid.buffer + scr_y * (vid.rowbytes >> 1) + scr_x;
for (v = 0; v < scr_vrect.height; v++, dest += (vid.rowbytes >> 1)) {
for (v = 0; v < scr_h; v++, dest += (vid.rowbytes >> 1)) {
col = &column[turb[v]];
row = &rowptr[v];
for (u = 0; u < scr_vrect.width; u += 4) {
for (u = 0; u < scr_w; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]];
dest[u + 2] = row[turb[u + 2]][col[u + 2]];
@ -152,6 +159,10 @@ sw32_D_WarpScreen (void)
{
int w, h;
int u, v;
int scr_x = vr_data.scr_view->xpos;
int scr_y = vr_data.scr_view->ylen;
int scr_w = vr_data.scr_view->xpos;
int scr_h = vr_data.scr_view->ylen;
int *dest;
int *turb;
int *col;
@ -163,29 +174,28 @@ sw32_D_WarpScreen (void)
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
wratio = w / (float) scr_vrect.width;
hratio = h / (float) scr_vrect.height;
wratio = w / (float) scr_w;
hratio = h / (float) scr_h;
for (v = 0; v < scr_vrect.height + AMP2 * 2; v++) {
for (v = 0; v < scr_h + AMP2 * 2; v++) {
rowptr[v] = (int *) sw32_d_viewbuffer +
(r_refdef.vrect.y * sw32_screenwidth) +
(sw32_screenwidth * (int) ((float) v * hratio * h /
(h + AMP2 * 2)));
}
for (u = 0; u < scr_vrect.width + AMP2 * 2; u++) {
for (u = 0; u < scr_w + AMP2 * 2; u++) {
column[u] = r_refdef.vrect.x +
(int) ((float) u * wratio * w / (w + AMP2 * 2));
}
turb = sw32_intsintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
dest = (int *) vid.buffer + scr_vrect.y * (vid.rowbytes >> 2) +
scr_vrect.x;
dest = (int *) vid.buffer + scr_y * (vid.rowbytes >> 2) + scr_x;
for (v = 0; v < scr_vrect.height; v++, dest += (vid.rowbytes >> 2)) {
for (v = 0; v < scr_h; v++, dest += (vid.rowbytes >> 2)) {
col = &column[turb[v]];
row = &rowptr[v];
for (u = 0; u < scr_vrect.width; u += 4) {
for (u = 0; u < scr_w; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]];
dest[u + 2] = row[turb[u + 2]][col[u + 2]];

View file

@ -45,6 +45,7 @@
#include "QF/quakefs.h"
#include "QF/sound.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "d_iface.h"
#include "r_internal.h"
@ -265,7 +266,7 @@ sw32_Draw_Character (int x, int y, unsigned int chr)
if (y <= -8)
return; // totally off screen
if (y > vid.conheight - 8 || x < 0 || x > vid.conwidth - 8)
if (y > vid.conview->ylen - 8 || x < 0 || x > vid.conview->xlen - 8)
return;
if (chr > 255)
return;
@ -538,8 +539,8 @@ sw32_Draw_Crosshair (void)
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = vid.conwidth / 2 + cl_crossx->int_val;
y = vid.conheight / 2 + cl_crossy->int_val;
x = vid.conview->xlen / 2 + cl_crossx->int_val;
y = vid.conview->ylen / 2 + cl_crossy->int_val;
crosshair_func[ch] (x, y);
}
@ -560,8 +561,8 @@ sw32_Draw_Pic (int x, int y, qpic_t *pic)
byte *source, tbyte;
int v, u;
if (x < 0 || (x + pic->width) > vid.conwidth
|| y < 0 || (y + pic->height) > vid.conheight) {
if (x < 0 || (x + pic->width) > vid.conview->xlen
|| y < 0 || (y + pic->height) > vid.conview->ylen) {
Sys_MaskPrintf (SYS_vid, "Draw_Pic: bad coordinates");
sw32_Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height);
return;
@ -659,8 +660,8 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
byte *source, tbyte;
int v, u;
if ((x < 0) || (x + width > vid.conwidth)
|| (y < 0) || (y + height > vid.conheight)) {
if ((x < 0) || (x + width > vid.conview->xlen)
|| (y < 0) || (y + height > vid.conview->ylen)) {
Sys_MaskPrintf (SYS_vid, "Draw_SubPic: bad coordinates");
}
// first, clip to screen
@ -746,14 +747,14 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
byte *dest = vid.conbuffer;
for (y = 0; y < lines; y++, dest += vid.conrowbytes) {
v = (vid.conheight - lines + y) * 200 / vid.conheight;
v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen;
src = conback->data + v * 320;
if (vid.conwidth == 320)
memcpy (dest, src, vid.conwidth);
if (vid.conview->xlen == 320)
memcpy (dest, src, vid.conview->xlen);
else {
f = 0;
fstep = 320 * 0x10000 / vid.conwidth;
for (x = 0; x < vid.conwidth; x += 4) {
fstep = 320 * 0x10000 / vid.conview->xlen;
for (x = 0; x < vid.conview->xlen; x += 4) {
dest[x] = src[f >> 16];
f += fstep;
dest[x + 1] = src[f >> 16];
@ -774,11 +775,11 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
for (y = 0; y < lines; y++, dest += (vid.conrowbytes >> 1)) {
// FIXME: pre-expand to native format?
// FIXME: does the endian switching go away in production?
v = (vid.conheight - lines + y) * 200 / vid.conheight;
v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen;
src = conback->data + v * 320;
f = 0;
fstep = 320 * 0x10000 / vid.conwidth;
for (x = 0; x < vid.conwidth; x += 4) {
fstep = 320 * 0x10000 / vid.conview->xlen;
for (x = 0; x < vid.conview->xlen; x += 4) {
dest[x] = sw32_8to16table[src[f >> 16]];
f += fstep;
dest[x + 1] = sw32_8to16table[src[f >> 16]];
@ -795,11 +796,11 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
{
unsigned int *dest = (unsigned int *) vid.conbuffer;
for (y = 0; y < lines; y++, dest += (vid.conrowbytes >> 2)) {
v = (vid.conheight - lines + y) * 200 / vid.conheight;
v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen;
src = conback->data + v * 320;
f = 0;
fstep = 320 * 0x10000 / vid.conwidth;
for (x = 0; x < vid.conwidth; x += 4) {
fstep = 320 * 0x10000 / vid.conview->xlen;
for (x = 0; x < vid.conview->xlen; x += 4) {
dest[x ] = d_8to24table[src[f >> 16]];f += fstep;
dest[x + 1] = d_8to24table[src[f >> 16]];f += fstep;
dest[x + 2] = d_8to24table[src[f >> 16]];f += fstep;
@ -815,7 +816,8 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
}
// if (!cls.download)
sw32_Draw_AltString (vid.conwidth - strlen (cl_verstring->string) * 8 - 11,
int len = strlen (cl_verstring->string);
sw32_Draw_AltString (vid.conview->xlen - len * 8 - 11,
lines - 14, cl_verstring->string);
}
@ -1174,8 +1176,8 @@ sw32_Draw_Fill (int x, int y, int w, int h, int c)
{
int u, v;
if (x < 0 || x + w > vid.conwidth
|| y < 0 || y + h > vid.conheight) {
if (x < 0 || x + w > vid.conview->xlen
|| y < 0 || y + h > vid.conview->ylen) {
Sys_MaskPrintf (SYS_vid, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
x, y, w, h, c);
}
@ -1228,12 +1230,12 @@ sw32_Draw_FadeScreen (void)
switch(sw32_r_pixbytes) {
case 1:
{
for (y = 0; y < vid.conheight; y++) {
for (y = 0; y < vid.conview->ylen; y++) {
unsigned int t;
byte *pbuf = (byte *) ((byte *) vid.buffer + vid.rowbytes * y);
t = (y & 1) << 1;
for (x = 0; x < vid.conwidth; x++) {
for (x = 0; x < vid.conview->xlen; x++) {
if ((x & 3) != t)
pbuf[x] = 0;
}
@ -1242,21 +1244,21 @@ sw32_Draw_FadeScreen (void)
break;
case 2:
{
for (y = 0; y < vid.conheight; y++) {
for (y = 0; y < vid.conview->ylen; y++) {
unsigned short *pbuf = (unsigned short *)
((byte *) vid.buffer + vid.rowbytes * y);
pbuf = (unsigned short *) vid.buffer + (vid.rowbytes >> 1) * y;
for (x = 0; x < vid.conwidth; x++)
for (x = 0; x < vid.conview->xlen; x++)
pbuf[x] = (pbuf[x] >> 1) & 0x7BEF;
}
}
break;
case 4:
{
for (y = 0; y < vid.conheight; y++) {
for (y = 0; y < vid.conview->ylen; y++) {
unsigned int *pbuf = (unsigned int *)
((byte *) vid.buffer + vid.rowbytes * y);
for (x = 0; x < vid.conwidth; x++)
for (x = 0; x < vid.conview->xlen; x++)
pbuf[x] = (pbuf[x] >> 1) & 0x7F7F7F7F;
}
}

View file

@ -50,6 +50,7 @@
#include "QF/screen.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
@ -164,6 +165,7 @@ sw32_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
sw32_D_EnableBackBufferAccess (); // of all overlay stuff if drawing
// directly
view_draw (vr_data.scr_view);
while (*scr_funcs) {
(*scr_funcs)();
scr_funcs++;
@ -189,10 +191,10 @@ sw32_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
vrect.height = vid.height - vr_data.lineadj;
vrect.next = 0;
} else {
vrect.x = scr_vrect.x;
vrect.y = scr_vrect.y;
vrect.width = scr_vrect.width;
vrect.height = scr_vrect.height;
vrect.x = vr_data.scr_view->xpos;
vrect.y = vr_data.scr_view->ypos;
vrect.width = vr_data.scr_view->xlen;
vrect.height = vr_data.scr_view->ylen;
vrect.next = 0;
}
sw32_ctx->update (&vrect);

View file

@ -36,6 +36,7 @@
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "r_internal.h"
@ -291,7 +292,10 @@ sw32_R_SetupFrame (void)
vrect.width = vid.width;
vrect.height = vid.height;
r_refdef.vrect = scr_vrect;
r_refdef.vrect.x = vr_data.scr_view->xpos;
r_refdef.vrect.y = vr_data.scr_view->ypos;
r_refdef.vrect.width = vr_data.scr_view->xlen;
r_refdef.vrect.height = vr_data.scr_view->ylen;
sw32_R_ViewChanged ();
}

View file

@ -31,13 +31,16 @@
#include "QF/plugin/general.h"
#include "QF/plugin/vid_render.h"
#include "QF/ui/view.h"
#include "mod_internal.h"
#include "r_internal.h"
viddef_t vid; // global video state
view_t scr_view;
vid_render_data_t vid_render_data = {
&vid, &r_refdef, &scr_vrect,
&vid, &r_refdef, &scr_view,
0, 0, 0,
0,
0, 0,

View file

@ -56,6 +56,7 @@
#include "QF/Vulkan/instance.h"
#include "QF/Vulkan/renderpass.h"
#include "QF/Vulkan/swapchain.h"
#include "QF/ui/view.h"
#include "mod_internal.h"
#include "r_internal.h"
@ -131,6 +132,8 @@ vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
frame->framebuffer = vulkan_ctx->framebuffers->a[imageIndex];
scr_3dfunc ();
view_draw (vr_data.scr_view);
while (*scr_funcs) {
(*scr_funcs) ();
scr_funcs++;

View file

@ -61,6 +61,7 @@
#include "QF/Vulkan/image.h"
#include "QF/Vulkan/scrap.h"
#include "QF/Vulkan/staging.h"
#include "QF/ui/view.h"
#include "r_internal.h"
#include "vid_vulkan.h"
@ -508,10 +509,10 @@ Vulkan_Draw_Character (int x, int y, unsigned int chr, vulkan_ctx_t *ctx)
if (chr == ' ') {
return;
}
if (y <= -8 || y >= vid.conheight) {
if (y <= -8 || y >= vid.conview->ylen) {
return;
}
if (x <= -8 || x >= vid.conwidth) {
if (x <= -8 || x >= vid.conview->xlen) {
return;
}
queue_character (x, y, chr, ctx);
@ -525,11 +526,11 @@ Vulkan_Draw_String (int x, int y, const char *str, vulkan_ctx_t *ctx)
if (!str || !str[0]) {
return;
}
if (y <= -8 || y >= vid.conheight) {
if (y <= -8 || y >= vid.conview->ylen) {
return;
}
while (*str) {
if ((chr = *str++) != ' ' && x >= -8 && x < vid.conwidth) {
if ((chr = *str++) != ' ' && x >= -8 && x < vid.conview->xlen) {
queue_character (x, y, chr, ctx);
}
x += 8;
@ -545,11 +546,11 @@ Vulkan_Draw_nString (int x, int y, const char *str, int count,
if (!str || !str[0]) {
return;
}
if (y <= -8 || y >= vid.conheight) {
if (y <= -8 || y >= vid.conview->ylen) {
return;
}
while (count-- > 0 && *str) {
if ((chr = *str++) != ' ' && x >= -8 && x < vid.conwidth) {
if ((chr = *str++) != ' ' && x >= -8 && x < vid.conview->xlen) {
queue_character (x, y, chr, ctx);
}
x += 8;
@ -564,12 +565,12 @@ Vulkan_Draw_AltString (int x, int y, const char *str, vulkan_ctx_t *ctx)
if (!str || !str[0]) {
return;
}
if (y <= -8 || y >= vid.conheight) {
if (y <= -8 || y >= vid.conview->ylen) {
return;
}
while (*str) {
if ((chr = *str++ | 0x80) != (' ' | 0x80)
&& x >= -8 && x < vid.conwidth) {
&& x >= -8 && x < vid.conview->xlen) {
queue_character (x, y, chr, ctx);
}
x += 8;
@ -632,7 +633,7 @@ Vulkan_Draw_ConsoleBackground (int lines, byte alpha, vulkan_ctx_t *ctx)
cpic = Vulkan_Draw_CachePic ("gfx/conback.lmp", false, ctx);
int ofs = max (0, cpic->height - lines);
lines = min (lines, cpic->height);
draw_pic (0, 0, vid.conwidth, lines, cpic,
draw_pic (0, 0, vid.conview->xlen, lines, cpic,
0, ofs, cpic->width, lines, color, frame);
}
@ -660,8 +661,8 @@ draw_blendscreen (quat_t color, vulkan_ctx_t *ctx)
drawctx_t *dctx = ctx->draw_context;
drawframe_t *frame = &dctx->frames.a[ctx->curFrame];
draw_pic (0, 0, vid.conwidth, vid.conheight, dctx->white_pic, 0, 0, 1, 1,
color, frame);
draw_pic (0, 0, vid.conview->xlen, vid.conview->ylen, dctx->white_pic,
0, 0, 1, 1, color, frame);
}
void

View file

@ -38,6 +38,7 @@
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/projection.h"
#include "QF/ui/view.h"
#include "r_internal.h"
#include "vid_vulkan.h"
@ -105,8 +106,8 @@ Vulkan_CalcProjectionMatrices (vulkan_ctx_t *ctx)
__auto_type mat = &ctx->matrices;
int width = vid.conwidth;
int height = vid.conheight;
int width = vid.conview->xlen;
int height = vid.conview->ylen;
QFV_Orthographic (mat->projection_2d, 0, width, 0, height, -99999, 99999);
float aspect = (float) r_refdef.vrect.width / r_refdef.vrect.height;

View file

@ -42,6 +42,7 @@
#include "QF/qargs.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/ui/view.h"
#include "compat.h"
#include "d_iface.h"
@ -63,6 +64,8 @@ cvar_t *vid_height;
cvar_t *vid_fullscreen;
static view_t conview;
void
VID_GetWindowSize (int def_w, int def_h)
{
@ -112,6 +115,7 @@ VID_GetWindowSize (int def_w, int def_h)
viddef.width = vid_width->int_val;
viddef.height = vid_height->int_val;
viddef.conview = &conview;
con_width = Cvar_Get ("con_width", va (0, "%d", viddef.width), CVAR_NONE,
NULL, "console effective width (GL only)");
@ -123,9 +127,9 @@ VID_GetWindowSize (int def_w, int def_h)
// make con_width a multiple of 8 and >= 320
Cvar_Set (con_width, va (0, "%d", max (con_width->int_val & ~7, 320)));
Cvar_SetFlags (con_width, con_width->flags | CVAR_ROM);
viddef.conwidth = con_width->int_val;
viddef.conview->xlen = con_width->int_val;
conheight = (viddef.conwidth * viddef.height) / viddef.width;
conheight = (viddef.conview->xlen * viddef.height) / viddef.width;
con_height = Cvar_Get ("con_height", va (0, "%d", conheight), CVAR_NONE,
NULL, "console effective height (GL only)");
if ((pnum = COM_CheckParm ("-conheight"))) {
@ -136,7 +140,7 @@ VID_GetWindowSize (int def_w, int def_h)
// make con_height >= 200
Cvar_Set (con_height, va (0, "%d", max (con_height->int_val, 200)));
Cvar_SetFlags (con_height, con_height->flags | CVAR_ROM);
viddef.conheight = con_height->int_val;
viddef.conview->ylen = con_height->int_val;
Con_CheckResize (); // Now that we have a window size, fix console
}
@ -243,8 +247,8 @@ VID_InitBuffers (void)
int buffersize, zbuffersize, cachesize = 1;
// No console scaling in the sw renderer
viddef.conwidth = viddef.width;
viddef.conheight = viddef.height;
viddef.conview->xlen = viddef.width;
viddef.conview->ylen = viddef.height;
Con_CheckResize ();
// Calculate the sizes we want first

View file

@ -46,37 +46,26 @@
#include "QF/plugin/vid_render.h"
#include "QF/ui/view.h"
#include "sbar.h"
#include "nq/include/client.h"
static qpic_t *scr_net;
static view_t *net_view;
static view_t *loading_view;
static void
SCR_DrawNet (void)
draw_pic (view_t *view)
{
if (realtime - cl.last_servermessage < 0.3)
return;
if (cls.demoplayback)
return;
if (!scr_net)
scr_net = r_funcs->Draw_PicFromWad ("net");
r_funcs->Draw_Pic (r_data->scr_vrect->x + 64, r_data->scr_vrect->y,
scr_net);
r_funcs->Draw_Pic (view->xabs, view->yabs, view->data);
}
static void
SCR_DrawLoading (void)
draw_cachepic (view_t *view)
{
qpic_t *pic;
if (!cl.loading)
return;
pic = r_funcs->Draw_CachePic ("gfx/loading.lmp", 1);
r_funcs->Draw_Pic ((r_data->vid->conwidth - pic->width) / 2,
(r_data->vid->conheight - 48 - pic->height) / 2, pic);
qpic_t *pic = r_funcs->Draw_CachePic (view->data, 1);
r_funcs->Draw_Pic (view->xabs, view->yabs, pic);
}
static void
@ -100,12 +89,10 @@ static SCR_Func scr_funcs_normal[] = {
0, //SCR_DrawRam,
0, //SCR_DrawTurtle,
0, //SCR_DrawPause,
SCR_DrawNet,
Sbar_Draw,
SCR_CShift,
Sbar_DrawCenterPrint,
Con_DrawConsole,
SCR_DrawLoading,
0
};
@ -135,6 +122,29 @@ CL_UpdateScreen (double realtime)
if (index >= sizeof (scr_funcs) / sizeof (scr_funcs[0]))
index = 0;
if (!net_view) {
qpic_t *pic = r_funcs->Draw_PicFromWad ("net");
net_view = view_new (64, 0, pic->width, pic->height, grav_northwest);
net_view->draw = draw_pic;
net_view->data = pic;
net_view->visible = 0;
view_add (r_data->scr_view, net_view);
}
if (!loading_view) {
const char *name = "gfx/loading.lmp";
qpic_t *pic = r_funcs->Draw_CachePic (name, 1);
loading_view = view_new (0, -24, pic->width, pic->height, grav_center);
loading_view->draw = draw_cachepic;
loading_view->data = (void *) name;
loading_view->visible = 0;
view_add (r_data->vid->conview, loading_view);
}
net_view->visible = (!cls.demoplayback
&& realtime - cl.last_servermessage >= 0.3);
loading_view->visible = cl.loading;
//FIXME not every time
if (cls.state == ca_active) {
if (cl.watervis)

View file

@ -447,7 +447,7 @@ draw_weapons_hud (view_t *view)
if (view->parent->gravity == grav_southeast)
x = view->xlen - 24;
for (i = r_data->vid->conheight < 204; i < 7; i++) {
for (i = r_data->vid->conview->ylen < 204; i < 7; i++) {
if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN << i)) {
flashon = calc_flashon (cl.item_gettime[i], IT_SHOTGUN << i);
draw_subpic (view, x, i * 16, sb_weapons[flashon][i], 0, 0, 24, 16);
@ -733,7 +733,7 @@ draw_rogue_weapons_hud (view_t *view)
int flashon, i, j;
qpic_t *pic;
for (i = r_data->vid->conheight < 204; i < 7; i++) {
for (i = r_data->vid->conview->ylen < 204; i < 7; i++) {
if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN << i)) {
flashon = calc_flashon (cl.item_gettime[i], IT_SHOTGUN << i);
if (i >= 2) {
@ -1004,7 +1004,7 @@ sbar_update_vis (void)
return;
if (con_module &&
con_module->data->console->lines == r_data->vid->conheight)
con_module->data->console->lines == r_data->vid->conview->ylen)
return; // console is full screen
if (cls.state == ca_active
@ -1325,8 +1325,8 @@ init_sbar_views (void)
view->draw = draw_status;
view_add (sbar_view, view);
if (r_data->vid->conwidth > 320) {
int l = (r_data->vid->conwidth - 320) / 2;
if (r_data->vid->conview->xlen > 320) {
int l = (r_data->vid->conview->xlen - 320) / 2;
view = view_new (-l, 0, l, 48, grav_southwest);
view->draw = draw_tile;
@ -1379,7 +1379,7 @@ init_hud_views (void)
if (hud_frags_view)
view_add (hud_inventory_view, hud_frags_view);
view = view_new (0, 0, r_data->vid->conwidth, 48, grav_south);
view = view_new (0, 0, r_data->vid->conview->xlen, 48, grav_south);
view_add (view, hud_view);
hud_view = view;
@ -1430,8 +1430,8 @@ init_hipnotic_sbar_views (void)
view->draw = draw_hipnotic_status;
view_add (sbar_view, view);
if (r_data->vid->conwidth > 320) {
int l = (r_data->vid->conwidth - 320) / 2;
if (r_data->vid->conview->xlen > 320) {
int l = (r_data->vid->conview->xlen - 320) / 2;
view = view_new (-l, 0, l, 48, grav_southwest);
view->draw = draw_tile;
@ -1456,9 +1456,10 @@ init_hipnotic_hud_views (void)
hud_view->resize_y = 1;
if (r_data->vid->conheight < 252) {
if (r_data->vid->conview->ylen < 252) {
hud_armament_view = view_new (0,
min (r_data->vid->conheight - 160, 48),
min (r_data->vid->conview->ylen - 160,
48),
66, 160, grav_southeast);
} else {
hud_armament_view = view_new (0, 48, 42, 204, grav_southeast);
@ -1490,7 +1491,7 @@ init_hipnotic_hud_views (void)
if (hud_frags_view)
view_add (hud_inventory_view, hud_frags_view);
view = view_new (0, 0, r_data->vid->conwidth, 48, grav_south);
view = view_new (0, 0, r_data->vid->conview->xlen, 48, grav_south);
view_add (view, hud_view);
hud_view = view;
@ -1537,8 +1538,8 @@ init_rogue_sbar_views (void)
view->draw = draw_rogue_status;
view_add (sbar_view, view);
if (r_data->vid->conwidth > 320) {
int l = (r_data->vid->conwidth - 320) / 2;
if (r_data->vid->conview->xlen > 320) {
int l = (r_data->vid->conview->xlen - 320) / 2;
view = view_new (-l, 0, l, 48, grav_southwest);
view->draw = draw_tile;
@ -1587,7 +1588,7 @@ init_rogue_hud_views (void)
if (hud_frags_view)
view_add (hud_inventory_view, hud_frags_view);
view = view_new (0, 0, r_data->vid->conwidth, 48, grav_south);
view = view_new (0, 0, r_data->vid->conview->xlen, 48, grav_south);
view_add (view, hud_view);
hud_view = view;
@ -1599,17 +1600,18 @@ init_rogue_hud_views (void)
static void
init_views (void)
{
main_view = view_new (0, 0, r_data->vid->conwidth, r_data->vid->conheight,
main_view = view_new (0, 0, r_data->vid->conview->xlen,
r_data->vid->conview->ylen,
grav_northwest);
if (con_module)
view_insert (con_module->data->console->view, main_view, 0);
main_view->resize_x = 1; // get resized if the 2d view resizes
main_view->resize_y = 1;
main_view->visible = 0; // but don't let the console draw our stuff
if (r_data->vid->conheight > 300)
if (r_data->vid->conview->ylen > 300)
overlay_view = view_new (0, 0, 320, 300, grav_center);
else
overlay_view = view_new (0, 0, 320, r_data->vid->conheight,
overlay_view = view_new (0, 0, 320, r_data->vid->conview->ylen,
grav_center);
overlay_view->draw = draw_overlay;
overlay_view->visible = 0;

View file

@ -331,7 +331,8 @@ extern struct cbuf_s *cl_stbuf;
void Cvar_Info (struct cvar_s *var);
void CL_NetGraph (void);
struct view_s;
void CL_NetGraph (struct view_s *view);
void CL_UpdateScreen (double realtime);
void CL_SetState (cactive_t state);

View file

@ -39,6 +39,8 @@
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/screen.h"
#include "QF/va.h"
#include "QF/ui/view.h"
#include "compat.h"
@ -51,17 +53,12 @@ cvar_t *r_netgraph_alpha;
cvar_t *r_netgraph_box;
void
CL_NetGraph (void)
CL_NetGraph (view_t *view)
{
char st[80];
int lost, a, l, x, y, i;
if (!r_netgraph->int_val)
return;
x = hudswap ? r_data->vid->conwidth - (NET_TIMINGS + 16): 0;
y = r_data->vid->conheight - sb_lines - 24
- r_data->graphheight->int_val - 1;
x = view->xabs;
y = view->yabs;
if (r_netgraph_box->int_val)
r_funcs->Draw_TextBox (x, y, NET_TIMINGS / 8,
@ -69,8 +66,8 @@ CL_NetGraph (void)
r_netgraph_alpha->value * 255);
lost = CL_CalcNet ();
x = hudswap ? r_data->vid->conwidth - (NET_TIMINGS + 8) : 8;
y = r_data->vid->conheight - sb_lines - 9;
x = view->xabs + 8;
y = view->yabs + view->ylen - 9;
l = NET_TIMINGS;
if (l > r_data->refdef->vrect.width - 8)
@ -85,13 +82,7 @@ CL_NetGraph (void)
}
r_funcs->R_LineGraph (x, y, &packet_latency[a], l);
y = r_data->vid->conheight - sb_lines - 24
- r_data->graphheight->int_val + 7;
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
if (hudswap) {
r_funcs->Draw_String (r_data->vid->conwidth - ((strlen (st) * 8) + 8),
y, st);
} else {
r_funcs->Draw_String (8, y, st);
}
x = view->xabs + 8;
y = view->yabs + 8;
r_funcs->Draw_String (x, y, va (0, "%3i%% packet loss", lost));
}

View file

@ -44,40 +44,30 @@
#include "QF/pcx.h"
#include "QF/screen.h"
#include "QF/ui/view.h"
#include "sbar.h"
#include "client/view.h"
#include "qw/include/client.h"
#include "qw/include/cl_parse.h"
static qpic_t *scr_net;
static view_t *net_view;
static view_t *loading_view;
static view_t *graph_view;
static void
SCR_DrawNet (void)
draw_pic (view_t *view)
{
if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged <
UPDATE_BACKUP - 1)
return;
if (cls.demoplayback)
return;
if (!scr_net)
scr_net = r_funcs->Draw_PicFromWad ("net");
r_funcs->Draw_Pic (r_data->scr_vrect->x + 64, r_data->scr_vrect->y,
scr_net);
r_funcs->Draw_Pic (view->xabs, view->yabs, view->data);
}
static void
SCR_DrawLoading (void)
draw_cachepic (view_t *view)
{
qpic_t *pic;
if (!cl.loading)
return;
pic = r_funcs->Draw_CachePic ("gfx/loading.lmp", 1);
r_funcs->Draw_Pic ((r_data->vid->conwidth - pic->width) / 2,
(r_data->vid->conheight - 48 - pic->height) / 2, pic);
qpic_t *pic = r_funcs->Draw_CachePic (view->data, 1);
r_funcs->Draw_Pic (view->xabs, view->yabs, pic);
}
static void
@ -96,30 +86,49 @@ SCR_CShift (void)
r_funcs->Draw_BlendScreen (r_data->vid->cshift_color);
}
static void
scr_draw_views (void)
{
net_view->visible = (!cls.demoplayback
&& (cls.netchan.outgoing_sequence
- cls.netchan.incoming_acknowledged)
>= UPDATE_BACKUP - 1);
loading_view->visible = cl.loading;
graph_view->visible = r_netgraph->int_val != 0;
//FIXME don't do every frame
view_move (graph_view, graph_view->xpos, sb_lines);
view_setgravity (graph_view,
hud_swap->int_val ? grav_southeast : grav_southwest);
view_draw (r_data->vid->conview);
}
static SCR_Func scr_funcs_normal[] = {
0, //Draw_Crosshair,
0, //SCR_DrawRam,
0, //SCR_DrawTurtle,
0, //SCR_DrawPause,
SCR_DrawNet,
CL_NetGraph,
//CL_NetGraph,FIXME
Sbar_Draw,
SCR_CShift,
Sbar_DrawCenterPrint,
Con_DrawConsole,
SCR_DrawLoading,
scr_draw_views,
0
};
static SCR_Func scr_funcs_intermission[] = {
Sbar_IntermissionOverlay,
Con_DrawConsole,
scr_draw_views,
0
};
static SCR_Func scr_funcs_finale[] = {
Sbar_FinaleOverlay,
Con_DrawConsole,
scr_draw_views,
0,
};
@ -137,6 +146,35 @@ CL_UpdateScreen (double realtime)
if (index >= sizeof (scr_funcs) / sizeof (scr_funcs[0]))
index = 0;
if (!net_view) {
qpic_t *pic = r_funcs->Draw_PicFromWad ("net");
net_view = view_new (64, 0, pic->width, pic->height, grav_northwest);
net_view->draw = draw_pic;
net_view->data = pic;
net_view->visible = 0;
view_add (r_data->scr_view, net_view);
}
if (!loading_view) {
const char *name = "gfx/loading.lmp";
qpic_t *pic = r_funcs->Draw_CachePic (name, 1);
loading_view = view_new (0, -24, pic->width, pic->height, grav_center);
loading_view->draw = draw_cachepic;
loading_view->data = (void *) name;
loading_view->visible = 0;
view_add (r_data->vid->conview, loading_view);
}
if (!graph_view) {
graph_view = view_new (0, -24,
NET_TIMINGS + 16,
r_data->graphheight->int_val + 25,
grav_southwest);
graph_view->draw = CL_NetGraph;
graph_view->visible = 0;
view_add (r_data->vid->conview, graph_view);
}
//FIXME not every time
if (cls.state == ca_active) {
if (cl.watervis)

View file

@ -123,15 +123,12 @@ hud_swap_f (cvar_t *var)
{
hudswap = var->int_val;
if (var->int_val) {
hud_armament_view->gravity = grav_southwest;
stuff_view->gravity = grav_southeast;
view_setgravity (hud_armament_view, grav_southwest);
view_setgravity (stuff_view, grav_southeast);
} else {
hud_armament_view->gravity = grav_southeast;
stuff_view->gravity = grav_southwest;
view_setgravity (hud_armament_view, grav_southeast);
view_setgravity (stuff_view, grav_southwest);
}
view_move (hud_armament_view, hud_armament_view->xpos,
hud_armament_view->ypos);
view_move (stuff_view, stuff_view->xpos, stuff_view->ypos);
}
static void
@ -571,7 +568,7 @@ draw_weapons_hud (view_t *view)
if (view->parent->gravity == grav_southeast)
x = view->xlen - 24;
for (i = r_data->vid->conheight < 204; i < 7; i++) {
for (i = r_data->vid->conview->ylen < 204; i < 7; i++) {
if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN << i)) {
flashon = calc_flashon (cl.item_gettime[i], IT_SHOTGUN << i);
draw_subpic (view, x, i * 16, sb_weapons[flashon][i], 0, 0, 24, 16);
@ -903,7 +900,7 @@ Sbar_DeathmatchOverlay (view_t *view, int start)
int l, y;
int skip = 10;
if (r_data->vid->conwidth < 244) // FIXME: magic number, gained through experimentation
if (r_data->vid->conview->xlen < 244) // FIXME: magic number, gained through experimentation
return;
if (largegame)
@ -1056,7 +1053,7 @@ sbar_update_vis (void)
return;
if (con_module
&& con_module->data->console->lines == r_data->vid->conheight)
&& con_module->data->console->lines == r_data->vid->conview->ylen)
return; // console is full screen
if (!sb_lines)
@ -1750,12 +1747,12 @@ init_sbar_views (void)
view_t *minifrags_view = 0;
view_t *miniteam_view = 0;
if (r_data->vid->conwidth < 512) {
if (r_data->vid->conview->xlen < 512) {
sbar_view = view_new (0, 0, 320, 48, grav_south);
sbar_frags_view = view_new (0, 0, 130, 8, grav_northeast);
sbar_frags_view->draw = draw_frags;
} else if (r_data->vid->conwidth < 640) {
} else if (r_data->vid->conview->xlen < 640) {
sbar_view = view_new (0, 0, 512, 48, grav_south);
minifrags_view = view_new (320, 0, 192, 48, grav_southwest);
minifrags_view->draw = draw_minifrags;
@ -1817,8 +1814,8 @@ init_sbar_views (void)
if (miniteam_view)
view_add (sbar_view, miniteam_view);
if (r_data->vid->conwidth > 640) {
int l = (r_data->vid->conwidth - 640) / 2;
if (r_data->vid->conview->xlen > 640) {
int l = (r_data->vid->conview->xlen - 640) / 2;
view = view_new (-l, 0, l, 48, grav_southwest);
view->draw = draw_tile;
@ -1839,12 +1836,12 @@ init_hud_views (void)
view_t *minifrags_view = 0;
view_t *miniteam_view = 0;
if (r_data->vid->conwidth < 512) {
if (r_data->vid->conview->xlen < 512) {
hud_view = view_new (0, 0, 320, 48, grav_south);
hud_frags_view = view_new (0, 0, 130, 8, grav_northeast);
hud_frags_view->draw = draw_frags;
} else if (r_data->vid->conwidth < 640) {
} else if (r_data->vid->conview->xlen < 640) {
hud_view = view_new (0, 0, 512, 48, grav_south);
minifrags_view = view_new (320, 0, 192, 48, grav_southwest);
@ -1896,7 +1893,7 @@ init_hud_views (void)
if (miniteam_view)
view_add (hud_view, miniteam_view);
view = view_new (0, 0, r_data->vid->conwidth, 48, grav_south);
view = view_new (0, 0, r_data->vid->conview->xlen, 48, grav_south);
view_add (view, hud_view);
hud_view = view;
@ -1908,17 +1905,18 @@ init_hud_views (void)
static void
init_views (void)
{
main_view = view_new (0, 0, r_data->vid->conwidth, r_data->vid->conheight,
main_view = view_new (0, 0, r_data->vid->conview->xlen,
r_data->vid->conview->ylen,
grav_northwest);
if (con_module)
view_insert (con_module->data->console->view, main_view, 0);
main_view->resize_x = 1; // get resized if the 2d view resizes
main_view->resize_y = 1;
main_view->visible = 0; // but don't let the console draw our stuff
if (r_data->vid->conheight > 300)
if (r_data->vid->conview->ylen > 300)
overlay_view = view_new (0, 0, 320, 300, grav_center);
else
overlay_view = view_new (0, 0, 320, r_data->vid->conheight,
overlay_view = view_new (0, 0, 320, r_data->vid->conview->ylen,
grav_center);
overlay_view->draw = draw_overlay;
overlay_view->visible = 0;