def createTexture(self, gl, width=None, height=None, wrapMode=QOpenGLTexture.ClampToEdge, format=QOpenGLTexture.RGBA8U, filter=QOpenGLTexture.Linear, filename=None, allocate=True, **kwparams): ''' Creates texture object with required parameters ''' assert width is not None or filename is not None if height is None: height = width if filename: texture = QOpenGLTexture(QImage('{}/{}'.format(Resources.directory, filename)).mirrored(), QOpenGLTexture.DontGenerateMipMaps) else: texture = QOpenGLTexture(QOpenGLTexture.Target2D) texture.setFormat(format) texture.setSize(width, height) if allocate: texture.allocateStorage() texture.setMinificationFilter(filter) texture.setMagnificationFilter(filter) texture.setWrapMode(wrapMode) assert texture.create() texture.bind() for k, v in kwparams.items(): gl.glTexParameteri(gl.GL_TEXTURE_2D, getattr(gl, k), v) texture.release() return texture