qt: Try to fix linux gcc 11 build
This commit is contained in:
@@ -72,14 +72,14 @@ OpenGLOptions::OpenGLOptions(QObject *parent, bool loadConfig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OpenGLOptions::save()
|
OpenGLOptions::save() const
|
||||||
{
|
{
|
||||||
video_vsync = m_vsync ? 1 : 0;
|
video_vsync = m_vsync ? 1 : 0;
|
||||||
video_framerate = m_renderBehavior == RenderBehaviorType::SyncWithVideo ? -1 : m_framerate;
|
video_framerate = m_renderBehavior == RenderBehaviorType::SyncWithVideo ? -1 : m_framerate;
|
||||||
video_filter_method = m_filter == FilterType::Nearest ? 0 : 1;
|
video_filter_method = m_filter == FilterType::Nearest ? 0 : 1;
|
||||||
|
|
||||||
/* TODO: multiple shaders */
|
/* TODO: multiple shaders */
|
||||||
auto path = m_shaders.first().path.toLocal8Bit();
|
auto path = m_shaders.first().path().toLocal8Bit();
|
||||||
|
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
memcpy(video_shader, path.constData(), path.size());
|
memcpy(video_shader, path.constData(), path.size());
|
||||||
|
@@ -21,31 +21,44 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QOpenGLShaderProgram>
|
#include <QOpenGLShaderProgram>
|
||||||
|
|
||||||
struct OpenGLShaderPass {
|
class OpenGLShaderPass {
|
||||||
|
public:
|
||||||
OpenGLShaderPass(QOpenGLShaderProgram *shader, const QString &path)
|
OpenGLShaderPass(QOpenGLShaderProgram *shader, const QString &path)
|
||||||
: shader(shader)
|
: m_shader(shader)
|
||||||
, path(path)
|
, m_path(path)
|
||||||
, vertex_coord(shader->attributeLocation("VertexCoord"))
|
, m_vertex_coord(shader->attributeLocation("VertexCoord"))
|
||||||
, tex_coord(shader->attributeLocation("TexCoord"))
|
, m_tex_coord(shader->attributeLocation("TexCoord"))
|
||||||
, color(shader->attributeLocation("Color"))
|
, m_color(shader->attributeLocation("Color"))
|
||||||
, mvp_matrix(shader->uniformLocation("MVPMatrix"))
|
, m_mvp_matrix(shader->uniformLocation("MVPMatrix"))
|
||||||
, input_size(shader->uniformLocation("InputSize"))
|
, m_input_size(shader->uniformLocation("InputSize"))
|
||||||
, output_size(shader->uniformLocation("OutputSize"))
|
, m_output_size(shader->uniformLocation("OutputSize"))
|
||||||
, texture_size(shader->uniformLocation("TextureSize"))
|
, m_texture_size(shader->uniformLocation("TextureSize"))
|
||||||
, frame_count(shader->uniformLocation("FrameCount"))
|
, m_frame_count(shader->uniformLocation("FrameCount"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QOpenGLShaderProgram *shader;
|
bool bind() const { return m_shader->bind(); }
|
||||||
const QString path;
|
const QString &path() const { return m_path; }
|
||||||
const GLint vertex_coord;
|
const GLint &vertex_coord() const { return m_vertex_coord; }
|
||||||
const GLint tex_coord;
|
const GLint &tex_coord() const { return m_tex_coord; }
|
||||||
const GLint color;
|
const GLint &color() const { return m_color; }
|
||||||
const GLint mvp_matrix;
|
const GLint &mvp_matrix() const { return m_mvp_matrix; }
|
||||||
const GLint input_size;
|
const GLint &input_size() const { return m_input_size; }
|
||||||
const GLint output_size;
|
const GLint &output_size() const { return m_output_size; }
|
||||||
const GLint texture_size;
|
const GLint &texture_size() const { return m_texture_size; }
|
||||||
const GLint frame_count;
|
const GLint &frame_count() const { return m_frame_count; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QOpenGLShaderProgram *m_shader;
|
||||||
|
QString m_path;
|
||||||
|
GLint m_vertex_coord;
|
||||||
|
GLint m_tex_coord;
|
||||||
|
GLint m_color;
|
||||||
|
GLint m_mvp_matrix;
|
||||||
|
GLint m_input_size;
|
||||||
|
GLint m_output_size;
|
||||||
|
GLint m_texture_size;
|
||||||
|
GLint m_frame_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenGLOptions : public QObject {
|
class OpenGLOptions : public QObject {
|
||||||
@@ -65,7 +78,7 @@ public:
|
|||||||
bool vSync() const { return m_vsync; }
|
bool vSync() const { return m_vsync; }
|
||||||
FilterType filter() const;
|
FilterType filter() const;
|
||||||
|
|
||||||
QList<OpenGLShaderPass> shaders() const { return m_shaders; };
|
const QList<OpenGLShaderPass> &shaders() const { return m_shaders; };
|
||||||
|
|
||||||
void setRenderBehavior(RenderBehaviorType value);
|
void setRenderBehavior(RenderBehaviorType value);
|
||||||
void setFrameRate(int value);
|
void setFrameRate(int value);
|
||||||
@@ -73,7 +86,7 @@ public:
|
|||||||
void setFilter(FilterType value);
|
void setFilter(FilterType value);
|
||||||
void addShader(const QString &path);
|
void addShader(const QString &path);
|
||||||
void addDefaultShader();
|
void addDefaultShader();
|
||||||
void save();
|
void save() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RenderBehaviorType m_renderBehavior = SyncWithVideo;
|
RenderBehaviorType m_renderBehavior = SyncWithVideo;
|
||||||
|
@@ -40,7 +40,7 @@ OpenGLOptionsDialog::OpenGLOptionsDialog(QWidget *parent, const OpenGLOptions &o
|
|||||||
ui->vsync->setChecked(options.vSync());
|
ui->vsync->setChecked(options.vSync());
|
||||||
|
|
||||||
if (!options.shaders().isEmpty()) {
|
if (!options.shaders().isEmpty()) {
|
||||||
auto path = options.shaders().first().path;
|
auto path = options.shaders().first().path();
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
ui->shader->setPlainText(path);
|
ui->shader->setPlainText(path);
|
||||||
}
|
}
|
||||||
|
@@ -281,45 +281,45 @@ OpenGLRenderer::applyOptions()
|
|||||||
void
|
void
|
||||||
OpenGLRenderer::applyShader(const OpenGLShaderPass &shader)
|
OpenGLRenderer::applyShader(const OpenGLShaderPass &shader)
|
||||||
{
|
{
|
||||||
if (!shader.shader->bind())
|
if (!shader.bind())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (shader.vertex_coord != -1) {
|
if (shader.vertex_coord() != -1) {
|
||||||
glEnableVertexAttribArray(shader.vertex_coord);
|
glEnableVertexAttribArray(shader.vertex_coord());
|
||||||
glVertexAttribPointer(shader.vertex_coord, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0);
|
glVertexAttribPointer(shader.vertex_coord(), 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shader.tex_coord != -1) {
|
if (shader.tex_coord() != -1) {
|
||||||
glEnableVertexAttribArray(shader.tex_coord);
|
glEnableVertexAttribArray(shader.tex_coord());
|
||||||
glVertexAttribPointer(shader.tex_coord, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *) (2 * sizeof(GLfloat)));
|
glVertexAttribPointer(shader.tex_coord(), 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *) (2 * sizeof(GLfloat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shader.color != -1) {
|
if (shader.color() != -1) {
|
||||||
glEnableVertexAttribArray(shader.color);
|
glEnableVertexAttribArray(shader.color());
|
||||||
glVertexAttribPointer(shader.color, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *) (4 * sizeof(GLfloat)));
|
glVertexAttribPointer(shader.color(), 4, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *) (4 * sizeof(GLfloat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shader.mvp_matrix != -1) {
|
if (shader.mvp_matrix() != -1) {
|
||||||
static const GLfloat mvp[] = {
|
static const GLfloat mvp[] = {
|
||||||
1.f, 0.f, 0.f, 0.f,
|
1.f, 0.f, 0.f, 0.f,
|
||||||
0.f, 1.f, 0.f, 0.f,
|
0.f, 1.f, 0.f, 0.f,
|
||||||
0.f, 0.f, 1.f, 0.f,
|
0.f, 0.f, 1.f, 0.f,
|
||||||
0.f, 0.f, 0.f, 1.f
|
0.f, 0.f, 0.f, 1.f
|
||||||
};
|
};
|
||||||
glUniformMatrix4fv(shader.mvp_matrix, 1, GL_FALSE, mvp);
|
glUniformMatrix4fv(shader.mvp_matrix(), 1, GL_FALSE, mvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shader.output_size != -1)
|
if (shader.output_size() != -1)
|
||||||
glUniform2f(shader.output_size, destination.width(), destination.height());
|
glUniform2f(shader.output_size(), destination.width(), destination.height());
|
||||||
|
|
||||||
if (shader.input_size != -1)
|
if (shader.input_size() != -1)
|
||||||
glUniform2f(shader.input_size, source.width(), source.height());
|
glUniform2f(shader.input_size(), source.width(), source.height());
|
||||||
|
|
||||||
if (shader.texture_size != -1)
|
if (shader.texture_size() != -1)
|
||||||
glUniform2f(shader.texture_size, source.width(), source.height());
|
glUniform2f(shader.texture_size(), source.width(), source.height());
|
||||||
|
|
||||||
if (shader.frame_count != -1)
|
if (shader.frame_count() != -1)
|
||||||
glUniform1i(shader.frame_count, frameCounter);
|
glUniform1i(shader.frame_count(), frameCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user