shithub: qk1

Download patch

ref: 8661f939ba045c83d39f3b0da40cefde6d2a875c
parent: f925d22c8fba04eb85fa9e39dd5f034ec4f6e764
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Nov 28 20:12:57 EST 2023

water-warp with the same resolution

--- a/d_iface.h
+++ b/d_iface.h
@@ -1,8 +1,5 @@
 // d_iface.h: interface header file for rasterization driver modules
 
-#define WARP_WIDTH		320
-#define WARP_HEIGHT		200
-
 #define MAX_LBM_HEIGHT	480
 
 typedef struct
--- a/d_init.c
+++ b/d_init.c
@@ -25,13 +25,8 @@
 {
 	int i;
 
-	if(r_dowarp){
-		d_viewbuffer = r_warpbuffer;
-		screenwidth = WARP_WIDTH;
-	}else{
-		d_viewbuffer = vid.buffer;
-		screenwidth = vid.rowbytes;
-	}
+	d_viewbuffer = r_dowarp ? r_warpbuffer : vid.buffer;
+	screenwidth = vid.rowbytes;
 
 	d_roverwrapped = false;
 	d_initial_rover = sc_rover;
--- a/d_modech.c
+++ b/d_modech.c
@@ -12,7 +12,7 @@
 	int rowbytes, i;
 
 	d_zwidth = vid.width;
-	rowbytes = r_dowarp ? WARP_WIDTH : vid.rowbytes;
+	rowbytes = vid.rowbytes;
 	scale_for_mip = max(xscale, yscale);
 
 	d_pix_scale = 90.0 / r_refdef.fov_x;
--- a/r_main.c
+++ b/r_main.c
@@ -691,13 +691,8 @@
 */
 void R_RenderView (void)
 {
-	static pixel_t *warpbuffer;
 	entity_t *e;
 	int i;
-
-	if(warpbuffer == nil)
-		warpbuffer = malloc(WARP_WIDTH * WARP_HEIGHT * sizeof(*warpbuffer));
-	r_warpbuffer = warpbuffer;
 
 	R_SetupFrame ();
 	R_MarkLeaves ();	// done here so we know if we're in water
--- a/unix/vid.c
+++ b/unix/vid.c
@@ -7,6 +7,7 @@
 static SDL_Texture *fbi;
 static SDL_Window *win;
 static pixel_t *vidbuffer;
+extern pixel_t *r_warpbuffer;
 
 s32int fbpal[256];
 pixel_t q1pal[256];
@@ -33,7 +34,11 @@
 	vid.conheight = vid.height;
 
 	free(vidbuffer);
-	vidbuffer = emalloc((vid.width*vid.height+16)*4);
+	vidbuffer = emalloc((vid.width*vid.height+16)*sizeof(pixel_t));
+	free(r_warpbuffer);
+	r_warpbuffer = emalloc((vid.width*vid.height+16)*sizeof(pixel_t));
+	vid.maxwarpwidth = vid.width;
+	vid.maxwarpheight = vid.height;
 
 	if(fbi != nil)
 		SDL_DestroyTexture(fbi);
@@ -107,8 +112,6 @@
 void
 initfb(void)
 {
-	vid.maxwarpwidth = WARP_WIDTH;
-	vid.maxwarpheight = WARP_HEIGHT;
 	vid.numpages = 2;
 	vid.colormap = malloc(256*64*sizeof(pixel_t));
 	torgbx(host_colormap, vid.colormap, 256*64);
--- a/vid.c
+++ b/vid.c
@@ -59,6 +59,10 @@
 	grabr = Rpt(subpt(center, p), addpt(center, p));
 	for(i = 0; i < nelem(vidbuffers); i++)
 		vidbuffers[i] = realloc(vidbuffers[i], (vid.width*vid.height+16)*sizeof(pixel_t));
+	free(r_warpbuffer);
+	r_warpbuffer = emalloc((vid.width*vid.height+16)*sizeof(pixel_t));
+	vid.maxwarpwidth = vid.width;
+	vid.maxwarpheight = vid.height;
 	freeimage(fbi);
 	fbi = allocimage(display, Rect(0, 0, vid.width, vid.height), XRGB32, 0, 0);
 	if(fbi == nil)
@@ -142,8 +146,6 @@
 void
 initfb(void)
 {
-	vid.maxwarpwidth = WARP_WIDTH;
-	vid.maxwarpheight = WARP_HEIGHT;
 	vid.numpages = 2;
 	vid.colormap = malloc(256*64*sizeof(pixel_t));
 	torgbx(host_colormap, vid.colormap, 256*64);