1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#pragma once
#include <map>
#include <RmlUi/Core/SystemInterface.h>
#include <RmlUi/Core/RenderInterface.h>
#include <RmlUi/Core/FileInterface.h>
#include "Renderer.hpp"
class AssetTreeNode;
class RmlSystemInterface : public Rml::SystemInterface {
double totalTime;
public:
virtual double GetElapsedTime() override;
virtual bool LogMessage(Rml::Log::Type type, const Rml::String& message) override;
virtual void SetClipboardText(const Rml::String& text) override;
virtual void GetClipboardText(Rml::String& text) override;
inline void Update(double timeToUpdate) {
totalTime += timeToUpdate;
}
std::string clipboard;
};
class RmlRenderInterface : public Rml::RenderInterface {
RenderState* State;
GLuint Vao, Vbo, Ebo;
unsigned int vpWidth, vpHeight;
public:
RmlRenderInterface(RenderState &renderState);
RmlRenderInterface(const RmlRenderInterface&) = delete;
RmlRenderInterface(RmlRenderInterface&&) = delete;
RmlRenderInterface& operator=(const RmlRenderInterface&) = delete;
RmlRenderInterface& operator=(RmlRenderInterface&&) = delete;
~RmlRenderInterface();
virtual void RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture, const Rml::Vector2f& translation) override;
virtual void EnableScissorRegion(bool enable) override;
virtual void SetScissorRegion(int x, int y, int width, int height) override;
virtual bool LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) override;
virtual bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) override;
virtual void ReleaseTexture(Rml::TextureHandle texture) override;
void Update(unsigned int windowWidth, unsigned int windowHeight);
};
class RmlFileInterface : public Rml::FileInterface {
struct AssetHandle {
std::string fileName;
unsigned long long filePos;
AssetTreeNode* assetPtr;
};
std::map<Rml::FileHandle, AssetHandle> handles;
public:
virtual Rml::FileHandle Open(const Rml::String& path) override;
virtual void Close(Rml::FileHandle file) override;
virtual size_t Read(void* buffer, size_t size, Rml::FileHandle file) override;
virtual bool Seek(Rml::FileHandle file, long offset, int origin) override;
virtual size_t Tell(Rml::FileHandle file) override;
};
|