Skip to content

Commit

Permalink
Merge #1417
Browse files Browse the repository at this point in the history
1417: Move examples to explicit gfx_support crate/module. Also move to virtual cargo workspace. r=kvark

I noticed [this issue about gfx_app](#922) has pretty much stopped, when I was just looking, and realized the exact same thing had been confusing me trying to learn gfx. In the thread, it was brought up maybe it was a good idea to move gfx_app to it's own module, to help users with learning the API (whom are reading the example code).

Since progress has slowed down in [the PR for cargo workspaces](#1250) I thought I would submit this as *some* progress. I thought it was good timing since the last commit to the gfx repository just accepted a [pull-request doing a similar rename](d1e99ce), it seems smart to do another rename pull-request like this (since others maintaining branches will already need to rebase). I could be wrong about this, but the alternative would for me to sit back and wait until another point in the future to do this.

I think renaming gfx_app to gfx_support, and more importantly moving the code out of gfx's root (and under examples/) will help users understand what is "gfx library code" vs "gfx support library code". The distinction is subtle but important, I believe. It certainty wasn't clear to me until quite a while of digging by myself.

I have a few things I'd like to discuss moving forward, this pull request certainly isn't ready as is.
1. I'd like to gather consensus that this is the right direction to move gfx. Are there any objections to the direction of this pull-request?
2. Is gfx_project a good name for the "root project"?
3. I'm not sure that duplicating the Cargo.toml file is the right way to express what I'm intending. Right now I'm duplicating the dependencies section in both Cargo.toml files.  Apart from going through each dependency one-by-one, and seeing whether examples/ or gfx/ requires the dependency, is there a way to not duplicate the dependencies your aware of? Is duplicating them a problem?
4. In the other thread glium was brought up as an example, in glium's example code, the helper code lives in the [examples/support/](https://github.com/glium/glium/tree/master/examples/support) directory, causing all examples to have to add  [explicitly mod support it](https://github.com/glium/glium/blob/master/examples/deferred.rs#L10). I tried emulating the same setup, but I wasn't able to get it to compile. I would need to spend more time comparing with the glium project to emulate that setup.
5. I need to try using the support code from another package, to make sure it's visible the way I think it should be. This is a TODO.

Anyways, I stole this list from the other thread. Here is what is working:

cargo build
cargo run --example (they all seem to work)

What is not working:

cargo test -- this isn't working for me on master/, not completely sure abouit this one.
cargo build --all (error: native frameworks are only available on macOS targets)
cargo test --all (error: Could not compile `core-foundation-sys`)

Pretty tired now when writing this up, so posting this looking to get some direction/guidance to move forward with this change. 

edit:
Resolves:
* #1248
* #1424
  • Loading branch information
bors[bot] committed Aug 17, 2017
2 parents 9e9a330 + 08b2624 commit bc2f8be
Show file tree
Hide file tree
Showing 261 changed files with 762 additions and 405 deletions.
182 changes: 24 additions & 158 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,158 +1,24 @@
[package]
name = "gfx_app"
version = "0.7.0"
description = "GFX example application framework"
homepage = "https://github.com/gfx-rs/gfx"
keywords = ["graphics", "gamedev"]
license = "Apache-2.0"
authors = ["The Gfx-rs Developers"]
documentation = "https://docs.rs/gfx_app"
exclude = ["bors.toml", ".travis.yml"]

[features]
default = ["gl"]
mint = ["gfx/mint", "gfx_core/mint"]
metal = ["gfx_device_metal", "gfx_window_metal", "gfx_device_metalll"]
metal_argument_buffer = ["gfx_device_metalll/argument_buffer"]
gl = ["gfx_device_gl", "gfx_window_glutin"]
dx11 = ["gfx_device_dx11", "gfx_window_dxgi"]
dx12 = ["gfx_device_dx12", "gfx_window_dxgi"]
vulkan = ["gfx_device_vulkan", "gfx_device_vulkanll", "gfx_window_vulkan"]
sdl = ["gfx_window_sdl"]
serialize = ["gfx/serialize", "gfx_core/serialize"]
headless = ["gfx_window_glutin/headless"]
unstable = []

[lib]
name = "gfx_app"

[dependencies]
log = "0.3"
env_logger = "0.4"
glutin = "0.9"
winit = "0.7"
gfx_core = { path = "src/core", version = "0.7.1" }
gfx_corell = { path = "src/corell", version = "0.1" }
gfx = { path = "src/render", version = "0.16" }
gfx_macros = { path = "src/macros", version = "0.2" }

gfx_device_gl = { path = "src/backend/gl", version = "0.14", optional = true }
gfx_window_glutin = { path = "src/window/glutin", version = "0.17", optional = true }

[dependencies.gfx_device_vulkan]
path = "src/backend/vulkan"
version = "0.2"
optional = true

[dependencies.gfx_device_vulkanll]
path = "src/backend/vulkanll"
version = "0.1"
optional = true

[dependencies.gfx_window_vulkan]
path = "src/window/vulkan"
version = "0.3"
optional = true

[dependencies.gfx_device_metal]
path = "src/backend/metal"
version = "0.3"
optional = true

[dependencies.gfx_window_metal]
path = "src/window/metal"
version = "0.4"
optional = true

[dependencies.gfx_device_metalll]
path = "src/backend/metalll"
version = "0.2"
optional = true
#features = ["native_fence"]

[dependencies.gfx_window_sdl]
path = "src/window/sdl"
version = "0.7"
optional = true

[target.'cfg(unix)'.dependencies]
gfx_window_glfw = { path = "src/window/glfw", version = "0.15" }
gfx_window_sdl = { path = "src/window/sdl", version = "0.7" }

[target.'cfg(windows)'.dependencies]
gfx_device_dx11 = { path = "src/backend/dx11", version = "0.6", optional = true }
gfx_device_dx12 = { path = "src/backend/dx12", version = "0.1", optional = true }
gfx_window_dxgi = { path = "src/window/dxgi", version = "0.9", optional = true }
gfx_device_dx12ll = { path = "src/backend/dx12ll", version = "0.1" }

[[example]]
name = "blend"
path = "examples/blend/main.rs"

[[example]]
name = "cube"
path = "examples/cube/main.rs"

[[example]]
name = "deferred"
path = "examples/deferred/main.rs"

[[example]]
name = "flowmap"
path = "examples/flowmap/main.rs"

[[example]]
name = "gamma"
path = "examples/gamma/main.rs"

[[example]]
name = "performance"
path = "examples/performance/main.rs"

[[example]]
name = "shadow"
path = "examples/shadow/main.rs"

[[example]]
name = "skybox"
path = "examples/skybox/main.rs"

[[example]]
name = "terrain"
path = "examples/terrain/main.rs"

[[example]]
name = "terrain_tessellated"
path = "examples/terrain_tessellated/main.rs"

[[example]]
name = "triangle"
path = "examples/triangle/main.rs"

[[example]]
name = "instancing"
path = "examples/instancing/main.rs"

[[example]]
name = "ubo_tilemap"
path = "examples/ubo_tilemap/main.rs"

[[example]]
name = "mipmap"
path = "examples/mipmap/main.rs"

[[example]]
name = "particle"
path = "examples/particle/main.rs"

[[example]]
name = "trianglell"
path = "examples/trianglell/main.rs"

[dev-dependencies]
cgmath = "0.15"
gfx_gl = "0.3"
rand = "0.3"
genmesh = "0.5"
noise = "0.4"
image = "0.15"
[workspace]

members = [
"src/backend/dx11",
"src/backend/dx12",
"src/backend/dx12ll",
"src/backend/gl",
"src/backend/metal",
"src/backend/metalll",
"src/backend/vulkan",
"src/backend/vulkanll",
"src/core",
"src/corell",
"src/macros",
"src/render",
"src/support",
"src/window/dxgi",
"src/window/glfw",
"src/window/glutin",
"src/window/metal",
"src/window/sdl",
"src/window/vulkan",
"examples"
]
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,21 @@ Shiny screens, including some older projects:

## Getting started

The gfx-rs git repository contains a number of examples.
Those examples are automatically downloaded if you clone the gfx directory:

$ cd <my_dir>
$ git clone https://github.com/gfx-rs/gfx

where `<my_dir>` is a directory name of your choice. Once gfx is downloaded you can build any of the gfx examples.
The examples are listed in the `<my_dir>/gfx/Cargo.toml` file.
For example try:

$ cd gfx
$ cargo run --example cube

If you compile the example for the first time, it may take some while since all dependencies must be compiled too.

If you want to build your own stand-alone gfx program, add the following to your new `Cargo.toml`:

[dependencies]
gfx = "0.16"

or, if you want the absolute latest commits to master, you can instead add.

[dependencies]
gfx = { git = "https://github.com/gfx-rs/gfx.git" }

For gfx to work, it needs access to the graphics system of the OS. This is typically provided through some window initialization API.
gfx can use a couple of those to acquire graphical contexts.
For example; [glfw](https://github.com/PistonDevelopers/glfw-rs) or [glutin](https://github.com/tomaka/glutin/).

To see how the graphic context is acquired, see the [cube example](https://github.com/gfx-rs/gfx/tree/master/examples/cube) or the [triangle example](https://github.com/gfx-rs/gfx/tree/master/examples/triangle).
To see how the graphic context is acquired, see the [cube example](https://github.com/gfx-rs/gfx/tree/master/support/examples/cube) or the [triangle example](https://github.com/gfx-rs/gfx/tree/master/render/examples/triangle).

To use `glutin`, for example, your `Cargo.toml` must be extended with the following dependencies:

Expand All @@ -133,13 +122,19 @@ To use `glutin`, for example, your `Cargo.toml` must be extended with the follow

Alternatively, an excellent introduction into gfx and its related crates can be found [here](https://wiki.alopex.li/LearningGfx).

## Running the Examples

The [examples directory](./examples) contains all the examples for GFX, as well as the
[accompanying documentation](./examples/README.md) for understanding and running those examples.


## Structure and current versions
`gfx` consist of several crates. You can find all of them in this repository.

| Core functionality: | Graphic backends: | Window backends: |
| :---: | :---: | :---: |
| [![gfx on crates.io](http://img.shields.io/crates/v/gfx.svg?label=gfx)](http://crates.io/crates/gfx) | [![gfx_device_gl on crates.io](http://img.shields.io/crates/v/gfx_device_gl.svg?label=gfx_device_gl)](http://crates.io/crates/gfx_device_gl) | [![gfx_window_sdl on crates.io](http://img.shields.io/crates/v/gfx_window_sdl.svg?label=gfx_window_sdl)](http://crates.io/crates/gfx_window_sdl) |
| [![gfx_app on crates.io](http://img.shields.io/crates/v/gfx_app.svg?label=gfx_app)](http://crates.io/crates/gfx_app) | [![gfx_device_dx11 on crates.io](http://img.shields.io/crates/v/gfx_device_dx11.svg?label=gfx_device_dx11)](http://crates.io/crates/gfx_device_dx11) | [![gfx_window_dxgi on crates.io](http://img.shields.io/crates/v/gfx_window_dxgi.svg?label=gfx_window_dxgi)](http://crates.io/crates/gfx_window_dxgi) |
| | [![gfx_device_dx11 on crates.io](http://img.shields.io/crates/v/gfx_device_dx11.svg?label=gfx_device_dx11)](http://crates.io/crates/gfx_device_dx11) | [![gfx_window_dxgi on crates.io](http://img.shields.io/crates/v/gfx_window_dxgi.svg?label=gfx_window_dxgi)](http://crates.io/crates/gfx_window_dxgi) |
| [![gfx_core on crates.io](http://img.shields.io/crates/v/gfx_core.svg?label=gfx_core)](http://crates.io/crates/gfx_core) | [![gfx_device_metal on crates.io](http://img.shields.io/crates/v/gfx_device_metal.svg?label=gfx_device_metal)](http://crates.io/crates/gfx_device_metal) | [![gfx_window_glfw on crates.io](http://img.shields.io/crates/v/gfx_window_glfw.svg?label=gfx_window_glfw)](http://crates.io/crates/gfx_window_glfw) |
| [![gfx_macros on crates.io](http://img.shields.io/crates/v/gfx_macros.svg?label=gfx_macros)](http://crates.io/crates/gfx_macros) | [![gfx_device_vulkan on crates.io](http://img.shields.io/crates/v/gfx_device_vulkan.svg?label=gfx_device_vulkan)](http://crates.io/crates/gfx_device_vulkan) | [![gfx_window_metal on crates.io](http://img.shields.io/crates/v/gfx_window_metal.svg?label=gfx_window_metal)](http://crates.io/crates/gfx_window_metal) |
| | | [![gfx_window_glutin on crates.io](http://img.shields.io/crates/v/gfx_window_glutin.svg?label=gfx_window_glutin)](http://crates.io/crates/gfx_window_glutin) |
Expand Down
48 changes: 41 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
environment:
matrix:
- TARGET: 1.18.0-x86_64-pc-windows
- TARGET: 1.19.0-x86_64-pc-windows
COMPILER: gnu
- TARGET: 1.18.0-x86_64-pc-windows
- TARGET: 1.19.0-x86_64-pc-windows
COMPILER: msvc
- TARGET: nightly-x86_64-pc-windows
COMPILER: msvc
Expand All @@ -15,9 +15,43 @@ install:
- rustc -vV
- cargo -vV
build_script:
- cargo build --features vulkan
# No d3d12 support on GNU windows ATM
# context: https://github.com/gfx-rs/gfx/pull/1417
- if (%COMPILER%==gnu) {
- >
cargo build --all --features vulkan
--exclude gfx_window_glfw
--exclude gfx_device_metal
--exclude gfx_device_metalll
--exclude gfx_window_metal
--exclude gfx_device_dx12ll
} else {
- >
cargo build --all --features vulkan
--exclude gfx_window_glfw
--exclude gfx_device_metal
--exclude gfx_device_metalll
--exclude gfx_window_metal
}
test_script:
- cargo test --all --features vulkan
- cargo test -p gfx -p gfx_core --features "mint serialize"
- if %COMPILER%==msvc cargo test --all --features dx11
- if %COMPILER%==msvc cargo test --all --features dx12
# re: gfx is gfx_render
- cargo test -p gfx -p gfx_core
- if (%COMPILER%==gnu) {
- >
cargo test --all --features vulkan
--exclude gfx_window_glfw
--exclude gfx_device_metal
--exclude gfx_device_metalll
--exclude gfx_window_metal
--exclude gfx_device_dx12ll
} else {
- >
cargo test --all --features vulkan
--exclude gfx_window_glfw
--exclude gfx_device_metal
--exclude gfx_device_metalll
--exclude gfx_window_metal
- cargo test -p gfx -p gfx_core --features dx11
- cargo test -p gfx -p gfx_core --features dx12
- cargo test -p gfx -p gfx_core --features dx12ll
}
Loading

0 comments on commit bc2f8be

Please sign in to comment.