Tremendous Optimizations!!!!

February 18, 2009

Yeah, you counted right ; those are 4 exclamation marks. As it turns out, I’m an idiot.
My original object hierarchy meant that each instance of the object dealt with its own sprite pointer and texture. It wasn’t a perfect solution by any scalar multiplication (over zero, anyways.. ha!), but it worked. And now I decided to implement a hash table ADT, I am keeping all the textures in that ADT. Each object now has a pointer to a sprite and a pointer to its texture. (The obvious solution). So now, instead of each object having to free and load and take up memory on its creation, the texture needs to be loaded only once, and only freed once the program terminates. DRASTIC performance increase. Also, instead of each object’s render() method initializing its own sprite’s begin and end methods (required before and after drawing is done), the object is passed a pointer to the Object Core’s sprite pointer upon creation. The object core originally iterated through all objects and called their render(). Now, it does the exact same thing, except it calls the begin() and end() method of its own sprite only ONCE, and each object’s render() simply tells the sprite to draw in a certain way. Essentially, the sprite object inside the object core is a paintbrush. The object core says when it is OK to pick up the paintbrush and when it is not OK, and each object takes it and draws a picture with it.

STEEPED.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.