Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL_TEXTURE_RECTANGLE texture target support #997

Merged
merged 4 commits into from Mar 30, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add new TextureTarget::Rect texture target type for external image Te…

…xtureRectHandle.
  • Loading branch information
JerryShih committed Mar 30, 2017
commit 1305f38cbff082e07f9a015e2812237cfa4cda9f
@@ -51,6 +51,17 @@ pub enum DepthFunction {
pub enum TextureTarget {
Default,
Array,
Rect,
}

impl TextureTarget {
pub fn to_gl_target(&self) -> gl::GLuint {
match *self {
TextureTarget::Default => gl::TEXTURE_2D,
TextureTarget::Array => gl::TEXTURE_2D_ARRAY,
TextureTarget::Rect => gl::TEXTURE_RECTANGLE,
}
}
}

#[derive(Copy, Clone, Debug, PartialEq)]
@@ -304,10 +315,10 @@ impl TextureId {
gl.bind_texture(self.target, self.name);
}

pub fn new(name: gl::GLuint) -> TextureId {
pub fn new(name: gl::GLuint, texture_target: TextureTarget) -> TextureId {
TextureId {
name: name,
target: gl::TEXTURE_2D,
target: texture_target.to_gl_target(),
}
}

@@ -1090,15 +1101,10 @@ impl Device {
let id_list = self.gl.gen_textures(count);
let mut texture_ids = Vec::new();

let target = match target {
TextureTarget::Default => gl::TEXTURE_2D,
TextureTarget::Array => gl::TEXTURE_2D_ARRAY,
};

for id in id_list {
let texture_id = TextureId {
name: id,
target: target,
target: target.to_gl_target(),
};

let texture = Texture {
@@ -1675,9 +1675,17 @@ impl Renderer {
let ext_image = props.external_image
.expect("BUG: Deferred resolves must be external images!");
let image = handler.lock(ext_image.id);
let texture_target = match ext_image.image_type {
ExternalImageType::Texture2DHandle => TextureTarget::Default,
ExternalImageType::TextureRectHandle => TextureTarget::Rect,
_ => {
panic!("{:?} is not a suitable image type in update_deferred_resolves().",
ext_image.image_type);
}
};

let texture_id = match image.source {
ExternalImageSource::NativeTexture(texture_id) => TextureId::new(texture_id),
ExternalImageSource::NativeTexture(texture_id) => TextureId::new(texture_id, texture_target),
_ => panic!("No native texture found."),
};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.