paletterenderer screentex stuff again
this didnt really work like it shouldve so ill keep it here for now
This commit is contained in:
1 parent
d3e5dfc346
commit
34500d32d0
10 files changed
+161
-239
No files matched your search
@@ -288,4 +288,16 @@ enum hwdfiltermode
|
||||
HWD_SET_TEXTUREFILTER_MIXED3,
|
||||
};
|
||||
|
||||
// Screen texture slots
|
||||
enum hwdscreentexture
|
||||
{
|
||||
HWD_SCREENTEXTURE_WIPE_START, // source image for the wipe/fade effect
|
||||
HWD_SCREENTEXTURE_WIPE_END, // destination image for the wipe/fade effect
|
||||
HWD_SCREENTEXTURE_GENERIC1, // underwater/heat effect, intermission background
|
||||
HWD_SCREENTEXTURE_GENERIC2, // screen before palette rendering's postprocessing
|
||||
HWD_SCREENTEXTURE_GENERIC3, // screen after palette rendering's postprocessing
|
||||
NUMSCREENTEXTURES, // (generic3 is unused if palette rendering is disabled)
|
||||
};
|
||||
typedef enum hwdscreentexture hwdscreentexture_t;
|
||||
|
||||
#endif //_HWR_DEFS_
|
||||
@@ -1158,6 +1158,7 @@ static inline boolean saveTGA(const char *file_name, void *buffer,
|
||||
UINT8 *HWR_GetScreenshot(void)
|
||||
{
|
||||
static UINT8 *buf = NULL;
|
||||
int tex = ((HWR_ShouldUsePaletteRendering() && !cv_groldpal.value) ? HWD_SCREENTEXTURE_GENERIC3 : HWD_SCREENTEXTURE_GENERIC2);
|
||||
|
||||
buf = realloc(buf, vid.width * vid.height * 3);
|
||||
|
||||
@@ -1165,7 +1166,7 @@ UINT8 *HWR_GetScreenshot(void)
|
||||
return NULL;
|
||||
|
||||
// returns 24bit 888 RGB
|
||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||
HWD.pfnReadScreenTexture(tex, (void *)buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -1173,6 +1174,7 @@ boolean HWR_Screenshot(const char *pathname)
|
||||
{
|
||||
boolean ret;
|
||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||
int tex = ((HWR_ShouldUsePaletteRendering() && !cv_groldpal.value) ? HWD_SCREENTEXTURE_GENERIC3 : HWD_SCREENTEXTURE_GENERIC2);
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
@@ -1181,7 +1183,7 @@ boolean HWR_Screenshot(const char *pathname)
|
||||
}
|
||||
|
||||
// returns 24bit 888 RGB
|
||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||
HWD.pfnReadScreenTexture(tex, (void *)buf);
|
||||
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||
|
||||
+9
-14
@@ -38,7 +38,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
|
||||
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
|
||||
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
|
||||
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo);
|
||||
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
|
||||
EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT16 *dst_data);
|
||||
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
|
||||
EXPORT void HWRAPI(ClearMipMapCache) (void);
|
||||
|
||||
@@ -56,14 +56,12 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void);
|
||||
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform);
|
||||
|
||||
EXPORT void HWRAPI(FlushScreenTextures) (void);
|
||||
EXPORT void HWRAPI(StartScreenWipe) (void);
|
||||
EXPORT void HWRAPI(EndScreenWipe) (void);
|
||||
EXPORT void HWRAPI(DoScreenWipe) (void);
|
||||
EXPORT void HWRAPI(DrawIntermissionBG) (void);
|
||||
EXPORT void HWRAPI(MakeScreenTexture) (void);
|
||||
EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd);
|
||||
EXPORT void HWRAPI(DrawScreenTexture) (int tex);
|
||||
EXPORT void HWRAPI(MakeScreenTexture) (int tex);
|
||||
EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, int width, int height);
|
||||
|
||||
EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
|
||||
EXPORT void HWRAPI(MakeScreenFinalTexture) (void);
|
||||
EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height);
|
||||
|
||||
#define SCREENVERTS 10
|
||||
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
|
||||
@@ -102,7 +100,7 @@ struct hwdriver_s
|
||||
ClearBuffer pfnClearBuffer;
|
||||
SetTexture pfnSetTexture;
|
||||
UpdateTexture pfnUpdateTexture;
|
||||
ReadRect pfnReadRect;
|
||||
ReadScreenTexture pfnReadScreenTexture;
|
||||
GClipRect pfnGClipRect;
|
||||
ClearMipMapCache pfnClearMipMapCache;
|
||||
SetSpecialState pfnSetSpecialState;
|
||||
@@ -112,13 +110,10 @@ struct hwdriver_s
|
||||
GetTextureUsed pfnGetTextureUsed;
|
||||
PostImgRedraw pfnPostImgRedraw;
|
||||
FlushScreenTextures pfnFlushScreenTextures;
|
||||
StartScreenWipe pfnStartScreenWipe;
|
||||
EndScreenWipe pfnEndScreenWipe;
|
||||
DoScreenWipe pfnDoScreenWipe;
|
||||
DrawIntermissionBG pfnDrawIntermissionBG;
|
||||
DrawScreenTexture pfnDrawScreenTexture;
|
||||
MakeScreenTexture pfnMakeScreenTexture;
|
||||
RenderVhsEffect pfnRenderVhsEffect;
|
||||
MakeScreenFinalTexture pfnMakeScreenFinalTexture;
|
||||
RenderVhsEffect pfnRenderVhsEffect;
|
||||
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
|
||||
|
||||
RenderSkyDome pfnRenderSkyDome;
|
||||
|
||||
+13
-9
@@ -152,6 +152,7 @@ static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 b
|
||||
consvar_t cv_grpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_grpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grshaders_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_groldpal = {"gr_oldpal", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grmdls = {"gr_mdls", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -6420,7 +6421,8 @@ void HWR_AddCommands(void)
|
||||
|
||||
CV_RegisterVar(&cv_grpaletterendering);
|
||||
CV_RegisterVar(&cv_grpalettedepth);
|
||||
CV_RegisterVar(&cv_grflashpal);
|
||||
CV_RegisterVar(&cv_grflashpal);
|
||||
CV_RegisterVar(&cv_groldpal);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -6562,7 +6564,7 @@ void HWR_DoPostProcessor(player_t *player)
|
||||
|
||||
// Capture the screen for intermission and screen waving
|
||||
if(gamestate != GS_INTERMISSION)
|
||||
HWD.pfnMakeScreenTexture();
|
||||
HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
|
||||
|
||||
if (splitscreen) // Not supported in splitscreen - someone want to add support?
|
||||
return;
|
||||
@@ -6606,24 +6608,24 @@ void HWR_DoPostProcessor(player_t *player)
|
||||
|
||||
// Capture the screen again for screen waving on the intermission
|
||||
if(gamestate != GS_INTERMISSION)
|
||||
HWD.pfnMakeScreenTexture();
|
||||
HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
|
||||
}
|
||||
// Flipping of the screen isn't done here anymore
|
||||
}
|
||||
|
||||
void HWR_StartScreenWipe(void)
|
||||
{
|
||||
HWD.pfnStartScreenWipe();
|
||||
HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START);
|
||||
}
|
||||
|
||||
void HWR_EndScreenWipe(void)
|
||||
{
|
||||
HWD.pfnEndScreenWipe();
|
||||
HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END);
|
||||
}
|
||||
|
||||
void HWR_DrawIntermissionBG(void)
|
||||
{
|
||||
HWD.pfnDrawIntermissionBG();
|
||||
HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
|
||||
}
|
||||
|
||||
void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum)
|
||||
@@ -6651,7 +6653,7 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum)
|
||||
}
|
||||
|
||||
HWR_GetFadeMask(lumpnum);
|
||||
HWD.pfnDoScreenWipe();
|
||||
HWD.pfnDoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END);
|
||||
}
|
||||
|
||||
void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize)
|
||||
@@ -6661,12 +6663,14 @@ void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT
|
||||
|
||||
void HWR_MakeScreenFinalTexture(void)
|
||||
{
|
||||
HWD.pfnMakeScreenFinalTexture();
|
||||
int tex = ((HWR_ShouldUsePaletteRendering() && !cv_groldpal.value) ? HWD_SCREENTEXTURE_GENERIC3 : HWD_SCREENTEXTURE_GENERIC2);
|
||||
HWD.pfnMakeScreenTexture(tex);
|
||||
}
|
||||
|
||||
void HWR_DrawScreenFinalTexture(int width, int height)
|
||||
{
|
||||
HWD.pfnDrawScreenFinalTexture(width, height);
|
||||
int tex = ((HWR_ShouldUsePaletteRendering() && !cv_groldpal.value) ? HWD_SCREENTEXTURE_GENERIC3 : HWD_SCREENTEXTURE_GENERIC2);
|
||||
HWD.pfnDrawScreenFinalTexture(tex, width, height);
|
||||
}
|
||||
|
||||
// jimita 18032019
|
||||
|
||||
@@ -192,6 +192,7 @@ extern consvar_t cv_grrenderdistance;
|
||||
extern consvar_t cv_grusecustomshaders;
|
||||
extern consvar_t cv_grpaletterendering;
|
||||
extern consvar_t cv_grpalettedepth;
|
||||
extern consvar_t cv_groldpal;
|
||||
extern consvar_t cv_grflashpal;
|
||||
extern consvar_t cv_grscreentextures;
|
||||
extern consvar_t cv_grportals;
|
||||
|
||||
@@ -124,10 +124,7 @@ static GLint viewport[4];
|
||||
// flush all of the stored textures, leaving them unavailable at times such as between levels
|
||||
// These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs
|
||||
// can know when the textures aren't there, as textures are always considered resident in their virtual memory
|
||||
static GLuint screentexture = 0;
|
||||
static GLuint startScreenWipe = 0;
|
||||
static GLuint endScreenWipe = 0;
|
||||
static GLuint finalScreenTexture = 0;
|
||||
static GLuint screenTextures[NUMSCREENTEXTURES] = {0};
|
||||
|
||||
// Lactozilla: Set shader programs and uniforms
|
||||
static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade);
|
||||
@@ -563,7 +560,7 @@ boolean SetupGLfunc(void)
|
||||
GETOPENGLFUNC(pglTexParameteri, glTexParameteri)
|
||||
GETOPENGLFUNC(pglTexImage1D, glTexImage1D)
|
||||
GETOPENGLFUNC(pglTexImage2D, glTexImage2D)
|
||||
GETOPENGLFUNC(pglTexSubImage2D , glTexSubImage2D)
|
||||
GETOPENGLFUNC(pglTexSubImage2D, glTexSubImage2D)
|
||||
|
||||
GETOPENGLFUNC(pglGenTextures, glGenTextures)
|
||||
GETOPENGLFUNC(pglDeleteTextures, glDeleteTextures)
|
||||
@@ -1314,14 +1311,19 @@ EXPORT void HWRAPI(SetShader) (int shader)
|
||||
EXPORT void HWRAPI(UnSetShader) (void)
|
||||
{
|
||||
#ifdef GL_SHADERS
|
||||
gl_shadersenabled = false;
|
||||
gl_currentshaderprogram = 0;
|
||||
gl_shaderprogramchanged = true;// not sure if this is needed
|
||||
if (!pglUseProgram) return;
|
||||
pglUseProgram(0);
|
||||
if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed
|
||||
{
|
||||
gl_shadersenabled = false;
|
||||
gl_currentshaderprogram = 0;
|
||||
gl_shaderprogramchanged = true;// not sure if this is needed
|
||||
if (!pglUseProgram) return;
|
||||
pglUseProgram(0);
|
||||
}
|
||||
#endif
|
||||
gl_shadersenabled = false;
|
||||
}
|
||||
|
||||
|
||||
EXPORT void HWRAPI(KillShaders) (void)
|
||||
{
|
||||
// unused.........................
|
||||
@@ -1514,58 +1516,40 @@ EXPORT void HWRAPI(ClearMipMapCache) (void)
|
||||
Flush();
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// ReadRect : Read a rectangle region of the truecolor framebuffer
|
||||
// : store pixels as 16bit 565 RGB
|
||||
// Returns : 16bit 565 RGB pixel array stored in dst_data
|
||||
// -----------------+
|
||||
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height,
|
||||
INT32 dst_stride, UINT16 * dst_data)
|
||||
// Writes screen texture tex into dst_data.
|
||||
// Pixel format is 24-bit RGB. Row order is top to bottom.
|
||||
// Dimensions are screen_width * screen_height.
|
||||
EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT16 *dst_data)
|
||||
{
|
||||
INT32 i;
|
||||
//GL_DBG_Printf("ReadRect()\n");
|
||||
if (dst_stride == width*3)
|
||||
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 *row;
|
||||
row = malloc(dst_stride);
|
||||
if (!row) return;
|
||||
// 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
|
||||
// and draw generic2 back after reading the framebuffer.
|
||||
// this hack is for some reason **much** faster than the simple solution of using glGetTexImage.
|
||||
if (tex != HWD_SCREENTEXTURE_GENERIC2)
|
||||
DrawScreenTexture(tex);
|
||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, dst_data);
|
||||
if (tex != HWD_SCREENTEXTURE_GENERIC2)
|
||||
DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2);
|
||||
// Flip image upside down.
|
||||
// In other words, convert OpenGL's "bottom->top" row order into "top->bottom".
|
||||
for(i = 0; i < screen_height/2; i++)
|
||||
{
|
||||
GLubyte*top = (GLvoid*)dst_data, *bottom = top + dst_stride * (height - 1);
|
||||
GLubyte *row = malloc(dst_stride);
|
||||
if (!row) return;
|
||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, dst_data);
|
||||
pglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
for(i = 0; i < height/2; i++)
|
||||
{
|
||||
memcpy(row, top, dst_stride);
|
||||
memcpy(top, bottom, dst_stride);
|
||||
memcpy(bottom, row, dst_stride);
|
||||
top += dst_stride;
|
||||
bottom -= dst_stride;
|
||||
}
|
||||
free(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
INT32 j;
|
||||
GLubyte *image = malloc(width*height*3*sizeof (*image));
|
||||
if (!image) return;
|
||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||
pglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
for (i = height-1; i >= 0; i--)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
dst_data[(height-1-i)*width+j] =
|
||||
(UINT16)(
|
||||
((image[(i*width+j)*3]>>3)<<11) |
|
||||
((image[(i*width+j)*3+1]>>2)<<5) |
|
||||
((image[(i*width+j)*3+2]>>3)));
|
||||
}
|
||||
}
|
||||
free(image);
|
||||
memcpy(row, top, dst_stride);
|
||||
memcpy(top, bottom, dst_stride);
|
||||
memcpy(bottom, row, dst_stride);
|
||||
top += dst_stride;
|
||||
bottom -= dst_stride;
|
||||
}
|
||||
free(row);
|
||||
}
|
||||
|
||||
|
||||
// -----------------+
|
||||
// GClipRect : Defines the 2D hardware clipping window
|
||||
// -----------------+
|
||||
@@ -3227,7 +3211,7 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
|
||||
16.0f, 16.0f, 6.0f,
|
||||
16.0f, -16.0f, 6.0f
|
||||
};
|
||||
|
||||
|
||||
if (!gl_enable_screen_textures) return;
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
@@ -3302,77 +3286,13 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
|
||||
// a new size
|
||||
EXPORT void HWRAPI(FlushScreenTextures) (void)
|
||||
{
|
||||
pglDeleteTextures(1, &screentexture);
|
||||
pglDeleteTextures(1, &startScreenWipe);
|
||||
pglDeleteTextures(1, &endScreenWipe);
|
||||
pglDeleteTextures(1, &finalScreenTexture);
|
||||
|
||||
screentexture = 0;
|
||||
startScreenWipe = 0;
|
||||
endScreenWipe = 0;
|
||||
finalScreenTexture = 0;
|
||||
int i;
|
||||
pglDeleteTextures(NUMSCREENTEXTURES, screenTextures);
|
||||
for (i = 0; i < NUMSCREENTEXTURES; i++)
|
||||
screenTextures[i] = 0;
|
||||
}
|
||||
|
||||
// Create Screen to fade from
|
||||
EXPORT void HWRAPI(StartScreenWipe) (void)
|
||||
{
|
||||
INT32 texsize = 512;
|
||||
boolean firstTime = (startScreenWipe == 0);
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
while (texsize < screen_width || texsize < screen_height)
|
||||
texsize <<= 1;
|
||||
|
||||
// Create screen texture
|
||||
if (firstTime)
|
||||
pglGenTextures(1, &startScreenWipe);
|
||||
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
Clamp2D(GL_TEXTURE_WRAP_S);
|
||||
Clamp2D(GL_TEXTURE_WRAP_T);
|
||||
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0);
|
||||
}
|
||||
else
|
||||
pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize);
|
||||
|
||||
tex_downloaded = startScreenWipe;
|
||||
}
|
||||
|
||||
// Create Screen to fade to
|
||||
EXPORT void HWRAPI(EndScreenWipe)(void)
|
||||
{
|
||||
INT32 texsize = 512;
|
||||
boolean firstTime = (endScreenWipe == 0);
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
while (texsize < screen_width || texsize < screen_height)
|
||||
texsize <<= 1;
|
||||
|
||||
// Create screen texture
|
||||
if (firstTime)
|
||||
pglGenTextures(1, &endScreenWipe);
|
||||
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
Clamp2D(GL_TEXTURE_WRAP_S);
|
||||
Clamp2D(GL_TEXTURE_WRAP_T);
|
||||
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0);
|
||||
}
|
||||
else
|
||||
pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize);
|
||||
|
||||
tex_downloaded = endScreenWipe;
|
||||
}
|
||||
|
||||
// Draw the last scene under the intermission
|
||||
EXPORT void HWRAPI(DrawIntermissionBG)(void)
|
||||
EXPORT void HWRAPI(DrawScreenTexture)(int tex)
|
||||
{
|
||||
float xfix, yfix;
|
||||
INT32 texsize = 512;
|
||||
@@ -3386,6 +3306,8 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
|
||||
};
|
||||
|
||||
float fix[8];
|
||||
|
||||
if (!gl_enable_screen_textures) return;
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
while (texsize < screen_width || texsize < screen_height)
|
||||
@@ -3394,6 +3316,9 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
|
||||
xfix = 1/((float)(texsize)/((float)((screen_width))));
|
||||
yfix = 1/((float)(texsize)/((float)((screen_height))));
|
||||
|
||||
// const float screenVerts[12]
|
||||
|
||||
// float fix[8];
|
||||
fix[0] = 0.0f;
|
||||
fix[1] = 0.0f;
|
||||
fix[2] = 0.0f;
|
||||
@@ -3404,17 +3329,27 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
|
||||
fix[7] = 0.0f;
|
||||
|
||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
|
||||
|
||||
if (((HWR_ShouldUsePaletteRendering()) && (tex == HWD_SCREENTEXTURE_GENERIC2)) && !cv_groldpal.value)
|
||||
pglUseProgram(gl_shaderprograms[8].program); // palette postprocess shader
|
||||
|
||||
pglColor4ubv(white);
|
||||
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
if (((HWR_ShouldUsePaletteRendering()) && (tex == HWD_SCREENTEXTURE_GENERIC2)) && !cv_groldpal.value)
|
||||
pglUseProgram(0);
|
||||
|
||||
tex_downloaded = screentexture;
|
||||
tex_downloaded = screenTextures[tex];
|
||||
}
|
||||
|
||||
|
||||
// Do screen fades!
|
||||
EXPORT void HWRAPI(DoScreenWipe)(void)
|
||||
EXPORT void HWRAPI(DoScreenWipe)(int wipeStart, int wipeEnd)
|
||||
{
|
||||
INT32 texsize = 512;
|
||||
float xfix, yfix;
|
||||
@@ -3446,6 +3381,9 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
|
||||
xfix = 1/((float)(texsize)/((float)((screen_width))));
|
||||
yfix = 1/((float)(texsize)/((float)((screen_height))));
|
||||
|
||||
// const float screenVerts[12]
|
||||
|
||||
// float fix[8];
|
||||
fix[0] = 0.0f;
|
||||
fix[1] = 0.0f;
|
||||
fix[2] = 0.0f;
|
||||
@@ -3461,7 +3399,7 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
|
||||
pglEnable(GL_TEXTURE_2D);
|
||||
|
||||
// Draw the original screen
|
||||
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[wipeStart]);
|
||||
pglColor4ubv(white);
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
@@ -3472,7 +3410,7 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
|
||||
// Draw the end screen that fades in
|
||||
pglActiveTexture(GL_TEXTURE0);
|
||||
pglEnable(GL_TEXTURE_2D);
|
||||
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[wipeEnd]);
|
||||
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
pglActiveTexture(GL_TEXTURE1);
|
||||
@@ -3481,6 +3419,8 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
|
||||
|
||||
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
// const float defaultST[8]
|
||||
|
||||
pglClientActiveTexture(GL_TEXTURE0);
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
@@ -3494,38 +3434,7 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
|
||||
|
||||
pglActiveTexture(GL_TEXTURE0);
|
||||
pglClientActiveTexture(GL_TEXTURE0);
|
||||
tex_downloaded = endScreenWipe;
|
||||
}
|
||||
|
||||
// Create a texture from the screen.
|
||||
EXPORT void HWRAPI(MakeScreenTexture) (void)
|
||||
{
|
||||
INT32 texsize = 512;
|
||||
boolean firstTime = (screentexture == 0);
|
||||
|
||||
if (!gl_enable_screen_textures) return;
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
while (texsize < screen_width || texsize < screen_height)
|
||||
texsize <<= 1;
|
||||
|
||||
// Create screen texture
|
||||
if (firstTime)
|
||||
pglGenTextures(1, &screentexture);
|
||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
Clamp2D(GL_TEXTURE_WRAP_S);
|
||||
Clamp2D(GL_TEXTURE_WRAP_T);
|
||||
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0);
|
||||
}
|
||||
else
|
||||
pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize);
|
||||
|
||||
tex_downloaded = screentexture;
|
||||
tex_downloaded = screenTextures[wipeEnd];
|
||||
}
|
||||
|
||||
EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize)
|
||||
@@ -3552,9 +3461,9 @@ EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 upd
|
||||
yfix = 1/((float)(texsize)/((float)((screen_height))));
|
||||
|
||||
// Slight fuzziness
|
||||
MakeScreenTexture();
|
||||
MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
|
||||
SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
|
||||
for (i = 0; i < 1; i += 2.f/vid.height)
|
||||
{
|
||||
@@ -3576,8 +3485,8 @@ EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 upd
|
||||
}
|
||||
|
||||
// Upward bar
|
||||
MakeScreenTexture();
|
||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
color[0] = color[1] = color[2] = 190;
|
||||
color[3] = 250;
|
||||
pglColor4ubv(color);
|
||||
@@ -3604,8 +3513,8 @@ EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 upd
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
// Downward bar
|
||||
MakeScreenTexture();
|
||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||
|
||||
fix[0] = 0.0f;
|
||||
fix[6] = xfix;
|
||||
@@ -3629,11 +3538,12 @@ EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 upd
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
|
||||
// Create a texture from the screen.
|
||||
EXPORT void HWRAPI(MakeScreenTexture) (int tex)
|
||||
{
|
||||
INT32 texsize = 512;
|
||||
boolean firstTime = (finalScreenTexture == 0);
|
||||
|
||||
boolean firstTime = (screenTextures[tex] == 0);
|
||||
|
||||
if (!gl_enable_screen_textures) return;
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
@@ -3642,8 +3552,8 @@ EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
|
||||
|
||||
// Create screen texture
|
||||
if (firstTime)
|
||||
pglGenTextures(1, &finalScreenTexture);
|
||||
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
||||
pglGenTextures(1, &screenTextures[tex]);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
@@ -3656,10 +3566,10 @@ EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
|
||||
else
|
||||
pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize);
|
||||
|
||||
tex_downloaded = finalScreenTexture;
|
||||
tex_downloaded = screenTextures[tex];
|
||||
}
|
||||
|
||||
EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||
EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height)
|
||||
{
|
||||
float xfix, yfix;
|
||||
float origaspect, newaspect;
|
||||
@@ -3669,7 +3579,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||
|
||||
float off[12];
|
||||
float fix[8];
|
||||
|
||||
|
||||
if (!gl_enable_screen_textures) return;
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
@@ -3692,6 +3602,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||
yoff = newaspect / origaspect;
|
||||
}
|
||||
|
||||
// float off[12];
|
||||
off[0] = -xoff;
|
||||
off[1] = -yoff;
|
||||
off[2] = 1.0f;
|
||||
@@ -3705,6 +3616,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||
off[10] = -yoff;
|
||||
off[11] = 1.0f;
|
||||
|
||||
// float fix[8];
|
||||
fix[0] = 0.0f;
|
||||
fix[1] = 0.0f;
|
||||
fix[2] = 0.0f;
|
||||
@@ -3723,23 +3635,23 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
SetBlend(PF_NoDepthTest);
|
||||
|
||||
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering()) // still quite hacky, but the replacement code in i_video didnt work and killed performance instead. somehow need to figure out whats up with that.
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
|
||||
|
||||
if ((HWR_ShouldUsePaletteRendering()) && cv_groldpal.value)
|
||||
pglUseProgram(gl_shaderprograms[8].program); // palette postprocess shader
|
||||
|
||||
pglColor4ubv(white);
|
||||
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, off);
|
||||
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
tex_downloaded = finalScreenTexture;
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
if ((HWR_ShouldUsePaletteRendering()) && cv_groldpal.value)
|
||||
pglUseProgram(0);
|
||||
}
|
||||
|
||||
tex_downloaded = screenTextures[tex];
|
||||
}
|
||||
|
||||
EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut)
|
||||
{
|
||||
|
||||
+14
-9
@@ -1484,20 +1484,23 @@ static menuitem_t OP_ColorOptionsMenu[] =
|
||||
static menuitem_t OP_ExpOptionsMenu[] =
|
||||
{
|
||||
{IT_HEADER, NULL, "Experimental Options", NULL, 10},
|
||||
{IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 35},
|
||||
{IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 45},
|
||||
{IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 25},
|
||||
{IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 65},
|
||||
{IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 55},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 85},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 95},
|
||||
{IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 75},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 85},
|
||||
#ifdef HWRENDER
|
||||
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 75},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 95},
|
||||
{IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 105},
|
||||
{IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 115},
|
||||
{IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 125},
|
||||
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 75},
|
||||
{IT_STRING | IT_CVAR, NULL, "Old Palshader", &cv_groldpal, 85},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 105},
|
||||
{IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 115},
|
||||
{IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 125},
|
||||
{IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 135},
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1512,6 +1515,8 @@ static const char* OP_ExpTooltips[] =
|
||||
#ifdef HWRENDER
|
||||
"Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.",
|
||||
"Fixes issues that resulted in Textures sticking from the\nground sometimes.\nThis may be CPU heavy and result in worse performance in some cases.",
|
||||
"Changes back to old Palette renderer screentexture behaviour\nthis makes performance better and keeps the old visuals\nat the cost of accuracy.",
|
||||
"Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.",
|
||||
"Fixes issues that resulted in Textures not being properly skewed\n example: Fences on slopes that didnt show proper.\n This may be CPU heavy and result in worse performance in some cases.",
|
||||
"Fixes issues that resulted in Textures on Floor over Floors\nZFighting heavily.",
|
||||
"Toggle for FOF wall cutoff with slopes.",
|
||||
|
||||
+2
-5
@@ -86,7 +86,7 @@ void *hwSym(const char *funcName,void *handle)
|
||||
GETFUNC(ClearBuffer);
|
||||
GETFUNC(SetTexture);
|
||||
GETFUNC(UpdateTexture);
|
||||
GETFUNC(ReadRect);
|
||||
GETFUNC(ReadScreenTexture);
|
||||
GETFUNC(GClipRect);
|
||||
GETFUNC(ClearMipMapCache);
|
||||
GETFUNC(SetSpecialState);
|
||||
@@ -96,13 +96,10 @@ void *hwSym(const char *funcName,void *handle)
|
||||
GETFUNC(SetTransform);
|
||||
GETFUNC(PostImgRedraw);
|
||||
GETFUNC(FlushScreenTextures);
|
||||
GETFUNC(StartScreenWipe);
|
||||
GETFUNC(EndScreenWipe);
|
||||
GETFUNC(DoScreenWipe);
|
||||
GETFUNC(DrawIntermissionBG);
|
||||
GETFUNC(DrawScreenTexture);
|
||||
GETFUNC(MakeScreenTexture);
|
||||
GETFUNC(RenderVhsEffect);
|
||||
GETFUNC(MakeScreenFinalTexture);
|
||||
GETFUNC(DrawScreenFinalTexture);
|
||||
|
||||
GETFUNC(RenderSkyDome);
|
||||
|
||||
+7
-15
@@ -1483,17 +1483,12 @@ void I_FinishUpdate(void)
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
/*// Final postprocess step of palette rendering, after everything else has been drawn.
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
// Final postprocess step of palette rendering, after everything else has been drawn.
|
||||
if (HWR_ShouldUsePaletteRendering() && !cv_groldpal.value)
|
||||
{
|
||||
// not using the function for its original named purpose but can be used like this too
|
||||
HWR_MakeScreenFinalTexture();
|
||||
HWD.pfnSetSpecialState(HWD_SET_SHADERS, 1);
|
||||
HWD.pfnSetShader(8);
|
||||
HWR_DrawScreenFinalTexture(vid.width, vid.height);
|
||||
HWD.pfnUnSetShader();
|
||||
HWD.pfnSetSpecialState(HWD_SET_SHADERS, 0);
|
||||
}*/ //for some reason this does not work here,so ill keep it in DrawScreenFinalTexture itself for now
|
||||
HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2);
|
||||
HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2);
|
||||
}
|
||||
|
||||
OglSdlFinishUpdate(cv_vidwait.value);
|
||||
}
|
||||
@@ -2130,7 +2125,7 @@ void I_StartupGraphics(void)
|
||||
HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL);
|
||||
HWD.pfnSetTexture = hwSym("SetTexture",NULL);
|
||||
HWD.pfnUpdateTexture = hwSym("UpdateTexture",NULL);
|
||||
HWD.pfnReadRect = hwSym("ReadRect",NULL);
|
||||
HWD.pfnReadScreenTexture= hwSym("ReadScreenTexture",NULL);
|
||||
HWD.pfnGClipRect = hwSym("GClipRect",NULL);
|
||||
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
|
||||
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
|
||||
@@ -2141,13 +2136,10 @@ void I_StartupGraphics(void)
|
||||
HWD.pfnSetTransform = hwSym("SetTransform",NULL);
|
||||
HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL);
|
||||
HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL);
|
||||
HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL);
|
||||
HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL);
|
||||
HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL);
|
||||
HWD.pfnDrawIntermissionBG=hwSym("DrawIntermissionBG",NULL);
|
||||
HWD.pfnDrawScreenTexture= hwSym("DrawScreenTexture",NULL);
|
||||
HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL);
|
||||
HWD.pfnRenderVhsEffect = hwSym("RenderVhsEffect",NULL);
|
||||
HWD.pfnMakeScreenFinalTexture=hwSym("MakeScreenFinalTexture",NULL);
|
||||
HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL);
|
||||
|
||||
HWD.pfnRenderSkyDome = hwSym("RenderSkyDome",NULL);
|
||||
|
||||
+3
-1
@@ -233,7 +233,9 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||
|
||||
// Sryder: We need to draw the final screen texture again into the other buffer in the original position so that
|
||||
// effects that want to take the old screen can do so after this
|
||||
HWR_DrawScreenFinalTexture(realwidth, realheight);
|
||||
// Generic2 has the screen image without palette rendering brightness adjustments.
|
||||
// Using that here will prevent brightness adjustments being applied twice.
|
||||
DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2);
|
||||
}
|
||||
|
||||
EXPORT void HWRAPI(OglSdlSetPalette) (RGBA_t *palette)
|
||||
|
||||
Reference in new issue
Block a user