Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
71
dev_sandbox/imgui_renderer.hpp
Normal file
71
dev_sandbox/imgui_renderer.hpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#pragma once
|
||||
|
||||
#include "drape/glsl_types.hpp"
|
||||
#include "drape/graphics_context.hpp"
|
||||
#include "drape/mesh_object.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
#include "drape/render_state.hpp"
|
||||
#include "drape/static_texture.hpp"
|
||||
#include "drape/texture_manager.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
class ImguiRenderer
|
||||
{
|
||||
public:
|
||||
ImguiRenderer();
|
||||
void Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> textureManager,
|
||||
ref_ptr<gpu::ProgramManager> programManager);
|
||||
void Update(std::function<void()> const & uiCallback);
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
void UpdateTexture();
|
||||
void UpdateBuffers();
|
||||
|
||||
struct ImguiVertex
|
||||
{
|
||||
glsl::vec2 position;
|
||||
glsl::vec2 texCoords;
|
||||
glsl::vec4 color;
|
||||
};
|
||||
static_assert(sizeof(ImguiVertex) == 2 * sizeof(glsl::vec4));
|
||||
|
||||
struct DrawCall
|
||||
{
|
||||
uint32_t indexCount = 0;
|
||||
uint32_t startIndex = 0;
|
||||
glsl::uvec4 clipRect{};
|
||||
};
|
||||
|
||||
drape_ptr<dp::MeshObject> m_mesh;
|
||||
uint32_t m_vertexCount = 2000;
|
||||
uint32_t m_indexCount = 3000;
|
||||
|
||||
drape_ptr<dp::StaticTexture> m_texture;
|
||||
std::vector<unsigned char> m_textureData;
|
||||
uint32_t m_textureWidth = 0;
|
||||
uint32_t m_textureHeight = 0;
|
||||
|
||||
dp::RenderState m_state;
|
||||
|
||||
struct UiDataBuffer
|
||||
{
|
||||
std::vector<ImguiVertex> m_vertices;
|
||||
std::vector<uint16_t> m_indices;
|
||||
std::vector<DrawCall> m_drawCalls;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
};
|
||||
std::array<UiDataBuffer, 2> m_uiDataBuffer;
|
||||
size_t m_updateIndex = 0;
|
||||
|
||||
glsl::mat4 m_projection;
|
||||
|
||||
std::mutex m_bufferMutex;
|
||||
std::mutex m_textureMutex;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue