Skip to content

Commit 91c17a4

Browse files
committed
Basic reimplementation with -sys crate, remove old code
1 parent ede1f0e commit 91c17a4

File tree

14 files changed

+681
-1078
lines changed

14 files changed

+681
-1078
lines changed

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ default = ["glutin"]
1414

1515
[dependencies]
1616
bitflags = "~1.0"
17+
glutin = { version = "~0.12", optional = true }
1718
lazy_static = "0.2.8"
19+
renderdoc_sys = { version = "0.1", path = "renderdoc_sys" }
1820
shared_library = "0.1.8"
1921

20-
glutin = { version = "~0.12", optional = true }
21-
2222
[target.'cfg(windows)'.dependencies]
2323
winapi = "~0.2.8"
2424
wio = "~0.1.2"
2525

2626
[dev-dependencies]
27-
gfx = "0.16.2"
28-
gfx_window_glutin = "0.19"
27+
gfx = "~0.17"
28+
gfx_window_glutin = "~0.20"
2929
glutin = "~0.12"
3030

3131
[workspace]

examples/triangle.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ extern crate renderdoc;
2121
use gfx::traits::FactoryExt;
2222
use gfx::Device;
2323
use glutin::GlContext;
24-
use renderdoc::{OverlayBits, RenderDoc, V110};
25-
use renderdoc::prelude::*;
24+
use renderdoc::app::{OverlayBits, RenderDoc, V100};
25+
use renderdoc::app::api::RenderDocV100;
2626

2727
pub type ColorFormat = gfx::format::Rgba8;
2828
pub type DepthFormat = gfx::format::DepthStencil;
@@ -57,7 +57,7 @@ const TRIANGLE: [Vertex; 3] = [
5757
const CLEAR_COLOR: [f32; 4] = [0.1, 0.2, 0.3, 1.0];
5858

5959
pub fn main() {
60-
let mut rd: RenderDoc<V110> = RenderDoc::new().unwrap();
60+
let mut rd: RenderDoc<V100> = RenderDoc::new().unwrap();
6161

6262
let mut events_loop = glutin::EventsLoop::new();
6363
let window_config = glutin::WindowBuilder::new()
@@ -83,25 +83,24 @@ pub fn main() {
8383
rd.set_active_window(window.context(), ::std::ptr::null());
8484
rd.set_focus_toggle_keys(&[glutin::VirtualKeyCode::F]);
8585
rd.set_capture_keys(&[glutin::VirtualKeyCode::C]);
86-
rd.mask_overlay_bits(OverlayBits::DEFAULT, OverlayBits::DEFAULT);
8786

8887
let mut running = true;
8988
while running {
9089
events_loop.poll_events(|event| {
9190
if let glutin::Event::WindowEvent { event, .. } = event {
9291
match event {
93-
glutin::WindowEvent::KeyboardInput {
94-
input:
95-
glutin::KeyboardInput {
96-
virtual_keycode: Some(glutin::VirtualKeyCode::R),
97-
state: glutin::ElementState::Pressed,
98-
..
99-
},
100-
..
101-
} => match rd.launch_replay_ui(None) {
102-
Ok(pid) => println!("Launched replay UI ({}).", pid),
103-
Err(err) => println!("{:?}", err),
104-
},
92+
// glutin::WindowEvent::KeyboardInput {
93+
// input:
94+
// glutin::KeyboardInput {
95+
// virtual_keycode: Some(glutin::VirtualKeyCode::R),
96+
// state: glutin::ElementState::Pressed,
97+
// ..
98+
// },
99+
// ..
100+
// } => match rd.launch_replay_ui(None) {
101+
// Ok(pid) => println!("Launched replay UI ({}).", pid),
102+
// Err(err) => println!("{:?}", err),
103+
// },
105104
glutin::WindowEvent::KeyboardInput {
106105
input:
107106
glutin::KeyboardInput {

renderdoc_sys/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "renderdoc_sys"
33
version = "0.1.0"
44
authors = ["Eyal Kalderon <[email protected]>"]
5+
description = "Raw FFI bindings to the RenderDoc API"
56
license = "MIT OR Apache-2.0"
67
repository = "https://github.com/ebkalderon/renderdoc-rs"
78
documentation = "https://docs.rs/renderdoc_sys/"

renderdoc_sys/build.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,35 @@ extern crate bindgen;
22
extern crate cc;
33

44
use std::env;
5-
use std::path::PathBuf;
5+
use std::path::{Path, PathBuf};
66

77
fn main() {
8+
println!("cargo:rerun-if-changed=build.rs");
9+
810
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
911

12+
if cfg!(feature = "app") {
13+
gen_app_bindings(&out_path);
14+
}
15+
16+
if cfg!(feature = "replay") {
17+
gen_replay_bindings(&out_path);
18+
}
19+
}
20+
21+
fn gen_app_bindings<P: AsRef<Path>>(out_path: P) {
1022
let app = bindgen::Builder::default()
1123
.header("renderdoc/renderdoc/api/app/renderdoc_app.h")
1224
.whitelist_type("RENDERDOC_.*")
1325
.blacklist_type("__.*")
1426
.generate()
1527
.expect("Unable to generate app bindings!");
1628

17-
app.write_to_file(out_path.join("app.rs"))
29+
app.write_to_file(out_path.as_ref().join("app.rs"))
1830
.expect("Couldn't write app bindings!");
31+
}
1932

33+
fn gen_replay_bindings<P: AsRef<Path>>(out_path: P) {
2034
let replay = bindgen::Builder::default()
2135
.header("replay/wrapper.h")
2236
.clang_args(&[
@@ -54,13 +68,12 @@ fn main() {
5468
.whitelist_type("ReplayController")
5569
.whitelist_type("ReplayOutput")
5670
.whitelist_type("TargetControl")
57-
// .opaque_type("Camera")
5871
.generate_inline_functions(true)
5972
.generate()
6073
.expect("Unable to generate replay bindings!");
6174

6275
replay
63-
.write_to_file(out_path.join("replay.rs"))
76+
.write_to_file(out_path.as_ref().join("replay.rs"))
6477
.expect("Couldn't write replay bindings!");
6578

6679
cc::Build::new()
@@ -75,7 +88,6 @@ fn main() {
7588
.file("replay/src/TargetControl.cpp")
7689
.define("RENDERDOC_PLATFORM_LINUX", None)
7790
.define("RENDERDOC_WINDOWING_XLIB", None)
78-
.object("/usr/lib/librenderdoc.so")
7991
.pic(true)
8092
.cpp(true)
8193
.compile("librenderdoc.a");

0 commit comments

Comments
 (0)