summaryrefslogtreecommitdiffstats
path: root/src/Rml.hpp
blob: 5815c3e62286e3d42e310c7fa05fdf3f7c420f2e (plain) (blame)
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
#pragma once

#include <RmlUi/Core/SystemInterface.h>
#include <RmlUi/Core/RenderInterface.h>

#include "Renderer.hpp"

class RmlSystemInterface : public Rml::SystemInterface {
	double totalTime;

public:

	virtual double GetElapsedTime() override;

	virtual bool LogMessage(Rml::Log::Type type, const Rml::String& message) override;

	inline void Update(double timeToUpdate) {
		totalTime += timeToUpdate;
	}

};

class RmlRenderInterface : public Rml::RenderInterface {
	RenderState* State;

	GLuint Vao, Vbo, Ebo;

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);

};