예제 #1
0
def wrapPointerFunction(name, baseFunction, glType, arrayType,startArgs, defaultSize):
    """Wrap the given pointer-setting function"""
    function= wrapper.wrapper(baseFunction)
    if "ptr" in baseFunction.argNames:
        pointer_name = "ptr"
    else:
        pointer_name = "pointer"
    assert not getattr(function, "pyConverters", None), """Reusing wrappers?"""
    if arrayType:
        arrayModuleType = arraydatatype.GL_CONSTANT_TO_ARRAY_TYPE[ glType ]
        function.setPyConverter(pointer_name, arrayhelpers.asArrayType(arrayModuleType))
    else:
        function.setPyConverter(pointer_name, arrayhelpers.AsArrayOfType(pointer_name,"type"))
    function.setCConverter(pointer_name, converters.getPyArgsName(pointer_name))
    if "size" in function.argNames:
        function.setPyConverter("size")
        function.setCConverter("size", arrayhelpers.arraySizeOfFirstType(arrayModuleType,defaultSize))
    if "type" in function.argNames:
        function.setPyConverter("type")
        function.setCConverter("type", glType)
    if "stride" in function.argNames:
        function.setPyConverter("stride")
        function.setCConverter("stride", 0)
    function.setStoreValues(arrayhelpers.storePointerType(pointer_name, arrayType))
    function.setReturnValues(wrapper.returnPyArgument(pointer_name))
    return name,function
예제 #2
0
def wrapPointerFunction( name, baseFunction, glType, arrayType,startArgs, defaultSize ):
    """Wrap the given pointer-setting function"""
    function= wrapper.wrapper( baseFunction )
    if 'ptr' in baseFunction.argNames:
        pointer_name = 'ptr'
    else:
        pointer_name = 'pointer'
    assert not getattr( function, 'pyConverters', None ), """Reusing wrappers?"""
    if arrayType:
        arrayModuleType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ glType ]
        function.setPyConverter( pointer_name, arrays.asArrayType(arrayModuleType) )
    else:
        function.setPyConverter( pointer_name, arrays.AsArrayOfType(pointer_name,'type') )
    function.setCConverter( pointer_name, converters.getPyArgsName( pointer_name ) )
    if 'size' in function.argNames:
        function.setPyConverter( 'size' )
        function.setCConverter( 'size', arrays.arraySizeOfFirstType(arrayModuleType,defaultSize) )
    if 'type' in function.argNames:
        function.setPyConverter( 'type' )
        function.setCConverter( 'type', glType )
    if 'stride' in function.argNames:
        function.setPyConverter( 'stride' )
        function.setCConverter( 'stride', 0 )
    function.setStoreValues( arrays.storePointerType( pointer_name, arrayType ) )
    function.setReturnValues( wrapper.returnPyArgument( pointer_name ) )
    return name,function
예제 #3
0
def glDrawElementsTyped(type, suffix):
    arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[type]
    function = wrapper.wrapper(
        simple.glDrawElements).setPyConverter('type').setCConverter(
            'type', type).setPyConverter('count').setCConverter(
                'count',
                arrays.AsArrayTypedSize('indices', arrayType),
            ).setPyConverter(
                'indices',
                arrays.AsArrayTyped('indices', arrayType),
            ).setReturnValues(wrapper.returnPyArgument('indices'))
    return function
예제 #4
0
def glDrawElementsTyped(type, suffix):
    arrayType = arraydatatype.GL_CONSTANT_TO_ARRAY_TYPE[ type ]
    function = wrapper.wrapper(
        _simple.glDrawElements
   ).setPyConverter("type").setCConverter(
        "type", type
   ).setPyConverter("count").setCConverter(
        "count", arrayhelpers.AsArrayTypedSize("indices", arrayType),
   ).setPyConverter(
        "indices", arrayhelpers.AsArrayTyped("indices", arrayType),
   ).setReturnValues(
        wrapper.returnPyArgument("indices")
   )
    return function
예제 #5
0
def glDrawElementsTyped( type, suffix ):
    arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ type ]
    function = wrapper.wrapper(
        simple.glDrawElements
    ).setPyConverter('type').setCConverter(
        'type', type
    ).setPyConverter('count').setCConverter(
        'count', arrays.AsArrayTypedSize( 'indices', arrayType ),
    ).setPyConverter(
        'indices', arrays.AsArrayTyped( 'indices', arrayType ),
    ).setReturnValues(
        wrapper.returnPyArgument( 'indices' )
    )
    return function
예제 #6
0
for name,function in [
    wrapPointerFunction( *args )
    for args in POINTER_FUNCTION_DATA
]:
    globals()[name] = function
