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

Remove support for the "image" library #1337

Merged
merged 1 commit into from
Nov 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove support for the "image" library
  • Loading branch information
tomaka committed Nov 21, 2015
commit 2438a3f17bf98ec0733d9c8712d24fbe2b4c559d
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
matrix:
- FEATURES='' TEST=0 COVERAGE=0
- FEATURES='glutin' TEST=1 COVERAGE=0
- FEATURES='glutin image cgmath nalgebra' TEST=1 COVERAGE=1
- FEATURES='glutin cgmath nalgebra' TEST=1 COVERAGE=1

addons:
apt:
Expand All @@ -41,7 +41,7 @@ after_success:
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
[ $TRAVIS_RUST_VERSION = nightly ] &&
cargo doc -j 1 --features "glutin image cgmath nalgebra" &&
cargo doc -j 1 --features "glutin cgmath nalgebra" &&
npm install gitbook-cli -g &&
gitbook build ./book &&
mv ./book/_book ./target/doc/book &&
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Unreleased

- Removed the "image" feature and native support for the `image`. You now have to perform conversions yourself.

## Version 0.11.1 (2015-11-10)

- Fix broken compilation after libc 0.2.
Expand Down
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build = "build/main.rs"
exclude = ["doc", ".travis.yml", "circle.yml"]

[features]
default = ["glutin", "image", "nalgebra", "cgmath"]
default = ["glutin", "nalgebra", "cgmath"]
unstable = [] # used for benchmarks

[dependencies.glutin]
Expand All @@ -39,10 +39,6 @@ optional = true
version = "0.3"
optional = true

[dependencies.image]
version = "0.4.0"
optional = true

[dependencies]
backtrace = "0.1.5"
lazy_static = "0.1"
Expand All @@ -56,5 +52,6 @@ khronos_api = "0.0.8"
[dev-dependencies]
clock_ticks = "0.1.0"
genmesh = "0.2.1"
image = "0.4.0"
obj = "0.2.1"
rand = "0.3"
4 changes: 3 additions & 1 deletion book/tuto-06-texture.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ In order to load the image, we just need to use `image::load`:
```rust
use std::io::Cursor;
let image = image::load(Cursor::new(&include_bytes!("/path/to/image.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
```

And in order to upload the image as a texture, it's as simple as:
Expand Down
4 changes: 3 additions & 1 deletion book/tuto-14-wall.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ Loading the texture is done like we have already done before:

```rust
let image = image::load(Cursor::new(&include_bytes!("../book/tuto-14-diffuse.jpg")[..]),
image::JPEG).unwrap();
image::JPEG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let diffuse_texture = glium::texture::SrgbTexture2d::new(&display, image).unwrap();
```

Expand Down
15 changes: 3 additions & 12 deletions examples/blitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@ extern crate rand;

#[macro_use]
extern crate glium;

#[cfg(feature = "image")]
extern crate image;

#[cfg(feature = "image")]
use std::io::Cursor;

#[cfg(feature = "image")]
use glium::{DisplayBuild, Surface};

use glium::glutin;

mod support;

#[cfg(not(feature = "image"))]
fn main() {
println!("This example requires the `image` feature to be enabled");
}

#[cfg(feature = "image")]
fn main() {
// building the display, ie. the main object
let display = glutin::WindowBuilder::new()
Expand All @@ -31,7 +20,9 @@ fn main() {

// building a texture with "OpenGL" drawn on it
let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let opengl_texture = glium::Texture2d::new(&display, image).unwrap();

// building a 1024x1024 empty texture
Expand Down
9 changes: 5 additions & 4 deletions examples/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
extern crate glium;
#[cfg(feature = "cgmath")]
extern crate cgmath;
#[cfg(feature = "image")]
extern crate image;

use glium::glutin;
Expand All @@ -14,12 +13,12 @@ use std::io::Cursor;

mod support;

#[cfg(not(all(feature = "cgmath", feature = "image")))]
#[cfg(not(feature = "cgmath"))]
fn main() {
println!("This example requires the `cgmath` and `image` features to be enabled");
}

#[cfg(all(feature = "cgmath", feature = "image"))]
#[cfg(feature = "cgmath")]
fn main() {
use glium::DisplayBuild;

Expand All @@ -30,7 +29,9 @@ fn main() {
.build_glium()
.unwrap();

let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]), image::PNG).unwrap();
let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]), image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let opengl_texture = glium::texture::Texture2d::new(&display, image).unwrap();

