GithubHelp home page GithubHelp logo

skulpin's Introduction

skulpin

Skia + Vulkan = Skulpin

This crate provides an easy option for drawing hardware-accelerated 2D by combining vulkan and skia. (And a dash of winit!)

Build Status Crates.io

Example Screenshot

This crate mainly depends on:

  • ash - Vulkan bindings for Rust
  • skia-safe - Skia bindings for Rust
  • winit - Cross-platform window handling

Usage

Currently there are two ways to use this library.

  • app - Implement the AppHandler trait and launch the app. It's simple but not as flexible.
  • renderer_only - You manage the window and event loop yourself. Then add the renderer to draw to it.

The interactive example is good to look at for an easy way to get keyboard/mouse input.

Don't forget to install the prerequisites below appropriate to your platform! (See "Requirements")

Running the Examples

First, ensure that the below requirements are met depending on OS. Afterwards, the examples can be run normally:

cargo run --example interactive

Requirements

Windows

All examples require the LunarG Validation layers and a Vulkan library that is visible in your PATH. An easy way to get started is to use the LunarG Vulkan SDK

MacOS

All examples require the LunarG Validation layers and a Vulkan library that is visible in your PATH. An easy way to get started is to use the LunarG Vulkan SDK

Linux

All examples require the LunarG Validation layers and a Vulkan library that is visible in your PATH. An easy way to get started is to use the LunarG Vulkan SDK

On linux you'll also need to link against bz2, GL, fontconfig, and freetype.

On ubuntu, you could use libbz2-dev, libfreetype6-dev, libfontconfig1-dev, and libgl-dev. (And libvulkan-dev to pick up the Vulkan SDK)

Other Platforms

It may be possible to build this for mobile platforms, but I've not investigated this yet.

Status

For now this is a proof-of-concept. I think there is desire for a simple entry point to drawing on the screen, and that this approach can provide a good balance of performance, features, and ease-of-use for many applications.

Flutter, Google's new UI framework, uses a Skia + Vulkan stack to achieve 60+ FPS on mobile devices. So I expect this type of usage to be maintained and improved as needed in the upstream libraries.

A note on High-DPI Display Support

For the common case, you can draw to the skia canvas using winit's "logical" coordinates and not worry about dpi/scaling issues.

Internally, the skia surface will match the swapchain size, but this size is not necessarily winit's LogicalSize or PhysicalSize of the window. In order to produce consistently-sized results, the renderer will apply a scaling factor to the skia canvas before handing it off to your draw implementation.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See LICENSE-APACHE and LICENSE-MIT.

skulpin's People

Contributors

aclysma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.