Skip to content

File DebugPoints.h

File List > scene > DebugPoints.h

Go to the documentation of this file

#pragma once

#include "Context.h"

#include "ID.h"
#include "Transform.h"

#include "VertexArray.h"
#include "buffers/IndexBuffer.h"
#include "shaders/RenderShader.h"

#include "buffers/StorageBuffer.h"

enum PointType {
    SQUARE_POINT, RHOMBUS_POINT, CIR_POINT, CUBE_POINT
};

class DebugPoints : public ObjectID, public Transform3D
{
private:
    VertexArray dp_vertArry;
    VertexBuffer dp_vertBuffer;
    IndexBuffer dp_index;
    StorageBuffer dp_pos_buffer;

    static std::vector<float> VertData;

public:
    PointType dp_type = SQUARE_POINT;
    bool is_proj = true;
    bool is_list_changed = true;
    bool is_scaled;
    std::array<RenderShader, 2> dp_shader; //no proj | using proj

    mutable float dp_scale = 1.0f;
    float dp_opacity = 1.0f;
    glm::vec3 dp_color = glm::vec3(1.0f, 1.0f, 1.0f);
    std::vector<glm::vec3> dp_pos_list;

    DebugPoints();
    DebugPoints(const std::vector<glm::vec3>& pos_list);

    void RenderDebugPoint(const Context& ctx);

    void SetDebugPointsShader(PointType type, bool proj);
    void PushDebugPoint(const glm::vec3& point);
    void PushDebugPoint(float x, float y, float z);
    void PushDebugPoints(const std::vector<glm::vec3>& points);

    void* GetShader()       override { return &dp_shader[is_proj]; };
    void* GetTransform()    override { return dynamic_cast<Transform*>(GetTransformPtr()); }
};