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

First pass at editor GUI #421

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ sponza*

# Ignore compiled shaders
*.spv

# Checking in a socket is probably a terrible idea
*.socket
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"webgl-glsl-editor.format.placeSpaceAfterKeywords": true
"webgl-glsl-editor.format.placeSpaceAfterKeywords": true,
"rust-analyzer.check.extraArgs": [
"--target-dir",
"C:/windows/temp/rust-analyzer-check"
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look portable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm thinking I should just remove this file from the repo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced the best way forward is to remove the whole file. These settings are good for keeping the files tidy and consistent. Can we at least resolve this in a separate PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the problem is that there's always going to be a case where a developer might have overrides that are unique to their specific environment, right? For me the rust analyzer one is super common that I need per project to avoid locking issues.

I think anything related to style etc should probably best be left to clippy, otherwise there's no way to, for example. get developers who aren't using VSCode to have their code correctly formatted.

}
11 changes: 10 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@
"label": "Run Hotham simple scene on the simulator",
"group": {
"kind": "test",
"isDefault": true,
"isDefault": false,
}
},
{
"label": "Test OpenXR Client",
"type": "shell",
"command": "./hotham-openxr-client/test.ps1",
"group": {
"kind": "test",
"isDefault": true,
}
}
]
}
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ members = [
"hotham-asset-client",
"hotham-asset-server",
"hotham-simulator",
"hotham-editor",
"hotham-editor-protocol",
"hotham-openxr-client",
"hotham",
]

Expand Down
2 changes: 2 additions & 0 deletions examples/simple-scene/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ name = "hotham_simple_scene_example"
path = "src/main.rs"

[dependencies]
env_logger = "0.10.0"
hotham = {path = "../../hotham"}
log = "0.4.17"

[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = "0.6"
Expand Down
12 changes: 12 additions & 0 deletions examples/simple-scene/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use hotham::{
},
xr, Engine, HothamResult, TickData,
};
use log::info;

#[derive(Clone, Debug, Default)]
/// Most Hotham applications will want to keep track of some sort of state.
Expand All @@ -24,9 +25,20 @@ pub fn main() {
}

pub fn real_main() -> HothamResult<()> {
let _ = env_logger::builder()
.filter_module("hotham-openxr-client", log::LevelFilter::Trace)
.filter_module("simple_scene_example", log::LevelFilter::Trace)
.init();

println!("Hello!");
info!("Building engine..");
let mut engine = Engine::new();
info!("..done!");

info!("Initialising app..");
let mut state = Default::default();
init(&mut engine)?;
info!("Done! Entering main loop..");

while let Ok(tick_data) = engine.update() {
tick(tick_data, &mut engine, &mut state);
Expand Down
10 changes: 10 additions & 0 deletions hotham-editor-protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "hotham-editor-protocol"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ash = "0.37.2"
openxr-sys = "0.9.3"
39 changes: 39 additions & 0 deletions hotham-editor-protocol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Hotham Editor Protocol
## Why?
Whenever two programs want to talk to eachother, the most complicated question is *where is the protocol defined?*. Sometimes the protocol is inferred from the way the programs serialise and deserialise their messages, but this leads to all sorts of problems.

In essence, this is a *contract* problem. What is the contract, where is it, and how is it enforced?

For more on this topic, we can, as always, defer to [Joe Armstrong (RIP)](https://www.youtube.com/watch?v=ed7A7r6DBsM).

## How?
Simple. We define:

- What the messages of the protocol are
- A means to **encode** them to bytes
- A means to **decode** them to bytes

We can even take that a step further and define FSMs (as Joe would suggest), but that is future work.


## Examples
Let's say we're using Unix sockets:

```rust
let socket = UnixStream::connect("hotham_editor.socket").unwrap();
let client = EditorClient::new(socket); // woah, generics

let view_configuration = client.request(&requests::GetViewConfiguration {}).unwrap(); // view_configuration is the correct type!!
```

This magic is made possible through the `Request` trait:

```rust
pub trait Request {
/// What should the response to this request be?
type Response: Clone;

/// Get a `RequestType` tag that we can use to identify requests
fn request_type(&self) -> RequestType;
}
```
Loading