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

Unified renderer #143

Merged
merged 19 commits into from
Jan 30, 2024
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
26 changes: 4 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hudhook"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
description = "A graphics API hook with dear imgui render loop. Supports DirectX 9, 11, 12, and OpenGL 3."
homepage = "https://github.com/veeenu/hudhook"
Expand All @@ -11,7 +11,7 @@ authors = ["Andrea Venuta <[email protected]>"]

[package.metadata.docs.rs]
default-target = "x86_64-pc-windows-msvc"
targets = ["x86_64-pc-windows-msvc"]
targets = ["x86_64-pc-windows-msvc", "i686-pc-windows-msvc"]

[features]
default = ["dx9", "dx11", "dx12", "opengl3", "inject"]
Expand Down Expand Up @@ -54,26 +54,6 @@ crate-type = ["cdylib"]
name = "dx11_host"
crate-type = ["bin"]

# Renderers examples
#
# These examples contain code that creates a window and a rendering surface and
# plainly renders some imgui code with the appropriate renderer.

[[example]]
name = "renderer-dx9"
path = "examples/renderers/dx9.rs"
crate-type = ["bin"]

[[example]]
name = "renderer-dx11"
path = "examples/renderers/dx11.rs"
crate-type = ["bin"]

[[example]]
name = "renderer-dx12"
path = "examples/renderers/dx12.rs"
crate-type = ["bin"]

[dependencies]
imgui = "0.11"
imgui-opengl = "0.1"
Expand All @@ -99,6 +79,7 @@ windows = { version = "0.51.0", features = [
"Win32_Graphics_Direct3D12",
"Win32_Graphics_Direct3D_Fxc",
"Win32_Graphics_Direct3D",
"Win32_Graphics_DirectComposition",
"Win32_Graphics_Gdi",
"Win32_Graphics_OpenGL",
"Win32_UI_Input",
Expand All @@ -108,6 +89,7 @@ windows = { version = "0.51.0", features = [
tracing = { version = "0.1", features = ["log"] }
memoffset = "0.9.0"
once_cell = "1.18.0"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[dev-dependencies]
tracing-subscriber = "0.3"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ impl ImguiRenderLoop for MyRenderLoop {
{
// Use this if hooking into a DirectX 9 application.
use hudhook::hooks::dx9::ImguiDx9Hooks;
hudhook!(MyRenderLoop.into_hook::<ImguiDx9Hooks>());
hudhook!(ImguiDx9Hooks, MyRenderLoop);
}

{
// Use this if hooking into a DirectX 11 application.
use hudhook::hooks::dx11::ImguiDx11Hooks;
hudhook!(MyRenderLoop.into_hook::<ImguiDx11Hooks>());
hudhook!(ImguiDx11Hooks, MyRenderLoop);
}

{
// Use this if hooking into a DirectX 12 application.
use hudhook::hooks::dx12::ImguiDx12Hooks;
hudhook!(MyRenderLoop.into_hook::<ImguiDx12Hooks>());
hudhook!(ImguiDx12Hooks, MyRenderLoop);
}

{
// Use this if hooking into an OpenGL 3 application.
use hudhook::hooks::opengl3::ImguiOpenGl3Hooks;
hudhook!(MyRenderLoop.into_hook::<ImguiOpenGl3Hooks>());
hudhook!(ImguiOpenGl3Hooks, MyRenderLoop);
}
```

Expand Down
8 changes: 5 additions & 3 deletions examples/dx11_hook.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Please ignore these examples; they are broken.

use hudhook::hooks::dx11::ImguiDx11Hooks;
use hudhook::hooks::ImguiRenderLoop;
use hudhook::*;
use imgui::Condition;
use tracing::metadata::LevelFilter;
struct Dx11HookExample;

impl Dx11HookExample {
fn new() -> Self {
println!("Initializing");
hudhook::alloc_console().expect("AllocConsole");
hudhook::alloc_console().ok();
hudhook::enable_console_colors();

tracing_subscriber::fmt()
Expand Down Expand Up @@ -35,4 +37,4 @@ impl ImguiRenderLoop for Dx11HookExample {
}
}

hudhook::hudhook!(Dx11HookExample::new().into_hook::<ImguiDx11Hooks>());
hudhook::hudhook!(ImguiDx11Hooks, Dx11HookExample::new());
2 changes: 1 addition & 1 deletion examples/dx11_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn main(_argc: i32, _argv: *const *const u8) {

let mut dll_path = std::env::current_exe().unwrap();
dll_path.pop();
dll_path.push("hook_you.dll");
dll_path.push("dx11_hook.dll");

println!("{:?}", dll_path.canonicalize());
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions examples/dx12_hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hudhook::hooks::dx12::ImguiDx12Hooks;
use hudhook::hooks::ImguiRenderLoop;
use hudhook::*;
use imgui::Condition;
use tracing::metadata::LevelFilter;
struct Dx12HookExample;
Expand Down Expand Up @@ -35,4 +35,4 @@ impl ImguiRenderLoop for Dx12HookExample {
}
}

hudhook::hudhook!(Dx12HookExample::new().into_hook::<ImguiDx12Hooks>());
hudhook::hudhook!(ImguiDx12Hooks, Dx12HookExample::new());
4 changes: 2 additions & 2 deletions examples/dx9_hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hudhook::hooks::dx9::ImguiDx9Hooks;
use hudhook::hooks::ImguiRenderLoop;
use hudhook::*;
use imgui::Condition;
use tracing::metadata::LevelFilter;
struct Dx9HookExample;
Expand Down Expand Up @@ -35,4 +35,4 @@ impl ImguiRenderLoop for Dx9HookExample {
}
}

hudhook::hudhook!(Dx9HookExample::new().into_hook::<ImguiDx9Hooks>());
hudhook::hudhook!(ImguiDx9Hooks, Dx9HookExample::new());
4 changes: 2 additions & 2 deletions examples/opengl3_hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hudhook::hooks::opengl3::ImguiOpenGl3Hooks;
use hudhook::hooks::ImguiRenderLoop;
use hudhook::*;
use imgui::Condition;
use tracing::metadata::LevelFilter;
struct HookYou;
Expand Down Expand Up @@ -35,4 +35,4 @@ impl ImguiRenderLoop for HookYou {
}
}

hudhook::hudhook!(HookYou::new().into_hook::<ImguiOpenGl3Hooks>());
hudhook::hudhook!(ImguiOpenGl3Hooks, HookYou::new());
182 changes: 0 additions & 182 deletions examples/renderers/dx11.rs

This file was deleted.

Loading
Loading