#include #include "gfx/gfx.h" #include "base/timer.h" using std::cout; //#include "main/adonthell.h" //class AdonthellApp : public adonthell::app //{ int main(int argc, char * argv[]) //int main() { gfx::init("sdl"); gfx::screen::set_video_mode(640, 480); gfx::screen::get_surface()->fillrect(0,0,100,100,0x0000ff); const gfx::surface * s = gfx::surface_cache("catseye.png"); int j; for (j = 0; j < 100; j++) s->draw(rand() % 640,rand() % 480); gfx::screen::update(); s->draw(10, 10); gfx::screen::update(); //* for (j = 0; j < 100; j++) { cout << "catseye.png has " << gfx::surfaces->countsurface("catseye.png") << " references\n"; cout << "surfaces is using " << gfx::surfaces->getusedmem() << " bytes out of " << gfx::surfaces->getmaxmem() << " bytes\n"; const gfx::surface* t = gfx::surfaces->getsurfaceonly("catseye.png"); } for (j = 0; j < 101; j++) { cout << "catseye.png has " << gfx::surfaces->countsurface("catseye.png") << " references\n"; cout << "surfaces is using " << gfx::surfaces->getusedmem() << " bytes out of " << gfx::surfaces->getmaxmem() << " bytes\n"; gfx::surfaces->freesurface("catseye.png"); } gfx::surfaces->purge(); cout << "catseye.png has " << gfx::surfaces->countsurface("catseye.png") << " references\n"; cout << "surfaces is using " << gfx::surfaces->getusedmem() << " bytes out of " << gfx::surfaces->getmaxmem() << " bytes\n"; gfx::surfaces->freesurface("catseye.png"); gfx::surfaces->setmaxmem(1000); const gfx::surfaceref* test = gfx::surfaces->getsurface("catseye.png"); cout << "catseye.png has " << gfx::surfaces->countsurface("catseye.png") << " references when created as a reference\n"; cout << "surfaces is using " << gfx::surfaces->getusedmem() << " bytes out of " << gfx::surfaces->getmaxmem() << " bytes\n"; delete test; gfx::surfaces->conditionalpurge(); cout << "catseye.png has " << gfx::surfaces->countsurface("catseye.png") << " references\n"; cout << "surfaces is using " << gfx::surfaces->getusedmem() << " bytes out of " << gfx::surfaces->getmaxmem() << " bytes\n"; // */ base::timer::sleep(2000); return 0; } //} theApp;