From 8a15cb91c4ee05b2098ee16c5fcd930b084f3150 Mon Sep 17 00:00:00 2001 From: Zakor Gyula Date: Wed, 17 Jul 2019 10:58:18 +0200 Subject: [PATCH] Add alpha option to bind_to_gl_texture --- io-surface/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io-surface/src/lib.rs b/io-surface/src/lib.rs index c416676..9f41566 100644 --- a/io-surface/src/lib.rs +++ b/io-surface/src/lib.rs @@ -22,7 +22,7 @@ use core_foundation::base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, CFType, TC use core_foundation::dictionary::{CFDictionary, CFDictionaryRef}; use core_foundation::string::{CFString, CFStringRef}; use cgl::{kCGLNoError, CGLGetCurrentContext, CGLTexImageIOSurface2D, CGLErrorString}; -use gleam::gl::{BGRA, GLenum, RGBA, TEXTURE_RECTANGLE_ARB, UNSIGNED_INT_8_8_8_8_REV}; +use gleam::gl::{BGRA, GLenum, RGB, RGBA, TEXTURE_RECTANGLE_ARB, UNSIGNED_INT_8_8_8_8_REV}; use libc::{c_int, size_t}; use std::os::raw::c_void; use leaky_cow::LeakyCow; @@ -120,12 +120,12 @@ impl IOSurface { } /// Binds to the current GL texture. - pub fn bind_to_gl_texture(&self, width: i32, height: i32) { + pub fn bind_to_gl_texture(&self, width: i32, height: i32, has_alpha: bool) { unsafe { let context = CGLGetCurrentContext(); let gl_error = CGLTexImageIOSurface2D(context, TEXTURE_RECTANGLE_ARB, - RGBA as GLenum, + if has_alpha { RGBA as GLenum } else { RGB as GLenum }, width, height, BGRA as GLenum,