Results 1 to 2 of 2

Thread: glGetError() always returns GL_INVALID_OPERATION

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    1

    glGetError() always returns GL_INVALID_OPERATION

    Hello,

    I'm trying to code a button that uses OpenGL and Qt for rendering. I am running into a problem where immediately after constructing the main window, I make a looped call to glGetError() to both check and clear any errors. I am doing this in hopes of troubleshooting why textures aren't being mapped to the button object. Either way, the texture isn't mapping and glGetError() always returns GL_INVALID_OPERATION any time I call it. Here is the source code:

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
    {
    while(glGetError() != GL_NO_ERROR)
    glGetError();//<-always returns GL_INVALID_OPERATION
    GLError glError = GLError();
    QString str = glError.checkGLErrors();
    .....

    void AiderButton::setTexture(const char *pTextureFileName)
    {
    texture = new QImage(QGLWidget::convertToGLFormat(QImage(pTextur eFileName)));
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1,&amp;textureID);
    glBindTexture(GL_TEXTURE_2D, textureID);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->texture->width(), this->texture->height(),
    0, GL_RGB, GL_UNSIGNED_BYTE, this->texture->bits());
    GLError glError = GLError();
    QString str = glError.checkGLErrors();
    QString str2 = str;
    }

    void AiderButton::render()
    {
    glPushAttrib(GL_POLYGON_BIT);
    glPushAttrib(GL_CURRENT_BIT);

    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
    QPointF ul = this->getCornerCoords(AiderButton::UPPER_LEFT);
    QPointF ur = this->getCornerCoords(AiderButton::UPPER_RIGHT);
    QPointF lr = this->getCornerCoords(AiderButton::LOWER_RIGHT);
    QPointF ll = this->getCornerCoords(AiderButton::LOWER_LEFT);

    if(this->texture != NULL)
    {
    glBindTexture(GL_TEXTURE_2D, textureID);
    }
    glBegin(GL_QUADS);
    glNormal3f(0.0f, 0.0f, 1.0f);
    glTexCoord2f(0.0f, 0.0f);glVertex3f(ll.x(), ll.y(), 0.0f);//lower left, tex-coord(0,1)
    glTexCoord2f(1.0f, 0.0f);glVertex3f(lr.x(), lr.y(), 0.0f);//lower right, tex-coord(1,1)
    glTexCoord2f(1.0f, 1.0f);glVertex3f(ur.x(), ur.y(), 0.0f);//upper right, tex-coord(1,0)
    glTexCoord2f(0.0f, 1.0f);glVertex3f(ul.x(),ul.y(), 0.0f); //upper left, tex-coord(0,0)
    glEnd();

    glPopAttrib();//GL_CURRENT_BIT
    glPopAttrib();//GL_POLYGON_BIT

    GLError glError = GLError();
    QString str = glError.checkGLErrors();
    }

    Any suggestions are greatly appreciated.

    Thank You

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    317

    Re: glGetError() always returns GL_INVALID_OPERATION

    OpenGL context not created or not made current. Each thread that wants to use OpenGL must have OpenGL context.

    For Qt, read QGLWidget docs.

Similar Threads

  1. glReadPixels returns GL_INVALID_OPERATION
    By Nayan Kumar K in forum OpenGL ES
    Replies: 1
    Last Post: 01-16-2012, 03:29 AM
  2. glGetError Always Returns GL_INVALID_OPERATION
    By masnu in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-08-2009, 08:39 PM
  3. glGetError joy
    By Jeff Russell in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 03-03-2008, 02:26 AM
  4. glGetError always returns zero
    By remdul in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 02-18-2008, 08:14 AM
  5. glGetError returns an error before any openGL call ?
    By Escondida in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-17-2003, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean