mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 22:51:57 +00:00
fix graphic error with 8-bit images and gl_blend2d, don't Sys_Error loading textures when out of scrap space
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2327 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
3b0c07281d
commit
2b946b97f4
3 changed files with 33 additions and 18 deletions
|
@ -141,7 +141,7 @@ static gltexture_t *gltextures;
|
|||
#define BLOCK_HEIGHT 256
|
||||
|
||||
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
||||
qbyte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT*4];
|
||||
qbyte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT];
|
||||
qboolean scrap_dirty;
|
||||
int scrap_texnum;
|
||||
|
||||
|
@ -183,8 +183,7 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y)
|
|||
return texnum;
|
||||
}
|
||||
|
||||
Sys_Error ("Scrap_AllocBlock: full");
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int scrap_uploads;
|
||||
|
@ -285,20 +284,30 @@ qboolean Draw_RealPicFromWad (mpic_t *out, char *name)
|
|||
int texnum;
|
||||
|
||||
texnum = Scrap_AllocBlock (in->width, in->height, &x, &y);
|
||||
scrap_dirty = true;
|
||||
k = 0;
|
||||
for (i=0 ; i<in->height ; i++)
|
||||
for (j=0 ; j<in->width ; j++, k++)
|
||||
scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = in->data[k];
|
||||
texnum += scrap_texnum;
|
||||
gl->texnum = texnum;
|
||||
gl->sl = (x+0.01)/(float)BLOCK_WIDTH;
|
||||
gl->sh = (x+in->width-0.01)/(float)BLOCK_WIDTH;
|
||||
gl->tl = (y+0.01)/(float)BLOCK_WIDTH;
|
||||
gl->th = (y+in->height-0.01)/(float)BLOCK_WIDTH;
|
||||
|
||||
pic_count++;
|
||||
pic_texels += in->width*in->height;
|
||||
if (texnum >= 0)
|
||||
{
|
||||
scrap_dirty = true;
|
||||
k = 0;
|
||||
for (i=0 ; i<in->height ; i++)
|
||||
for (j=0 ; j<in->width ; j++, k++)
|
||||
scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = in->data[k];
|
||||
texnum += scrap_texnum;
|
||||
gl->texnum = texnum;
|
||||
gl->sl = (x+0.25)/(float)BLOCK_WIDTH;
|
||||
gl->sh = (x+in->width-0.25)/(float)BLOCK_WIDTH;
|
||||
gl->tl = (y+0.25)/(float)BLOCK_WIDTH;
|
||||
gl->th = (y+in->height-0.25)/(float)BLOCK_WIDTH;
|
||||
pic_count++;
|
||||
pic_texels += in->width*in->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
gl->texnum = GL_LoadPicTexture (in);
|
||||
gl->sl = 0;
|
||||
gl->sh = 1;
|
||||
gl->tl = 0;
|
||||
gl->th = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -740,6 +749,7 @@ void GLDraw_ReInit (void)
|
|||
GL_GAliasFlushSkinCache();
|
||||
|
||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||
memset(scrap_texels, 255, sizeof(scrap_texels));
|
||||
|
||||
|
||||
qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize);
|
||||
|
@ -1104,6 +1114,7 @@ void GLDraw_Init (void)
|
|||
{
|
||||
|
||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||
memset(scrap_texels, 255, sizeof(scrap_texels));
|
||||
|
||||
GLDraw_ReInit();
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ void (APIENTRY *qglTexGeni) (GLenum coord, GLenum pname, GLint param);
|
|||
void (APIENTRY *qglTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
void (APIENTRY *qglTexParameteri) (GLenum target, GLenum pname, GLint param);
|
||||
void (APIENTRY *qglTexParameterf) (GLenum target, GLenum pname, GLfloat param);
|
||||
void (APIENTRY *qglTexParameteriv) (GLenum target, GLenum pname, const GLint *params);
|
||||
void (APIENTRY *qglTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params);
|
||||
void (APIENTRY *qglTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
void (APIENTRY *qglTranslatef) (GLfloat x, GLfloat y, GLfloat z);
|
||||
void (APIENTRY *qglVertex2f) (GLfloat x, GLfloat y);
|
||||
|
@ -535,6 +537,8 @@ void GL_Init(void *(*getglfunction) (char *name))
|
|||
qglTexImage2D = (void *)getglcore("glTexImage2D");
|
||||
qglTexParameteri = (void *)getglcore("glTexParameteri");
|
||||
qglTexParameterf = (void *)getglcore("glTexParameterf");
|
||||
qglTexParameteriv = (void *)getglcore("glTexParameteriv");
|
||||
qglTexParameterfv = (void *)getglcore("glTexParameterfv");
|
||||
qglTexSubImage2D = (void *)getglcore("glTexSubImage2D");
|
||||
qglTranslatef = (void *)getglcore("glTranslatef");
|
||||
qglVertex2f = (void *)getglcore("glVertex2f");
|
||||
|
|
|
@ -1137,7 +1137,7 @@ void SV_StuffToClient_f(void)
|
|||
!strncmp(str, "quit", 4) &&
|
||||
!strncmp(str, "gl_fb", 5) &&
|
||||
!strncmp(str, "r_fb", 4) &&
|
||||
// !strncmp(str, "say", 3) && //note that the say parsing could be useful here.
|
||||
!strncmp(str, "say", 3) && //note that the say parsing could be useful here.
|
||||
!strncmp(str, "echo", 4) &&
|
||||
!strncmp(str, "name", 4) &&
|
||||
!strncmp(str, "skin", 4) &&
|
||||
|
|
Loading…
Reference in a new issue