Skip to content

Commit 1e57aae

Browse files
m0dBm0dB
authored andcommitted
let matrix be handled by qt scenegraph or by the opengl engine, removed engine class from scenegraph, get context from m_waveformRenderer, various cleanups
1 parent bf7ed15 commit 1e57aae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+487
-466
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,6 @@ if(QOPENGL)
15141514
src/shaders/vinylqualityshader.cpp
15151515
src/util/opengltexture2d.cpp
15161516
src/waveform/renderers/allshader/digitsrenderer.cpp
1517-
src/waveform/renderers/allshader/matrixforwidgetgeometry.cpp
15181517
src/waveform/renderers/allshader/waveformrenderbackground.cpp
15191518
src/waveform/renderers/allshader/waveformrenderbeat.cpp
15201519
src/waveform/renderers/allshader/waveformrenderer.cpp

src/rendergraph/common/engine.cpp

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/rendergraph/common/rendergraph/texture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Texture;
1212

1313
class rendergraph::Texture {
1414
public:
15-
Texture(Context& context, const QImage& image);
15+
Texture(Context* pContext, const QImage& image);
1616

1717
BaseTexture* backendTexture() const {
1818
return m_pTexture.get();

src/rendergraph/common/rendergraph/treenode.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,11 @@ class rendergraph::TreeNode {
5151
return m_pBackendNode;
5252
}
5353

54-
virtual void initialize() {
55-
}
56-
virtual void resize(int, int) {
57-
}
58-
59-
void setEngine(Engine* pEngine) {
60-
m_pEngine = pEngine;
61-
}
62-
Engine* engine() const {
63-
return m_pEngine;
64-
}
65-
6654
private:
6755
void onAppendChildNode(TreeNode* pChild);
6856
void onRemoveAllChildNodes();
6957
void onRemoveChildNode(TreeNode* pChild);
7058

71-
Engine* m_pEngine{};
7259
rendergraph::BaseNode* m_pBackendNode;
7360
TreeNode* m_pParent{};
7461
std::unique_ptr<TreeNode> m_pFirstChild;

src/rendergraph/common/rendergraph/vertexupdaters/rgbavertexupdater.h

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,48 @@ class rendergraph::RGBAVertexUpdater {
5555
rgbar.z(),
5656
rgbar.w());
5757
}
58+
int index() const {
59+
return static_cast<int>(m_pWrite - m_pData);
60+
}
61+
void addTriangle(QVector2D p1, QVector2D p2, QVector2D p3, QVector4D rgba) {
62+
addTriangle(p1.x(),
63+
p1.y(),
64+
p2.x(),
65+
p2.y(),
66+
p3.x(),
67+
p3.y(),
68+
rgba.x(),
69+
rgba.y(),
70+
rgba.z(),
71+
rgba.w());
72+
}
73+
void addTriangle(QVector2D p1,
74+
QVector2D p2,
75+
QVector2D p3,
76+
QVector4D rgba1,
77+
QVector4D rgba2,
78+
QVector4D rgba3) {
79+
addTriangle(p1.x(),
80+
p1.y(),
81+
p2.x(),
82+
p2.y(),
83+
p3.x(),
84+
p3.y(),
85+
rgba1.x(),
86+
rgba1.y(),
87+
rgba1.z(),
88+
rgba1.w(),
89+
rgba2.x(),
90+
rgba2.y(),
91+
rgba2.z(),
92+
rgba2.w(),
93+
rgba3.x(),
94+
rgba3.y(),
95+
rgba3.z(),
96+
rgba3.w());
97+
}
98+
99+
private:
58100
void addRectangle(float x1, float y1, float x2, float y2, float r, float g, float b, float a) {
59101
addTriangle(x1, y1, x2, y1, x1, y2, r, g, b, a);
60102
addTriangle(x1, y2, x2, y2, x2, y1, r, g, b, a);
@@ -127,11 +169,6 @@ class rendergraph::RGBAVertexUpdater {
127169
*m_pWrite++ = Geometry::RGBAColoredPoint2D{x2, y2, r2, g2, b2, a2};
128170
*m_pWrite++ = Geometry::RGBAColoredPoint2D{x3, y3, r3, g3, b3, a3};
129171
}
130-
int index() const {
131-
return static_cast<int>(m_pWrite - m_pData);
132-
}
133-
134-
private:
135172
Geometry::RGBAColoredPoint2D* const m_pData;
136173
Geometry::RGBAColoredPoint2D* m_pWrite;
137174
};

src/rendergraph/common/rendergraph/vertexupdaters/rgbvertexupdater.h

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,36 @@ class rendergraph::RGBVertexUpdater {
5151
rgbr.y(),
5252
rgbr.z());
5353
}
54+
void addTriangle(QVector2D p1, QVector2D p2, QVector2D p3, QVector3D rgb) {
55+
addTriangle(p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y(), rgb.x(), rgb.y(), rgb.z());
56+
}
57+
void addTriangle(QVector2D p1,
58+
QVector2D p2,
59+
QVector2D p3,
60+
QVector3D rgb1,
61+
QVector3D rgb2,
62+
QVector3D rgb3) {
63+
addTriangle(p1.x(),
64+
p1.y(),
65+
p2.x(),
66+
p2.y(),
67+
p3.x(),
68+
p3.y(),
69+
rgb1.x(),
70+
rgb1.y(),
71+
rgb1.z(),
72+
rgb2.x(),
73+
rgb2.y(),
74+
rgb2.z(),
75+
rgb3.x(),
76+
rgb3.y(),
77+
rgb3.z());
78+
}
79+
int index() const {
80+
return static_cast<int>(m_pWrite - m_pData);
81+
}
82+
83+
private:
5484
void addRectangle(float x1, float y1, float x2, float y2, float r, float g, float b) {
5585
addTriangle(x1, y1, x2, y1, x1, y2, r, g, b);
5686
addTriangle(x1, y2, x2, y2, x2, y1, r, g, b);
@@ -66,8 +96,8 @@ class rendergraph::RGBVertexUpdater {
6696
float r2,
6797
float g2,
6898
float b2) {
69-
addTriangle(x1, y1, x2, y1, x1, y2, r1, g1, b1, r2, g2, b2, r1, g1, b1);
70-
addTriangle(x1, y2, x2, y2, x2, y1, r1, g1, b1, r2, g2, b2, r2, g2, b2);
99+
addTriangle(x1, y1, x2, y1, x1, y2, r1, g1, b1, r1, g1, b1, r2, g2, b2);
100+
addTriangle(x1, y2, x2, y2, x2, y1, r2, g2, b2, r2, g2, b2, r1, g1, b1);
71101
}
72102
void addRectangleHGradient(
73103
float x1,
@@ -105,23 +135,16 @@ class rendergraph::RGBVertexUpdater {
105135
float r1,
106136
float g1,
107137
float b1,
108-
109138
float r2,
110139
float g2,
111140
float b2,
112-
113141
float r3,
114142
float g3,
115143
float b3) {
116144
*m_pWrite++ = Geometry::RGBColoredPoint2D{x1, y1, r1, g1, b1};
117145
*m_pWrite++ = Geometry::RGBColoredPoint2D{x2, y2, r2, g2, b2};
118146
*m_pWrite++ = Geometry::RGBColoredPoint2D{x3, y3, r3, g3, b3};
119147
}
120-
int index() const {
121-
return static_cast<int>(m_pWrite - m_pData);
122-
}
123-
124-
private:
125148
Geometry::RGBColoredPoint2D* const m_pData;
126149
Geometry::RGBColoredPoint2D* m_pWrite;
127150
};

src/rendergraph/common/rendergraph/vertexupdaters/texturedvertexupdater.h

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,38 @@ class rendergraph::TexturedVertexUpdater {
1212
: m_pData(pData),
1313
m_pWrite(pData) {
1414
}
15+
void addRectangle(
16+
QVector2D lt, QVector2D rb) {
17+
addRectangle(lt.x(), lt.y(), rb.x(), rb.y(), 0.f, 0.f, 1.f, 1.f);
18+
}
1519
void addRectangle(
1620
QVector2D lt, QVector2D rb, QVector2D tlr, QVector2D trb) {
1721
addRectangle(lt.x(), lt.y(), rb.x(), rb.y(), tlr.x(), tlr.y(), trb.x(), trb.y());
1822
}
23+
void addTriangle(QVector2D p1,
24+
QVector2D p2,
25+
QVector2D p3,
26+
QVector2D tp1,
27+
QVector2D tp2,
28+
QVector2D tp3) {
29+
addTriangle(p1.x(),
30+
p1.y(),
31+
p2.x(),
32+
p2.y(),
33+
p3.x(),
34+
p3.y(),
35+
tp1.x(),
36+
tp1.y(),
37+
tp2.x(),
38+
tp2.y(),
39+
tp3.x(),
40+
tp3.y());
41+
}
42+
int index() const {
43+
return static_cast<int>(m_pWrite - m_pData);
44+
}
45+
46+
private:
1947
void addRectangle(
2048
float x1, float y1, float x2, float y2, float tx1, float ty1, float tx2, float ty2) {
2149
addTriangle(x1, y1, x2, y1, x1, y2, tx1, ty1, tx2, ty1, tx1, ty2);
@@ -37,11 +65,6 @@ class rendergraph::TexturedVertexUpdater {
3765
*m_pWrite++ = Geometry::TexturedPoint2D{x2, y2, tx2, ty2};
3866
*m_pWrite++ = Geometry::TexturedPoint2D{x3, y3, tx3, ty3};
3967
}
40-
int index() const {
41-
return static_cast<int>(m_pWrite - m_pData);
42-
}
43-
44-
private:
4568
Geometry::TexturedPoint2D* const m_pData;
4669
Geometry::TexturedPoint2D* m_pWrite;
4770
};

src/rendergraph/common/rendergraph/vertexupdaters/vertexupdater.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ class rendergraph::VertexUpdater {
1414
QVector2D lt, QVector2D rb) {
1515
addRectangle(lt.x(), lt.y(), rb.x(), rb.y());
1616
}
17+
void addTriangle(QVector2D p1, QVector2D p2, QVector2D p3) {
18+
addTriangle(p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y());
19+
}
20+
int index() const {
21+
return static_cast<int>(m_pWrite - m_pData);
22+
}
23+
24+
private:
1725
void addRectangle(
1826
float x1,
1927
float y1,
@@ -27,11 +35,6 @@ class rendergraph::VertexUpdater {
2735
*m_pWrite++ = Geometry::Point2D{x2, y2};
2836
*m_pWrite++ = Geometry::Point2D{x3, y3};
2937
}
30-
int index() const {
31-
return static_cast<int>(m_pWrite - m_pData);
32-
}
33-
34-
private:
3538
Geometry::Point2D* const m_pData;
3639
Geometry::Point2D* m_pWrite;
3740
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "examplenode.h"
2+
3+
#include <QColor>
4+
#include <QMatrix4x4>
5+
#include <QVector2D>
6+
7+
#include "rendergraph/geometry.h"
8+
#include "rendergraph/material/rgbmaterial.h"
9+
#include "rendergraph/material/texturematerial.h"
10+
#include "rendergraph/material/unicolormaterial.h"
11+
#include "rendergraph/vertexupdaters/rgbvertexupdater.h"
12+
#include "rendergraph/vertexupdaters/texturedvertexupdater.h"
13+
#include "rendergraph/vertexupdaters/vertexupdater.h"
14+
15+
using namespace rendergraph;
16+
17+
ExampleNode::ExampleNode(rendergraph::Context* pContext) {
18+
{
19+
TreeNode::appendChildNode(std::make_unique<GeometryNode>());
20+
auto pNode = static_cast<GeometryNode*>(TreeNode::lastChild());
21+
pNode->initForRectangles<TextureMaterial>(1);
22+
auto& material = dynamic_cast<TextureMaterial&>(pNode->material());
23+
material.setTexture(std::make_unique<Texture>(
24+
pContext, QImage(":/example/images/test.png")));
25+
TexturedVertexUpdater vertexUpdater{
26+
pNode->geometry().vertexDataAs<Geometry::TexturedPoint2D>()};
27+
vertexUpdater.addRectangle({0, 0}, {100, 100}, {0.f, 0.f}, {1.f, 1.f});
28+
}
29+
{
30+
TreeNode::appendChildNode(std::make_unique<GeometryNode>());
31+
auto pNode = static_cast<GeometryNode*>(TreeNode::lastChild());
32+
pNode->initForRectangles<rendergraph::UniColorMaterial>(2);
33+
pNode->material().setUniform(1, QColor(255, 127, 0));
34+
pNode->geometry().setDrawingMode(Geometry::DrawingMode::Triangles);
35+
rendergraph::VertexUpdater vertexUpdater{
36+
pNode->geometry()
37+
.vertexDataAs<rendergraph::Geometry::Point2D>()};
38+
vertexUpdater.addRectangle({100, 100}, {160, 160});
39+
vertexUpdater.addRectangle({200, 160}, {240, 190});
40+
}
41+
{
42+
TreeNode::appendChildNode(std::make_unique<GeometryNode>());
43+
auto pNode = static_cast<GeometryNode*>(TreeNode::lastChild());
44+
pNode->initForRectangles<rendergraph::RGBMaterial>(2);
45+
pNode->geometry().setDrawingMode(Geometry::DrawingMode::Triangles);
46+
rendergraph::RGBVertexUpdater vertexUpdater{
47+
pNode->geometry().vertexDataAs<Geometry::RGBColoredPoint2D>()};
48+
vertexUpdater.addRectangle({300, 100}, {340, 140}, {1.f, 0.f, 0.5f});
49+
vertexUpdater.addRectangleHGradient(
50+
{340, 100}, {440, 130}, {0.f, 1.f, 0.5f}, {0.5f, 0.f, 1.f});
51+
}
52+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "rendergraph/geometrynode.h"
2+
#include "rendergraph/node.h"
3+
#include "rendergraph/texture.h"
4+
5+
namespace rendergraph {
6+
class ExampleNode;
7+
} // namespace rendergraph
8+
9+
class rendergraph::ExampleNode : public rendergraph::Node {
10+
public:
11+
ExampleNode(rendergraph::Context* pContext);
12+
};

0 commit comments

Comments
 (0)