mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-10 19:01:50 +00:00
Update r_opengl.c
This commit is contained in:
parent
5539341ebc
commit
0abc659168
1 changed files with 22 additions and 53 deletions
|
|
@ -62,6 +62,9 @@ static FBITFIELD CurrentPolyFlags;
|
||||||
static FTextureInfo *TexCacheTail = NULL;
|
static FTextureInfo *TexCacheTail = NULL;
|
||||||
static FTextureInfo *TexCacheHead = NULL;
|
static FTextureInfo *TexCacheHead = NULL;
|
||||||
|
|
||||||
|
static RGBA_t *textureBuffer = NULL;
|
||||||
|
static size_t textureBufferSize = 0;
|
||||||
|
|
||||||
RGBA_t myPaletteData[256];
|
RGBA_t myPaletteData[256];
|
||||||
GLint screen_width = 0; // used by Draw2DLine()
|
GLint screen_width = 0; // used by Draw2DLine()
|
||||||
GLint screen_height = 0;
|
GLint screen_height = 0;
|
||||||
|
|
@ -202,32 +205,6 @@ static void GL_MSG_Error(const char *format, ...)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------+
|
|
||||||
// GetTextureFormatName : Returns the corresponding texture format string from the texture format enumeration.
|
|
||||||
// ----------------------+
|
|
||||||
static const char *GetTextureFormatName(INT32 format)
|
|
||||||
{
|
|
||||||
static char num[12];
|
|
||||||
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case GL_TEXFMT_P_8: return "GL_TEXFMT_P_8";
|
|
||||||
case GL_TEXFMT_AP_88: return "GL_TEXFMT_AP_88";
|
|
||||||
case GL_TEXFMT_RGBA: return "GL_TEXFMT_RGBA";
|
|
||||||
case GL_TEXFMT_ALPHA_8: return "GL_TEXFMT_ALPHA_8";
|
|
||||||
case GL_TEXFMT_INTENSITY_8: return "GL_TEXFMT_INTENSITY_8";
|
|
||||||
case GL_TEXFMT_ALPHA_INTENSITY_88: return "GL_TEXFMT_ALPHA_INTENSITY_88";
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the texture format is not known (due to it being invalid),
|
|
||||||
// return a string containing the format index instead.
|
|
||||||
format = INT32_MIN;
|
|
||||||
snprintf(num, sizeof(num), "%d", format);
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef STATIC_OPENGL
|
#ifdef STATIC_OPENGL
|
||||||
/* 1.0 functions */
|
/* 1.0 functions */
|
||||||
/* Miscellaneous */
|
/* Miscellaneous */
|
||||||
|
|
@ -1398,6 +1375,10 @@ void Flush(void)
|
||||||
|
|
||||||
TexCacheTail = TexCacheHead = NULL; //Hurdler: well, TexCacheHead is already NULL
|
TexCacheTail = TexCacheHead = NULL; //Hurdler: well, TexCacheHead is already NULL
|
||||||
tex_downloaded = 0;
|
tex_downloaded = 0;
|
||||||
|
|
||||||
|
free(textureBuffer);
|
||||||
|
textureBuffer = NULL;
|
||||||
|
textureBufferSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1790,28 +1771,16 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
|
||||||
CurrentPolyFlags = PolyFlags;
|
CurrentPolyFlags = PolyFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------+
|
static void AllocTextureBuffer(GLMipmap_t *pTexInfo)
|
||||||
// AllocTextureBuffer : Allocates memory for converting a non-RGBA texture into an RGBA texture.
|
|
||||||
// -------------------+
|
|
||||||
static RGBA_t *AllocTextureBuffer(GLMipmap_t *pTexInfo)
|
|
||||||
{
|
{
|
||||||
size_t len = (pTexInfo->width * pTexInfo->height);
|
size_t size = pTexInfo->width * pTexInfo->height;
|
||||||
RGBA_t *tex = calloc(len, sizeof(RGBA_t));
|
if (size > textureBufferSize)
|
||||||
|
{
|
||||||
if (tex == NULL)
|
textureBuffer = realloc(textureBuffer, size * sizeof(RGBA_t));
|
||||||
I_Error("AllocTextureBuffer: out of memory allocating %s bytes for texture %d, format %s",
|
if (textureBuffer == NULL)
|
||||||
sizeu1(len * sizeof(RGBA_t)), pTexInfo->downloaded, GetTextureFormatName(pTexInfo->format));
|
I_Error("AllocTextureBuffer: out of memory allocating %s bytes", sizeu1(size * sizeof(RGBA_t)));
|
||||||
|
textureBufferSize = size;
|
||||||
return tex;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------+
|
|
||||||
// FreeTextureBuffer : Frees memory allocated by AllocTextureBuffer.
|
|
||||||
// ------------------+
|
|
||||||
static void FreeTextureBuffer(RGBA_t *tex)
|
|
||||||
{
|
|
||||||
if (tex)
|
|
||||||
free(tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------+
|
// -----------------+
|
||||||
|
|
@ -1842,7 +1811,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
|
||||||
|
|
||||||
if ((pTexInfo->format == GL_TEXFMT_P_8) || (pTexInfo->format == GL_TEXFMT_AP_88))
|
if ((pTexInfo->format == GL_TEXFMT_P_8) || (pTexInfo->format == GL_TEXFMT_AP_88))
|
||||||
{
|
{
|
||||||
ptex = tex = AllocTextureBuffer(pTexInfo);
|
AllocTextureBuffer(pTexInfo);
|
||||||
|
ptex = tex = textureBuffer;
|
||||||
|
|
||||||
for (j = 0; j < h; j++)
|
for (j = 0; j < h; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1883,7 +1853,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
|
||||||
}
|
}
|
||||||
else if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88)
|
else if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88)
|
||||||
{
|
{
|
||||||
ptex = tex = AllocTextureBuffer(pTexInfo);
|
AllocTextureBuffer(pTexInfo);
|
||||||
|
ptex = tex = textureBuffer;
|
||||||
|
|
||||||
for (j = 0; j < h; j++)
|
for (j = 0; j < h; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1900,7 +1871,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
|
||||||
}
|
}
|
||||||
else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) // Used for fade masks
|
else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) // Used for fade masks
|
||||||
{
|
{
|
||||||
ptex = tex = AllocTextureBuffer(pTexInfo);
|
AllocTextureBuffer(pTexInfo);
|
||||||
|
ptex = tex = textureBuffer;
|
||||||
|
|
||||||
for (j = 0; j < h; j++)
|
for (j = 0; j < h; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1995,9 +1967,6 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the texture buffer
|
|
||||||
FreeTextureBuffer(tex);
|
|
||||||
|
|
||||||
if (pTexInfo->flags & TF_WRAPX)
|
if (pTexInfo->flags & TF_WRAPX)
|
||||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue