(ndim=2, mipmap=False, minfilter=None, magfilter=None)
return buffer
Create a texture with the specifyed number of dimensions.
Create a texture with the specifyed number of dimensions.
Create a texture with the specifyed number of dimensions .
def create(ndim=2, mipmap=False, minfilter=None, magfilter=None):
        """Create a texture with the specifyed number of dimensions."""
        buffer = gl.glGenTextures(1)
        gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
        Texture.bind(buffer, ndim)
        textype = getattr(gl, "GL_TEXTURE_%dD" % ndim)
        gl.glTexParameteri(textype, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP)
        gl.glTexParameteri(textype, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP)
        
        if mipmap:
            if hasattr(gl, 'glGenerateMipmap'):
                gl.glGenerateMipmap(textype)
            else:
                minfilter = 'NEAREST'
                magfilter = 'NEAREST'
            
        if minfilter is None:
            minfilter = 'NEAREST'
        if magfilter is None:
            magfilter = 'NEAREST'
            
        minfilter = getattr(gl, 'GL_' + minfilter)
        magfilter = getattr(gl, 'GL_' + magfilter)
            
        gl.glTexParameteri(textype, gl.GL_TEXTURE_MIN_FILTER, minfilter)
        gl.glTexParameteri(textype, gl.GL_TEXTURE_MAG_FILTER, magfilter)
        
        return buffer
def create ( ndim = 2 , mipmap = False , minfilter = None , magfilter = None ) : buffer = gl . glGenTextures ( 1 ) gl . glPixelStorei ( gl . GL_UNPACK_ALIGNMENT , 1 ) Texture . bind ( buffer , ndim ) textype = getattr ( gl , "GL_TEXTURE_%dD" % ndim ) gl . glTexParameteri ( textype , gl . GL_TEXTURE_WRAP_S , gl . GL_CLAMP ) gl . glTexParameteri ( textype , gl . GL_TEXTURE_WRAP_T , gl . GL_CLAMP ) if mipmap : if hasattr ( gl , 'glGenerateMipmap' ) : gl . glGenerateMipmap ( textype ) else : minfilter = 'NEAREST' magfilter = 'NEAREST' if minfilter is None : minfilter = 'NEAREST' if magfilter is None : magfilter = 'NEAREST' minfilter = getattr ( gl , 'GL_' + minfilter ) magfilter = getattr ( gl , 'GL_' + magfilter ) gl . glTexParameteri ( textype , gl . GL_TEXTURE_MIN_FILTER , minfilter ) gl . glTexParameteri ( textype , gl . GL_TEXTURE_MAG_FILTER , magfilter ) return buffer