Clearing everything on a new map?
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
Clearing everything on a new map?
I want to clear all models/textures/sprites/gfx on Start of a new map. How and where would I go about doing this?
I am up against a wall here. I just added in tga texture support into my engine, but when I goto reload a map, and there is an external texture, the game locks up.
I refuse to believe that this is an out-of-ram problem, because I can access other parts of the menu that seemed to crash when i was low on ram. Not only that, but the tga textures have Swizzle and DXT compression, so there isn't any reason for lockups.
I think I spent a bit too much time trying to get this all fixed and working. I didn't want to resort to asking for help, but heck, I'm drained of solutions here.
So all in all, How would I flush out external textures on the start of a new map. I did see Bakers tutorial on it, but It doesn't suffice for my case, and I fail to find where I would put that function.
Help would be greatly appreciated
I am up against a wall here. I just added in tga texture support into my engine, but when I goto reload a map, and there is an external texture, the game locks up.
I refuse to believe that this is an out-of-ram problem, because I can access other parts of the menu that seemed to crash when i was low on ram. Not only that, but the tga textures have Swizzle and DXT compression, so there isn't any reason for lockups.
I think I spent a bit too much time trying to get this all fixed and working. I didn't want to resort to asking for help, but heck, I'm drained of solutions here.
So all in all, How would I flush out external textures on the start of a new map. I did see Bakers tutorial on it, but It doesn't suffice for my case, and I fail to find where I would put that function.
Help would be greatly appreciated
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
There "where" goes like this ...
cl_main.c
Kurok unloads textures in ...
Which if you look at Host_ClearMemory, calls Mod_ClearAll.
Mod_ClearAll occurs at the start of any map. But if look through CL_ParseServerInfo in cl_parse.c ... it keeps models cached.
Enhanced GLQuake modified Mod_ClearAll to accept a -freemdl command line parameter which would also clear the models out ...
FitzQuake has a modification that deletes the textures when the model is freed ...
cl_main.c
- Code: Select all
/*
================
Host_ClearMemory
This clears all the memory used by both the client and server, but does
not reinitialize anything.
================
*/
void Host_ClearMemory (void)
{
Con_DPrintf ("Clearing memory\n");
D_FlushCaches ();
Mod_ClearAll ();
if (host_hunklevel)
Hunk_FreeToLowMark (host_hunklevel);
cls.signon = 0;
memset (&sv, 0, sizeof(sv));
memset (&cl, 0, sizeof(cl));
}
Kurok unloads textures in ...
- Code: Select all
/*
===================
Mod_ClearAll
===================
*/
void Mod_ClearAll (void)
{
int i;
int texture_index;
model_t *mod;
for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
{
if (mod->type != mod_alias)
mod->needload = qtrue;
}
// maybe we should check if it is new map or not
// (so we dont unload textures unnecessary)
while (mapTextureNameList.size() > 0) {
texture_index = mapTextureNameList.front();
mapTextureNameList.pop_front();
GL_UnloadTexture(texture_index);
}
solidskytexture = -1;
alphaskytexture = -1;
//purge old sky textures
for (i=0; i<6; i++)
{
if (skyimage[i] && skyimage[i] != solidskytexture)
GL_UnloadTexture(skyimage[i]);
skyimage[i] = NULL;
}
//purge old lightmaps
for (i=0; i<MAX_LIGHTMAPS; i++)
{
if (lightmap_index[i] && lightmap_index[i] != 0)
GL_UnloadTexture(lightmap_index[i]);
lightmap_index[i] = NULL;
}
}
Which if you look at Host_ClearMemory, calls Mod_ClearAll.
Mod_ClearAll occurs at the start of any map. But if look through CL_ParseServerInfo in cl_parse.c ... it keeps models cached.
Enhanced GLQuake modified Mod_ClearAll to accept a -freemdl command line parameter which would also clear the models out ...
- Code: Select all
/*
===================
Mod_ClearAll
===================
*/
void Mod_ClearAll (void)
{
int i;
model_t *mod;
static qboolean NoFree, Done;
if (!Done)
{
// Some 3dfx miniGLs don't support glDeleteTextures (i.e. do nothing)
NoFree = COM_CheckParm ("-nofreetex");
FreeMdl = COM_CheckParm ("-freemdl"); // Free also mdls
Done = true;
}
for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
{
if (mod->type != mod_alias || FreeMdl)
mod->needload = true;
if (mod->type == mod_alias)
{
if (FreeMdl && mod->cache.data)
Cache_Free(&mod->cache); // Release memory buffer
mod->loadtimes = 0; // Clear inbetween maps
}
Mod_Free (mod);
}
if (!NoFree)
GL_FreeTextures ();
}
FitzQuake has a modification that deletes the textures when the model is freed ...
- Code: Select all
/*
==============
Cache_Free
Frees the memory and removes it from the LRU list
==============
*/
void Cache_Free (cache_user_t *c, qboolean freetextures) //johnfitz -- added second argument
{
cache_system_t *cs;
if (!c->data)
Sys_Error ("Cache_Free: not allocated");
cs = ((cache_system_t *)c->data) - 1;
cs->prev->next = cs->next;
cs->next->prev = cs->prev;
cs->next = cs->prev = NULL;
c->data = NULL;
Cache_UnlinkLRU (cs);
//johnfitz -- if a model becomes uncached, free the gltextures. This only works
//becuase the cache_user_t is the last component of the model_t struct. Should
//fail harmlessly if *c is actually part of an sfx_t struct. I FEEL DIRTY
if (freetextures)
TexMgr_FreeTexturesForOwner ((model_t *)(c + 1) - 1);
}
Last edited by Baker on Sun Mar 27, 2011 8:49 pm, edited 1 time in total.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Thanks Baker. I have browsed through Mod_ClearAll and modified it a bit, but I didn't have that much of luck. I'll see what I can do with this new info.
Thanks
Thanks
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
Mexicouger wrote:Thanks Baker. I have browsed through Mod_ClearAll and modified it a bit, but I didn't have that much of luck. I'll see what I can do with this new info.
Thanks
It isn't going to be an easy task, I hate to say. None of the PSP engines have a texture manager. You will have to invest probably too much time to mark the textures and figure out how to only unload model textures.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Well the only Reason I am bound and determined, is because DQuake managed to do it, so I know it is possible.
Thats my only Push right now, and well, the fact that the game will look better in the end.
Thats my only Push right now, and well, the fact that the game will look better in the end.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
On the DQuake Thread, I noticed that Downsider mentioned that Some libraries were needed to Compile DQuake. Do you think these libraries could be affecting the texture loading?
I don't get any linker errors without them, but I am thinking that maybe they are affecting the game.
Just some thoughts, because I can't think/find any other problems with the code
Edit: I am trying out different vram and valloc libraries, and I am definitely getting different results. With one of them, I am getting a constant screen flashing, and my tga textures are masked with purple
EDIT AGAIN: I finally got my Tgas working! I been working on them for a constant 4 days now, and I gotta say that Breadsticks post about DQuake Helped me more than anything. He listed the libraries that were required, and he mentioned a vram library. I did a search, found it, and applied it. First time I converted the functions and all, and I got some horrendous effects. I restarted(For the 7th time) and went through the code with a fine comb. To my success, I got tgas working 100%!
I think this will be one of my biggest accomplishments for a while. Oh how much I learned from doing this. I am now aware of where things are, and what alot more does.
Knowledge is great, just can't get enough of it!
I don't get any linker errors without them, but I am thinking that maybe they are affecting the game.
Just some thoughts, because I can't think/find any other problems with the code
Edit: I am trying out different vram and valloc libraries, and I am definitely getting different results. With one of them, I am getting a constant screen flashing, and my tga textures are masked with purple
EDIT AGAIN: I finally got my Tgas working! I been working on them for a constant 4 days now, and I gotta say that Breadsticks post about DQuake Helped me more than anything. He listed the libraries that were required, and he mentioned a vram library. I did a search, found it, and applied it. First time I converted the functions and all, and I got some horrendous effects. I restarted(For the 7th time) and went through the code with a fine comb. To my success, I got tgas working 100%!
I think this will be one of my biggest accomplishments for a while. Oh how much I learned from doing this. I am now aware of where things are, and what alot more does.
Knowledge is great, just can't get enough of it!
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest

