jshafferman
22nd March 2014, 01:24
I am trying to use raw OpenGL with Qt and I am trying to strictly use the Qt API to do so. I am using OpenGL 2.1 because that is our hardware limitation. I am able to build without any errors but the first instance of a gl* fails. The first opengl function is glGetIntergv(GL_ENUM, int*) and through the debugger I am able to see that is where I crash first. I am just curious if anyone can see what I am missing because my guess is I have to do something special to initialize these functions (which I thought initializeOpenGLFunctions() accomplished). Any help or direction would be great!!
I am subclassing with QOpenGLFunctions_2_1 like so:
class GLWidget : public QGLWidget, protected QOpenGLFunctions_2_1
These are the relevant source file functions
GLWidget::GLWidget(QWidget *parent) :
QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::Rgba | QGL::DepthBuffer),parent)
{
createActions();
createMenus();
}
void GLWidget::initializeGL()
{
initializeOpenGLFunctions();
pixels[0] = pixels[1] = pixels[2] = NULL;
frameGood[0] = frameGood[1] = frameGood[2] = GL_FALSE;
qDebug() << "Pixel Buffer Object Demo";
QGLFunctions funcs(QGLContext::currentContext());
bool isNonPowerTwo = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures) ;
// // Make sure required functionality is available!
// if (!GLEE_VERSION_2_1 && !GLEE_ARB_pixel_buffer_object)
// {
// qDebug() << "PBO extension is not available!";
//// fprintf(stderr, "PBO extension is not available!\n");
// Sleep(2000);
// exit(0);
// }
if (isNonPowerTwo)
{
npotTexturesAvailable = GL_TRUE;
}
else
{
qDebug() << "GL_ARB_texture_non_power_of_two extension is not available!";
qDebug() << "Only portion of window will be used for rendering";
}
// Check for minimum resources
GLint intVal = 0;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &intVal);
if (intVal < 3)
{
qDebug() << "Fewer than 3 texture units available!";
Sleep(2000);
exit(0);
}
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &intVal);
if (intVal < 1024)
{
qDebug() << "1024x1024 texture not supported!";
Sleep(2000);
exit(0);
}
qDebug() << "Controls:";
qDebug() << "\tRight-click for menu";
qDebug() << "\tb\tToggle motion blur";
qDebug() << "\tp\tToggle PBO usage";
qDebug() << "\tarrows\t+/- rotation speed";
qDebug() << "\tq\t\tExit demo";
// Colors
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glColor4f(0.0f, 0.0f, 0.0f, 1.0f );
// Texture matrix is the only one we'll change
glMatrixMode(GL_TEXTURE);
// Set up textures
SetupTextures();
}
And as stated above the first call to glGetIntergv is what fails :(. Any ideas?
I am subclassing with QOpenGLFunctions_2_1 like so:
class GLWidget : public QGLWidget, protected QOpenGLFunctions_2_1
These are the relevant source file functions
GLWidget::GLWidget(QWidget *parent) :
QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::Rgba | QGL::DepthBuffer),parent)
{
createActions();
createMenus();
}
void GLWidget::initializeGL()
{
initializeOpenGLFunctions();
pixels[0] = pixels[1] = pixels[2] = NULL;
frameGood[0] = frameGood[1] = frameGood[2] = GL_FALSE;
qDebug() << "Pixel Buffer Object Demo";
QGLFunctions funcs(QGLContext::currentContext());
bool isNonPowerTwo = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures) ;
// // Make sure required functionality is available!
// if (!GLEE_VERSION_2_1 && !GLEE_ARB_pixel_buffer_object)
// {
// qDebug() << "PBO extension is not available!";
//// fprintf(stderr, "PBO extension is not available!\n");
// Sleep(2000);
// exit(0);
// }
if (isNonPowerTwo)
{
npotTexturesAvailable = GL_TRUE;
}
else
{
qDebug() << "GL_ARB_texture_non_power_of_two extension is not available!";
qDebug() << "Only portion of window will be used for rendering";
}
// Check for minimum resources
GLint intVal = 0;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &intVal);
if (intVal < 3)
{
qDebug() << "Fewer than 3 texture units available!";
Sleep(2000);
exit(0);
}
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &intVal);
if (intVal < 1024)
{
qDebug() << "1024x1024 texture not supported!";
Sleep(2000);
exit(0);
}
qDebug() << "Controls:";
qDebug() << "\tRight-click for menu";
qDebug() << "\tb\tToggle motion blur";
qDebug() << "\tp\tToggle PBO usage";
qDebug() << "\tarrows\t+/- rotation speed";
qDebug() << "\tq\t\tExit demo";
// Colors
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glColor4f(0.0f, 0.0f, 0.0f, 1.0f );
// Texture matrix is the only one we'll change
glMatrixMode(GL_TEXTURE);
// Set up textures
SetupTextures();
}
And as stated above the first call to glGetIntergv is what fails :(. Any ideas?