Remove features from renderer no longer needed with new gui
This commit is contained in:
parent
53f64b8513
commit
8369181e9a
@ -93,7 +93,6 @@ set(CLIENT_ONLY_SOURCES
|
||||
"src/gfx/draw_list.hpp"
|
||||
"src/gfx/frustum.hpp"
|
||||
"src/gfx/frustum.cpp"
|
||||
"src/gfx/hud.hpp"
|
||||
"src/gfx/renderer.hpp"
|
||||
"src/gfx/renderer.cpp"
|
||||
"src/gfx/shader_defs.hpp"
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "assets/skeleton.hpp"
|
||||
#include "hud.hpp"
|
||||
#include "surface.hpp"
|
||||
#include "uniform_buffer.hpp"
|
||||
|
||||
@ -41,8 +40,6 @@ struct DrawHudCmd
|
||||
{
|
||||
const VertexArray* va = nullptr;
|
||||
const Texture* texture = nullptr;
|
||||
const HudPosition* pos = nullptr;
|
||||
const glm::vec4* color = nullptr;
|
||||
size_t first = 0;
|
||||
size_t count = 0;
|
||||
};
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace gfx
|
||||
{
|
||||
|
||||
struct HudPosition
|
||||
{
|
||||
glm::vec2 anchor = glm::vec2(0.0f); // <0;1>
|
||||
glm::vec2 pos = glm::vec2(0.0f); // px or px multiplies (scale != 1)
|
||||
glm::vec2 scale = glm::vec2(1.0f);
|
||||
};
|
||||
|
||||
}
|
||||
@ -417,39 +417,24 @@ void gfx::Renderer::DrawHudList(std::span<DrawHudCmd> queue, const DrawListParam
|
||||
glm::vec2 ndc_scale(2.0f / screen_size_px.x, -2.0f / screen_size_px.y);
|
||||
constexpr glm::vec2 ndc_offset(-1.0f, 1.0f);
|
||||
|
||||
glm::mat3 matrix(1.0f);
|
||||
matrix[0][0] = ndc_scale.x;
|
||||
matrix[1][1] = ndc_scale.y;
|
||||
matrix[2][0] = ndc_offset.x;
|
||||
matrix[2][1] = ndc_offset.y;
|
||||
|
||||
glUniformMatrix3fv(shader->U(SU_MODEL), 1, GL_FALSE, &matrix[0][0]);
|
||||
|
||||
const gfx::Texture* last_texture = nullptr;
|
||||
const gfx::VertexArray* last_vao = nullptr;
|
||||
glm::vec4 last_color = glm::vec4(-1.0f);
|
||||
|
||||
for (const auto& cmd : queue)
|
||||
{
|
||||
if (!cmd.va || !cmd.texture || !cmd.pos)
|
||||
if (!cmd.va || !cmd.texture)
|
||||
{
|
||||
throw std::runtime_error("invalid hud draw");
|
||||
}
|
||||
|
||||
// calculate transform
|
||||
const auto& hp = *cmd.pos;
|
||||
|
||||
glm::vec2 pos_px = hp.anchor * screen_size_px + hp.pos;
|
||||
glm::vec2 trans_ndc = ndc_offset + pos_px * ndc_scale;
|
||||
|
||||
glm::mat3 matrix(1.0f);
|
||||
matrix[0][0] = hp.scale.x * ndc_scale.x;
|
||||
matrix[1][1] = hp.scale.y * ndc_scale.y;
|
||||
matrix[2][0] = trans_ndc.x;
|
||||
matrix[2][1] = trans_ndc.y;
|
||||
|
||||
glUniformMatrix3fv(shader->U(SU_MODEL), 1, GL_FALSE, &matrix[0][0]);
|
||||
|
||||
//sync color
|
||||
glm::vec4 color = cmd.color ? *cmd.color : glm::vec4(1.0f);
|
||||
if (last_color != color)
|
||||
{
|
||||
glUniform4fv(shader->U(SU_COLOR), 1, &color[0]);
|
||||
last_color = color;
|
||||
}
|
||||
|
||||
// bind texture
|
||||
if (last_texture != cmd.texture)
|
||||
{
|
||||
|
||||
@ -250,7 +250,6 @@ layout (location = 2) in vec4 a_color;
|
||||
layout (location = 3) in vec2 a_uv;
|
||||
|
||||
uniform mat3 u_model;
|
||||
uniform vec4 u_color;
|
||||
|
||||
out vec4 v_color;
|
||||
out vec2 v_uv;
|
||||
@ -258,7 +257,7 @@ out vec2 v_uv;
|
||||
void main() {
|
||||
vec3 pos2d = u_model * vec3(a_pos.xy, 1.0);
|
||||
gl_Position = vec4(pos2d.xy, 0.0, 1.0);
|
||||
v_color = a_color * u_color;
|
||||
v_color = a_color;
|
||||
v_uv = a_uv;
|
||||
}
|
||||
)GLSL",
|
||||
|
||||
@ -204,13 +204,10 @@ void gui::Context::Render()
|
||||
va_.SetVBOData(vertices_.data(), vertices_.size() * sizeof(vertices_[0]));
|
||||
va_.SetIndices(indices_.data(), indices_.size());
|
||||
|
||||
static const gfx::HudPosition pos;
|
||||
|
||||
for (const auto& range : ranges_)
|
||||
{
|
||||
gfx::DrawHudCmd hudcmd;
|
||||
hudcmd.va = &va_;
|
||||
hudcmd.pos = &pos;
|
||||
hudcmd.texture = range.texture;
|
||||
hudcmd.first = range.start;
|
||||
hudcmd.count = range.count;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user