From 3d53561d5fd953672bde1581251d050900ef2772 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 15 May 2004 20:24:19 +0000 Subject: [PATCH] Tomaz fixed the envmap command; it was saving black images, and now saves images in the correct order with appropriate flipping, to comply with skybox arrangements git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4169 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 21 ++++++++++++--------- gl_backend.c | 19 ++++++++++++------- gl_backend.h | 2 +- r_shadow.c | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index fdb08f89..0fa9a6d8 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -677,7 +677,7 @@ void SCR_ScreenShot_f (void) else sprintf(filename, "%s%06d.tga", base, shotnumber); - if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, jpeg)) + if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, false, false, false, jpeg)) Con_Printf("Wrote %s\n", filename); else Con_Printf("unable to write %s\n", filename); @@ -696,7 +696,7 @@ void SCR_CaptureAVIDemo(void) else sprintf(filename, "video/dp%06d.tga", cl_avidemo_frame); - if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, jpeg)) + if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, false, false, false, jpeg)) cl_avidemo_frame++; else { @@ -717,15 +717,16 @@ struct { float angles[3]; char *name; + qboolean flipx, flipy; } envmapinfo[6] = { - {{ 0, 0, 0}, "ft"}, - {{ 0, 90, 0}, "rt"}, - {{ 0, 180, 0}, "bk"}, - {{ 0, 270, 0}, "lf"}, - {{-90, 90, 0}, "up"}, - {{ 90, 90, 0}, "dn"} + {{ 0, 0, 0}, "rt", true, false}, + {{ 0, 90, 0}, "ft", true, false}, + {{ 0, 180, 0}, "lf", true, false}, + {{ 0, 270, 0}, "bk", true, false}, + {{-90, 180, 0}, "up", false, true}, + {{ 90, 180, 0}, "dn", false, true} }; static void R_Envmap_f (void) @@ -767,8 +768,10 @@ static void R_Envmap_f (void) sprintf(filename, "env/%s%s.tga", basename, envmapinfo[j].name); Matrix4x4_CreateFromQuakeEntity(&r_refdef.viewentitymatrix, r_vieworigin[0], r_vieworigin[1], r_vieworigin[2], envmapinfo[j].angles[0], envmapinfo[j].angles[1], envmapinfo[j].angles[2], 1); R_ClearScreen(); + R_Mesh_Start(); R_RenderView(); - SCR_ScreenShot(filename, vid.realx, vid.realy + vid.realheight - (r_refdef.y + r_refdef.height), size, size, false); + R_Mesh_Finish(); + SCR_ScreenShot(filename, vid.realx, vid.realy + vid.realheight - (r_refdef.y + r_refdef.height), size, size, envmapinfo[j].flipx, envmapinfo[j].flipy, false, false); } envmap = false; diff --git a/gl_backend.c b/gl_backend.c index ee241172..4aa89b9f 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -1190,24 +1190,29 @@ void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, const int *elements) ============================================================================== */ -qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean jpeg) +qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg) { + int indices[3] = {0,1,2}; qboolean ret; - qbyte *buffer; + qbyte *buffer1, *buffer2; if (!r_render.integer) return false; - buffer = Mem_Alloc(tempmempool, width*height*3); - qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer); + buffer1 = Mem_Alloc(tempmempool, width*height*3); + buffer2 = Mem_Alloc(tempmempool, width*height*3); + qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer1); CHECKGLERROR + Image_CopyMux (buffer2, buffer1, width, height, flipx, flipy, flipdiagonal, 3, 3, indices); + if (jpeg) - ret = JPEG_SaveImage_preflipped (filename, width, height, buffer); + ret = JPEG_SaveImage_preflipped (filename, width, height, buffer2); else - ret = Image_WriteTGARGB_preflipped (filename, width, height, buffer); + ret = Image_WriteTGARGB_preflipped (filename, width, height, buffer2); - Mem_Free(buffer); + Mem_Free(buffer1); + Mem_Free(buffer2); return ret; } diff --git a/gl_backend.h b/gl_backend.h index 343f66b5..994b8d55 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -80,7 +80,7 @@ void R_Mesh_Draw(int numverts, int numtriangles, const int *elements); void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, const int *elements); // saves a section of the rendered frame to a .tga or .jpg file -qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean jpeg); +qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg); // used by R_Envmap_f and internally in backend, clears the frame void R_ClearScreen(void); // invoke refresh of frame diff --git a/r_shadow.c b/r_shadow.c index 81708960..646fac0e 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2247,7 +2247,7 @@ static cubemapinfo_t cubemaps[MAX_CUBEMAPS]; typedef struct suffixinfo_s { char *suffix; - int flipx, flipy, flipdiagonal; + qboolean flipx, flipy, flipdiagonal; } suffixinfo_t; static suffixinfo_t suffix[3][6] = -- 2.39.2