我的 OpenGL|ES 2.0 glClear 命令会冻结,直到窗口状态发生变化(例如,窗口被隐藏或显示)。
目标平台是带有 Mali 400 GPU 的 ARM7。
所有代码大部分都从 Qt OpenGL ES Cube 示例中复制而来。
我忘记了什么?
莱昂
来源:#include“streamplayer.h”
#include <QtOpenGL>
#include <QGLFunctions>
StreamPlayer::StreamPlayer(QWidget *parent) :
QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
program = new QGLShaderProgram();
}
StreamPlayer::~StreamPlayer()
{
}
void StreamPlayer::initializeGL()
{
qDebug() << "Initializing GL";
initShaders();
glClearColor(0.5f, 0.5f, 0.7f, 1.0f);
return;
}
void StreamPlayer::paintGL()
{
qDebug() << "Paint GL";
qDebug() << "Clearing buffers";
glClear(GL_COLOR_BUFFER_BIT);
qDebug() << "Never comes here until a window state change";
}
void StreamPlayer::resizeGL(int width, int height)
{
qDebug() << "Resizing GL to " << width << "x" << height;
glViewport(0, 0, width, height);
qDebug() << "Done resizing";
}
void StreamPlayer::initShaders()
{
qDebug() << "Initializing shaders";
setlocale(LC_NUMERIC, "C");
if(!program->addShaderFromSourceFile(QGLShader::Vertex, ":/shaders/vshader.glsl")) {
qDebug() << "Failed to create vertex shader";
}
if(!program->addShaderFromSourceFile(QGLShader::Fragment, ":/shaders/fshader.glsl")) {
qDebug() << "Failed to create fragment shader";
}
if(!program->link()) {
qDebug() << "Failed to link";
}
_gl_vertex = program->attributeLocation("vertex");
_gl_texCoord = program->attributeLocation("texCoord");
_gl_matrix = program->attributeLocation("matrix");
_gl_texture = program->attributeLocation("tex");
if(!program->bind()) {
qDebug() << "Failed to bind";
}
setlocale(LC_ALL, "");
qDebug() << "Shaders ready";
}