Resource Handle

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Resource Handle


      After some frustration with my last problem (posting) I decided that I need a ResourceMgr. One problem that I am seeing is how to implement a "Handle" that uniquely identifies a resource (be it a texture or sound). One suggestion was using a "Hash value" however, creating a hash might take some CPU time (slow). Magic Number's might be the way to go, but I think I would be limiting myslef to a limited set of numbers. ("MAX_MAGIC = 32; MAIC_NUMBER = 1 << MAX_MAGIC;"), GID well...

      What do you guys do to generate a HANDLE that is unigue? "Hashing a filename", "Magic Number", GUID. Anything else to concider using for a handle?

      "Creative minds what to know".
    • First thing I can think off, that's not bound to hashing (I would personally extend the EventType class that Mike has in GCC) is just have a static counter for your ResourceMgr class. Just increment it every time that you add a new resource. It garuntees no overlaps and it's about as simple as you can get for implementation.


      Like I said, though, I'd normally use my GenericType class and associate a type with a resource and a name. That way, you can classify the resource under a "family" of resource types and a specific name hash.
      Feel you safe and secure in the protection of your pants . . . but one day, one day there shall be a No Pants Day and that shall be the harbinger of your undoing . . .