openspades/Sources/Client/AsyncRenderer.h

111 lines
3.3 KiB
C
Raw Normal View History

2013-08-29 11:45:22 +09:00
/*
Copyright (c) 2013 yvt
This file is part of OpenSpades.
OpenSpades is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenSpades is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
*/
2013-08-18 16:18:06 +09:00
#pragma once
#include "../Core/ConcurrentDispatch.h"
#include "IRenderer.h"
#include <map>
namespace spades {
namespace client {
class TemporaryAsyncImage;
class TemporaryAsyncModel;
class AsyncRenderer: public IRenderer {
class RenderDispatch;
class CmdBufferGenerator;
class CmdBufferReader;
friend class TemporaryAsyncImage;
friend class TemporaryAsyncModel;
IRenderer *base;
DispatchQueue *queue;
RenderDispatch *dispatch;
CmdBufferGenerator *generator;
std::map<std::string, IImage *> images;
std::map<std::string, IModel *> models;
void FlushCommands();
void Sync();
public:
AsyncRenderer(IRenderer *base,
DispatchQueue *renderQueue);
virtual ~AsyncRenderer();
virtual void Init();
2013-09-14 13:36:05 +09:00
virtual void Shutdown();
2013-08-18 16:18:06 +09:00
virtual IImage *RegisterImage(const char *filename);
virtual IModel *RegisterModel(const char *filename);
virtual IImage *CreateImage(Bitmap *);
virtual IModel *CreateModel(VoxelModel *);
virtual void SetGameMap(GameMap *);
virtual void SetFogDistance(float);
virtual void SetFogColor(Vector3);
/** Starts rendering a scene and waits for additional objects. */
virtual void StartScene(const SceneDefinition&);
virtual void AddLight(const client::DynamicLightParam& light);
virtual void RenderModel(IModel *, const ModelRenderParam&);
virtual void AddDebugLine(Vector3 a, Vector3 b, Vector4 color);
virtual void AddSprite(IImage *, Vector3 center, float radius, float rotation);
2013-08-30 21:05:51 +09:00
virtual void AddLongSprite(IImage *, Vector3 p1, Vector3 p2, float radius);
2013-08-18 16:18:06 +09:00
/** Finalizes a scene. 2D drawing follows. */
virtual void EndScene();
virtual void MultiplyScreenColor(Vector3);
/** Sets color for image drawing. */
virtual void SetColor(Vector4);
virtual void SetColorAlphaPremultiplied(Vector4);
2013-08-18 16:18:06 +09:00
virtual void DrawImage(IImage *, const Vector2& outTopLeft);
virtual void DrawImage(IImage *, const AABB2& outRect);
virtual void DrawImage(IImage *, const Vector2& outTopLeft, const AABB2& inRect);
virtual void DrawImage(IImage *, const AABB2& outRect, const AABB2& inRect);
virtual void DrawImage(IImage *, const Vector2& outTopLeft, const Vector2& outTopRight, const Vector2& outBottomLeft, const AABB2& inRect);
virtual void DrawFlatGameMap(const AABB2& outRect, const AABB2& inRect);
/** Finalizes a frame. */
virtual void FrameDone() ;
/** displays a rendered image to the screen. */
virtual void Flip();
/** get a rendered image. */
virtual Bitmap *ReadBitmap();
virtual float ScreenWidth();
virtual float ScreenHeight();
};
}
}