Fix OpenGL screen texture resolution

This commit is contained in:
Zwip-Zwap Zapony 2023-08-08 12:31:27 +02:00 committed by NepDisk
parent dedfe35cc2
commit a56955c9fb

View file

@ -67,8 +67,9 @@ static RGBA_t *textureBuffer = NULL;
static size_t textureBufferSize = 0;
RGBA_t myPaletteData[256];
GLint screen_width = 0; // used by Draw2DLine()
GLint screen_width = 0; // used by Draw2DLine()
GLint screen_height = 0;
GLint texsize = 512; // Power-of-two screen texture render resolution
GLbyte screen_depth = 0;
GLint textureformatGL = 0;
GLint maximumAnisotropy = 0;
@ -1236,6 +1237,12 @@ void SetModelView(GLint w, GLint h)
screen_width = w;
screen_height = h;
texsize = 512;
// Use a power of two texture, dammit
while (texsize < screen_width || texsize < screen_height)
{
texsize *= 2;
}
pglViewport(0, 0, w, h);
@ -3094,7 +3101,6 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
INT32 x, y;
float float_x, float_y, float_nextx, float_nexty;
float xfix, yfix;
INT32 texsize = 2048;
const float blackBack[16] =
{
@ -3104,12 +3110,6 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
16.0f, -16.0f, 6.0f
};
// Use a power of two texture, dammit
if(screen_width <= 1024)
texsize = 1024;
if(screen_width <= 512)
texsize = 512;
// X/Y stretch fix for all resolutions(!)
xfix = (float)(texsize)/((float)((screen_width)/(float)(SCREENVERTS-1)));
yfix = (float)(texsize)/((float)((screen_height)/(float)(SCREENVERTS-1)));
@ -3195,15 +3195,8 @@ EXPORT void HWRAPI(FlushScreenTextures) (void)
// Create Screen to fade from
EXPORT void HWRAPI(StartScreenWipe) (void)
{
INT32 texsize = 2048;
boolean firstTime = (startScreenWipe == 0);
// Use a power of two texture, dammit
if(screen_width <= 512)
texsize = 512;
else if(screen_width <= 1024)
texsize = 1024;
// Create screen texture
if (firstTime)
pglGenTextures(1, &startScreenWipe);
@ -3226,15 +3219,8 @@ EXPORT void HWRAPI(StartScreenWipe) (void)
// Create Screen to fade to
EXPORT void HWRAPI(EndScreenWipe)(void)
{
INT32 texsize = 2048;
boolean firstTime = (endScreenWipe == 0);
// Use a power of two texture, dammit
if(screen_width <= 512)
texsize = 512;
else if(screen_width <= 1024)
texsize = 1024;
// Create screen texture
if (firstTime)
pglGenTextures(1, &endScreenWipe);
@ -3259,7 +3245,6 @@ EXPORT void HWRAPI(EndScreenWipe)(void)
EXPORT void HWRAPI(DrawIntermissionBG)(void)
{
float xfix, yfix;
INT32 texsize = 2048;
const float screenVerts[12] =
{
@ -3271,11 +3256,6 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
float fix[8];
if(screen_width <= 1024)
texsize = 1024;
if(screen_width <= 512)
texsize = 512;
xfix = 1/((float)(texsize)/((float)((screen_width))));
yfix = 1/((float)(texsize)/((float)((screen_height))));
@ -3306,7 +3286,6 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
// Do screen fades!
EXPORT void HWRAPI(DoScreenWipe)(void)
{
INT32 texsize = 2048;
float xfix, yfix;
INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set
@ -3329,12 +3308,6 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
1.0f, 1.0f
};
// Use a power of two texture, dammit
if(screen_width <= 1024)
texsize = 1024;
if(screen_width <= 512)
texsize = 512;
xfix = 1/((float)(texsize)/((float)((screen_width))));
yfix = 1/((float)(texsize)/((float)((screen_height))));
@ -3397,15 +3370,8 @@ EXPORT void HWRAPI(DoScreenWipe)(void)
// Create a texture from the screen.
EXPORT void HWRAPI(MakeScreenTexture) (void)
{
INT32 texsize = 2048;
boolean firstTime = (screentexture == 0);
// Use a power of two texture, dammit
if(screen_width <= 512)
texsize = 512;
else if(screen_width <= 1024)
texsize = 1024;
// Create screen texture
if (firstTime)
pglGenTextures(1, &screentexture);
@ -3427,15 +3393,8 @@ EXPORT void HWRAPI(MakeScreenTexture) (void)
EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
{
INT32 texsize = 2048;
boolean firstTime = (finalScreenTexture == 0);
// Use a power of two texture, dammit
if(screen_width <= 512)
texsize = 512;
else if(screen_width <= 1024)
texsize = 1024;
// Create screen texture
if (firstTime)
pglGenTextures(1, &finalScreenTexture);
@ -3461,16 +3420,10 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
float origaspect, newaspect;
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
FRGBAFloat clearColour;
INT32 texsize = 2048;
float off[12];
float fix[8];
if(screen_width <= 1024)
texsize = 1024;
if(screen_width <= 512)
texsize = 512;
xfix = 1/((float)(texsize)/((float)((screen_width))));
yfix = 1/((float)(texsize)/((float)((screen_height))));