whether the texture is loaded in texture memory directly or only on demand.
-Adapted all Draw_CachePic calls (I'll do some corrections, atm most of them
pass persistent := false)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5180
d7cf8633-e32d-0410-b094-
e92efae38249
- pic = Draw_CachePic ("gfx/pause.lmp");
+ pic = Draw_CachePic ("gfx/pause.lmp", true);
DrawQ_Pic ((vid.conwidth - pic->width)/2, (vid.conheight - pic->height)/2, "gfx/pause.lmp", 0, 0, 1, 1, 1, 1, 0);
}
DrawQ_Pic ((vid.conwidth - pic->width)/2, (vid.conheight - pic->height)/2, "gfx/pause.lmp", 0, 0, 1, 1, 1, 1, 0);
}
memset(&mesh, 0, sizeof(mesh));
if (picname && picname[0])
{
memset(&mesh, 0, sizeof(mesh));
if (picname && picname[0])
{
- pic = Draw_CachePic(picname);
+ pic = Draw_CachePic(picname, false);
if (width == 0)
width = pic->width;
if (height == 0)
if (width == 0)
width = pic->width;
if (height == 0)
cachepic_t;
void Draw_Init (void);
cachepic_t;
void Draw_Init (void);
-cachepic_t *Draw_CachePic (char *path);
+cachepic_t *Draw_CachePic (char *path, qboolean persistent);
// create or update a pic's image
cachepic_t *Draw_NewPic(char *picname, int width, int height, int alpha, qbyte *pixels);
// free the texture memory used by a pic
// create or update a pic's image
cachepic_t *Draw_NewPic(char *picname, int width, int height, int alpha, qbyte *pixels);
// free the texture memory used by a pic
R_Mesh_Start();
R_Mesh_Matrix(&r_identitymatrix);
// draw the loading plaque
R_Mesh_Start();
R_Mesh_Matrix(&r_identitymatrix);
// draw the loading plaque
- pic = Draw_CachePic("gfx/loading.lmp");
+ pic = Draw_CachePic("gfx/loading.lmp", false);
x = (vid_conwidth.integer - pic->width)/2;
y = (vid_conheight.integer - pic->height)/2;
GL_Color(1,1,1,1);
x = (vid_conwidth.integer - pic->width)/2;
y = (vid_conheight.integer - pic->height)/2;
GL_Color(1,1,1,1);
================
*/
// FIXME: move this to client somehow
================
*/
// FIXME: move this to client somehow
-cachepic_t *Draw_CachePic (char *path)
+cachepic_t *Draw_CachePic (char *path, qboolean persistent)
{
int i, crc, hashkey;
cachepic_t *pic;
qpic_t *p;
{
int i, crc, hashkey;
cachepic_t *pic;
qpic_t *p;
- if (!strncmp(CLVIDEOPREFIX, path, sizeof(CLVIDEOPREFIX) - 1)) {
+ if (!strncmp(CLVIDEOPREFIX, path, sizeof(CLVIDEOPREFIX) - 1)) {
clvideo_t *video;
video = CL_GetVideo(path);
clvideo_t *video;
video = CL_GetVideo(path);
+ if (persistent) {
+ persistentflag = TEXF_PRECACHE;
+ } else {
+ persistentflag = 0;
+ }
+
crc = CRC_Block(path, strlen(path));
hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
for (pic = cachepichash[hashkey];pic;pic = pic->chain)
crc = CRC_Block(path, strlen(path));
hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
for (pic = cachepichash[hashkey];pic;pic = pic->chain)
cachepichash[hashkey] = pic;
// load the pic from disk
cachepichash[hashkey] = pic;
// load the pic from disk
- pic->tex = loadtextureimage(drawtexturepool, path, 0, 0, false, TEXF_ALPHA | TEXF_PRECACHE);
+ pic->tex = loadtextureimage(drawtexturepool, path, 0, 0, false, TEXF_ALPHA | persistentflag);
if (pic->tex == NULL && !strncmp(path, "gfx/", 4))
{
// compatibility with older versions
if (pic->tex == NULL && !strncmp(path, "gfx/", 4))
{
// compatibility with older versions
- pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, TEXF_ALPHA | TEXF_PRECACHE);
+ pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, TEXF_ALPHA | persistentflag);
// failed to find gfx/whatever.tga or similar, try the wad
if (pic->tex == NULL && (p = W_GetLumpName (path + 4)))
{
// failed to find gfx/whatever.tga or similar, try the wad
if (pic->tex == NULL && (p = W_GetLumpName (path + 4)))
{
for (i = 0;i < 128 * 128;i++)
if (pix[i] == 0)
pix[i] = 255;
for (i = 0;i < 128 * 128;i++)
if (pix[i] == 0)
pix[i] = 255;
- pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, pix, TEXTYPE_PALETTE, TEXF_ALPHA | TEXF_PRECACHE, palette_complete);
+ pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, pix, TEXTYPE_PALETTE, TEXF_ALPHA | persistentflag, palette_complete);
- pic->tex = R_LoadTexture2D(drawtexturepool, path, p->width, p->height, p->data, TEXTYPE_PALETTE, TEXF_ALPHA | TEXF_PRECACHE, palette_complete);
+ pic->tex = R_LoadTexture2D(drawtexturepool, path, p->width, p->height, p->data, TEXTYPE_PALETTE, TEXF_ALPHA | persistentflag, palette_complete);
numcachepics = 0;
memset(cachepichash, 0, sizeof(cachepichash));
numcachepics = 0;
memset(cachepichash, 0, sizeof(cachepichash));
- char_texture = Draw_CachePic("gfx/conchars")->tex;
+ char_texture = Draw_CachePic("gfx/conchars", true)->tex;
}
static void gl_draw_shutdown(void)
}
static void gl_draw_shutdown(void)
if (gamemode == GAME_TRANSFUSION) {
int y1, y2, y3;
M_Background(640, 480);
if (gamemode == GAME_TRANSFUSION) {
int y1, y2, y3;
M_Background(640, 480);
- p = Draw_CachePic ("gfx/tb-transfusion");
+ p = Draw_CachePic ("gfx/tb-transfusion", false);
M_DrawPic (640/2 - p->width/2, 40, "gfx/tb-transfusion");
y2 = 120;
// 8 rather than MAIN_ITEMS to skip a number and not miss the last option
M_DrawPic (640/2 - p->width/2, 40, "gfx/tb-transfusion");
y2 = 120;
// 8 rather than MAIN_ITEMS to skip a number and not miss the last option
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic ("gfx/ttl_main.lmp");
+ p = Draw_CachePic ("gfx/ttl_main.lmp", false);
M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_main.lmp");
// Nehahra
if (gamemode == GAME_NEHAHRA)
M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_main.lmp");
// Nehahra
if (gamemode == GAME_NEHAHRA)
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic ("gfx/ttl_sgl.lmp");
+ p = Draw_CachePic ("gfx/ttl_sgl.lmp", false);
// Some mods don't have a single player mode
if (gamemode == GAME_NEXUIZ || gamemode == GAME_GOODVSBAD2 || gamemode == GAME_BATTLEMECH)
// Some mods don't have a single player mode
if (gamemode == GAME_NEXUIZ || gamemode == GAME_GOODVSBAD2 || gamemode == GAME_BATTLEMECH)
- p = Draw_CachePic ("gfx/p_load.lmp");
- M_DrawPic ( (320-p->width)/2, 4, "gfx/p_load.lmp");
+ p = Draw_CachePic ("gfx/p_load.lmp", false);
+ M_DrawPic ( (320-p->width)/2, 4, "gfx/p_load.lmp" );
for (i=0 ; i< MAX_SAVEGAMES; i++)
M_Print(16, 32 + 8*i, m_filenames[i]);
for (i=0 ; i< MAX_SAVEGAMES; i++)
M_Print(16, 32 + 8*i, m_filenames[i]);
- p = Draw_CachePic ("gfx/p_save.lmp");
+ p = Draw_CachePic ("gfx/p_save.lmp", false);
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_save.lmp");
for (i=0 ; i<MAX_SAVEGAMES ; i++)
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_save.lmp");
for (i=0 ; i<MAX_SAVEGAMES ; i++)
cachepic_t *p;
M_Background(640, 480);
cachepic_t *p;
M_Background(640, 480);
- p = Draw_CachePic ("gfx/tb-episodes");
+ p = Draw_CachePic ("gfx/tb-episodes", false);
M_DrawPic (640/2 - p->width/2, 40, "gfx/tb-episodes");
for (y = 0; y < EPISODE_ITEMS; y++){
M_DrawPic (0, 160 + y * 40, va("gfx/episode%i", y+1));
M_DrawPic (640/2 - p->width/2, 40, "gfx/tb-episodes");
for (y = 0; y < EPISODE_ITEMS; y++){
M_DrawPic (0, 160 + y * 40, va("gfx/episode%i", y+1));
cachepic_t *p;
M_Background(640, 480);
cachepic_t *p;
M_Background(640, 480);
- p = Draw_CachePic ("gfx/tb-difficulty");
+ p = Draw_CachePic ("gfx/tb-difficulty", false);
M_DrawPic(640/2 - p->width/2, 40, "gfx/tb-difficulty");
for (y = 0; y < SKILL_ITEMS; y++)
M_DrawPic(640/2 - p->width/2, 40, "gfx/tb-difficulty");
for (y = 0; y < SKILL_ITEMS; y++)
if (gamemode == GAME_TRANSFUSION)
{
M_Background(640, 480);
if (gamemode == GAME_TRANSFUSION)
{
M_Background(640, 480);
- p = Draw_CachePic ("gfx/tb-online");
+ p = Draw_CachePic ("gfx/tb-online", false);
M_DrawPic (640/2 - p->width/2, 140, "gfx/tb-online");
for (f = 1; f <= MULTIPLAYER_ITEMS; f++)
M_DrawPic (0, 180 + f*40, va("gfx/online%i", f));
M_DrawPic (640/2 - p->width/2, 140, "gfx/tb-online");
for (f = 1; f <= MULTIPLAYER_ITEMS; f++)
M_DrawPic (0, 180 + f*40, va("gfx/online%i", f));
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic ("gfx/p_multi.lmp");
+ p = Draw_CachePic ("gfx/p_multi.lmp", false);
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
M_DrawPic (72, 32, "gfx/mp_menu.lmp");
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
M_DrawPic (72, 32, "gfx/mp_menu.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic ("gfx/p_multi.lmp");
+ p = Draw_CachePic ("gfx/p_multi.lmp", false);
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
M_Print(64, 40, "Your name");
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
M_Print(64, 40, "Your name");
M_Background(320, bound(200, 32 + OPTIONS_ITEMS * 8, vid.conheight));
M_DrawPic(16, 4, "gfx/qplaque.lmp");
M_Background(320, bound(200, 32 + OPTIONS_ITEMS * 8, vid.conheight));
M_DrawPic(16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic("gfx/p_option.lmp");
+ p = Draw_CachePic("gfx/p_option.lmp", false);
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optnum = 0;
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optnum = 0;
M_Background(320, bound(200, 32 + OPTIONS_EFFECTS_ITEMS * 8, vid.conheight));
M_DrawPic(16, 4, "gfx/qplaque.lmp");
M_Background(320, bound(200, 32 + OPTIONS_EFFECTS_ITEMS * 8, vid.conheight));
M_DrawPic(16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic("gfx/p_option.lmp");
+ p = Draw_CachePic("gfx/p_option.lmp", false);
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optcursor = options_effects_cursor;
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optcursor = options_effects_cursor;
M_Background(320, bound(200, 32 + OPTIONS_GRAPHICS_ITEMS * 8, vid.conheight));
M_DrawPic(16, 4, "gfx/qplaque.lmp");
M_Background(320, bound(200, 32 + OPTIONS_GRAPHICS_ITEMS * 8, vid.conheight));
M_DrawPic(16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic("gfx/p_option.lmp");
+ p = Draw_CachePic("gfx/p_option.lmp", false);
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optcursor = options_graphics_cursor;
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optcursor = options_graphics_cursor;
M_Background(320, 256);
M_DrawPic(16, 4, "gfx/qplaque.lmp");
M_Background(320, 256);
M_DrawPic(16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic("gfx/p_option.lmp");
+ p = Draw_CachePic("gfx/p_option.lmp", false);
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optcursor = options_colorcontrol_cursor;
M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
optcursor = options_colorcontrol_cursor;
M_Background(320, 48 + 8 * numcommands);
M_Background(320, 48 + 8 * numcommands);
- p = Draw_CachePic ("gfx/ttl_cstm.lmp");
+ p = Draw_CachePic ("gfx/ttl_cstm.lmp", false);
M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_cstm.lmp");
if (bind_grab)
M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_cstm.lmp");
if (bind_grab)
M_Background(320, 200);
M_DrawPic(16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic(16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic("gfx/vidmodes.lmp");
+ p = Draw_CachePic("gfx/vidmodes.lmp", false);
M_DrawPic((320-p->width)/2, 4, "gfx/vidmodes.lmp");
// Resolution
M_DrawPic((320-p->width)/2, 4, "gfx/vidmodes.lmp");
// Resolution
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic ("gfx/p_multi.lmp");
+ p = Draw_CachePic ("gfx/p_multi.lmp", false);
basex = (320-p->width)/2;
M_DrawPic (basex, 4, "gfx/p_multi.lmp");
basex = (320-p->width)/2;
M_DrawPic (basex, 4, "gfx/p_multi.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
M_Background(320, 200);
M_DrawPic (16, 4, "gfx/qplaque.lmp");
- p = Draw_CachePic ("gfx/p_multi.lmp");
+ p = Draw_CachePic ("gfx/p_multi.lmp", false);
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
M_DrawTextBox (152, 32, 10, 1);
M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
M_DrawTextBox (152, 32, 10, 1);
start = bound(0, slist_cursor - (visible >> 1), serverlist_viewcount - visible);
end = min(start + visible, serverlist_viewcount);
start = bound(0, slist_cursor - (visible >> 1), serverlist_viewcount - visible);
end = min(start + visible, serverlist_viewcount);
- p = Draw_CachePic("gfx/p_multi.lmp");
+ p = Draw_CachePic("gfx/p_multi.lmp", false);
M_DrawPic((640 - p->width) / 2, 4, "gfx/p_multi.lmp");
if (end > start)
{
M_DrawPic((640 - p->width) / 2, 4, "gfx/p_multi.lmp");
if (end > start)
{
g = (int)(realtime * 64)%96;
scale_y_rate = (float)(g+1) / 96;
top_offset = (g+12)/12;
g = (int)(realtime * 64)%96;
scale_y_rate = (float)(g+1) / 96;
top_offset = (g+12)/12;
- p = Draw_CachePic (va("gfx/blooddrip%i", top_offset));
+ p = Draw_CachePic (va("gfx/blooddrip%i", top_offset), false);
for (scale_x = 0; scale_x <= vid.conwidth; scale_x += p->width) {
for (scale_y = -scale_y_repeat; scale_y <= vid.conheight; scale_y += scale_y_repeat) {
DrawQ_Pic (scale_x + 21, scale_y_repeat * .5 + scale_y + scale_y_rate * scale_y_repeat, "gfx/blooddrop3", 0, 0, 1, 1, 1, 1, 0);
for (scale_x = 0; scale_x <= vid.conwidth; scale_x += p->width) {
for (scale_y = -scale_y_repeat; scale_y <= vid.conheight; scale_y += scale_y_repeat) {
DrawQ_Pic (scale_x + 21, scale_y_repeat * .5 + scale_y + scale_y_rate * scale_y_repeat, "gfx/blooddrop3", 0, 0, 1, 1, 1, 1, 0);
extern char playername[];
extern int playercolor;
extern char playername[];
extern int playercolor;
-#define SERVERLIST_TOTALSIZE 2048
+#define SERVERLIST_TOTALSIZE 2048
#define SERVERLIST_VIEWLISTSIZE 128
#define SERVERLIST_ANDMASKCOUNT 5
#define SERVERLIST_ORMASKCOUNT 5
#define SERVERLIST_VIEWLISTSIZE 128
#define SERVERLIST_ANDMASKCOUNT 5
#define SERVERLIST_ORMASKCOUNT 5
+ if(!Draw_CachePic(s, false))
PRVM_G_INT(OFS_RETURN) = PRVM_SetString("");
}
PRVM_G_INT(OFS_RETURN) = PRVM_SetString("");
}
- pic = Draw_CachePic (p);
+ pic = Draw_CachePic (p, false);
PRVM_G_VECTOR(OFS_RETURN)[0] = pic->width;
PRVM_G_VECTOR(OFS_RETURN)[1] = pic->height;
PRVM_G_VECTOR(OFS_RETURN)[0] = pic->width;
PRVM_G_VECTOR(OFS_RETURN)[1] = pic->height;
return;
if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active)
return;
return;
if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active)
return;
- pic = Draw_CachePic(va("gfx/crosshair%i.tga", num));
+ pic = Draw_CachePic(va("gfx/crosshair%i.tga", num), true);
if (!pic)
return;
R_GetCrosshairColor(color);
if (!pic)
return;
R_GetCrosshairColor(color);
return;
if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active)
return;
return;
if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active)
return;
- pic = Draw_CachePic(va("gfx/crosshair%i.tga", num));
+ pic = Draw_CachePic(va("gfx/crosshair%i.tga", num), true);
if (pic)
{
R_GetCrosshairColor(color);
if (pic)
{
R_GetCrosshairColor(color);
for (i = 0;i < 5;i++)
{
lighttextures[i] = NULL;
for (i = 0;i < 5;i++)
{
lighttextures[i] = NULL;
- if ((pic = Draw_CachePic(va("gfx/crosshair%i.tga", i + 1))))
+ if ((pic = Draw_CachePic(va("gfx/crosshair%i.tga", i + 1), true)))
lighttextures[i] = pic->tex;
}
lighttextures[i] = pic->tex;
}
strcpy(sbarpics[numsbarpics].name, name);
// precache it
// FIXME: precache on every renderer restart (or move this to client)
strcpy(sbarpics[numsbarpics].name, name);
// precache it
// FIXME: precache on every renderer restart (or move this to client)
- Draw_CachePic(sbarpics[numsbarpics].name);
+ Draw_CachePic(sbarpics[numsbarpics].name, true);
return sbarpics + (numsbarpics++);
}
return sbarpics + (numsbarpics++);
}
int i, x, y;
cachepic_t *pic;
int i, x, y;
cachepic_t *pic;
- pic = Draw_CachePic ("gfx/ranking.lmp");
+ pic = Draw_CachePic ("gfx/ranking.lmp", true);
DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
// scores
DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
// scores
- pic = Draw_CachePic ("gfx/finale.lmp");
+ pic = Draw_CachePic ("gfx/finale.lmp", true);
DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
}
DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
}