Esempio n. 1
0
def create_image_texture(filepath):
    img = cv2.imread(filepath)[::-1]
    h, w = img.shape[:2]
    texture = Texture2D()
    with texture:
        texture.set_params(LINEAR_LINEAR + CLAMP_TO_EDGE + NO_MIPMAPING + [(GL_TEXTURE_BORDER_COLOR, [0.0, 0.0, 0.0, 0.0])])
        with configure_pixel_store([(GL_UNPACK_ALIGNMENT, 1)]):
            glTexImage2D(texture.target, 0, GL_RGBA, w, h, 0, {3: GL_BGR, 4: GL_BGRA}[img.shape[2]], GL_UNSIGNED_BYTE, img)
    return texture
Esempio n. 2
0
def create_image_texture(filepath):
    img = _np.array(load_image(filepath))
    assert img is not None
    h, w = img.shape[:2]
    texture = Texture2D()
    with texture:
        texture.set_params(LINEAR_LINEAR + CLAMP_TO_EDGE + NO_MIPMAPING + [(GL_TEXTURE_BORDER_COLOR, [0.0, 0.0, 0.0, 0.0])])
        with configure_pixel_store([(GL_UNPACK_ALIGNMENT, 1)]):
            glTexImage2D(texture.target, 0, GL_RGBA, w, h, 0, {3: GL_RGB, 4: GL_RGBA}[img.shape[2]], GL_UNSIGNED_BYTE, img[::-1])
    return texture
Esempio n. 3
0
def create_image_texture(filepath):
    img = _np.array(load_image(filepath))
    assert img is not None
    h, w = img.shape[:2]
    texture = Texture2D()
    with texture:
        texture.set_params(LINEAR_LINEAR + CLAMP_TO_EDGE + NO_MIPMAPING +
                           [(GL_TEXTURE_BORDER_COLOR, [0.0, 0.0, 0.0, 0.0])])
        with configure_pixel_store([(GL_UNPACK_ALIGNMENT, 1)]):
            glTexImage2D(texture.target, 0, GL_RGBA, w, h, 0, {
                3: GL_RGB,
                4: GL_RGBA
            }[img.shape[2]], GL_UNSIGNED_BYTE, img[::-1])
    return texture