Jump to content
  • Advertisement
Sign in to follow this  
Tjaalie

2D Engine design help!

This topic is 4152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Dear thread reader, After setting up some simple design stuff I came to the conclusion that Texture 'Sprite' loading isn't as easy as I tough. I know how to load a texture so I tough of making the following texture create functions: -Load from file -Create from color (need width, height) This seems easy just check if the file (or color) is already loaded and then pass the right pointer. It gets harder when you make the option to use alpha (aka load "Man.bmp" with our without alpha (2 different textures loaded for one file). I came around this with disabling or enabling alpha before rendering a sprite (so all textures have a alpha channel (D3DFMT_A8R8G8B8). But now I want to be able to acces the data of a texture and manipulate it (for on the fly terrain generation or to change the unit color). But the main problem is when I change one texture all the other objects using the same texture will also get changed. Say when I load "Unit.bmp", the image got black parts wich needs to be changed to the unit color. So the blue team gets his blue units but when the red theam wants to change their units to red the blue units change and become red. What is the best way around this problem and still allowing texture manipulation. Thanks in advance. Tjaalie, [Edited by - Tjaalie on May 13, 2007 11:49:48 AM]

Share this post


Link to post
Share on other sites
Advertisement
So I'd add a function to that. Something like GetInstanceOf(texture).

Essentially, it'll make a copy of that texture.

So if you need to modify a texture, you'd call GetInstanceOf first, THEN lock and modify it.

If you ever revert back to the unmodified texture , though, you may want to destroy your instance and go back to the original.

Just a quick idea, hope it helps!

Share this post


Link to post
Share on other sites
That sounds as a fine idea, I came up with an extra argument 'bool shared' if its true then you actualy say that it will never be modified or at least that it isn't a problem when they are. Any more idea's? I mean I can't be the first to stumble upon this problem?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!