Re: [GD-General] Compile times
Brought to you by:
vexxed72
From: <cas...@ya...> - 2002-12-16 17:24:56
|
Jesse Jones wrote: > I have some thoughts on how this can be done, but I'd like to hear > some more details on how you've implemented this. :-) Well, that was mentioned some time ago in the Algorithm mailing list by Tom Forsyth, I think... However, I saw that for the first time in the fmod sound library to handle channel references. Here is a snip from his mail: "Personally I prefer unique IDs. The bottom n bits are an index into an array (either of pointers to the object, or if the object is small enough, just an array of actual objects). The top 32-n bits are the "unique" part. Every time you allocate an item in the array, the top bits are incremented. Unless you really do get through a huge number of objects during your game, 32 bits for IDs is more thna enough. It means you can easily kill objects any time you like, and then when they are requested, you can return either NULL, or a placeholder, or whatever (as appropriate, e.g. if a texture is requested that isn't loaded any more, we return a 16x16 copy, which we always keep resident for all textures)." And this is from the FMOD documentation: "The channel handle : The return value is reference counted. This stops the user from updating a stolen channel. Basically it means the only sound you can change the attributes (ie volume/pan/frequency/3d position) for are the one you specifically called playsound for. If another sound steals that channel, and you keep trying to change its attributes (ie volume/pan/frequency/3d position), it will do nothing. This is great if you have sounds being updated from tasks and you just forget about it. You can keep updating the sound attributes and if another task steals that channel, your original task wont change the attributes of the new sound!!! The lower 12 bits contain the channel number. (yes this means a 4096 channel limit for FMOD :) The upper 19 bits contain the reference count. The top 1 bit is the sign bit. ie. S RRRRRRRRRRRRRRRRRRR CCCCCCCCCCCC" Sorry the copy&past thing, but English is not my mother language and I think this way is clearer and faster. :-) I don't think that handles are the solution to all the problems and that smart pointers are bad. However, I think that there are many ways of using smart pointers wrong, while the handle method is simple and errors are easy to catch. Ignacio Castaño cas...@ya... _______________________________________________________________ Copa del Mundo de la FIFA 2002 El único lugar de Internet con vídeos de los 64 partidos. ¡Apúntante ya! en http://fifaworldcup.yahoo.com/fc/es/ |