Some cleanup I forgot to do

This commit is contained in:
Hannu Hanhi 2021-10-08 22:07:58 +03:00
parent 89af6b10ad
commit 1ebc8096a0
5 changed files with 7 additions and 64 deletions

View file

@ -1489,7 +1489,7 @@ UINT8 *HWR_GetScreenshot(void)
if (!buf) if (!buf)
return NULL; return NULL;
// returns 24bit 888 RGB // returns 24bit 888 RGB
HWD.pfnReadRect(tex, (void *)buf); HWD.pfnReadScreenTexture(tex, (void *)buf);
return buf; return buf;
} }
@ -1506,7 +1506,7 @@ boolean HWR_Screenshot(const char *pathname)
} }
// returns 24bit 888 RGB // returns 24bit 888 RGB
HWD.pfnReadRect(tex, (void *)buf); HWD.pfnReadScreenTexture(tex, (void *)buf);
#ifdef USE_PNG #ifdef USE_PNG
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL); ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);

View file

@ -43,7 +43,7 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFl
EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo); EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo); EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo); EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(ReadRect) (int tex, UINT8 *dst_data); EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
EXPORT void HWRAPI(ClearMipMapCache) (void); EXPORT void HWRAPI(ClearMipMapCache) (void);
@ -55,7 +55,6 @@ EXPORT void HWRAPI(SetTransform) (FTransform *ptransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void); EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(FlushScreenTextures) (void);
EXPORT void HWRAPI(SwapScreenTextures) (int tex1, int tex2);
EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd); EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd);
EXPORT void HWRAPI(DrawScreenTexture) (int tex); EXPORT void HWRAPI(DrawScreenTexture) (int tex);
EXPORT void HWRAPI(MakeScreenTexture) (int tex); EXPORT void HWRAPI(MakeScreenTexture) (int tex);
@ -97,7 +96,7 @@ struct hwdriver_s
SetTexture pfnSetTexture; SetTexture pfnSetTexture;
UpdateTexture pfnUpdateTexture; UpdateTexture pfnUpdateTexture;
DeleteTexture pfnDeleteTexture; DeleteTexture pfnDeleteTexture;
ReadRect pfnReadRect; ReadScreenTexture pfnReadScreenTexture;
GClipRect pfnGClipRect; GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache; ClearMipMapCache pfnClearMipMapCache;
SetSpecialState pfnSetSpecialState; SetSpecialState pfnSetSpecialState;
@ -113,7 +112,6 @@ struct hwdriver_s
#endif #endif
PostImgRedraw pfnPostImgRedraw; PostImgRedraw pfnPostImgRedraw;
FlushScreenTextures pfnFlushScreenTextures; FlushScreenTextures pfnFlushScreenTextures;
SwapScreenTextures pfnSwapScreenTextures;
DoScreenWipe pfnDoScreenWipe; DoScreenWipe pfnDoScreenWipe;
DrawScreenTexture pfnDrawScreenTexture; DrawScreenTexture pfnDrawScreenTexture;
MakeScreenTexture pfnMakeScreenTexture; MakeScreenTexture pfnMakeScreenTexture;

View file

