Подробности

[В начало]

Проблема в реализации № D0092

Краткое описание

Вызов функций glLighti, glLightf, glLightiv, glLightfv между вызовами glBegin и glEnd не генерирует ошибку GL_INVALID_OPERATION

Подробное описание

В документации сказано: "GL_INVALID_OPERATION is generated if glLight is executed between the execution of glBegin and the corresponding execution of glEnd.", но вызов функций glLighti, glLightf, glLightiv, glLightfv между glBegin и glEnd не генерирует ошибку GL_INVALID_OPERATION.

Раздел стандарта

Linux Standard Base Desktop Specification 3.2, Chapter 7. Libraries, 7.1.2.1 Interfaces for OpenGL, который ссылается на OpenGL-1.2.1 (see also http://www.opengl.org/sdk/docs/man/xhtml/glLight.xml)

Пример

#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);
    
    glLighti (GL_LIGHT0, GL_SPOT_EXPONENT, 10);
    
    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;
}

Компонент

Mesa 6.4

Принято

Mesa Bugzilla – Bug 17408

Статус

Исправлено в Mesa 7.2

[В начало]