aboutsummaryrefslogtreecommitdiffstats
path: root/src/render.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render.cpp')
-rw-r--r--src/render.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/render.cpp b/src/render.cpp
index 2b49b2c..3eea57b 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -27,8 +27,10 @@
void RenderSystem::configure([[maybe_unused]] entityx::EntityManager& entities,
[[maybe_unused]] entityx::EventManager& events)
{
+ events.subscribe<NewRenderEvent>(*this);
events.subscribe<WorldMeshUpdateEvent>(*this);
events.subscribe<entityx::ComponentAddedEvent<Player>>(*this);
+
init();
}
@@ -221,6 +223,27 @@ void RenderSystem::update([[maybe_unused]] entityx::EntityManager& entities,
glDrawArrays(GL_TRIANGLES, 0, worldVertex);
}
+ // Update all UI VBOs
+ for (auto& r : uiRenders) {
+ auto& render = r.second;
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, render.tex);
+ glUniform1i(q, 0);
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, render.normal);
+ glUniform1i(n, 1);
+
+ glBindBuffer(GL_ARRAY_BUFFER, r.first);
+
+ glVertexAttribPointer(a, 3, GL_FLOAT, GL_FALSE,
+ 6*sizeof(float), 0);
+ glVertexAttribPointer(t, 2, GL_FLOAT, GL_FALSE,
+ 6*sizeof(float), (void*)(3*sizeof(float)));
+ glDrawArrays(GL_TRIANGLES, 0, render.vertex);
+ }
+
/*************
* CLEANUP *
*************/
@@ -310,6 +333,13 @@ int RenderSystem::init(void)
/************
* EVENTS *
************/
+
+void RenderSystem::receive(const NewRenderEvent &nre)
+{
+ uiRenders.insert_or_assign(nre.vbo,
+ UIRenderData(nre.tex, nre.normal, nre.vertex));
+}
+
void RenderSystem::receive(const WorldMeshUpdateEvent &wmu)
{
worldVBO = wmu.worldVBO;
@@ -322,3 +352,4 @@ void RenderSystem::receive(const entityx::ComponentAddedEvent<Player> &cae)
{
player = cae.entity;
}
+