try:
    del name, function
except NameError, err:
    pass

glVertexPointer = wrapper.wrapper( simple.glVertexPointer ).setPyConverter(
    'pointer', arrays.AsArrayOfType( 'pointer', 'type' ),
).setStoreValues(
    arrays.storePointerType( 'pointer', simple.GL_VERTEX_ARRAY_POINTER )
).setReturnValues(
    wrapper.returnPyArgument( 'pointer' )
)
glTexCoordPointer = wrapper.wrapper( simple.glTexCoordPointer ).setPyConverter(
    'pointer', arrays.AsArrayOfType( 'pointer', 'type' ),
).setStoreValues(
    arrays.storePointerType( 'pointer', simple.GL_TEXTURE_COORD_ARRAY_POINTER )
).setReturnValues(
    wrapper.returnPyArgument( 'pointer' )
)
glNormalPointer = wrapper.wrapper( simple.glNormalPointer ).setPyConverter(
    'pointer', arrays.AsArrayOfType( 'pointer', 'type' ),
).setStoreValues(
    arrays.storePointerType( 'pointer', simple.GL_NORMAL_ARRAY_POINTER )
).setReturnValues(
    wrapper.returnPyArgument( 'pointer' )
)
예제 #7
0
'''OpenGL extension VERSION.GL_1_2

This module customises the behaviour of the 
OpenGL.raw.GL.VERSION.GL_1_2 to provide a more 
Python-friendly API

The official definition of this extension is available here:
http://www.opengl.org/registry/specs/VERSION/GL_1_2.txt
'''
from OpenGL import platform, constants, constant, arrays
from OpenGL import extensions, wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.VERSION.GL_1_2 import *
### END AUTOGENERATED SECTION
from OpenGL.GL.VERSION.GL_1_2_images import *

glDrawRangeElements = wrapper.wrapper( simple.glDrawRangeElements ).setPyConverter(
    'indices', arrays.AsArrayOfType( 'indices', 'type' ),
).setReturnValues(
    wrapper.returnPyArgument( 'indices' )
)
예제 #8
0
This module customises the behaviour of the 
OpenGL.raw.GL.ARB.occlusion_query to provide a more 
Python-friendly API
'''
from OpenGL import platform, constants, constant, arrays
from OpenGL import extensions, wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.ARB.occlusion_query import *
### END AUTOGENERATED SECTION
from OpenGL.GL import glget
from OpenGL import converters
for func in ('glGenQueriesARB','glDeleteQueriesARB'):
	globals()[func] = wrapper.wrapper( 
		globals()[func],
	).setPyConverter('n').setCConverter(
		'n', arrays.AsArrayTypedSize( 'ids', arrays.GLuintArray ),
	).setCConverter(
		'ids', arrays.asArrayType(arrays.GLuintArray),
	).setReturnValues(
		wrapper.returnPyArgument( 'ids' )
	)

for func in (
	'glGetQueryivARB','glGetQueryObjectivARB','glGetQueryObjectuivARB',
):
	globals()[func] = wrapper.wrapper(globals()[func]).setOutput(
		"params", (1,)
	)
del func, glget
예제 #9
0
)

glGenBuffersARB = wrapper.wrapper( glGenBuffersARB ).setOutput(
	'buffers', lambda n: (n,), 'n',
)

def _sizeOfArrayInput( pyArgs, index, wrapper ):
	return (
		arrays.ArrayDatatype.arrayByteCount( pyArgs[index] )
	)

glBufferDataARB = wrapper.wrapper( glBufferDataARB ).setPyConverter(
	'data', arrays.asVoidArray(),
).setPyConverter( 'size' ).setCResolver( 
	'data', arrays.ArrayDatatype.voidDataPointer ,
).setCConverter(
	'size', _sizeOfArrayInput,
).setReturnValues( 
	wrapper.returnPyArgument( 'data' ) 
)

glBufferSubDataARB = wrapper.wrapper( glBufferSubDataARB ).setPyConverter(
	'data', arrays.asVoidArray(),
).setPyConverter( 'size' ).setCResolver( 
	'data', arrays.ArrayDatatype.voidDataPointer ,
).setCConverter(
	'size', _sizeOfArrayInput,
).setReturnValues( 
	wrapper.returnPyArgument( 'data' ) 
)
OpenGL.raw.GL.EXT.draw_range_elements to provide a more 
Python-friendly API

The official definition of this extension is available here:
http://www.opengl.org/registry/specs/EXT/draw_range_elements.txt
'''
from OpenGL import platform, constant, arrays
from OpenGL import extensions, wrapper
import ctypes
from OpenGL.raw.GL import _types, _glgets
from OpenGL.raw.GL.EXT.draw_range_elements import *
from OpenGL.raw.GL.EXT.draw_range_elements import _EXTENSION_NAME


