Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: Probably a context problem

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    Probably a context problem

    I have wrote an application that uses selection mode ( glRenderMode(GL_SELECTION) ). It draws some objects, and user is able to point some of them by clicking them. Everything is ok, when I run it on my PC (Win XP + Radeon 9100), it also works fine on Win XP or Win2k + GeForceMX440. But… at school, on Win98 or XP (I don’t know graphic card) it fails to render correctly. It’s ok until user clicks to select sth, then graphics stops refreshing, wglMakeCurrent returns false. Problem is, I can’t write code and test it there, only at home, where it is running correctly, but I need it to work there. I would be very thankful for any suggestions.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586

    Re: Probably a context problem

    nah, if the code works fine on your home machine sounds more like a graphics card driver bug.

    find out what card you have in there and download the newest drivers for it (if you don't have install privileges get the lab guy/gal to install them).

  3. #3
    Guest

    Re: Probably a context problem

    Do something like this after you call SwapBuffers() to print out your errors:

    Code :
      GLenum  glerr = glGetError();
      while(glerr != GL_NO_ERROR) {
         printf("glGetError: %s\n",gluErrorString(glerr));
         glerr = glGetError();
      }

  4. #4
    Guest

    Re: Probably a context problem

    Or something like this:

    Code :
     switch(glerr) {
        case GL_NO_ERROR:
             printf( "GL_ERROR: GL_NO_ERROR");
             break;
        case GL_INVALID_ENUM:
             printf( "GL_ERROR: GL_INVALID_ENUM");
             break;
        case GL_INVALID_VALUE:
             printf( "GL_ERROR: GL_INVALID_VALUE");
             break;
        case GL_INVALID_OPERATION:
             printf( "GL_ERROR: GL_INVALID_OPERATION");
             break;
        case GL_STACK_OVERFLOW:
             printf( "GL_ERROR: GL_STACK_OVERFLOW");
             break;
        case GL_STACK_UNDERFLOW:
             printf( "GL_ERROR: GL_STACK_UNDERFLOW");
             break;
        case GL_OUT_OF_MEMORY:
             printf( "GL_ERROR: GL_OUT_OF_MEMORY");
             break;
        default:
             printf( "GL_ERROR: Unknown: %08X", glerr );
             break;
     }

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    Re: Probably a context problem

    I've added that code, and it returns GL_INVALID_OPERATION . What does it mean? I guess nothing good. What am I possibly doing wrong?

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    México.
    Posts
    7

    Re: Probably a context problem

    From: glRenderMode (blue book)
    GL_INVALID_OPERATION is generated if glSelectBuffer is called while the render mode is GL_SELECT, or if glRenderMode is called with argument GL_SELECT before glSelectBuffer is called at least once.
    Dont know what is it, but is a start.. I guess .

    But that can be clarificated a little looking at: glSelectBuffer
    OpenGL Blue Book OpenGL Reed Book

    I have obtained that links from a guy posting here too.

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    Re: Probably a context problem

    that what I call a concrete information. But I think my selection function is OK, as far as it goes for that part. I think I’ll just paste my rendering function, maybe I’m doing sth foolish. I’m quite new to OpenGL, so I’m not sure anything I’ doing. Here's the code:
    Code :
     void __fastcall TForm1 :: Render(void)
    {
    float xp,yp,zp;
     
    if (ApplicationClosing == true) return;
     
    if(wglMakeCurrent(hdc, hrc) == false)
            {
      	ShowMessage("Context lost.");
            Application->Terminate();
            }
     glMatrixMode( GL_MODELVIEW);
     
     glPushMatrix();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glLoadIdentity();
     glLightfv( GL_LIGHT0, GL_POSITION, swiatlo_position);
     
    glTranslatef(XTranslation,YTranslation,ZTranslation);
     glRotatef(angle+XRotation+float(XDelta),0,1,0);
     
     glInitNames();
     glPushName(0);
     
       for (unsigned int i = 1; i <= Scena->ObjectCount; i++)
            {
            if (ActiveMod >-1)
                    {
                    glPushMatrix();
                    glLoadIdentity;
     
                     glTranslatef(Form1->Modifiers[ActiveMod].Translation[Scena->Displays[i-1].SequenceID-1].X,
                                    Form1->Modifiers[ActiveMod].Translation[Scena->Displays[i-1].SequenceID-1].Y,
                                    Form1->Modifiers[ActiveMod].Translation[Scena->Displays[i-1].SequenceID-1].Z);
                    glTranslatef(Scena->ObjectList[i-1].Midpoint.X,
                                    Scena->ObjectList[i-1].Midpoint.Y,
                                    Scena->ObjectList[i-1].Midpoint.Z);
                    glRotatef(Form1->Modifiers[ActiveMod].Rotation[Scena->Displays[i-1].SequenceID-1].X,1,0,0);
                    glTranslatef(-Scena->ObjectList[i-1].Midpoint.X,
                                    -Scena->ObjectList[i-1].Midpoint.Y,
                                    -Scena->ObjectList[i-1].Midpoint.Z);
                    }
     
            if (i == Selected)     glColor3f(1,0.2,0.2);
            else            glColor3f(0.7,0.7,0.7);
                    if (i < 26)  glLoadName(i);
                    else         glLoadName(0xFF);
     
                    glCallList(i);
     
            if (ActiveMod >-1)
                    {
                    glPopMatrix();
                    }
            }
     
     glPopMatrix();
     glFlush();
     SwapBuffers(hdc);
     
    GLenum  glerr = glGetError();
    }

  8. #8
    Guest

    Re: Probably a context problem

    You have to put glGetError(); in a while loop until there are no errors left.
    See the OpenGL docs why.

    And you can put it anywhere in your code. The reason why I put mine after SwapBuffers()
    is because I use it as a one time 'catch-all errors' test. You can put it elsewhere
    and narrow in what command is causing your error.

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    Re: Probably a context problem

    Now it has occurred that glCallList(i) causes GL_INVALID_OPERATION, I have changed it to
    Code :
     if (glIsList(i)) glCallList(i)
    of course without any effect. Without calling displaylists there is GL_NO_ERROR. When calling a displaylist, it’s drawn correctly but there is a GL_INVALID_OPERATION. I’m greedy for further suggestions

  10. #10
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Probably a context problem

    Maybe the GL code in the display list that trigger the error ?
    Instead of calling the DL, just put the gl commands to find out which one generate the error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •