Engine::~Engine() { for( size_t i = 0; i < subsystems.size(); i++ ) { Subsystem* system = subsystems[i]; Deallocate(system); } Deallocate(physicsManager); Deallocate(scriptManager); Deallocate(renderDevice); #ifdef ENABLE_AUDIO_OPENAL Deallocate(audioDevice); #endif Deallocate(resourceManager); InputDeinitialize(); GraphicsDeinitialize(); ResourcesDeinitialize(); NetworkDeinitialize(); TaskPoolDestroy(taskPool); StreamDestroy(stream); LogDestroy(log); }
Object* SerializerLoadObjectFromFile(Serializer* serializer, const Path& file) { Stream* stream = StreamCreateFromFile(serializer->alloc, file.c_str(), StreamOpenMode::Read); serializer->stream = stream; Object* object = SerializerLoad(serializer); StreamDestroy(stream); return object; }
bool SerializerSaveObjectToFile(Serializer* serializer, const Path& file, Object* object) { Stream* stream = StreamCreateFromFile(serializer->alloc, file.c_str(), StreamOpenMode::Write); if( !stream ) return false; serializer->stream = stream; serializer->object = object; if( !SerializerSave(serializer, object) ) return false; StreamDestroy(stream); return true; }
wxBitmap* ConvertImageToBitmap( Image* image, const Path& fullPath ) { if( !image || !image->isLoaded() ) return nullptr; PixelFormat pf = image->getPixelFormat(); if( pf != PixelFormat::R8G8B8A8 ) { LogDebug("Invalid image format: %s", EnumGetValueName(ReflectionGetType(PixelFormat), (int32)pf)); return nullptr; } //wxBitmap* bmp = new wxBitmap; //bmp->Create(&image->getBuffer(), wxBITMAP_TYPE_ANY, image->getWidth(), image->getHeight(), 4); Stream* stream = StreamCreateFromFile(AllocatorGetHeap(), fullPath, StreamOpenMode::Read); if( !stream ) return nullptr; std::vector<byte> data; StreamRead(stream, data); wxMemoryInputStream mem(&data[0], data.size()); wxImage img(mem); img.Rescale(32, 32); StreamDestroy(stream); #if 0 const wxSize& size = GetSize(); if( img.GetWidth() > size.GetWidth() || img.GetHeight() > size.GetHeight() ) { img.Rescale( size.GetWidth(), size.GetHeight() ); } #endif wxBitmap* bmp = new wxBitmap(img); return bmp; }