Details

[Home]

Issue of the Implementation # D0091

Brief

Invocation of the interface glGetString between glBegin and glEnd does not generate GL_INVALID_OPERATION error

Detailed Description

The standard states: "GL_INVALID_OPERATION is generated if glGetString is executed between the execution of glBegin and the corresponding execution of glEnd.", but invocation of the interface glGetString(GL_VERSION) between glBegin and glEnd does not generate GL_INVALID_OPERATION error.

Problem location(s) in the standard

Linux Standard Base Desktop Specification 3.2, Chapter 7. Libraries, 7.1.2.1 Interfaces for OpenGL that refers OpenGL 1.2.1 (see also http://www.opengl.org/sdk/docs/man/xhtml/glGetString.xml)

Example

#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>

typedef struct _TGLWindow
{
    Display *dpy;
    GLXContext cx;
    XVisualInfo *vi;
    Window win;
    GLXWindow  glxWin;
    GLXFBConfig *fbConfigs;
    int width;
    int height;
} TGLWindow;

static int tSingleBuffer_1_2[] = {GLX_RGBA,
                                    GLX_RED_SIZE,       1,
                                    GLX_GREEN_SIZE,     1,
                                    GLX_BLUE_SIZE,      1,
                                    None};
static int tDoubleBuffer_1_2[] = {GLX_RGBA,
                                    GLX_DOUBLEBUFFER,
                                    GLX_RED_SIZE,       1,
                                    GLX_GREEN_SIZE,     1,
                                    GLX_BLUE_SIZE,      1,
                                    None};


static Bool WaitForNotify(Display *d, XEvent *e, char *arg) {
    if (e->type == CreateNotify)
    {
        printf("Window was successfully created.");
    }
    return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
}
TGLWindow tWnd;

int main() {
    int errBase = 0;
    int evtBase = 0;
    tWnd.dpy = NULL;
    tWnd.vi = NULL;
    tWnd.fbConfigs = NULL;
    tWnd.cx = 0;
    tWnd.height = 600;
    tWnd.width = 800;
    
    /* get a connection */
    tWnd.dpy = XOpenDisplay(0);

    if (!tWnd.dpy)
    {
        printf ("XOpenDisplay () returned NULL.");
        return -1;
    }
    if (glXQueryExtension(tWnd.dpy, &errBase, &evtBase) == GL_FALSE)
    {
        printf("The GLX extension is not supported by the server.");
        printf("error base is %d, event base is %d.", errBase, evtBase);
        return -1;
    }

    Colormap cmap;
    XSetWindowAttributes swa;
    XEvent event;
    int *attrList = tSingleBuffer_1_2;
    tWnd.vi = glXChooseVisual(tWnd.dpy, DefaultScreen(tWnd.dpy), attrList);
    if (tWnd.vi == NULL)
    {
        printf("glXChooseVisual() returned NULL");
        return -1;
    }

    /* create a GLX context */
    tWnd.cx = glXCreateContext(tWnd.dpy, tWnd.vi, 0, GL_TRUE);

    /* create a color map */
    cmap = XCreateColormap(tWnd.dpy, RootWindow(tWnd.dpy, tWnd.vi->screen),
                tWnd.vi->visual, AllocNone);

    /* create a window */
    swa.colormap = cmap;
    swa.border_pixel = 0;
    swa.event_mask = StructureNotifyMask;
    tWnd.win = XCreateWindow(tWnd.dpy, RootWindow(tWnd.dpy, tWnd.vi->screen), 0,
                          0, tWnd.width, tWnd.height,
                          0, tWnd.vi->depth, InputOutput,tWnd.vi->visual,
                          CWBorderPixel|CWColormap|CWEventMask,
                          &swa);
    XMapWindow(tWnd.dpy, tWnd.win);
    XIfEvent(tWnd.dpy, &event, WaitForNotify, (char*)tWnd.win);

    /* connect the context to the window */
    glXMakeCurrent(tWnd.dpy, tWnd.win, tWnd.cx);
    
    
    glBegin (GL_TRIANGLES);
    
    glGetString (GL_VERSION);
    
    glEnd ();
    
    GLenum err = glGetError ();
    
    if (err != GL_INVALID_OPERATION)
    {
        printf ("GL_INVALID_OPERATION(%d) error was not generated, "
            "glGetError() returned %d.", GL_INVALID_OPERATION, err);
    }
    else
    {
        printf ("GL_INVALID_OPERATION was generated, the interface works "
            "correctly.");
    }

    return 1;
}

Component

Mesa 6.4.1

Accepted

Mesa Bugzilla – Bug 17407

[Home]