+
#include "quakedef.h"
cvar_t r_max_size = {CVAR_SAVE, "r_max_size", "2048"};
cvar_t r_lerpimages = {CVAR_SAVE, "r_lerpimages", "1"};
cvar_t r_precachetextures = {CVAR_SAVE, "r_precachetextures", "1"};
-int gl_filter_min = GL_LINEAR_MIPMAP_LINEAR; //NEAREST;
+int gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
int gl_filter_mag = GL_LINEAR;
{
texnum = image->texnum;
gltexnuminuse[image->texnum] = 0;
- glDeleteTextures(1, &texnum);
+ qglDeleteTextures(1, &texnum);
}
if (image->blockallocation)
Mem_Free(image->blockallocation);
pool = Mem_Alloc(texturemempool, sizeof(gltexturepool_t));
if (pool == NULL)
return NULL;
- //memset(pool, 0, sizeof(gltexturepool_t));
pool->next = gltexturepoolchain;
gltexturepoolchain = pool;
pool->sentinel = TEXTUREPOOL_SENTINEL;
// only update already uploaded images
if (!(image->flags & GLTEXF_UPLOAD))
{
- glBindTexture(GL_TEXTURE_2D, image->texnum);
+ qglBindTexture(GL_TEXTURE_2D, image->texnum);
if (image->flags & TEXF_MIPMAP)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
else
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
}
}
}
static void r_textures_start(void)
{
// deal with size limits of various drivers (3dfx in particular)
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &realmaxsize);
+ qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &realmaxsize);
CHECKGLERROR
// use the largest scrap texture size we can (not sure if this is really a good idea)
texturedatamempool = Mem_AllocPool("Texture Storage (not yet uploaded)");
textureprocessingmempool = Mem_AllocPool("Texture Processing Buffers");
gltexnuminuse = Mem_Alloc(texturemempool, MAX_GLTEXTURES);
- //memset(gltexnuminuse, 0, MAX_GLTEXTURES);
}
static void r_textures_shutdown(void)
R_FreeTexturePool(&temp);
}
- /*
- if (resizebuffer) Mem_Free(resizebuffer);resizebuffer = NULL;
- if (colorconvertbuffer) Mem_Free(colorconvertbuffer);colorconvertbuffer = NULL;
- if (texturebuffer) Mem_Free(texturebuffer);texturebuffer = NULL;
- if (gltexnuminuse) Mem_Free(gltexnuminuse);gltexnuminuse = NULL;
- */
resizebuffersize = 0;
texturebuffersize = 0;
resizebuffer = NULL;
qbyte *prevbuffer;
prevbuffer = data;
- glBindTexture(GL_TEXTURE_2D, glt->image->texnum);
+ qglBindTexture(GL_TEXTURE_2D, glt->image->texnum);
CHECKGLERROR
gl_backend_rebindtextures = true;
Con_DPrintf("uploaded new fragments image\n");
glt->image->flags &= ~GLTEXF_UPLOAD;
memset(resizebuffer, 255, glt->image->width * glt->image->height * glt->image->bytesperpixel);
- glTexImage2D (GL_TEXTURE_2D, 0, glt->image->glinternalformat, glt->image->width, glt->image->height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, resizebuffer);
+ qglTexImage2D (GL_TEXTURE_2D, 0, glt->image->glinternalformat, glt->image->width, glt->image->height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, resizebuffer);
CHECKGLERROR
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
CHECKGLERROR
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
CHECKGLERROR
}
prevbuffer = colorconvertbuffer;
}
- glTexSubImage2D(GL_TEXTURE_2D, 0, glt->x, glt->y, glt->width, glt->height, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+ qglTexSubImage2D(GL_TEXTURE_2D, 0, glt->x, glt->y, glt->width, glt->height, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
CHECKGLERROR
return;
}
internalformat = 4;
mip = 0;
- glTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+ qglTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
CHECKGLERROR
if (glt->flags & TEXF_MIPMAP)
{
Image_MipReduce(prevbuffer, resizebuffer, &width, &height, 1, 1, glt->image->bytesperpixel);
prevbuffer = resizebuffer;
- glTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+ qglTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
CHECKGLERROR
}
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
CHECKGLERROR
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
CHECKGLERROR
}
else
{
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
CHECKGLERROR
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+ qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
CHECKGLERROR
}
}
image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
if (image == NULL)
Sys_Error("R_FindImageForTexture: ran out of memory\n");
- //memset(image, 0, sizeof(*image));
image->type = GLIMAGETYPE_FRAGMENTS;
image->width = block_size;
image->height = block_size;
image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
if (image == NULL)
Sys_Error("R_FindImageForTexture: ran out of memory\n");
- //memset(image, 0, sizeof(*image));
image->type = GLIMAGETYPE_TILE;
image->blockallocation = NULL;
{
gltexture_t *glt;
glt = Mem_Alloc(texturemempool, sizeof(gltexture_t));
- //memset(glt, 0, sizeof(gltexture_t));
if (identifier)
{
glt->identifier = Mem_Alloc(texturemempool, strlen(identifier)+1);
texinfo = R_GetTexTypeInfo(textype, flags);
- // data can be NULL
-// if (data == NULL)
-// Host_Error("R_LoadTexture: \"%s\" has no data\n", identifier);
-
if (flags & TEXF_FRAGMENT)
{
if (width > block_size || height > block_size)
texinfo = R_GetTexTypeInfo(textype, flags);
- // no function is supported, for odd uses
-// if (generate == NULL)
-// Host_Error("R_ProceduralTexture: \"%s\" has no generate function\n", identifier);
if (flags & TEXF_FRAGMENT)
{
if (width > block_size || height > block_size)
if (data == NULL)
Host_Error("R_UpdateTexture: no data supplied\n");
glt = (gltexture_t *)rt;
- /*
- if (!(glt->flags & GLTEXF_PROCEDURAL))
- {
- if (glt->inputtexels == NULL)
- {
- glt->inputtexels = Mem_Alloc(texturedatamempool, glt->width * glt->height * glt->textype->inputbytesperpixel);
- if (glt->inputtexels == NULL)
- Host_Error("R_UpdateTexture: ran out of memory\n");
- }
- memcpy(glt->inputtexels, data, glt->width * glt->height * glt->textype->inputbytesperpixel);
- }
- R_Upload(glt, data);
- */
+
// if it has not been uploaded yet, update the data that will be used when it is
if (glt->inputtexels)
memcpy(glt->inputtexels, data, glt->width * glt->height * glt->textype->inputbytesperpixel);