def glInitDrawRangeElementsEXT():
    '''Return boolean indicating whether this extension is available'''
    from OpenGL import extensions
    return extensions.hasGLExtension(_EXTENSION_NAME)


# INPUT glDrawRangeElementsEXT.indices size not checked against 'count,type'
glDrawRangeElementsEXT = wrapper.wrapper(
    glDrawRangeElementsEXT).setInputArraySize('indices', None)
### END AUTOGENERATED SECTION

glDrawRangeElementsEXT = wrapper.wrapper(
    glDrawRangeElementsEXT).setPyConverter(
        'indices',
        arrays.AsArrayOfType('indices', 'type'),
    ).setReturnValues(wrapper.returnPyArgument('indices'))
예제 #11
0
'''OpenGL extension ARB.draw_buffers

This module customises the behaviour of the 
OpenGL.raw.GL.ARB.draw_buffers to provide a more 
Python-friendly API
'''
from OpenGL import platform, constants, constant, arrays
from OpenGL import extensions, wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.ARB.draw_buffers import *
### END AUTOGENERATED SECTION
# This is untested...
glDrawBuffersARB = wrapper.wrapper( 
	glDrawBuffersARB,
).setPyConverter('n').setCConverter(
	'n', arrays.AsArrayTypedSize( 'bufs', arrays.GLenumArray ),
).setPyConverter(
	'bufs', arrays.AsArrayTyped( 'bufs', arrays.GLenumArray ),
).setCResolver( 
	'bufs', arrays.GLenumArray.dataPointer,
).setReturnValues(
	wrapper.returnPyArgument( 'bufs' )
)

from OpenGL.GL import glget
glget.addGLGetConstant( GL_MAX_DRAW_BUFFERS_ARB, (1,) )
# Should have output arrays for the buffers too???

예제 #12
0
for name, function in [
        wrapPointerFunction(*args) for args in POINTER_FUNCTION_DATA
]:
    globals()[name] = function
try:
    del name, function
except NameError as err:
    pass

glVertexPointer = wrapper.wrapper(simple.glVertexPointer).setPyConverter(
    'pointer',
    arrays.AsArrayOfType('pointer', 'type'),
).setStoreValues(
    arrays.storePointerType('pointer',
                            simple.GL_VERTEX_ARRAY_POINTER)).setReturnValues(
                                wrapper.returnPyArgument('pointer'))
glTexCoordPointer = wrapper.wrapper(simple.glTexCoordPointer).setPyConverter(
    'pointer',
    arrays.AsArrayOfType('pointer', 'type'),
).setStoreValues(
    arrays.storePointerType(
        'pointer', simple.GL_TEXTURE_COORD_ARRAY_POINTER)).setReturnValues(
            wrapper.returnPyArgument('pointer'))
glNormalPointer = wrapper.wrapper(simple.glNormalPointer).setPyConverter(
    'pointer',
    arrays.AsArrayOfType('pointer', 'type'),
).setStoreValues(
    arrays.storePointerType('pointer',
                            simple.GL_NORMAL_ARRAY_POINTER)).setReturnValues(
                                wrapper.returnPyArgument('pointer'))
