PCB Environment 2
Loading...
Searching...
No Matches
PCBoardMesh.hpp
1
2#ifndef GYM_PCB_UI_PCBOARDMESH_H
3#define GYM_PCB_UI_PCBOARDMESH_H
4
5#include <map>
6#include <set>
7#include "GLContext.hpp"
8
9class AShape;
10class PCBoard;
11class Camera;
12
13class PCBoardMesh
14{
15 constexpr static const bool AlwaysDrawComponentsAsBoxes = false;
16public:
17 PCBoardMesh(const PCBoard&, int z, char mask = RENDER_MASK_ALL);
18 ~PCBoardMesh();
19
20 void update();
21 void draw(const Camera&);
22 void drawExtra();
23 void setCamera(const Camera&);
24 void setExtraSet(const std::set<Object *> *);
25 void setLineWidth(float w) { mLineWidthBase = w; }
26 void setLineAlpha(float a) { mLineAlpha = a; }
27 void setFillAlpha(float a) { mFillAlpha = a; }
28
29 static constexpr const GLushort RestartIndex = 0xffff;
30
31 static constexpr const char RENDER_MASK_COMPONENTS = 0x1;
32 static constexpr const char RENDER_MASK_PINS = 0x2;
33 static constexpr const char RENDER_MASK_ALL = 0x3;
34
35 struct IndexRange {
36 struct { uint16_t Line{0}, Fan{0}, Quad{0}; } Start, End;
37 };
38
39private:
40 const PCBoard &mBoard;
41 const int mZ;
42 const char mMask;
43 const std::set<Object *> *mExtraSet{0};
44
45 GLuint mVBO[2]{0}; // Fans/Lines, Circles.
46 GLuint mIBO[2]{0,0}; // Fans, Lines.
47 GLuint mVAO[3]{0,0}; // Fans, Lines, Circles.
48 GLsizei mIndexCountL{0};
49 GLsizei mIndexCountT{0};
50 GLsizei mRoundVertexCount{0};
51 GLfloat mLineWidth{4.0f};
52 GLfloat mLineWidthBase{4.0f};
53 GLfloat mLineAlpha{1.0f};
54 GLfloat mFillAlpha{1.0f};
55 std::map<Object *, IndexRange> mIndexRanges;
56 std::vector<GLsizei> mExtraCount;
57 std::vector<GLsizei> mExtraCountRound;
58 std::vector<void *> mExtraStart;
59 std::vector<GLint> mExtraStartRound;
60
61 void updateExtra();
62 void countVerticesAndIndices(GLsizei &numVerts, GLsizei &numRoundVerts, GLsizei &numIndsL, GLsizei &numIndsT) const;
63 void countVerticesAndIndices(GLsizei &numVerts, GLsizei &numRoundVerts, GLsizei &numIndsL, GLsizei &numIndsT, const AShape *) const;
64
65 void *indexAddress(uint16_t) const;
66
67private:
68 static void init();
69 static GLuint sVP, sRoundVP, sExtraVP;
70 static GLuint sFP, sRoundFP, sExtraFP;
71 static GLuint sPP, sRoundPP, sExtraPP;
72 static GLint sUniformRoundAlpha;
73 static GLint sUniformFillAlpha;
74};
75
76#endif // GYM_PCB_UI_PCBOARDMESH_H
Definition AShape.hpp:21
Definition Camera.hpp:15
Definition PCBoard.hpp:36
Definition PCBoardMesh.hpp:35