2013-08-29 11:45:22 +09:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 yvt
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-29 11:45:22 +09:00
|
|
|
This file is part of OpenSpades.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-29 11:45:22 +09:00
|
|
|
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.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-29 11:45:22 +09:00
|
|
|
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.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-29 11:45:22 +09:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-29 11:45:22 +09:00
|
|
|
*/
|
2013-08-18 16:18:06 +09:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-03 18:49:07 +09:00
|
|
|
#include <Core/Math.h>
|
2016-12-03 18:23:47 +09:00
|
|
|
#include "IImage.h"
|
2013-08-18 16:18:06 +09:00
|
|
|
#include "IModel.h"
|
2016-12-03 18:23:47 +09:00
|
|
|
#include "SceneDefinition.h"
|
2013-09-14 13:28:19 +09:00
|
|
|
#include <Core/RefCountedObject.h>
|
2013-08-18 16:18:06 +09:00
|
|
|
|
|
|
|
namespace spades {
|
|
|
|
class Bitmap;
|
|
|
|
class VoxelModel;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
namespace client {
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
class GameMap;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
struct ModelRenderParam {
|
|
|
|
Matrix4 matrix;
|
|
|
|
Vector3 customColor;
|
|
|
|
bool depthHack;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
ModelRenderParam() {
|
|
|
|
matrix = Matrix4::Identity();
|
|
|
|
customColor = MakeVector3(0, 0, 0);
|
|
|
|
depthHack = false;
|
|
|
|
}
|
|
|
|
};
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
enum DynamicLightType { DynamicLightTypePoint, DynamicLightTypeSpotlight };
|
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
struct DynamicLightParam {
|
|
|
|
DynamicLightType type;
|
|
|
|
Vector3 origin;
|
|
|
|
float radius;
|
|
|
|
Vector3 color;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
Vector3 spotAxis[3];
|
|
|
|
IImage *image;
|
|
|
|
float spotAngle;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-16 23:30:54 +09:00
|
|
|
bool useLensFlare;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
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
|
|
|
}
|
|
|
|
};
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
class IRenderer : public RefCountedObject {
|
2013-09-14 13:28:19 +09:00
|
|
|
protected:
|
2016-12-03 18:23:47 +09:00
|
|
|
virtual ~IRenderer() {}
|
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
public:
|
2016-12-03 18:23:47 +09:00
|
|
|
IRenderer() {}
|
|
|
|
|
2013-09-02 23:09:13 +09:00
|
|
|
virtual void Init() = 0;
|
2013-09-14 13:36:05 +09:00
|
|
|
virtual void Shutdown() = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual IImage *RegisterImage(const char *filename) = 0;
|
|
|
|
virtual IModel *RegisterModel(const char *filename) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual IImage *CreateImage(Bitmap *) = 0;
|
|
|
|
virtual IModel *CreateModel(VoxelModel *) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual void SetGameMap(GameMap *) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual void SetFogDistance(float) = 0;
|
|
|
|
virtual void SetFogColor(Vector3) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
/** Starts rendering a scene and waits for additional objects. */
|
2016-12-03 18:23:47 +09:00
|
|
|
virtual void StartScene(const SceneDefinition &) = 0;
|
|
|
|
|
|
|
|
virtual void AddLight(const client::DynamicLightParam &light) = 0;
|
|
|
|
|
|
|
|
virtual void RenderModel(IModel *, const ModelRenderParam &) = 0;
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual void AddDebugLine(Vector3 a, Vector3 b, Vector4 color) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
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;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
/** Finalizes a scene. 2D drawing follows. */
|
|
|
|
virtual void EndScene() = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual void MultiplyScreenColor(Vector3) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-09 01:00:09 +09:00
|
|
|
/** Sets color for image drawing. Deprecated because
|
2016-12-03 18:23:47 +09:00
|
|
|
* some methods treats this as an alpha premultiplied, while
|
2013-12-09 01:00:09 +09:00
|
|
|
* others treats this as an alpha non-premultiplied.
|
|
|
|
* @deprecated */
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual void SetColor(Vector4) = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-09 01:00:09 +09:00
|
|
|
/** Sets color for image drawing. Always alpha premultiplied. */
|
|
|
|
virtual void SetColorAlphaPremultiplied(Vector4) = 0;
|
2016-12-03 18:23:47 +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;
|
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
/** Finalizes a frame. */
|
|
|
|
virtual void FrameDone() = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
/** displays a rendered image to the screen. */
|
|
|
|
virtual void Flip() = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
/** get a rendered image. */
|
|
|
|
virtual Bitmap *ReadBitmap() = 0;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-08-18 16:18:06 +09:00
|
|
|
virtual float ScreenWidth() = 0;
|
|
|
|
virtual float ScreenHeight() = 0;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|