~matobet/pyopengl/Python3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''OpenGL extension EXT.multi_draw_arrays

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

Overview (from the spec)
	
	These functions behave identically to the standard OpenGL 1.1 functions
	glDrawArrays() and glDrawElements() except they handle multiple lists of
	vertices in one call. Their main purpose is to allow one function call
	to render more than one primitive such as triangle strip, triangle fan,
	etc.

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

@lazy( glMultiDrawElementsEXT )
def glMultiDrawElementsEXT(baseOperation, primtype, counts, typ, indices, primcount=None):
    """Currently glMultiDrawElementsEXT is not working in the wrapper 
    
    We are replacing the code with a sequence of glDrawElements calls
    as per the spec for the function.  Basically we'd spend more effort
    making an array of array pointers than we would creating a simple
    iteration in Python.
    """
    if primcount is not None:
        for i in range( primcount ):
            glDrawElements( primtype, counts[i], typ, indices[i] )
    else:
        for c,i in zip( counts, indices ):
            glDrawElements( primtype, c, typ, i )

#def convertIndices( arg, wrappedOperation, args ):
#	"""Convert indices to an array of arrays"""
#	return [
#		arrays.ArrayDatatype.asArray( element, args[2] )
#		for element in arg
#	]
#def resolveIndices( value ):
#	pointers = []
#	for v in value:
#		pointers.append( arrays.ArrayDatatype.voidDataPointer( v ) )
#	typ = ctypes.POINTER(None) * len(value)
#	return typ( *pointers )
#
#glMultiDrawElementsEXT = wrapper.wrapper( glMultiDrawElementsEXT ).setPyConverter(
#	'indices', convertIndices,
#).setCResolver( 
#	'indices', resolveIndices,
#).setPyConverter(
#	'count', arrays.AsArrayTyped( 'count', arrays.GLsizeiArray ),
#).setCResolver(
#	'count', arrays.ArrayDatatype.voidDataPointer ,
#)