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

doryen_rs merge #77

Closed
2 tasks
jice-nospam opened this issue Feb 25, 2020 · 14 comments
Closed
2 tasks

doryen_rs merge #77

jice-nospam opened this issue Feb 25, 2020 · 14 comments

Comments

@jice-nospam
Copy link
Contributor

jice-nospam commented Feb 25, 2020

I'm creating this issue to track work related to merging doryen_rs and bracket-lib.
Items that eventually require work in bracket-lib will have their dedicated issue.

WASM

  • MISSING cargo-web not supported. To be investigated

Windowing

  • MISSING easy way to save a screenshot, like BTerm::save_screenshot(file_path: &str)
@thebracket
Copy link
Collaborator

Thanks for that! I'll see what I can do.

@thebracket
Copy link
Collaborator

Re: Minimizing
I've fixed the crash when minimized in commit ( 8be9576 ). I'm going to try and get a bunch put together before I build the next crate versions.

I'd love to have an option to pause the game loop when minimized, but it's going to be tough to make that work with back-ends other than OpenGL/native. There might be a hook for WASM, but I'm pretty sure Curses and Crossterm won't tell me if the parent terminal is minimized (I'll have to look in Amethyst; pretty sure I remember seeing that somewhere).

@thebracket
Copy link
Collaborator

Re: not updating unless cls is called

There's a new example, no_cls designed to catch this. It only calls a CLS if you press C, otherwise, it just keeps adding to the terminals. In the current builds, it's working well for me - the parent issue (82) is "pending confirmation".

@thebracket
Copy link
Collaborator

Re: WASM not working

The current MASTER build (now includes local paths for easier building) is compiling fine for me, now. There was an issue with some code from a PR not updating the WASM tree correctly. I'm pretty sure that one is fixed.

@jice-nospam
Copy link
Contributor Author

jice-nospam commented Feb 27, 2020

I still can't make WASM target work. I'm using a cloned bracket-lib on master (commit 9a4d7fe) and run :

> cd bracket-lib/bracket-terminal
> cargo web start --example keyboard

I'm using the latest rust 1.41.1 and cargo-web 0.6.26 and tested on both firefox 73.0.1 and chromium 69.0. I get the same error in both :

Error loading Rust wasm module 'basic': TypeError: WebAssembly Instantiation: Import #0 module="__wbindgen_placeholder__" error: module is not an object or function

What is it you're doing different from me ?

@jice-nospam
Copy link
Contributor Author

Concerning the new input API, I'm back to my previous issue. Providing the existing doryen-rs API using bracketlib would require to copy all input state from bracketlib to another object because I can't pass the &mut BTerm reference around.

impl Doryen {
    // function called by the users of doryen-rs library
    pub fn key_pressed(scan_code: u32) -> bool {
        // can't do that without a reference to &mut BTerm
        // or having all BTerm state copied in Doryen
    }
}
impl GameState for Doryen {
    fn tick(&mut self, ctx: &mut BTerm) {
        ...
    }
}

There may be other solutions, but passing a Rc<RefCell> in tick would work:

impl Doryen {
    pub fn key_pressed(scan_code: u32) -> bool {
        self.ctx.borrow().input.is_scancode_pressed(scan_code)
    }
}
impl GameState for Doryen {
    fn tick(&mut self, ctx: Rc<RefCell<BTerm>>) {
        self.ctx=ctx.clone();
    }
}

@Zireael07
Copy link

Tangential, I just discovered glow does support WebGL 1 context and that floating point framebuffer isn't explicitly an WebGL2 thing... could we maybe get a fallback to WebGL1, please, for people stuck with MS Edge?

@thebracket
Copy link
Collaborator

The input_api has been merged, forgot to tag the merge commit.

thebracket added a commit that referenced this issue Mar 5, 2020
…e/context directly and to the command buffer.
thebracket added a commit that referenced this issue Mar 5, 2020
… name. Terminals now support a printer function for strings such as '#[blue]This blue text contains a #[pink]pink#[] word'. Also available in the command buffer.
@thebracket
Copy link
Collaborator

thebracket commented Mar 5, 2020

The last bundle of commits added:

  • Right aligned printing via context and command buffer.
  • Centered with an arbitrary center point printing via context and command buffer.
  • A new printer command that looks a whole like doryen_rs's printing format. (Also context and command buffer supported)

thebracket added a commit that referenced this issue Mar 5, 2020
… parent console. Put whatever you like in it. Submit it to a real console with print_sub_rect or a render batch (batch_sub_rect). Supports all of the formatting/options of other terminal types. Should serve as a basis for sub-consoles if you don't feel TextBlocky.
@thebracket
Copy link
Collaborator

thebracket commented Mar 5, 2020

Virtual Terminals are kind-of a compromise. I needed a way to handle consoles much bigger than the screen and view "windows" into them. Doryen_rs needed a way to make sub-consoles. So a VirtualConsole can do both: it can be of any, arbitrary size (including reading large amounts of text; I had a need for that for manual files).

It isn't "owned" or "attached" to a real console in any way - so you can make it and keep it around, without having it touch the underlying engine state until you need it.

Submission (via render batch or direct to context) works on any target console (whatever is active). So if you have multiple layers, you can splat it to a sparse top layer and have it partially apply (alpha isn't supported yet) - ideal for putting your HUD onto the screen. If a glyph has a value of 0, it isn't copied: so you can leave holes in it if you want to.

Once consoles support alpha, this will let you put nicely faded elements such as tool-tips on top of your main display (on systems that support alpha, obviously).
(Edit: changed my mind; I can think of good reasons for simple consoles to support alpha)

@thebracket
Copy link
Collaborator

thebracket commented Mar 6, 2020

The rgba branch is tracking progress on using RGBA and supporting alpha (on terminals that support it). The API is present but not as friendly as I'd like, yet (getting there). I have alpha blending working on a sparse console, native GL only in the new alpha example.

Update: Amethyst and WASM are working too! Just need to improve the interface a little. Example: https://bfnightly.bracketproductions.com/wasmtest/alpha/

@thebracket
Copy link
Collaborator

I forgot to mention that bracket-lib has supported non-greyscale fonts from the beginning, but it wasn't entirely obvious. Now that RGBA/alpha is baked in, it does it better! In the rgba branch, there's a new example called colorfont (try it online: https://bfnightly.bracketproductions.com/wasmtest/colorfont/ ) that does a better job of showing it. I took the VGA 8x16 font, applied a gradient to it in The Gimp, and used a blur filter to anti-alias the edges so they have some alpha content.

The same setup is used for the tiles example: https://bfnightly.bracketproductions.com/wasmtest/tiles/

Font files still have to be arranged 16 tiles per row, with 16 rows (to give 255 characters) - but they can be anything you want (you'll wind up accessing them by number). I'll see about relaxing that restriction and improving the mapping in a future update. I have a few related ideas I've been bouncing around, so it'll be a feature branch once rgba is wrapped. (It's getting close; I'm just finishing up "set all alpha" functions to mass-set fg/bg/all on a layer, and improving bracket-color handling of alpha options and conversion paths)

@thebracket
Copy link
Collaborator

RGBA is now merged. I added more conversions and unit testing to bracket-color, and benchtests showed performance is about the same as before even with the try stuff.

thebracket added a commit that referenced this issue Mar 10, 2020
thebracket added a commit that referenced this issue Mar 10, 2020
@jice-nospam
Copy link
Contributor Author

I'm closing this as pretty much all the major features have been imported to bracket-lib. What an amazing coding spree ! Congratulations :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants