Esempio n. 1
0
 def __enter__(self):
     for idx in self.state:
         texuint = 0
         if hasattr(idx, "__len__"):
             texunit = idx[1]
             idx = idx[0]
         if idx in self.ClientState:
             if idx == gl.GL_TEXTURE_COORD_ARRAY:
                 gl.glClientActiveTexture(GL_TEXTURE0 + texunit)
             gl.glEnableClientState(idx)
         else:
             gl.glEnable(idx)
Esempio n. 2
0
def draw_arrays(primitive, verts=None, colors=None, tc0=None, tc1=None, tc2=None, tc3=None):
    states = []
    if verts is not None:
        verts = ascont(verts)
        assert verts.ndim >= 2 and verts.shape[-1] <= 4
        gl.glVertexPointer( verts.shape[-1], arrayToGLType(verts), verts.strides[-2], verts.ctypes.data)
        states.append( gl.GL_VERTEX_ARRAY )
    if colors is not None:
        colors = ascont(colors)
        gl.glColorPointer( colors.shape[-1], arrayToGLType(colors), colors.strides[-2], colors.ctypes.data)
        states.append( gl.GL_COLOR_ARRAY )
    protect = []
    for i, tc in enumerate([tc0, tc1, tc2, tc3]):
        if tc is not None:
            tc = ascont(tc)
            protect.append(tc)
            gl.glClientActiveTexture(GL_TEXTURE0 + i) 
            gl.glTexCoordPointer(tc.shape[-1], arrayToGLType(tc), tc.strides[-2], tc.ctypes.data)
            states.append( (GL_TEXTURE_COORD_ARRAY, i) )
    with glstate(*states):
        gl.glDrawArrays( primitive, 0, np.prod(verts.shape[:-1]) )