openspades/Sources/Client/IRenderer.h

144 lines
3.9 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 "IImage.h"
#include "../Core/Math.h"
#include "SceneDefinition.h"
#include "IModel.h"
#include <Core/RefCountedObject.h>
2013-08-18 16:18:06 +09:00
namespace spades {
class Bitmap;
class VoxelModel;
namespace client {
class GameMap;
struct ModelRenderParam {
Matrix4 matrix;
Vector3 customColor;
bool depthHack;
ModelRenderParam() {
matrix = Matrix4::Identity();
customColor = MakeVector3(0, 0, 0);
depthHack = false;
}
};
enum DynamicLightType {
DynamicLightTypePoint,
DynamicLightTypeSpotlight
};
struct DynamicLightParam {
DynamicLightType type;
Vector3 origin;
float radius;
Vector3 color;
Vector3 spotAxis[3];
IImage *image;
float spotAngle;
2013-11-16 23:30:54 +09:00
bool useLensFlare;
2013-08-18 16:18:06 +09:00
DynamicLightParam() {
image = NULL;
type = DynamicLightTypePoint;
spotAngle = 0.f;
2013-11-16 23:30:54 +09:00
useLensFlare = false;
2013-08-18 16:18:06 +09:00
}
};
class IRenderer: public RefCountedObject {
protected:
virtual ~IRenderer(){}
2013-08-18 16:18:06 +09:00
public:
IRenderer(){}
2013-08-18 16:18:06 +09:00
virtual void Init() = 0;
2013-09-14 13:36:05 +09:00
virtual void Shutdown() = 0;
2013-08-18 16:18:06 +09:00
virtual IImage *RegisterImage(const char *filename) = 0;
virtual IModel *RegisterModel(const char *filename) = 0;
virtual IImage *CreateImage(Bitmap *) = 0;
virtual IModel *CreateModel(VoxelModel *) = 0;
virtual void SetGameMap(GameMap *) = 0;
virtual void SetFogDistance(float) = 0;
virtual void SetFogColor(Vector3) = 0;
/** Starts rendering a scene and waits for additional objects. */
virtual void StartScene(const SceneDefinition&) = 0;
virtual void AddLight(const client::DynamicLightParam& light) = 0;
virtual void RenderModel(IModel *, const ModelRenderParam&) = 0;
virtual void AddDebugLine(Vector3 a, Vector3 b, Vector4 color) = 0;
virtual void AddSprite(IImage *, Vector3 center, float radius, float rotation) = 0;
2013-08-30 21:05:51 +09:00
virtual void AddLongSprite(IImage *, Vector3 p1, Vector3 p2, float radius) = 0;
2013-08-18 16:18:06 +09:00
/** Finalizes a scene. 2D drawing follows. */
virtual void EndScene() = 0;
virtual void MultiplyScreenColor(Vector3) = 0;
/** Sets color for image drawing. Deprecated because
* some methods treats this as an alpha premultiplied, while
* others treats this as an alpha non-premultiplied.
* @deprecated */
2013-08-18 16:18:06 +09:00
virtual void SetColor(Vector4) = 0;
/** Sets color for image drawing. Always alpha premultiplied. */
virtual void SetColorAlphaPremultiplied(Vector4) = 0;
2013-08-18 16:18:06 +09:00
virtual void DrawImage(IImage *, const Vector2& outTopLeft) = 0;
virtual void DrawImage(IImage *, const AABB2& outRect) = 0;
virtual void DrawImage(IImage *, const Vector2& outTopLeft, const AABB2& inRect) = 0;
virtual void DrawImage(IImage *, const AABB2& outRect, const AABB2& inRect) = 0;
virtual void DrawImage(IImage *, const Vector2& outTopLeft, const Vector2& outTopRight, const Vector2& outBottomLeft, const AABB2& inRect) = 0;
virtual void DrawFlatGameMap(const AABB2& outRect, const AABB2& inRect) = 0;
/** Finalizes a frame. */
virtual void FrameDone() = 0;
/** displays a rendered image to the screen. */
virtual void Flip() = 0;
/** get a rendered image. */
virtual Bitmap *ReadBitmap() = 0;
virtual float ScreenWidth() = 0;
virtual float ScreenHeight() = 0;
};
}
}