Example #1
0
def glRenderMode(newMode):
    """Change to the given rendering mode

    If the current mode is GL_FEEDBACK or GL_SELECT, return
    the current buffer appropriate to the mode
    """
    # must get the current mode to determine operation...
    from OpenGL.GL import glGetIntegerv
    from OpenGL.GL import selection, feedback
    currentMode = glGetIntegerv(simple.GL_RENDER_MODE)
    try:
        currentMode = currentMode[0]
    except (TypeError, ValueError, IndexError) as err:
        pass
    if currentMode in (simple.GL_RENDER, 0):
        # no array needs to be returned...
        return simple.glRenderMode(newMode)
    result = simple.glRenderMode(newMode)
    # result is now an integer telling us how many elements were copied...

    if result < 0:
        if currentMode == simple.GL_SELECT:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "glSelectBuffer too small to hold selection results",
            )
        elif currentMode == simple.GL_FEEDBACK:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "glFeedbackBuffer too small to hold selection results",
            )
        else:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "Unknown glRenderMode buffer (%s) too small to hold selection results"
                % (currentMode, ),
            )
    # Okay, now that the easy cases are out of the way...
    #  Do we have a pre-stored pointer about which the user already knows?
    context = platform.GetCurrentContext()
    if context == 0:
        raise error.Error(
            """Returning from glRenderMode without a valid context!""")
    arrayConstant, wrapperFunction = {
        simple.GL_FEEDBACK:
        (simple.GL_FEEDBACK_BUFFER_POINTER, feedback.parseFeedback),
        simple.GL_SELECT: (simple.GL_SELECTION_BUFFER_POINTER,
                           selection.GLSelectRecord.fromArray),
    }[currentMode]
    current = contextdata.getValue(arrayConstant)
    # XXX check to see if it's the *same* array we set currently!
    if current is None:
        current = glGetPointerv(arrayConstant)
    # XXX now, can turn the array into the appropriate wrapper type...
    if wrapperFunction:
        current = wrapperFunction(current, result)
    return current
Example #2
0
def glRenderMode( newMode ):
    """Change to the given rendering mode

    If the current mode is GL_FEEDBACK or GL_SELECT, return
    the current buffer appropriate to the mode
    """
    # must get the current mode to determine operation...
    from OpenGL.GL import glGetIntegerv
    from OpenGL.GL import selection, feedback
    currentMode = glGetIntegerv( simple.GL_RENDER_MODE )
    try:
        currentMode = currentMode[0]
    except (TypeError,ValueError,IndexError) as err:
        pass
    if currentMode in (simple.GL_RENDER,0):
        # no array needs to be returned...
        return simple.glRenderMode( newMode )
    result = simple.glRenderMode( newMode )
    # result is now an integer telling us how many elements were copied...

    if result < 0:
        if currentMode == simple.GL_SELECT:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "glSelectBuffer too small to hold selection results",
            )
        elif currentMode == simple.GL_FEEDBACK:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "glFeedbackBuffer too small to hold selection results",
            )
        else:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "Unknown glRenderMode buffer (%s) too small to hold selection results"%(
                    currentMode,
                ),
            )
    # Okay, now that the easy cases are out of the way...
    #  Do we have a pre-stored pointer about which the user already knows?
    context = platform.GetCurrentContext()
    if context == 0:
        raise error.Error(
            """Returning from glRenderMode without a valid context!"""
        )
    arrayConstant, wrapperFunction = {
        simple.GL_FEEDBACK: (simple.GL_FEEDBACK_BUFFER_POINTER,feedback.parseFeedback),
        simple.GL_SELECT: (simple.GL_SELECTION_BUFFER_POINTER, selection.GLSelectRecord.fromArray),
    }[ currentMode ]
    current = contextdata.getValue( arrayConstant )
    # XXX check to see if it's the *same* array we set currently!
    if current is None:
        current = glGetPointerv( arrayConstant )
    # XXX now, can turn the array into the appropriate wrapper type...
    if wrapperFunction:
        current = wrapperFunction( current, result )
    return current
Example #3
0
    """Change to the given rendering mode

    If the current mode is GL_FEEDBACK or GL_SELECT, return
    the current buffer appropriate to the mode
    """
    # must get the current mode to determine operation...
    from OpenGL.GL import glGetIntegerv
    from OpenGL.GL import selection, feedback
    currentMode = glGetIntegerv( simple.GL_RENDER_MODE )
    try:
        currentMode = currentMode[0]
    except (TypeError,ValueError,IndexError), err:
        pass
    if currentMode in (simple.GL_RENDER,0):
        # no array needs to be returned...
        return simple.glRenderMode( newMode )
    result = simple.glRenderMode( newMode )
    # result is now an integer telling us how many elements were copied...

    if result < 0:
        if currentMode == simple.GL_SELECT:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "glSelectBuffer too small to hold selection results",
            )
        elif currentMode == simple.GL_FEEDBACK:
            raise error.GLError(
                simple.GL_STACK_OVERFLOW,
                "glFeedbackBuffer too small to hold selection results",
            )
        else: