🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published July 20, 2006
Advertisement
While I'm still not happy with my sprite manager, my texture manager is now fearsome. I expanded my tilesheet manager to do any square textures < 256x256 (I.e. every texture my engine supports). It now breaks the master sheet (which is something like 2048x2048) into 256x256 blocks. Each block can be 256x256, 128x128, 64x64 or 32x32.

Sample code time:
std::vector > vSprites;for(size_t i=0; i<500; ++i){   if((rand()%2 == 0) && (vSprites.size() > 100))   {      size_t nOfs = (size_t)rand()%vSprites.size();      vSprites.erase(vSprites.begin()+nOfs);   }   else   {      std::string strRes;      switch(rand()%6)      {      case 0: case 1: case 2:         strRes = "Data/Test/32.bmp"; ++nCounts[0];         break;      case 3: case 4:         strRes = "Data/Test/64.bmp"; ++nCounts[1];         break;      case 5:         strRes = "Data/Test/128.bmp"; ++nCounts[2];         break;      }      SmartPointer p = NEW SOSprite("foo");      p->SetResource(strRes);      vSprites.push_back(p);   }}CTextureMgr::Get().Dump();

I have a debug flag to fill all unused / freed texture space with magenta, so I can catch bugs. It'll be slow as shit though, since it locks the texture for every texture deallocation. But anyway, the result of the above code after loading the background map:
Wootage
Green dots are "32", red are "64" and the blue things are "128".

Not too shabby. And it works pretty nicely.

I need to have a think about how to do sprites still, I can probably abuse the fact the maps batch sprites anyway, but it still seems pretty expensive to sort them into a multiset prior to rendering.

I'm ill. There's some bug of some sort going around our office, which I've been suffering with for 4 days, but since Beta has been due I decided against taking a day or 2 off. I was considering phoning in sick today, but then I figured I was awake anyway and it wouldn't be too hectic a day so I may as well go in. And similarly, I feel shitty just now but I might as well go in tomorrow since it's the last day of the week and I can sleep most of Saturday before going out to a par-tay at a friends house.

Oh well. Bed.
Previous Entry Untitled
Next Entry Untitled
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement