예제 #1
0
static int
GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
{
    GLint compsize;
    GLenum format, type, target;
    GLboolean swapBytes;
    __GLXcontext *cx;
    ClientPtr client = cl->client;
    int error;

    __GLX_DECLARE_SWAP_VARIABLES;
    char *answer, answerBuffer[200];
    GLint width = 0;
    xGLXSingleReply reply = { 0, };

    cx = __glXForceCurrent(cl, tag, &error);
    if (!cx) {
        return error;
    }

    __GLX_SWAP_INT(pc + 0);
    __GLX_SWAP_INT(pc + 4);
    __GLX_SWAP_INT(pc + 8);

    format = *(GLenum *) (pc + 4);
    type = *(GLenum *) (pc + 8);
    target = *(GLenum *) (pc + 0);
    swapBytes = *(GLboolean *) (pc + 12);

    glGetColorTableParameteriv(target, GL_COLOR_TABLE_WIDTH, &width);
    /*
     * The one query above might fail if we're in a state where queries
     * are illegal, but then width would still be zero anyway.
     */
    compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
    if (compsize < 0)
        return BadLength;

    glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
    __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
    __glXClearErrorOccured();
    glGetColorTable(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
                    *(GLenum *) (pc + 8), answer);

    if (__glXErrorOccured()) {
        __GLX_BEGIN_REPLY(0);
        __GLX_SWAP_REPLY_HEADER();
    }
    else {
        __GLX_BEGIN_REPLY(compsize);
        __GLX_SWAP_REPLY_HEADER();
        __GLX_SWAP_INT(&width);
        ((xGLXGetColorTableReply *) &reply)->width = width;
        __GLX_SEND_VOID_ARRAY(compsize);
    }

    return Success;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBImaging_nglGetColorTable(JNIEnv *env, jclass clazz, jint target, jint format, jint type, jlong data, jlong function_pointer) {
    GLvoid *data_address = (GLvoid *)(intptr_t)data;
    glGetColorTablePROC glGetColorTable = (glGetColorTablePROC)((intptr_t)function_pointer);
    glGetColorTable(target, format, type, data_address);
}