~matobet/pyopengl/Python3

« back to all changes in this revision

Viewing changes to GL/EXT/multi_draw_arrays.py

  • Committer: matobet at gmail
  • Date: 2010-06-26 14:11:04 UTC
  • Revision ID: matobet@gmail.com-20100626141104-k011ofmltgiiu60g
Initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''OpenGL extension EXT.multi_draw_arrays
 
2
 
 
3
This module customises the behaviour of the 
 
4
OpenGL.raw.GL.EXT.multi_draw_arrays to provide a more 
 
5
Python-friendly API
 
6
 
 
7
Overview (from the spec)
 
8
        
 
9
        These functions behave identically to the standard OpenGL 1.1 functions
 
10
        glDrawArrays() and glDrawElements() except they handle multiple lists of
 
11
        vertices in one call. Their main purpose is to allow one function call
 
12
        to render more than one primitive such as triangle strip, triangle fan,
 
13
        etc.
 
14
 
 
15
The official definition of this extension is available here:
 
16
http://www.opengl.org/registry/specs/EXT/multi_draw_arrays.txt
 
17
'''
 
18
from OpenGL import platform, constants, constant, arrays
 
19
from OpenGL import extensions, wrapper
 
20
from OpenGL.GL import glget
 
21
import ctypes
 
22
from OpenGL.raw.GL.EXT.multi_draw_arrays import *
 
23
### END AUTOGENERATED SECTION
 
24
from OpenGL.lazywrapper import lazy
 
25
from OpenGL.GL.pointers import glDrawElements
 
26
 
 
27
@lazy( glMultiDrawElementsEXT )
 
28
def glMultiDrawElementsEXT(baseOperation, primtype, counts, typ, indices, primcount=None):
 
29
    """Currently glMultiDrawElementsEXT is not working in the wrapper 
 
30
    
 
31
    We are replacing the code with a sequence of glDrawElements calls
 
32
    as per the spec for the function.  Basically we'd spend more effort
 
33
    making an array of array pointers than we would creating a simple
 
34
    iteration in Python.
 
35
    """
 
36
    if primcount is not None:
 
37
        for i in range( primcount ):
 
38
            glDrawElements( primtype, counts[i], typ, indices[i] )
 
39
    else:
 
40
        for c,i in zip( counts, indices ):
 
41
            glDrawElements( primtype, c, typ, i )
 
42
 
 
43
#def convertIndices( arg, wrappedOperation, args ):
 
44
#       """Convert indices to an array of arrays"""
 
45
#       return [
 
46
#               arrays.ArrayDatatype.asArray( element, args[2] )
 
47
#               for element in arg
 
48
#       ]
 
49
#def resolveIndices( value ):
 
50
#       pointers = []
 
51
#       for v in value:
 
52
#               pointers.append( arrays.ArrayDatatype.voidDataPointer( v ) )
 
53
#       typ = ctypes.POINTER(None) * len(value)
 
54
#       return typ( *pointers )
 
55
#
 
56
#glMultiDrawElementsEXT = wrapper.wrapper( glMultiDrawElementsEXT ).setPyConverter(
 
57
#       'indices', convertIndices,
 
58
#).setCResolver( 
 
59
#       'indices', resolveIndices,
 
60
#).setPyConverter(
 
61
#       'count', arrays.AsArrayTyped( 'count', arrays.GLsizeiArray ),
 
62
#).setCResolver(
 
63
#       'count', arrays.ArrayDatatype.voidDataPointer ,
 
64
#)
 
 
b'\\ No newline at end of file'