glIndexPointer = wrapper.wrapper(simple.glIndexPointer).setPyConverter(
예제 #13
0
from OpenGL.raw.GL.ARB.vertex_buffer_object import *


def _sizeOfArrayInput(pyArgs, index, wrapper):
    return (
        # Was arraySize.
        arrays.ArrayDatatype.arrayByteCount(pyArgs[index]))


glBufferDataARB = wrapper.wrapper(glBufferDataARB).setPyConverter(
    'data',
    arrays.asVoidArray(),
).setPyConverter('size').setCResolver(
    'data',
    arrays.ArrayDatatype.voidDataPointer,
).setCConverter(
    'size',
    _sizeOfArrayInput,
).setReturnValues(wrapper.returnPyArgument('data'))

glBufferSubDataARB = wrapper.wrapper(glBufferSubDataARB).setPyConverter(
    'data',
    arrays.asVoidArray(),
).setPyConverter('size').setCResolver(
    'data',
    arrays.ArrayDatatype.voidDataPointer,
).setCConverter(
    'size',
    _sizeOfArrayInput,
).setReturnValues(wrapper.returnPyArgument('data'))
예제 #14
0
for name,function in [
    wrapPointerFunction(*args)
    for args in POINTER_FUNCTION_DATA
]:
    globals()[name] = function
try:
    del name, function
except NameError as err:
    pass

glVertexPointer = wrapper.wrapper(_simple.glVertexPointer).setPyConverter(
    "pointer", arrayhelpers.AsArrayOfType("pointer", "type"),
).setStoreValues(
    arrayhelpers.storePointerType("pointer", _simple.GL_VERTEX_ARRAY_POINTER)
).setReturnValues(
    wrapper.returnPyArgument("pointer")
)
glTexCoordPointer = wrapper.wrapper(_simple.glTexCoordPointer).setPyConverter(
    "pointer", arrayhelpers.AsArrayOfType("pointer", "type"),
).setStoreValues(
    arrayhelpers.storePointerType("pointer", _simple.GL_TEXTURE_COORD_ARRAY_POINTER)
).setReturnValues(
    wrapper.returnPyArgument("pointer")
)
glNormalPointer = wrapper.wrapper(_simple.glNormalPointer).setPyConverter(
    "pointer", arrayhelpers.AsArrayOfType("pointer", "type"),
).setStoreValues(
    arrayhelpers.storePointerType("pointer", _simple.GL_NORMAL_ARRAY_POINTER)
).setReturnValues(
    wrapper.returnPyArgument("pointer")
)
예제 #15
0
'''OpenGL extension ARB.draw_buffers

This module customises the behaviour of the 
OpenGL.raw.GL.ARB.draw_buffers to provide a more 
Python-friendly API
'''
from OpenGL import platform, constants, constant, arrays
from OpenGL import extensions, wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.ARB.draw_buffers import *
### END AUTOGENERATED SECTION
# This is untested...
glDrawBuffersARB = wrapper.wrapper(
    glDrawBuffersARB, ).setPyConverter('n').setCConverter(
        'n',
        arrays.AsArrayTypedSize('bufs', arrays.GLenumArray),
    ).setPyConverter(
        'bufs',
        arrays.AsArrayTyped('bufs', arrays.GLenumArray),
    ).setCResolver(
        'bufs',
        arrays.GLenumArray.dataPointer,
    ).setReturnValues(wrapper.returnPyArgument('bufs'))

from OpenGL.GL import glget
glget.addGLGetConstant(GL_MAX_DRAW_BUFFERS_ARB, (1, ))
# Should have output arrays for the buffers too???
예제 #16
0
OpenGL.raw.GL.EXT.draw_range_elements to provide a more 
Python-friendly API

The official definition of this extension is available here:
https://www.opengl.org/registry/specs/EXT/draw_range_elements.txt
"""
from OpenGL import platform, constant, arrays
from OpenGL import extensions, wrapper
import ctypes
from OpenGL.raw.GL import _types, _glgets
from OpenGL.raw.GL.EXT.draw_range_elements import *
from OpenGL.raw.GL.EXT.draw_range_elements import _EXTENSION_NAME


def glInitDrawRangeElementsEXT():
    """Return boolean indicating whether this extension is available"""
    from OpenGL import extensions
    return extensions.hasGLExtension(_EXTENSION_NAME)


# INPUT glDrawRangeElementsEXT.indices size not checked against "count,type"
glDrawRangeElementsEXT = wrapper.wrapper(
    glDrawRangeElementsEXT).setInputArraySize("indices", None)
# END AUTOGENERATED SECTION

glDrawRangeElementsEXT = wrapper.wrapper(
    glDrawRangeElementsEXT).setPyConverter(
        "indices",
        arrays.AsArrayOfType("indices", "type"),
    ).setReturnValues(wrapper.returnPyArgument("indices"))
예제 #17
0
	'buffers', lambda n: (n,), 'n',
)

def _sizeOfArrayInput( pyArgs, index, wrapper ):
	return (
		arrays.ArrayDatatype.arrayByteCount( pyArgs[index] )
	)

glBufferData = wrapper.wrapper( glBufferData ).setPyConverter(
	'data', arrays.asVoidArray(),
).setPyConverter( 'size' ).setCResolver( 
	'data', arrays.ArrayDatatype.voidDataPointer ,
).setCConverter(
	'size', _sizeOfArrayInput,
).setReturnValues( 
	wrapper.returnPyArgument( 'data' ) 
)

glBufferSubData = wrapper.wrapper( glBufferSubData ).setPyConverter(
	'data', arrays.asVoidArray(),
).setPyConverter( 'size' ).setCResolver( 
	'data', arrays.ArrayDatatype.voidDataPointer ,
).setCConverter(
	'size', _sizeOfArrayInput,
).setReturnValues( 
	wrapper.returnPyArgument( 'data' ) 
)

glGetBufferParameteriv = wrapper.wrapper(glGetBufferParameteriv).setOutput(
	"params",(1,),
)