About Store Forum Documentation Contact
Donations:
225$/mo



Post Reply 
Question regarding Files and Caching
Author Message
Impz0r Offline
Member

Post: #1
Question regarding Files and Caching
Hey there,

I just stumbled over the Pak Tutorial source and found something like:

Code:
{
      // you can open files stored in that Pak:
      {
         File f;
         f.read   ("folder/image.gfx"); // start reading file
         f.getByte(                  ); // get Byte from that file
      }
      // you can access resources through cache
      {
         image=Images("folder/image.gfx");
      }
   }

So as i read it right, you open a file, read its content and just close the file, and later you use the "precached" data while accessing it once again?

Is this common behavior of the engine? Meaning, if i want to precache some data i open the file, read its content, close it and later if i neet the actual data, image, mesh, whatever, i just open it with the specific type and the engine "knows" this file has been preached and read its data from memory?

If so, how do i release this precached data for good?

Thanks in advance!


Mfg Imp
05-31-2010 04:22 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Question regarding Files and Caching
to precache you don't need to use File, you can just call Images(..)
you can't release precached objects, to release you must create manual object and delete it
Image image;
image.load();
image.del();
06-01-2010 07:20 PM
Find all posts by this user Quote this message in a reply
Impz0r Offline
Member

Post: #3
RE: Question regarding Files and Caching
Thanks Esenthel!

So as far as I understand you right, if I want to precache things I have to use the appropriate Cache<Type> to load the actual objects and later if I need them I have to access the Cache by get("file", NULL); ?

Does that mean that if I have loaded an Image into the Cache<Image> the method call Image.load("name"); looks up first the Cache and if the Image is not there it tries to load it from disk?

And is this common behavior over the entire API ?

Thanks in advance!


Mfg Imp
06-02-2010 12:14 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Question regarding Files and Caching
Image::load doesn't use Images Cache, it always loads from disk
cache is used only when using Images("..")
06-02-2010 10:41 PM
Find all posts by this user Quote this message in a reply
Impz0r Offline
Member

Post: #5
RE: Question regarding Files and Caching
Ok, thanks Esenthel!
06-02-2010 11:46 PM
Find all posts by this user Quote this message in a reply
Post Reply