TazGraph Project v0.1.0
Loading...
Searching...
No Matches
LineRenderer.h
1#pragma once
2
3#include "../Renderer.h"
4#include "../../Vertex.h"
5
6class LineRenderer : public Taz::Renderer {
7public:
8 const char* VERT_SRC = R"(#version 400
9
10in vec3 vertexPosition; //vec3 is array of 3 floats
11in vec4 vertexColor;
12
13out vec4 fragmentColor;
14
15uniform mat4 u_ViewProjection;
16
17void main() {
18 gl_Position = u_ViewProjection * vec4(vertexPosition.xyz, 1.0);
19
20 fragmentColor = vertexColor;
21})";
22
23 const char* FRAG_SRC = R"(#version 400
24
25in vec4 fragmentColor;
26
27out vec4 color; //rgb value
28
29void main() {
30 color = vec4(fragmentColor.rgb, fragmentColor.a);
31})";
32
35
36 void init();
37
38 void begin();
39 void end();
40
41 void initBatch(Taz::RenderBatch& batch);
42
43 void drawLine(size_t v_index,
44 const glm::vec3 srcPosition, const glm::vec3 destPosition,
45 const TazColor& srcColor, const TazColor& destColor,
46 const float width = 5.0f);
47 void drawRectangle(size_t v_index, const glm::vec2& rectSize,
48 const glm::vec3& position,
49 const TazColor& color,
50 const glm::vec3& mRotation = glm::vec3(0),
51 const float width = 5.0f);
52 void drawBox(size_t v_index, const glm::vec3& rectSize,
53 const glm::vec3& position,
54 const TazColor& color,
55 const glm::vec3& mRotation = glm::vec3(0),
56 const float width = 5.0f);
57 void drawSphere(size_t v_index, const glm::vec3& rectSize, const glm::vec3& position, const TazColor& color, const glm::vec3& mRotation, const float width);
58 void drawCircle(const glm::vec2& center, const TazColor& color, float radius);
59
60 void endBatch(const Taz::RenderBatch& batch);
61
62 void dispose();
63
64 int box_edgePairs[12][2] = {
65 {0, 1}, {1, 2}, {2, 3}, {3, 0}, // Bottom face
66 {4, 5}, {5, 6}, {6, 7}, {7, 4}, // Top face
67 {0, 4}, {1, 5}, {2, 6}, {3, 7} // Vertical edges
68 };
69
70 std::vector<TazPosition> sphereVertices = {
71 // Generated vertices will go here
72 };
73
74 std::vector<GLuint> sphereIndices = {
75 // Generated indices will go here
76 };
77
78private:
79 void createInstancesVBO();
80 void createWireframeInstancesVBO();
81 void createVertexArray();
82
83 std::vector<LineMeshRenderer> _meshesArrays;
84 std::vector<WireframeMeshRenderer> _meshesElements;
85
86 GLuint _vboWireframeInstances;
87
88 size_t currentBatchIndex = 0;
89
90};
Definition LineRenderer.h:6
Definition Renderer.h:51
Definition Vertex.h:44
Definition Renderer.h:19