mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-13 07:47:45 +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
|
#define BLOCK_HEIGHT 256
|
||||||
|
|
||||||
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
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;
|
qboolean scrap_dirty;
|
||||||
int scrap_texnum;
|
int scrap_texnum;
|
||||||
|
|
||||||
|
@ -183,8 +183,7 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y)
|
||||||
return texnum;
|
return texnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Error ("Scrap_AllocBlock: full");
|
return -1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int scrap_uploads;
|
int scrap_uploads;
|
||||||
|
@ -285,20 +284,30 @@ qboolean Draw_RealPicFromWad (mpic_t *out, char *name)
|
||||||
int texnum;
|
int texnum;
|
||||||
|
|
||||||
texnum = Scrap_AllocBlock (in->width, in->height, &x, &y);
|
texnum = Scrap_AllocBlock (in->width, in->height, &x, &y);
|
||||||
scrap_dirty = true;
|
if (texnum >= 0)
|
||||||
k = 0;
|
{
|
||||||
for (i=0 ; i<in->height ; i++)
|
scrap_dirty = true;
|
||||||
for (j=0 ; j<in->width ; j++, k++)
|
k = 0;
|
||||||
scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = in->data[k];
|
for (i=0 ; i<in->height ; i++)
|
||||||
texnum += scrap_texnum;
|
for (j=0 ; j<in->width ; j++, k++)
|
||||||
gl->texnum = texnum;
|
scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = in->data[k];
|
||||||
gl->sl = (x+0.01)/(float)BLOCK_WIDTH;
|
texnum += scrap_texnum;
|
||||||
gl->sh = (x+in->width-0.01)/(float)BLOCK_WIDTH;
|
gl->texnum = texnum;
|
||||||
gl->tl = (y+0.01)/(float)BLOCK_WIDTH;
|
gl->sl = (x+0.25)/(float)BLOCK_WIDTH;
|
||||||
gl->th = (y+in->height-0.01)/(float)BLOCK_WIDTH;
|
gl->sh = (x+in->width-0.25)/(float)BLOCK_WIDTH;
|
||||||
|
gl->tl = (y+0.25)/(float)BLOCK_WIDTH;
|
||||||
pic_count++;
|
gl->th = (y+in->height-0.25)/(float)BLOCK_WIDTH;
|
||||||
pic_texels += in->width*in->height;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -740,6 +749,7 @@ void GLDraw_ReInit (void)
|
||||||
GL_GAliasFlushSkinCache();
|
GL_GAliasFlushSkinCache();
|
||||||
|
|
||||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||||
|
memset(scrap_texels, 255, sizeof(scrap_texels));
|
||||||
|
|
||||||
|
|
||||||
qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize);
|
qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize);
|
||||||
|
@ -1104,6 +1114,7 @@ void GLDraw_Init (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||||
|
memset(scrap_texels, 255, sizeof(scrap_texels));
|
||||||
|
|
||||||
GLDraw_ReInit();
|
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 *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 *qglTexParameteri) (GLenum target, GLenum pname, GLint param);
|
||||||
void (APIENTRY *qglTexParameterf) (GLenum target, GLenum pname, GLfloat 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 *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 *qglTranslatef) (GLfloat x, GLfloat y, GLfloat z);
|
||||||
void (APIENTRY *qglVertex2f) (GLfloat x, GLfloat y);
|
void (APIENTRY *qglVertex2f) (GLfloat x, GLfloat y);
|
||||||
|
@ -535,6 +537,8 @@ void GL_Init(void *(*getglfunction) (char *name))
|
||||||
qglTexImage2D = (void *)getglcore("glTexImage2D");
|
qglTexImage2D = (void *)getglcore("glTexImage2D");
|
||||||
qglTexParameteri = (void *)getglcore("glTexParameteri");
|
qglTexParameteri = (void *)getglcore("glTexParameteri");
|
||||||
qglTexParameterf = (void *)getglcore("glTexParameterf");
|
qglTexParameterf = (void *)getglcore("glTexParameterf");
|
||||||
|
qglTexParameteriv = (void *)getglcore("glTexParameteriv");
|
||||||
|
qglTexParameterfv = (void *)getglcore("glTexParameterfv");
|
||||||
qglTexSubImage2D = (void *)getglcore("glTexSubImage2D");
|
qglTexSubImage2D = (void *)getglcore("glTexSubImage2D");
|
||||||
qglTranslatef = (void *)getglcore("glTranslatef");
|
qglTranslatef = (void *)getglcore("glTranslatef");
|
||||||
qglVertex2f = (void *)getglcore("glVertex2f");
|
qglVertex2f = (void *)getglcore("glVertex2f");
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ void SV_StuffToClient_f(void)
|
||||||
!strncmp(str, "quit", 4) &&
|
!strncmp(str, "quit", 4) &&
|
||||||
!strncmp(str, "gl_fb", 5) &&
|
!strncmp(str, "gl_fb", 5) &&
|
||||||
!strncmp(str, "r_fb", 4) &&
|
!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, "echo", 4) &&
|
||||||
!strncmp(str, "name", 4) &&
|
!strncmp(str, "name", 4) &&
|
||||||
!strncmp(str, "skin", 4) &&
|
!strncmp(str, "skin", 4) &&
|
||||||
|
|
Loading…
Reference in a new issue