I find that QGLShaderProgram sequentially fails to compile any shaders and does not provide an error log. Here are the symptoms:
- QGLShaderProgram reports that it could not compile, but creates an empty error log. If I try to bind a shader, an exception is thrown.
I can compile the shader using glCompileShaderwithout problems. However, the first time I try to compile this path after QGLShaderProgram failed, this error log does not work:
ERROR: error (# 270) Internal error: incorrect character table level
ERROR: 0: 2: error (# 232) Declaration of functions cannot occur inside functions:
main
ERROR: error (# 273) 2 compilation errors. Generated code
After this failure, the next time I try to compile with glCompileShader, it works fine.
The problem only occurred after upgrading from Qt 4.8 to 5.2. Nothing has changed on this machine.
- I tested on two PCs, one with an ATI Radeon HD 5700, the other with an AMD FirePro V7900. The problem only occurs on the Radeon PC.
Here is my test code showing the problem:
main.cpp
#include <QApplication>
#include "Test.h"
int main(int argc, char* argv[])
{
QApplication* app = new QApplication(argc, argv);
Drawer* drawer = new Drawer;
return app->exec();
}
test.h
#pragma once
#include <qobject>
#include <QTimer>
#include <QWindow>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
class Drawer : public QWindow, protected QOpenGLFunctions
{
Q_OBJECT;
public:
Drawer();
QTimer* mTimer;
QOpenGLContext* mContext;
int frame;
public Q_SLOTS:
void draw();
};
test.cpp
#include "Test.h"
#include <QGLShaderProgram>
#include <iostream>
#include <ostream>
using namespace std;
Drawer::Drawer()
: mTimer(new QTimer)
, mContext(new QOpenGLContext)
, frame(0)
{
mContext->create();
setSurfaceType(OpenGLSurface);
mTimer->setInterval(40);
connect(mTimer, SIGNAL(timeout()), this, SLOT(draw()));
mTimer->start();
show();
}
const char* vertex = "#version 110 \n void main() { gl_Position = gl_Vertex; }";
const char* fragment = "#version 110 \n void main() { gl_FragColor = vec4(0.0,0.0,0.0,0.0); }";
void Drawer::draw()
{
mContext->makeCurrent(this);
if (frame==0) {
initializeOpenGLFunctions();
}
if (frame < 5)
{
QGLShaderProgram* prog = new QGLShaderProgram;
bool f = prog->addShaderFromSourceCode(QGLShader::Fragment, fragment);
cout << "fragment "<<f<<endl;
bool v = prog->addShaderFromSourceCode(QGLShader::Vertex, vertex);
cout << "vertex "<<v<<endl;
bool link = prog->link();
cout << "link "<<link<<endl;
}
{
GLuint prog = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(prog, 1, &fragment, 0);
glCompileShader(prog);
GLint success = 0;
glGetShaderiv(prog, GL_COMPILE_STATUS, &success);
GLint logSize = 0;
glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &logSize);
GLchar* log = new char[8192];
glGetShaderInfoLog(prog, 8192, 0, log);
cout << "manual compile " << success << endl << log << endl;
delete[] log;
}
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
mContext->swapBuffers(this);
frame++;
}
Elsewhere, I tested QGLWidget and a project that uses GLEW instead of QOpenGLFunctions with exactly the same results.
Qt, , :
configure -developer-build -opensource -nomake examples -nomake tests -mp -opengl desktop -icu -confirm-license
? ?
Update
peppe:
1) QOpenGLDebugLogger?
, QOpenGLDebugLogger, -
QWindowsGLContext::getProcAddress: Unable to resolve 'glGetPointerv'
, ( , ). , mContext->hasExtension(QByteArrayLiteral("GL_KHR_debug")) true, draw() .
2) QOGLShaders, ?
QOpenGLShader QGLShader , . GL .
3) GL ? ( QSurfaceFormat).
3.0, 3.2, 4.2, .
4) , QSurfaceFormat , 5) ()
, .
, . , , , Mac Pro, Windows bootcamp. , ATI, , , - ATI, QOpenGLShaderProgram .
, , . !