remove that stuff

This commit is contained in:
alufolie91 committed 2023-11-14 21:16:04 +01:00
1 parent 116328c7bf
commit 7da8c20409
1 file changed
+36 -84
+36 -84
View File
@@ -249,34 +249,6 @@ static void GL_MSG_Error(const char *format, ...)
#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 GR_TEXFMT_P_8: return "GR_TEXFMT_P_8";
case GR_TEXFMT_AP_88: return "GR_TEXFMT_AP_88";
case GR_RGBA: return "GR_RGBA";
case GR_TEXFMT_ALPHA_8: return "GR_TEXFMT_ALPHA_8";
case GR_TEXFMT_INTENSITY_8: return "GR_TEXFMT_INTENSITY_8";
case GR_TEXFMT_ALPHA_INTENSITY_88: return "GR_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
/* 1.0 functions */
/* Miscellaneous */
@@ -1995,60 +1967,38 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
CurrentPolyFlags = PolyFlags;
}
// -------------------+
// 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);
RGBA_t *tex = calloc(len, sizeof(RGBA_t));
if (tex == NULL)
I_Error("AllocTextureBuffer: out of memory allocating %s bytes for texture %d, format %s",
sizeu1(len * sizeof(RGBA_t)), pTexInfo->downloaded, GetTextureFormatName(pTexInfo->grInfo.format));
return tex;
}
// ------------------+
// FreeTextureBuffer : Frees memory allocated by AllocTextureBuffer.
// ------------------+
static void FreeTextureBuffer(RGBA_t *tex)
{
if (tex)
free(tex);
}
// -----------------+
// UpdateTexture : Updates texture data.
// -----------------+
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
{
// Upload a texture
GLuint num = pTexInfo->downloaded;
boolean update = true;
// Download a mipmap
boolean updatemipmap = true;
static RGBA_t tex[2048*2048];
const GLvoid *ptex = tex;
INT32 w, h;
GLuint texnum = 0;
INT32 w = pTexInfo->width, h = pTexInfo->height;
INT32 i, j;
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
const GLvoid *ptex = NULL;
RGBA_t *tex = NULL;
// Generate a new texture name.
if (!num)
if (!pTexInfo->downloaded)
{
pglGenTextures(1, &num);
pTexInfo->downloaded = num;
update = false;
pglGenTextures(1, &texnum);
pTexInfo->downloaded = texnum;
updatemipmap = false;
}
//GL_DBG_Printf("UpdateTexture %d %x\n", (INT32)num, pImgData);
else
texnum = pTexInfo->downloaded;
//GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data);
w = pTexInfo->width;
h = pTexInfo->height;
if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) || (pTexInfo->grInfo.format == GR_TEXFMT_AP_88))
if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) ||
(pTexInfo->grInfo.format == GR_TEXFMT_AP_88))
{
ptex = tex = AllocTextureBuffer(pTexInfo);
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
@@ -2085,12 +2035,14 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else if (pTexInfo->grInfo.format == GR_RGBA)
{
// Directly upload the texture data without any kind of conversion.
ptex = pImgData;
// corona test : passed as ARGB 8888, which is not in glide formats
// Hurdler: not used for coronas anymore, just for dynamic lighting
ptex = pTexInfo->grInfo.data;
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88)
{
ptex = tex = AllocTextureBuffer(pTexInfo);
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
@@ -2107,7 +2059,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) // Used for fade masks
{
ptex = tex = AllocTextureBuffer(pTexInfo);
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
@@ -2122,10 +2075,12 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
}
else
GL_MSG_Warning("UpdateTexture: bad format %d\n", pTexInfo->grInfo.format);
GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
pglBindTexture(GL_TEXTURE_2D, num);
tex_downloaded = num;
// the texture number was already generated by pglGenTextures
pglBindTexture(GL_TEXTURE_2D, texnum);
tex_downloaded = texnum;
// disable texture filtering on any texture that has holes so there's no dumb borders or blending issues
if (pTexInfo->flags & TF_TRANSPARENT)
@@ -2154,7 +2109,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else
{
if (update)
if (updatemipmap)
pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
else
pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
@@ -2175,7 +2130,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else
{
if (update)
if (updatemipmap)
pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
else
pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
@@ -2195,15 +2150,12 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else
{
if (update)
if (updatemipmap)
pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
else
pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
}
}
// Free the texture buffer
FreeTextureBuffer(tex);
if (pTexInfo->flags & TF_WRAPX)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);