SleepySamurai

Members
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

125 Neutral

About SleepySamurai

  • Rank
    Newbie
  1. Preferred Mapping Mode

    Thanks for the replies everyone. I think I'll put the time into learning how to use origins if so many people find it convenient.
  2. I'm wondering if anyone can comment on what I should set my Mapping Mode to in regards to game programming. Is it better to have the origin on the top left, or bottom left? While the mathematics seem to be more intuitive from the bottom left, I imagine there's a reason the default is top left.   Can anyone tell me if there's an (unofficial) standard for Mapping Modes when it comes to game programming?
  3. Remember how you would move in the first GTA? Press up to move forward from the characters perspective, and left/right to turn. Anybody know if there's a technical name for that? Thanks!.
  4. Do I need to release() these textures?

    Ah yes! And the reason nothing is copied is because LPDIRECT3DTEXTURE9 is a pointer! I forgot about that. Okay, thanks for taking the time not just to answer, but to help me understand as well.
  5. Do I need to release() these textures?

      COM objects don't really work that way.  Because they're internally reference counted, if anything needs to hold on to the object for any reason, that assignment should be accompanied by an AddRef.  Then it can be safely Released later on, which will just decrement the reference count rather than destroying the object.  When the final Release happens, the object is destroyed.   The reason for this is that if something else Releases the texture while your myArray (to use the example here) is still using it, the texture won't be destroyed and myArray can continue to safely use it.   So in other words, yes, Release the defaultTexture 1000 times as you currently are, but also add an AddRef when you set them to your myArray, and the Release won't crash, giving you proper COM object lifetimes.   You see this kind of pattern all over the design of D3D; e.g. GetSurfaceLevel will require a Release otherwise the surface leaks, and - more relevant here - ID3DXEffect will AddRef on a SetTexture call.   Thanks for the help! Very informative. I'm new to development so I'll put some time into studying AddRef, as it sounds pretty vital. But just for the sake of understanding, if I only release defaultImage like in the second example, is that causing a memory leak in myArray? Is it bad/dangerous coding or just improvable coding? (for the record I don't intend on settling for poor coding).
  6. 2D Top-Down Map

    If the character is surrounded by tall buildings, he'd also be coved in shadow right? Perhaps you could portray the height of buildings by the level of darkness the character is standing in?
  7. So lets say I have a struct called 'Sprite.' Inside that struct is the member LPDIRECT3DTEXTURE9 texture. Let's say I make an array of Sprite's that looks like: Sprite myArray[1000].   I want the same image to be loaded to all 1000 of myArray texture members.   I could make a for loop that uses 'LoadTexture' (My texture loading function) to load an image to each texture member. But this is a very taxing process and takes a noticable amount of time to complete. At the end of my program I would then release() each texture via for loop.   So the other option is to create a LPDIRECT3DTEXTURE9 defaultImage. Load an image to defaultImage, then run a loop that: myArray[i].texture = defaultImage;   The load time is unnoticible using this method.   So here's my question:   Do I have to release() all 1000 textures in myArray or do I only have to release() defaultImage? For the record, I've tried realease()ing all 1000. Get the Unhandled exception at 0x00430906 error and have to break. Does that mean I'm doing something wrong, or that I only have to release the one? An explination as to why would be nice as well.   Thanks for the help!