[renderer] Clean up viewport setting

Software is still a mess, and vulkan never supported viewsize, but
otherwise everything seems fine.
This commit is contained in:
Bill Currie 2022-03-26 09:41:58 +09:00
parent f2bc5b560f
commit 77a797d04b
6 changed files with 13 additions and 31 deletions

View file

@ -255,24 +255,10 @@ static void
R_SetupGL_Viewport_and_Perspective (void) R_SetupGL_Viewport_and_Perspective (void)
{ {
float screenaspect; float screenaspect;
int x, y2, w, h;
// set up viewpoint
qfglMatrixMode (GL_PROJECTION); qfglMatrixMode (GL_PROJECTION);
qfglLoadIdentity (); qfglLoadIdentity ();
if (gl_envmap) {
x = y2 = 0;
w = h = 256;
} else {
x = r_refdef.vrect.x;
y2 = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height));
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
}
// printf ("glViewport(%d, %d, %d, %d)\n", glx + x, gly + y2, w, h);
qfglViewport (x, y2, w, h);
screenaspect = r_refdef.vrect.width / (float) r_refdef.vrect.height; screenaspect = r_refdef.vrect.width / (float) r_refdef.vrect.height;
MYgluPerspective (r_refdef.fov_y, screenaspect, r_nearclip->value, MYgluPerspective (r_refdef.fov_y, screenaspect, r_nearclip->value,
r_farclip->value); r_farclip->value);

View file

@ -98,7 +98,6 @@ glsl_R_ViewChanged (void)
static void static void
R_SetupView (void) R_SetupView (void)
{ {
float x, y, w, h;
static mat4f_t z_up = { static mat4f_t z_up = {
{ 0, 0, 1, 0}, { 0, 0, 1, 0},
{-1, 0, 0, 0}, {-1, 0, 0, 0},
@ -106,12 +105,6 @@ R_SetupView (void)
{ 0, 0, 0, 1}, { 0, 0, 0, 1},
}; };
x = r_refdef.vrect.x;
y = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height));
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
qfeglViewport (x, y, w, h);
mmulf (glsl_view, z_up, r_refdef.camera_inverse); mmulf (glsl_view, z_up, r_refdef.camera_inverse);
qfeglEnable (GL_CULL_FACE); qfeglEnable (GL_CULL_FACE);

View file

@ -289,6 +289,9 @@ SCR_UpdateScreen (transform_t *camera, double realtime, SCR_Func *scr_funcs)
r_funcs->bind_framebuffer (warp_buffer); r_funcs->bind_framebuffer (warp_buffer);
} }
if (scr_fisheye->int_val) { if (scr_fisheye->int_val) {
int side = fisheye_cube_map->width;
vrect_t feye = { 0, 0, side, side };
r_funcs->set_viewport (&feye);
switch (scr_fviews->int_val) { switch (scr_fviews->int_val) {
case 6: render_side (BOX_BEHIND); case 6: render_side (BOX_BEHIND);
case 5: render_side (BOX_BOTTOM); case 5: render_side (BOX_BOTTOM);
@ -301,6 +304,7 @@ SCR_UpdateScreen (transform_t *camera, double realtime, SCR_Func *scr_funcs)
r_funcs->set_viewport (&r_refdef.vrect); r_funcs->set_viewport (&r_refdef.vrect);
r_funcs->post_process (fisheye_cube_map); r_funcs->post_process (fisheye_cube_map);
} else { } else {
r_funcs->set_viewport (&r_refdef.vrect);
render_scene (); render_scene ();
if (r_dowarp) { if (r_dowarp) {
r_funcs->bind_framebuffer (0); r_funcs->bind_framebuffer (0);

View file

@ -325,6 +325,11 @@ gl_bind_framebuffer (framebuffer_t *framebuffer)
static void static void
gl_set_viewport (const vrect_t *view) gl_set_viewport (const vrect_t *view)
{ {
int x = r_refdef.vrect.x;
int y2 = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height));
int w = r_refdef.vrect.width;
int h = r_refdef.vrect.height;
qfglViewport (x, y2, w, h);
} }
vid_render_funcs_t gl_vid_render_funcs = { vid_render_funcs_t gl_vid_render_funcs = {

View file

@ -375,10 +375,10 @@ glsl_bind_framebuffer (framebuffer_t *framebuffer)
static void static void
glsl_set_viewport (const vrect_t *view) glsl_set_viewport (const vrect_t *view)
{ {
float x = view->x; int x = view->x;
float y = vid.height - (view->y + view->height); int y = vid.height - (view->y + view->height);
float w = view->width; int w = view->width;
float h = view->height; int h = view->height;
qfeglViewport (x, y, w, h); qfeglViewport (x, y, w, h);
} }

View file

@ -73,12 +73,6 @@ setup_view (vulkan_ctx_t *ctx)
{ 0, 0, 0, 1}, { 0, 0, 0, 1},
}; };
/*x = r_refdef.vrect.x;
y = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height));
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
qfeglViewport (x, y, w, h);*/
mmulf (view, z_up, r_refdef.camera_inverse); mmulf (view, z_up, r_refdef.camera_inverse);
Vulkan_SetViewMatrix (ctx, view); Vulkan_SetViewMatrix (ctx, view);
} }