Renderer refactor
This commit is contained in:
parent
13692657e1
commit
e7d5b210c3
@ -49,6 +49,12 @@ namespace spades {
|
||||
r->Init();
|
||||
}
|
||||
};
|
||||
class Shutdown: public Command {
|
||||
public:
|
||||
virtual void Execute(IRenderer *r) {
|
||||
r->Shutdown();
|
||||
}
|
||||
};
|
||||
class SetGameMap: public Command {
|
||||
public:
|
||||
GameMap *map;
|
||||
@ -324,6 +330,11 @@ namespace spades {
|
||||
generator->AllocCommand<rcmds::Init>();
|
||||
}
|
||||
|
||||
void AsyncRenderer::Shutdown() {
|
||||
SPADES_MARK_FUNCTION();
|
||||
generator->AllocCommand<rcmds::Shutdown>();
|
||||
}
|
||||
|
||||
IImage *AsyncRenderer::CreateImage(spades::Bitmap *bmp) {
|
||||
SPADES_MARK_FUNCTION();
|
||||
|
||||
|
@ -52,6 +52,7 @@ namespace spades {
|
||||
virtual ~AsyncRenderer();
|
||||
|
||||
virtual void Init();
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual IImage *RegisterImage(const char *filename);
|
||||
virtual IModel *RegisterModel(const char *filename);
|
||||
|
@ -76,6 +76,7 @@ namespace spades {
|
||||
IRenderer(){}
|
||||
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual IImage *RegisterImage(const char *filename) = 0;
|
||||
virtual IModel *RegisterModel(const char *filename) = 0;
|
||||
|
@ -80,7 +80,7 @@ SPADES_SETTING(r_debugTiming, "0");
|
||||
|
||||
namespace spades {
|
||||
namespace draw {
|
||||
|
||||
// TODO: raise error for any calls after Shutdown().
|
||||
|
||||
GLRenderer::GLRenderer(IGLDevice *_device):
|
||||
device(_device){
|
||||
@ -125,46 +125,8 @@ namespace spades {
|
||||
GLRenderer::~GLRenderer() {
|
||||
SPADES_MARK_FUNCTION();
|
||||
|
||||
// FIXME: remove itself from map's listener
|
||||
Shutdown();
|
||||
|
||||
SPLog("GLRender finalizing");
|
||||
if(radiosityRenderer)
|
||||
delete radiosityRenderer;
|
||||
if(ambientShadowRenderer)
|
||||
delete ambientShadowRenderer;
|
||||
if(flatMapRenderer)
|
||||
delete flatMapRenderer;
|
||||
if(mapShadowRenderer)
|
||||
delete mapShadowRenderer;
|
||||
if(mapRenderer)
|
||||
delete mapRenderer;
|
||||
if(waterRenderer)
|
||||
delete waterRenderer;
|
||||
if(ambientShadowRenderer)
|
||||
delete ambientShadowRenderer;
|
||||
if(shadowMapRenderer)
|
||||
delete shadowMapRenderer;
|
||||
if(cameraBlur)
|
||||
delete cameraBlur;
|
||||
if(longSpriteRenderer)
|
||||
delete longSpriteRenderer;
|
||||
if(waterRenderer)
|
||||
delete waterRenderer;
|
||||
if(modelRenderer)
|
||||
delete modelRenderer;
|
||||
if(spriteRenderer)
|
||||
delete spriteRenderer;
|
||||
if(imageRenderer)
|
||||
delete imageRenderer;
|
||||
if(modelRenderer)
|
||||
delete modelManager;
|
||||
if(programManager)
|
||||
delete programManager;
|
||||
if(imageManager)
|
||||
delete imageManager;
|
||||
if(fbManager)
|
||||
delete fbManager;
|
||||
SPLog("GLRenderer finalized");
|
||||
}
|
||||
|
||||
void GLRenderer::Init() {
|
||||
@ -216,6 +178,49 @@ namespace spades {
|
||||
SPLog("GLRenderer initialized");
|
||||
}
|
||||
|
||||
void GLRenderer::Shutdown() {
|
||||
// FIXME: remove itself from map's listener
|
||||
|
||||
SPLog("GLRender finalizing");
|
||||
if(radiosityRenderer)
|
||||
delete radiosityRenderer;
|
||||
if(ambientShadowRenderer)
|
||||
delete ambientShadowRenderer;
|
||||
if(flatMapRenderer)
|
||||
delete flatMapRenderer;
|
||||
if(mapShadowRenderer)
|
||||
delete mapShadowRenderer;
|
||||
if(mapRenderer)
|
||||
delete mapRenderer;
|
||||
if(waterRenderer)
|
||||
delete waterRenderer;
|
||||
if(ambientShadowRenderer)
|
||||
delete ambientShadowRenderer;
|
||||
if(shadowMapRenderer)
|
||||
delete shadowMapRenderer;
|
||||
if(cameraBlur)
|
||||
delete cameraBlur;
|
||||
if(longSpriteRenderer)
|
||||
delete longSpriteRenderer;
|
||||
if(waterRenderer)
|
||||
delete waterRenderer;
|
||||
if(modelRenderer)
|
||||
delete modelRenderer;
|
||||
if(spriteRenderer)
|
||||
delete spriteRenderer;
|
||||
if(imageRenderer)
|
||||
delete imageRenderer;
|
||||
if(modelRenderer)
|
||||
delete modelManager;
|
||||
if(programManager)
|
||||
delete programManager;
|
||||
if(imageManager)
|
||||
delete imageManager;
|
||||
if(fbManager)
|
||||
delete fbManager;
|
||||
SPLog("GLRenderer finalized");
|
||||
}
|
||||
|
||||
client::IImage *GLRenderer::RegisterImage(const char *filename) {
|
||||
SPADES_MARK_FUNCTION();
|
||||
return imageManager->RegisterImage(filename);
|
||||
|
@ -114,11 +114,14 @@ namespace spades {
|
||||
|
||||
void RenderObjects();
|
||||
|
||||
public:
|
||||
GLRenderer(IGLDevice *glDevice);
|
||||
protected:
|
||||
virtual ~GLRenderer();
|
||||
|
||||
public:
|
||||
GLRenderer(IGLDevice *glDevice);
|
||||
|
||||
virtual void Init();
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual client::IImage *RegisterImage(const char *filename);
|
||||
virtual client::IModel *RegisterModel(const char *filename);
|
||||
|
@ -255,10 +255,12 @@ namespace spades {
|
||||
|
||||
{
|
||||
SDLGLDevice glDevice(surface);
|
||||
draw::GLRenderer renderer(&glDevice);
|
||||
Handle<draw::GLRenderer> renderer = new draw::GLRenderer(&glDevice);
|
||||
audio::ALDevice audio;
|
||||
|
||||
RunClientLoop(&renderer, &audio);
|
||||
RunClientLoop(renderer, &audio);
|
||||
|
||||
renderer->Shutdown();
|
||||
}
|
||||
}catch(...){
|
||||
SDL_Quit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user