예제 #1
0
def glTexParameter( target, pname, parameter ):
    """Set a texture parameter, choose underlying call based on pname and parameter"""
    if isinstance( parameter, float ):
        return full.glTexParameterf( target, pname, parameter )
    elif isinstance( parameter, int ):
        return full.glTexParameteri( target, pname, parameter )
    else:
        value = GLfloatArray.asArray( parameter, full.GL_FLOAT )
        return full.glTexParameterfv( target, pname, value )
def glTexParameter( target, pname, parameter ):
    """Set a texture parameter, choose underlying call based on pname and parameter"""
    if isinstance( parameter, float ):
        return full.glTexParameterf( target, pname, parameter )
    elif isinstance( parameter, int ):
        return full.glTexParameteri( target, pname, parameter )
    else:
        value = GLfloatArray.asArray( parameter, full.GL_FLOAT )
        return full.glTexParameterfv( target, pname, value )
예제 #3
0
def glMaterial( faces, constant, *args ):
    """glMaterial -- convenience function to dispatch on argument type

    If passed a single argument in args, calls:
        glMaterialfv( faces, constant, args[0] )
    else calls:
        glMaterialf( faces, constant, *args )
    """
    if len(args) == 1:
        arg = GLfloatArray.asArray( args[0] )
        if arg is None:
            raise ValueError( """Null value in glMaterial: %s"""%(args,) )
        return full.glMaterialfv( faces, constant, arg )
    else:
        return full.glMaterialf( faces, constant, *args )
def glMaterial( faces, constant, *args ):
    """glMaterial -- convenience function to dispatch on argument type

    If passed a single argument in args, calls:
        glMaterialfv( faces, constant, args[0] )
    else calls:
        glMaterialf( faces, constant, *args )
    """
    if len(args) == 1:
        arg = GLfloatArray.asArray( args[0] )
        if arg is None:
            raise ValueError( """Null value in glMaterial: %s"""%(args,) )
        return full.glMaterialfv( faces, constant, arg )
    else:
        return full.glMaterialf( faces, constant, *args )
예제 #5
0
def createGetVertex():
    mode = contextdata.getValue("GL_FEEDBACK_BUFFER_TYPE")
    indexMode = _simple.glGetBooleanv(_simple.GL_INDEX_MODE)
    colorSize = [4, 1][int(indexMode)]
    if mode in (_simple.GL_2D, _simple.GL_3D):
        if mode == _simple.GL_2D:
            size = 2
        else:
            size = 3

        def getVertex(buffer, bufferIndex):
            end = bufferIndex + size
            return (buffer[bufferIndex:end], None, None), end
    elif mode == _simple.GL_3D_COLOR:

        def getVertex(buffer, bufferIndex):
            end = bufferIndex + 3
            colorEnd = end + colorSize
            return (buffer[bufferIndex:end], buffer[end:colorEnd],
                    None), colorEnd
    else:
        if mode == _simple.GL_3D_COLOR_TEXTURE:
            size = 3
        else:
            size = 4

        def getVertex(buffer, bufferIndex):
            end = bufferIndex + size
            colorEnd = end + colorSize
            textureEnd = colorEnd + 4
            return (buffer[bufferIndex:end], buffer[end:colorEnd],
                    buffer[colorEnd:textureEnd]), textureEnd

    return getVertex
예제 #6
0
def createGetVertex():
    mode = contextdata.getValue("GL_FEEDBACK_BUFFER_TYPE")
    indexMode = _simple.glGetBooleanv(_simple.GL_INDEX_MODE)
    colorSize = [4, 1][int(indexMode)]
    if mode in (_simple.GL_2D, _simple.GL_3D):
        if mode == _simple.GL_2D:
            size = 2
        else:
            size = 3

        def getVertex(buffer, bufferIndex):
            end = bufferIndex + size
            return (buffer[bufferIndex:end], None, None), end

    elif mode == _simple.GL_3D_COLOR:

        def getVertex(buffer, bufferIndex):
            end = bufferIndex + 3
            colorEnd = end + colorSize
            return (buffer[bufferIndex:end], buffer[end:colorEnd], None), colorEnd

    else:
        if mode == _simple.GL_3D_COLOR_TEXTURE:
            size = 3
        else:
            size = 4

        def getVertex(buffer, bufferIndex):
            end = bufferIndex + size
            colorEnd = end + colorSize
            textureEnd = colorEnd + 4
            return (buffer[bufferIndex:end], buffer[end:colorEnd], buffer[colorEnd:textureEnd]), textureEnd

    return getVertex
예제 #7
0
def glColor( *args ):
    """glColor*f* -- convenience function to dispatch on argument type

    dispatches to glColor3f, glColor2f, glColor4f, glColor3f, glColor2f, glColor4f
    depending on the arguments passed...
    """
    arglen = len(args)
    if arglen == 1:
        arg = arrays.GLfloatArray.asArray( args[0] )
        function = glColorDispatch[arrays.GLfloatArray.arraySize( arg )]
        return function( arg )
    elif arglen == 2:
        return full.glColor2d( *args )
    elif arglen == 3:
        return full.glColor3d( *args )
    elif arglen == 4:
        return full.glColor4d( *args )
    else:
        raise ValueError( """Don't know how to handle arguments: %s"""%(args,))
def glColor( *args ):
    """glColor*f* -- convenience function to dispatch on argument type

    dispatches to glColor3f, glColor2f, glColor4f, glColor3f, glColor2f, glColor4f
    depending on the arguments passed...
    """
    arglen = len(args)
    if arglen == 1:
        arg = arrays.GLfloatArray.asArray( args[0] )
        function = glColorDispatch[arrays.GLfloatArray.arraySize( arg )]
        return function( arg )
    elif arglen == 2:
        return full.glColor2d( *args )
    elif arglen == 3:
        return full.glColor3d( *args )
    elif arglen == 4:
        return full.glColor4d( *args )
    else:
        raise ValueError( """Don't know how to handle arguments: %s"""%(args,))