mirror of https://github.com/mgba-emu/mgba.git
Qt: Better error checking in mGLWidget
This commit is contained in:
parent
b1f1da4f7d
commit
5349cab4b2
|
@ -87,8 +87,14 @@ void mGLWidget::initializeGL() {
|
||||||
connect(&m_refresh, &QTimer::timeout, this, static_cast<void (QWidget::*)()>(&QWidget::update));
|
connect(&m_refresh, &QTimer::timeout, this, static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mGLWidget::finalizeVAO() {
|
bool mGLWidget::finalizeVAO() {
|
||||||
|
if (!context() || !m_vao) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
QOpenGLFunctions_Baseline* fn = context()->versionFunctions<QOpenGLFunctions_Baseline>();
|
QOpenGLFunctions_Baseline* fn = context()->versionFunctions<QOpenGLFunctions_Baseline>();
|
||||||
|
if (!fn) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
fn->glGetError(); // Clear the error
|
fn->glGetError(); // Clear the error
|
||||||
m_vao->bind();
|
m_vao->bind();
|
||||||
fn->glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
fn->glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||||
|
@ -98,6 +104,7 @@ void mGLWidget::finalizeVAO() {
|
||||||
if (fn->glGetError() == GL_NO_ERROR) {
|
if (fn->glGetError() == GL_NO_ERROR) {
|
||||||
m_vaoDone = true;
|
m_vaoDone = true;
|
||||||
}
|
}
|
||||||
|
return m_vaoDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mGLWidget::reset() {
|
void mGLWidget::reset() {
|
||||||
|
@ -105,8 +112,8 @@ void mGLWidget::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mGLWidget::paintGL() {
|
void mGLWidget::paintGL() {
|
||||||
if (!m_vaoDone) {
|
if (!m_vaoDone && !finalizeVAO()) {
|
||||||
finalizeVAO();
|
return;
|
||||||
}
|
}
|
||||||
QOpenGLFunctions_Baseline* fn = context()->versionFunctions<QOpenGLFunctions_Baseline>();
|
QOpenGLFunctions_Baseline* fn = context()->versionFunctions<QOpenGLFunctions_Baseline>();
|
||||||
m_program->bind();
|
m_program->bind();
|
||||||
|
|
|
@ -52,7 +52,7 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
void setTex(GLuint tex) { m_tex = tex; }
|
void setTex(GLuint tex) { m_tex = tex; }
|
||||||
void setVBO(GLuint vbo) { m_vbo = vbo; }
|
void setVBO(GLuint vbo) { m_vbo = vbo; }
|
||||||
void finalizeVAO();
|
bool finalizeVAO();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue