From e0b9e118a019c35b12bd7e15b6cb73adf8937c95 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 20 Nov 2022 01:17:09 +0900 Subject: [PATCH] [renderer] Remove the 1/2 pixel shift of the 2d screen It seemed like a good idea at the time, but it exacerbates pixel leakage in atlas textures that have no border pixels (even in nearest sampling modes). --- libs/video/renderer/gl/gl_draw.c | 2 +- libs/video/renderer/glsl/glsl_draw.c | 3 +-- libs/video/renderer/vid_render_vulkan.c | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index d72673468..2ccf8a7c4 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -971,7 +971,7 @@ set_2d (int width, int height) qfglMatrixMode (GL_PROJECTION); qfglLoadIdentity (); - qfglOrtho (-0.5, width - 0.5, height - 0.5, -0.5, -99999, 99999); + qfglOrtho (0, width, height, 0, -99999, 99999); qfglMatrixMode (GL_MODELVIEW); qfglLoadIdentity (); diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index 9b2607df4..b6e7e797c 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -785,8 +785,7 @@ set_2d (int width, int height) qfeglDisable (GL_DEPTH_TEST); qfeglDisable (GL_CULL_FACE); - ortho_mat (proj_matrix, -0.5, width - 0.5, height - 0.5, -0.5, - -99999, 99999); + ortho_mat (proj_matrix, 0, width, height, 0, -99999, 99999); qfeglUseProgram (quake_2d.program); qfeglEnableVertexAttribArray (quake_2d.vertex.location); diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 5e7c06d04..7c9761bac 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -369,8 +369,8 @@ vulkan_set_2d (int scaled) __auto_type mat = &mctx->matrices; int scale = vulkan_ctx->twod_scale; - float left = -0.5; - float top = -0.5; + float left = 0; + float top = 0; float right = left + vid.width / scale; float bottom = top + vid.height / scale; QFV_Orthographic (mat->Projection2d, left, right, top, bottom, 0, 99999);