@ -1166,18 +1166,14 @@ EXPORT void HWRAPI(ClearMipMapCache) (void)
// Writes screen texture tex into dst_data. // Writes screen texture tex into dst_data.
// Pixel format is 24-bit RGB. Row order is top to bottom. // Pixel format is 24-bit RGB. Row order is top to bottom.
// Dimensions are screen_width * screen_height. // Dimensions are screen_width * screen_height.
// TODO should rename to ReadScreenTexture EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data)
EXPORT void HWRAPI(ReadRect) (int tex, UINT8 *dst_data)
{ {
INT32 i; INT32 i;
int dst_stride = screen_width * 3; // stride between rows of image data int dst_stride = screen_width * 3; // stride between rows of image data
GLubyte*top = (GLvoid*)dst_data, *bottom = top + dst_stride * (screen_height - 1); GLubyte*top = (GLvoid*)dst_data, *bottom = top + dst_stride * (screen_height - 1);
//precise_t ts1, ts2, ts3, ts4, ts5, total_time, get_time, loop_time;
GLubyte *row; GLubyte *row;
//ts1 = I_GetPreciseTime();
row = malloc(dst_stride); row = malloc(dst_stride);
if (!row) return; if (!row) return;
//ts2 = I_GetPreciseTime();
// at the time this function is called, generic2 can be found drawn on the framebuffer // at the time this function is called, generic2 can be found drawn on the framebuffer
// if some other screen texture is needed, draw it to the framebuffer // if some other screen texture is needed, draw it to the framebuffer
// and draw generic2 back after reading the framebuffer. // and draw generic2 back after reading the framebuffer.
@ -1188,7 +1184,6 @@ EXPORT void HWRAPI(ReadRect) (int tex, UINT8 *dst_data)
pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, dst_data); pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, dst_data);
if (tex != HWD_SCREENTEXTURE_GENERIC2) if (tex != HWD_SCREENTEXTURE_GENERIC2)
DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2); DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2);
//ts3 = I_GetPreciseTime();
// Flip image upside down. // Flip image upside down.
// In other words, convert OpenGL's "bottom->top" row order into "top->bottom". // In other words, convert OpenGL's "bottom->top" row order into "top->bottom".
for(i = 0; i < screen_height/2; i++) for(i = 0; i < screen_height/2; i++)
@ -1199,47 +1194,7 @@ EXPORT void HWRAPI(ReadRect) (int tex, UINT8 *dst_data)
top += dst_stride; top += dst_stride;
bottom -= dst_stride; bottom -= dst_stride;
} }
//ts4 = I_GetPreciseTime();
free(row); free(row);
//ts5 = I_GetPreciseTime();
//total_time = I_PreciseToMicros(ts5 - ts1);
//get_time = I_PreciseToMicros(ts3 - ts2);
//loop_time = I_PreciseToMicros(ts4 - ts3);
//CONS_Printf("ReadRect: total time: %" PRIu64 ", read pixels thing: %" PRIu64 " memcpy loop: %" PRIu64 "\n", total_time, get_time, loop_time);
// the slow glGetTexImage based implementation. left in here in case i wanna test it more
// TODO remove this at some point
/*int texsize = 512;
GLsizei buffer_size;
GLubyte *buffer;
// GL_DBG_Printf ("ReadRect()\n");
precise_t ts1, ts2, ts3, ts4, ts5, total_time, get_time, loop_time;
ts1 = I_GetPreciseTime();
// look for power of two that is large enough for the screen
while (texsize < screen_width || texsize < screen_height)
texsize <<= 1;
buffer_size = texsize * texsize * 4;
buffer = malloc(buffer_size);
tex_downloaded = screenTextures[tex];
pglBindTexture(GL_TEXTURE_2D, tex_downloaded);
ts2 = I_GetPreciseTime();
pglGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer); // GL better not overwrite my buffer :v
ts3 = I_GetPreciseTime();
//for (i = 0; i < screen_height; i++) // i: pixel row index that we are writing
//{
// // read the frame from the lower left corner of the GL screen texture
// // flip it upside down so it's in correct format
// memcpy(dst_data + (screen_height - i - 1) * screen_width * 3,
// buffer + i * texsize * 3, screen_width * 3);
//}
ts4 = I_GetPreciseTime();
free(buffer);
ts5 = I_GetPreciseTime();
total_time = I_PreciseToMicros(ts5 - ts1);
get_time = I_PreciseToMicros(ts3 - ts2);
loop_time = I_PreciseToMicros(ts4 - ts3);
CONS_Printf("ReadRect: total time: %" PRIu64 ", glGetTexImage: %" PRIu64 " memcpy loop: %" PRIu64 "\n", total_time, get_time, loop_time);*/
} }
@ -3016,14 +2971,6 @@ EXPORT void HWRAPI(FlushScreenTextures) (void)
screenTextures[i] = 0; screenTextures[i] = 0;
} }
EXPORT void HWRAPI(SwapScreenTextures) (int tex1, int tex2)
{
GLuint temp = screenTextures[tex1];
screenTextures[tex1] = screenTextures[tex2];
screenTextures[tex2] = temp;
}
EXPORT void HWRAPI(DrawScreenTexture)(int tex) EXPORT void HWRAPI(DrawScreenTexture)(int tex)
{ {
float xfix, yfix; float xfix, yfix;

View file

@ -87,7 +87,7 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(SetTexture); GETFUNC(SetTexture);
GETFUNC(UpdateTexture); GETFUNC(UpdateTexture);
GETFUNC(DeleteTexture); GETFUNC(DeleteTexture);
GETFUNC(ReadRect); GETFUNC(ReadScreenTexture);
GETFUNC(GClipRect); GETFUNC(GClipRect);
GETFUNC(ClearMipMapCache); GETFUNC(ClearMipMapCache);
GETFUNC(SetSpecialState); GETFUNC(SetSpecialState);
@ -97,7 +97,6 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(SetTransform); GETFUNC(SetTransform);
GETFUNC(PostImgRedraw); GETFUNC(PostImgRedraw);
GETFUNC(FlushScreenTextures); GETFUNC(FlushScreenTextures);
GETFUNC(SwapScreenTextures);
GETFUNC(DoScreenWipe); GETFUNC(DoScreenWipe);
GETFUNC(DrawScreenTexture); GETFUNC(DrawScreenTexture);
GETFUNC(MakeScreenTexture); GETFUNC(MakeScreenTexture);

View file

@ -1869,7 +1869,7 @@ void VID_StartupOpenGL(void)
HWD.pfnSetTexture = hwSym("SetTexture",NULL); HWD.pfnSetTexture = hwSym("SetTexture",NULL);
HWD.pfnUpdateTexture = hwSym("UpdateTexture",NULL); HWD.pfnUpdateTexture = hwSym("UpdateTexture",NULL);
HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL); HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL);
HWD.pfnReadRect = hwSym("ReadRect",NULL); HWD.pfnReadScreenTexture= hwSym("ReadScreenTexture",NULL);
HWD.pfnGClipRect = hwSym("GClipRect",NULL); HWD.pfnGClipRect = hwSym("GClipRect",NULL);
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
@ -1880,7 +1880,6 @@ void VID_StartupOpenGL(void)
HWD.pfnSetTransform = hwSym("SetTransform",NULL); HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL); HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL);
HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL); HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL);
HWD.pfnSwapScreenTextures=hwSym("SwapScreenTextures",NULL);
HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL); HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL);
HWD.pfnDrawScreenTexture= hwSym("DrawScreenTexture",NULL); HWD.pfnDrawScreenTexture= hwSym("DrawScreenTexture",NULL);
HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL); HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL);