Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
rmlrenderinterface.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2023 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <RmlUi/Core.h>
20#include <spdlog/spdlog.h>
21
22#include <memory>
23
24#include <glm/glm.hpp>
25
26#include "engine/engine.h"
28
29namespace cqsp::engine {
30class CQSPRenderInterface : public Rml::RenderInterface {
31 public:
34
35 void RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices,
36 Rml::TextureHandle texture, const Rml::Vector2f& translation) override;
37
38 Rml::CompiledGeometryHandle CompileGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices,
39 Rml::TextureHandle texture) override;
40
41 void RenderCompiledGeometry(Rml::CompiledGeometryHandle geometry, const Rml::Vector2f& translation) override;
42
43 void ReleaseCompiledGeometry(Rml::CompiledGeometryHandle geometry) override;
44
45 void EnableScissorRegion(bool enable) override;
46
47 void SetScissorRegion(int x, int y, int width, int height) override;
48
49 bool LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions,
50 const Rml::String& source) override;
51
52 bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source,
53 const Rml::Vector2i& source_dimensions) override;
54
55 void ReleaseTexture(Rml::TextureHandle texture) override;
56
57 void SetTransform(const Rml::Matrix4f* transform) override;
58
59 // In the past the general idea was to present the ui on a separate
60 // frame buffer, but since frame buffers are kinda wacky with their
61 // alpha values, i choose not to do that.
64
65 private:
70
71 // Shaders
74 bool m_transform_enabled = false;
75 glm::mat4 m_transform_matrix = glm::mat4(1.0);
76
77 int counter = 0;
78 std::shared_ptr<spdlog::logger> logger;
79};
80} // namespace cqsp::engine
Definition: shader.h:42
Definition: application.h:47
Definition: rmlrenderinterface.h:30
void SetTransform(const Rml::Matrix4f *transform) override
Definition: rmlrenderinterface.cpp:269
asset::Shader vert_shader
Definition: rmlrenderinterface.h:67
void RenderGeometry(Rml::Vertex *vertices, int num_vertices, int *indices, int num_indices, Rml::TextureHandle texture, const Rml::Vector2f &translation) override
Definition: rmlrenderinterface.cpp:124
asset::Shader frag_shader
Definition: rmlrenderinterface.h:68
void ReleaseTexture(Rml::TextureHandle texture) override
Definition: rmlrenderinterface.cpp:265
asset::Shader texture_frag_shader
Definition: rmlrenderinterface.h:69
glm::mat4 m_transform_matrix
Definition: rmlrenderinterface.h:75
bool LoadTexture(Rml::TextureHandle &texture_handle, Rml::Vector2i &texture_dimensions, const Rml::String &source) override
Definition: rmlrenderinterface.cpp:226
void PrepareRenderBuffer()
Definition: rmlrenderinterface.cpp:283
CQSPRenderInterface(Application &app)
Definition: rmlrenderinterface.cpp:56
bool GenerateTexture(Rml::TextureHandle &texture_handle, const Rml::byte *source, const Rml::Vector2i &source_dimensions) override
Definition: rmlrenderinterface.cpp:253
int counter
Definition: rmlrenderinterface.h:77
void ReleaseCompiledGeometry(Rml::CompiledGeometryHandle geometry) override
Definition: rmlrenderinterface.cpp:200
bool m_transform_enabled
Definition: rmlrenderinterface.h:74
void RenderCompiledGeometry(Rml::CompiledGeometryHandle geometry, const Rml::Vector2f &translation) override
Definition: rmlrenderinterface.cpp:169
cqsp::asset::ShaderProgram_t texture_shader
Definition: rmlrenderinterface.h:73
void SetScissorRegion(int x, int y, int width, int height) override
Definition: rmlrenderinterface.cpp:219
cqsp::asset::ShaderProgram_t color_shader
Definition: rmlrenderinterface.h:72
void PresentRenderBuffer()
Definition: rmlrenderinterface.cpp:285
std::shared_ptr< spdlog::logger > logger
Definition: rmlrenderinterface.h:78
Rml::CompiledGeometryHandle CompileGeometry(Rml::Vertex *vertices, int num_vertices, int *indices, int num_indices, Rml::TextureHandle texture) override
Definition: rmlrenderinterface.cpp:135
Application & app
Definition: rmlrenderinterface.h:66
void EnableScissorRegion(bool enable) override
Definition: rmlrenderinterface.cpp:204
std::shared_ptr< ShaderProgram > ShaderProgram_t
The preferred way of using a shader program.
Definition: shader.h:112
Definition: application.cpp:54