diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
commit | 66dd17664c08aca17b53d2853558121aa9e702e4 (patch) | |
tree | b6bc5dd919e5f525ec7328861b81f616673a1ea6 /gui/lineshader.h | |
parent | e91241f10d68fcaaf0a81fa77e9a91666120ccee (diff) | |
parent | 15d9b3d3cc05656e58d01ba2f97ec92b6daaee1c (diff) | |
download | nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.gz nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.bz2 nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.zip |
Merge branch 'master' of github.com:YosysHQ/nextpnr into router_improve
Diffstat (limited to 'gui/lineshader.h')
-rw-r--r-- | gui/lineshader.h | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/gui/lineshader.h b/gui/lineshader.h index 3f4c4057..eb0f9e09 100644 --- a/gui/lineshader.h +++ b/gui/lineshader.h @@ -20,12 +20,14 @@ #ifndef LINESHADER_H #define LINESHADER_H +#include <array> #include <QOpenGLBuffer> #include <QOpenGLFunctions> #include <QOpenGLShaderProgram> #include <QOpenGLVertexArrayObject> #include <QOpenGLWidget> +#include "log.h" #include "nextpnr.h" NEXTPNR_NAMESPACE_BEGIN @@ -49,7 +51,7 @@ struct LineShaderData std::vector<GLfloat> miters; std::vector<GLuint> indices; - LineShaderData(void) {} + int last_render = 0; void clear(void) { @@ -142,13 +144,18 @@ class LineShader } attributes_; // GL buffers - struct + struct Buffers { QOpenGLBuffer position; QOpenGLBuffer normal; QOpenGLBuffer miter; QOpenGLBuffer index; - } buffers_; + QOpenGLVertexArrayObject vao; + int indices = 0; + + int last_vbo_update = 0; + }; + std::array<Buffers, GraphicElement::STYLE_MAX> buffers_; // GL uniform locations. struct @@ -161,22 +168,9 @@ class LineShader GLuint color; } uniforms_; - QOpenGLVertexArrayObject vao_; - public: LineShader(QObject *parent) : parent_(parent), program_(nullptr) { - buffers_.position = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); - buffers_.position.setUsagePattern(QOpenGLBuffer::StaticDraw); - - buffers_.normal = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); - buffers_.normal.setUsagePattern(QOpenGLBuffer::StaticDraw); - - buffers_.miter = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); - buffers_.miter.setUsagePattern(QOpenGLBuffer::StaticDraw); - - buffers_.index = QOpenGLBuffer(QOpenGLBuffer::IndexBuffer); - buffers_.index.setUsagePattern(QOpenGLBuffer::StaticDraw); } static constexpr const char *vertexShaderSource_ = @@ -200,8 +194,12 @@ class LineShader // Must be called on initialization. bool compile(void); + void update_vbos(enum GraphicElement::style_t style, + const LineShaderData &line); + // Render a LineShaderData with a given M/V/P transformation. - void draw(const LineShaderData &data, const QColor &color, float thickness, const QMatrix4x4 &projection); + void draw(enum GraphicElement::style_t style, const QColor &color, + float thickness, const QMatrix4x4 &projection); }; NEXTPNR_NAMESPACE_END |