let floor_vertex_buffer = {
Expand Down
14 changes: 6 additions & 8 deletions examples/displacement_mapping.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#[cfg(feature = "image")]
extern crate image;

#[macro_use]
extern crate glium;

use glium::glutin;
#[cfg(feature = "image")]
use std::io::Cursor;
#[cfg(feature = "image")]
use glium::Surface;

mod support;

#[cfg(not(all(feature = "image", feature = "nalgebra")))]
#[cfg(not(feature = "nalgebra"))]
fn main() {
println!("This example requires the `image` feature to be enabled");
println!("This example requires the `nalgebra` feature to be enabled");
}

#[cfg(all(feature = "image", feature = "nalgebra"))]
#[cfg(feature = "nalgebra")]
fn main() {
use glium::DisplayBuild;

Expand All @@ -27,7 +23,9 @@ fn main() {
.unwrap();

let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let opengl_texture = glium::texture::CompressedSrgbTexture2d::new(&display, image).unwrap();

// building the vertex buffer, which contains all the vertices that we will draw
Expand Down
13 changes: 3 additions & 10 deletions examples/fullscreen.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
#[macro_use]
extern crate glium;

#[cfg(feature = "image")]
extern crate image;

#[cfg(feature = "image")]
use std::io::Cursor;

#[cfg(feature = "image")]
use glium::{DisplayBuild, Surface};
use glium::glutin;
use glium::index::PrimitiveType;

mod support;

#[cfg(not(feature = "image"))]
fn main() {
println!("This example requires the `image` feature to be enabled");
}

#[cfg(feature = "image")]
fn main() {
// building the display, ie. the main object
let display = glutin::WindowBuilder::new().build_glium().unwrap();

// building a texture with "OpenGL" drawn on it
let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let opengl_texture = glium::texture::CompressedTexture2d::new(&display, image).unwrap();

// building the vertex buffer, which contains all the vertices that we will draw
Expand Down
14 changes: 3 additions & 11 deletions examples/image.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
#[macro_use]
extern crate glium;

#[cfg(feature = "image")]
extern crate image;

#[cfg(feature = "image")]
use std::io::Cursor;

#[cfg(feature = "image")]
use glium::{DisplayBuild, Surface};
use glium::glutin;
use glium::index::PrimitiveType;

mod support;

#[cfg(not(feature = "image"))]
fn main() {
println!("This example requires the `image` feature to be enabled");
}

#[cfg(feature = "image")]
fn main() {
// building the display, ie. the main object
let display = glutin::WindowBuilder::new()
Expand All @@ -29,7 +19,9 @@ fn main() {

// building a texture with "OpenGL" drawn on it
let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let opengl_texture = glium::texture::CompressedSrgbTexture2d::new(&display, image).unwrap();

// building the vertex buffer, which contains all the vertices that we will draw
Expand Down
12 changes: 3 additions & 9 deletions examples/screenshot.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
#[macro_use]
extern crate glium;

#[cfg(feature = "image")]
extern crate image;

use glium::Surface;
use glium::glutin;
use glium::index::PrimitiveType;
use std::path::Path;

#[cfg(not(feature = "image"))]
fn main() {
println!("You need to compile glium with the `image` feature in order to run this example");
}

#[cfg(feature = "image")]
fn main() {
use glium::DisplayBuild;

Expand Down Expand Up @@ -124,7 +116,9 @@ fn main() {
target.finish().unwrap();

// reading the front buffer into an image
let image: image::DynamicImage = display.read_front_buffer();
let image: glium::texture::RawImage2d<u8> = display.read_front_buffer();
let image = image::ImageBuffer::from_raw(image.width, image.height, image.data.into_owned()).unwrap();
let image = image::DynamicImage::ImageRgba8(image);
let mut output = std::fs::File::create(&Path::new("glium-example-screenshot.png")).unwrap();
image.save(&mut output, image::ImageFormat::PNG).unwrap();
}
9 changes: 3 additions & 6 deletions examples/tutorial-06.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#[macro_use]
extern crate glium;

#[cfg(feature = "image")]
extern crate image;

use std::io::Cursor;

#[cfg(not(feature = "image"))]
fn main() { println!("This example requires the `image` feature to be enabled"); }
#[cfg(feature = "image")]
fn main() {
use glium::{DisplayBuild, Surface};
let display = glium::glutin::WindowBuilder::new().build_glium().unwrap();

let image = image::load(Cursor::new(&include_bytes!("../tests/fixture/opengl.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let texture = glium::texture::Texture2d::new(&display, image).unwrap();

#[derive(Copy, Clone)]
Expand Down
12 changes: 6 additions & 6 deletions examples/tutorial-14.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#[macro_use]
extern crate glium;
#[cfg(feature = "image")]
extern crate image;

use std::io::Cursor;

#[cfg(not(feature = "image"))]
fn main() { println!("This example requires the `image` feature to be enabled"); }
#[cfg(feature = "image")]
fn main() {
use glium::{DisplayBuild, Surface};
let display = glium::glutin::WindowBuilder::new()
Expand All @@ -33,11 +29,15 @@ fn main() {


let image = image::load(Cursor::new(&include_bytes!("../book/tuto-14-diffuse.jpg")[..]),
image::JPEG).unwrap();
image::JPEG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let diffuse_texture = glium::texture::SrgbTexture2d::new(&display, image).unwrap();

let image = image::load(Cursor::new(&include_bytes!("../book/tuto-14-normal.png")[..]),
image::PNG).unwrap();
image::PNG).unwrap().to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(image.into_raw(), image_dimensions);
let normal_map = glium::texture::Texture2d::new(&display, image).unwrap();


Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ extern crate lazy_static;

#[cfg(feature = "cgmath")]
extern crate cgmath;
#[cfg(feature = "image")]
extern crate image;
extern crate libc;
#[cfg(feature = "nalgebra")]
extern crate nalgebra;
Expand Down
Loading