Game Development Community

Flushing terrain cache?

by James Holmes · in Torque Game Engine · 10/25/2002 (10:43 am) · 3 replies

I'm working on a day/night cycler which blends a series of light maps. Everything works pretty OK, (or rather as well as it can with this technique)

Once I've prepared a new lightmap I flush the cached terrain texture maps with:-
for (int i=0; i < AllocatedTextureCount; i++) {
   if (TerrainRender::mTextureGrid[i]) {
      TerrainRender::mTextureGrid[i]->handle = NULL;
   }
}

a) Is that the correct way to flush the cache?
b) Are there some implications that I should be aware of? memory leaks etc. (I know about the one time cpu hit and I'm trying to manage that to the extent where it will be unnoticible.)

James

#1
10/25/2002 (10:58 am)
try :

flushtexturecache();

(That flushes the whole texture cache in script)
#2
10/25/2002 (11:50 am)
James, I'm sure there are many people who would be interested in how you achieve your day/night cycles. Is there any chance you could post a description as a resource? I'm sure many people (myself included) would be most grateful for this!

Thanks
#3
10/25/2002 (12:54 pm)
Stuart
Thanks for the lead, I was not aware of that call. I just want to check if it does not chuck out all textures, including those on models and interiors. I had forgotten about textures in the video card, which flushtexturecache() deals with, time to learn some OpenGL I guess.

BTW I saw this interesting statement in that code
postTextureEvent(BeginZombification);

Mike
Sure I'll post a resource. I still need to add a changing skybox and try to optimize a little. I've no need for interior lighting yet so thats for a later time but my guess is that the techniques are just about the same as for the terrain.

James