CSEngine
Loading...
Searching...
No Matches
RenderInterfaces.h
1#pragma once
2#include <vector>
3#include "../../SObject.h"
4#include "../../Manager/ResMgr.h"
5#include "../Matrix.h"
6#include "GLMeshID.h"
7
8#define SURFACE_CONSTRUCTOR(CLASSNAME) \
9namespace __REFELCTION_DUMP__ { namespace CLASSNAME { \
10unsigned char* __CSE_REFLECTION_DUMP__ = \
11CSE::ReflectionMgr::DefineWrapper::SetDefine(#CLASSNAME, []() { return new CSE::CLASSNAME(); });}} \
12CSE::CLASSNAME::CLASSNAME() : CSE::SISurface(#CLASSNAME)
13
14#define SURFACE_SUB_CONSTRUCTOR(CLASSNAME, ...) \
15CSE::CLASSNAME::CLASSNAME(__VA_ARGS__) : CSE::SISurface(#CLASSNAME)
16
17namespace CSE {
18 struct CameraMatrixStruct;
19 class SMaterial;
20 class CameraBase;
21 class RenderMgr;
22
23 class SISurface : public SResource {
24 public:
25
26 explicit SISurface(std::string&& classType) : SResource(classType) {
27 SetUndestroyable(true);
28 }
29
30 ~SISurface() override = default;
31
32 virtual int GetVertexCount() const = 0;
33
34 virtual int GetLineIndexCount() const = 0;
35
36 virtual int GetTriangleIndexCount() const = 0;
37
38 virtual void GenerateVertices(std::vector<float>& vertices, unsigned char flags = 0) const = 0;
39
40 virtual void GenerateLineIndices(std::vector<unsigned short>& indices) const = 0;
41
42 virtual void GenerateTriangleIndices(std::vector<unsigned short>& indices) const = 0;
43
44 public:
45 mutable GLMeshID m_meshId;
46 };
47
48 class SIRender {
49 public:
50 SIRender() = default;
51
52 virtual ~SIRender() = default;
53
54 virtual void
55 SetMatrix(const CameraMatrixStruct& cameraMatrixStruct,
56 const GLProgramHandle* handle) = 0;
57
58 virtual void Render(const GLProgramHandle* handle) const = 0;
59
60 virtual SMaterial* GetMaterial() const = 0;
61
62 SMaterial* GetMaterialReference() const {
63 return material;
64 }
65
66 protected:
67 SMaterial* material = nullptr;
68 public:
69 bool isRenderActive = false;
70 };
71}