Skip to content

Commit

Permalink
- triangle working macos
Browse files Browse the repository at this point in the history
  • Loading branch information
polymonster committed Jun 7, 2024
1 parent dbcd103 commit 4a0ece3
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 32 deletions.
23 changes: 22 additions & 1 deletion config.jsn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
pmfx_dev: "../pmfx-shader/pmfx.py"
}

tools<mac>: {
pmfx_dev: "python3 ../pmfx-shader/pmfx.py"
}

tools_help: {
pmfx: {
help_arg: "-help"
Expand All @@ -15,7 +19,7 @@
}
pmfx_dev(pmfx): {}
}

tools_update: {
pmfx: {
tag_name: latest
Expand Down Expand Up @@ -137,6 +141,23 @@
}
}

mac-data(base): {
pmfx_dev: {
explicit: true
args: [
"-shader_platform metal"
"-shader_version 6_0"
"-i ${src_data_dir}/shaders/"
"-o ${data_dir}/shaders"
"-t ${temp_dir}/shaders"
"-num_threads 1"
"-f"
"-args"
"-Zpr"
]
}
}

// win32 debug client, plugins and data
win32-debug(win32-data, hotline): {
copy: {
Expand Down
20 changes: 14 additions & 6 deletions examples/triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,36 @@ use os::win32 as os_platform;
#[cfg(target_os = "windows")]
use gfx::d3d12 as gfx_platform;

#[cfg(target_os = "macos")]
use os::macos as os_platform;

#[cfg(target_os = "macos")]
use gfx::mtl as gfx_platform;

#[repr(C)]
struct Vertex {
position: [f32; 3],
color: [f32; 4],
}

fn main() -> Result<(), hotline_rs::Error> {
// create app
let mut app = os_platform::App::create(os::AppInfo {
name: String::from("triangle"),
window: false,
num_buffers: 0,
dpi_aware: true,
});

// create gfx device
let num_buffers : u32 = 2;

let mut device = gfx_platform::Device::create(&gfx::DeviceInfo {
render_target_heap_size: num_buffers as usize,
..Default::default()
});
println!("{}", device.get_adapter_info());

//
let mut window = app.create_window(os::WindowInfo {
title: String::from("triangle!"),
..Default::default()
Expand All @@ -58,15 +66,15 @@ fn main() -> Result<(), hotline_rs::Error> {

let vertices = [
Vertex {
position: [0.0, 0.25, 0.0],
position: [0.0, 0.5, 0.0],
color: [1.0, 0.0, 0.0, 1.0],
},
Vertex {
position: [0.25, -0.25, 0.0],
position: [-0.25, -0.25, 0.0],
color: [0.0, 1.0, 0.0, 1.0],
},
Vertex {
position: [-0.25, -0.25, 0.0],
position: [0.25, -0.25, 0.0],
color: [0.0, 0.0, 1.0, 1.0],
},
];
Expand Down Expand Up @@ -154,8 +162,8 @@ fn main() -> Result<(), hotline_rs::Error> {
});

cmd.begin_render_pass(swap_chain.get_backbuffer_pass_mut());
cmd.set_viewport(&viewport);
cmd.set_scissor_rect(&scissor);
// cmd.set_viewport(&viewport);
// cmd.set_scissor_rect(&scissor);
cmd.set_render_pipeline(&pso);
cmd.set_vertex_buffer(&vertex_buffer, 0);
cmd.draw_instanced(3, 1, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion hotline-data
Loading

0 comments on commit 4a0ece3

Please sign in to comment.