aboutsummaryrefslogtreecommitdiffstats
path: root/gui/lineshader.h
diff options
context:
space:
mode:
Diffstat (limited to 'gui/lineshader.h')
-rw-r--r--gui/lineshader.h32
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