Giter Site home page Giter Site logo

nazariglez / notan Goto Github PK

View Code? Open in Web Editor NEW
732.0 12.0 51.0 27.25 MB

Cross-platform multimedia layer

Home Page: https://nazariglez.github.io/notan-web/

License: Apache License 2.0

HTML 0.50% Rust 98.27% Shell 0.55% PowerShell 0.68%
rust gamedev multimedia-library game-2d crates game-development

notan's Introduction

Notan

Portable Multimedia Layer

Notan is a simple and portable layer, designed to make your own multimedia apps on top of it without worrying too much about platform-specific code.

The main goal is to provide a set of APIs and tools that can be used to create your project in an ergonomic manner without enforcing any structure or pattern, always trying to stay out of your way.

Community

Examples

Do you want to open a window?

Window Open

use notan::prelude::*;

#[notan_main]
fn main() -> Result<(), String> {
    notan::init().build()
}

Do you want to draw a triangle?

Draw Triangle

use notan::prelude::*;
use notan::draw::*;

#[notan_main]
fn main() -> Result<(), String> {
    notan::init().draw(draw)
        .add_config(DrawConfig)
        .build()
}

fn draw(gfx: &mut Graphics) {
    let mut draw = gfx.create_draw();
    draw.clear(Color::BLACK);
    draw.triangle((400.0, 100.0), (100.0, 500.0), (700.0, 500.0));
    gfx.render(&draw);
}

How about render the triangle directly?

Renderer Triangle

use notan::prelude::*;

//language=glsl
const VERT: ShaderSource = notan::vertex_shader! {
    r#"
    #version 450
    layout(location = 0) in vec2 a_pos;
    layout(location = 1) in vec3 a_color;

    layout(location = 0) out vec3 v_color;

    void main() {
        v_color = a_color;
        gl_Position = vec4(a_pos - 0.5, 0.0, 1.0);
    }
    "#
};

//language=glsl
const FRAG: ShaderSource = notan::fragment_shader! {
    r#"
    #version 450
    precision mediump float;

    layout(location = 0) in vec3 v_color;
    layout(location = 0) out vec4 color;

    void main() {
        color = vec4(v_color, 1.0);
    }
    "#
};

#[derive(AppState)]
struct State {
    clear_options: ClearOptions,
    pipeline: Pipeline,
    vbo: Buffer,
}

#[notan_main]
fn main() -> Result<(), String> {
    notan::init_with(setup).draw(draw).build()
}

fn setup(gfx: &mut Graphics) -> State {
    let clear_options = ClearOptions::color(Color::new(0.1, 0.2, 0.3, 1.0));

    let vertex_info = VertexInfo::new()
        .attr(0, VertexFormat::Float32x2)
        .attr(1, VertexFormat::Float32x3);

    let pipeline = gfx
        .create_pipeline()
        .from(&VERT, &FRAG)
        .with_vertex_info(&vertex_info)
        .build()
        .unwrap();

    #[rustfmt::skip]
    let vertices = [
        0.5, 1.0,   1.0, 0.2, 0.3,
        0.0, 0.0,   0.1, 1.0, 0.3,
        1.0, 0.0,   0.1, 0.2, 1.0,
    ];

    let vbo = gfx
        .create_vertex_buffer()
        .with_info(&vertex_info)
        .with_data(&vertices)
        .build()
        .unwrap();

    State {
        clear_options,
        pipeline,
        vbo,
    }
}

fn draw(gfx: &mut Graphics, state: &mut State) {
    let mut renderer = gfx.create_renderer();

    renderer.begin(Some(state.clear_options));
    renderer.set_pipeline(&state.pipeline);
    renderer.bind_buffer(&state.vbo);
    renderer.draw(0, 3);
    renderer.end();

    gfx.render(&renderer);
}

Looking for more examples?

Sure! Check the examples folder. You will find there a few of them for any matter, like rendering, windowing, input, etc...

Installation

Add notan to your project from crates.io. The main branch should always be the latest version on crates.io.

WebAssembly

We treat the web as a first class citizen. WebAssembly compilation is dead simple, we recommend to just use trunk. You only need to add an index.html file to your project and run trunk serve to see it working.

Here is a simple index.html file as an example:

<html>
    <head>
        <title>Notan App</title>
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport"
              content="minimal-ui, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <style>
            html, body {
                width: 100%;
                height: 100%;
                padding: 0;
                margin: 0;
                background-color: #252526;
            }

            * {
                outline: none;
            }

            body {
                display: flex;
                align-items: center;
                justify-content: center;
            }
        </style>
    </head>
    <body>
        <canvas id="notan_canvas"></canvas>
    </body>
</html>

However, you can also use wasm-bindgen or wasm-pack.

How it works

Is quite simple, Notan defines a set of APIs for different things (like windows, graphics, inputs, audio, etc...) as a "core". Below this "core" exists the backends, which are crates that add support for any platform managing the platform-specific code and translating it to our "core" APIs. Anybody should be able to create and use a custom backend easily. And, on top of the "core" we can build more ergonomic APIs that are usable with any backend made for Notan.

Then the final user only needs to worrying to build their apps on top of Notan and it should be fine no matter the compilation target. Of course, there are still things to have in mind if you want to target different targets, writing portable code can be tricky sometimes but Notan should help with most of them.

Supported platforms

  • Web Browsers (wasm32) - WebGL2
  • Window - OpenGL 3.3
  • MacOS - OpenGL 3.3
  • Linux - OpenGL 3.3

The current graphics backend in place for these platforms is using glow.rs which allow us to target WebGl2, GL and GL ES easily.

Performance

People love to see performance numbers and benchmarks (I love it too), but the truth is that any benchmark or numbers worth nothing without the full context of how these numbers were calculated.

We didn't check (yet) about which parts of the code can be changed to improve the performance. Is not an easy task to keep in balance a good API, small boilerplate, and been performant. However, this is something that we try to accomplish with this project since the idea was born.

Notan try to give to the user a simple to build things, and the performance will depend on a lot of factors, user's code included.

Let's see a simple example, the 2D Draw API is built on top of the Graphics API, it has plenty of room for improvements, but I got some decent numbers on my machine running the example draw_bunnymark.

On a Macbook (2.3Hz i9 - 16GB RAM):

  • Native: 85000 Bunnies at 60FPS
  • Chrome: 78000 Bunnies at 60FPS

On a high-end Desktop with Archlinux:

  • Native: 205000 Bunnies at 60FPS
  • Chrome: 131000 Bunnies at 60FPS

Let's keep in mind that the conditions for bunnymark are very unlikely to see in a real project. However, it's widely used to test the performance in 2D Draw APIs.

Integration

Notan is designed to be as modular as possible. It's flexible enough to allow change how the event life cycle works with a plugin (i.e: FpsLimit), or to allow us to draw custom things easily on top of the graphics API using Graphic Extensions (i.e: egui or draw).

Even any backend can be easily plugged-in from the code just using init_with_backend.

We include some of these plugins or graphics extensions behind feature flags, as a part of the project. However, everybody can create their own plugins or extension to extend Notan.

Why?

I have been looking since ever for a project that allows me to create multimedia apps (games in my case) with just one codebase, not been too much opinionated about how to do it, with multiple platforms support and treating the web as a first-class citizen.

I felt that it was a tricky thing to find until I found Haxe and Kha, the perfect match. However, I did not like a few things about the build system, the lack of tools and IDEs, and how the language itself does some things. So, after a while I decided to start looking again, and I saw that Rust had a great WebAssembly compiler among other targets, and check all those boxes.

For the last three years, I have been working on this project in different repositories with different names and multiple "start-over" times. It was my place to learn Rust and OpenGL, you can say that it was my sandbox and my hobby.

However, I feel that it could be useful for more people than me in the current state.

The name Notan comes from not an engine. The main purpose of the project is to be used as foundation providing a basic but useful set of features.

They are:

  • Platform abstraction (desktop, mobile, etc...)
  • Windowing
  • Graphics rendering
  • Text rendering
  • Draw 2D API
  • Audio
  • Input (Keyboard, mouse, etc...)
  • Simple UI via egui

Everything else, like particles, physics, etc..., is out of the scope of the project and can be added via external crates, plugins or extensions. Although we can always talk if you think that something should be part of the project.

So... what's next?

Improving the project step by step, aiming for a more mature and better APIs, fixes, better platform support, more graphics backends etc...

License

This project is licensed under either of Apache License, Version 2.0 or MIT license, at your option.

Contribution

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

notan's People

Contributors

allstreamer avatar anna-singleton avatar apekros avatar ar37-rs avatar danny-burrows avatar devmeat avatar f01dab1e avatar fand avatar jawadsh123 avatar joffreybesos avatar jonatino avatar joseluis avatar kianmeng avatar mantasarm avatar mgalos999 avatar nazariglez avatar richardmarks avatar rzial avatar taotao54321 avatar tranzystorekk avatar troyc avatar woelper avatar z33ky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notan's Issues

panic with `WindowConfig` and `draw_image` example

In develop and f/egui, combining the draw_image example with a default WindowConfig like this

use notan::draw::*;
use notan::prelude::*;

#[derive(AppState)]
struct State {
    img: Texture,
}

#[notan_main]
fn main() -> Result<(), String> {
    let window_config = WindowConfig::new();

    notan::init_with(init)
        .add_config(window_config)
        .draw(draw)
        .build()
}

fn init(gfx: &mut Graphics) -> State {
    let texture = gfx
        .create_texture()
        .from_image(include_bytes!("assets/ferris.png"))
        .build()
        .unwrap();
    State { img: texture }
}

fn draw(gfx: &mut Graphics, state: &mut State) {
    let mut draw = gfx.create_draw();
    draw.clear(Color::BLACK);
    draw.image(&state.img).position(250.0, 200.0);
    gfx.render(&draw);
}

results in

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', crates/notan_draw/src/extension.rs:41:72

The line in question is

let mut text_ext = extensions.get_mut::<Text, TextExtension>().unwrap();

Expose winit's decorations and transparency options to WindowConfig

I'm unsure if this was an intentional decision or not, but it would be nice to have these window options, especially considering winit already provides them. I made a fork with these changes but quite frankly I'm new to contributing so I don't know if I should go ahead and submit a pull request. Regardless, I figured there may be a reason as to why these options weren't exposed, so I thought I'd ask here first.

(A side note: I'm very impressed by Notan! I much appreciate the straightforward and easy-to-use API. The extensive number of demos is wonderful, and I'm happy to see that it isn't very memory-intensive (at least for toy examples). Thank you for your hard work!)

RTL support

Screencast.from.04-29-2022.02_47_38.PM.mp4

It will be great if there is Right to Left support, unfortunately there is so little support for RTL languages in rust there is no good GUI library that support it

wayland support

getting the Error: "Couldn't find any pixel format that matches the criteria" on wayland.

Cannot compile fragment shader macros on Windows

I think this was caused by updating to 0.4

error: proc macro panicked
   --> C:\Users\Rhys\.cargo\registry\src\github.com-1ecc6299db9ec823\notan_glyph-0.4.2\src\pipeline.rs:99:38
    |
99  |   const GLYPH_FRAGMENT: ShaderSource = fragment_shader! {
    |  ______________________________________^
100 | |     r#"
101 | |     #version 450
102 | |     precision mediump float;
...   |
120 | |     "#
121 | | };
    | |_^
    |
    = help: message: Invalid Fragment shader:
            C:\Users\Rhys\AppData\Local\Temp\.tmpufFMRR\0.frag
            ERROR: C:\Users\Rhys\AppData\Local\Temp\.tmpufFMRR\0.frag:4: 'binding' : sampler/texture/image requires layout(binding=X)
            ERROR: 1 compilation errors.  No code generated.


            ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point

            SPIR-V is not generated for failed compile or link


error: could not compile `notan_glyph` due to previous error

and

error: proc macro panicked
   --> C:\Users\Rhys\.cargo\registry\src\github.com-1ecc6299db9ec823\notan_egui-0.4.2\src\extension.rs:62:37
    |
62  |   const EGUI_FRAGMENT: ShaderSource = notan_macro::fragment_shader! {
    |  _____________________________________^
63  | |     r#"
64  | |     #version 450
65  | |
...   |
110 | | "#
111 | | };
    | |_^
    |
    = help: message: Invalid Fragment shader:
            C:\Users\Rhys\AppData\Local\Temp\.tmp0BMtEW\0.frag
            ERROR: C:\Users\Rhys\AppData\Local\Temp\.tmp0BMtEW\0.frag:11: 'binding' : sampler/texture/image requires layout(binding=X)
            ERROR: 1 compilation errors.  No code generated.


            ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point

            SPIR-V is not generated for failed compile or link


error: could not compile `notan_egui` due to previous error

wasm [notan_app::graphics] ERROR: Invalid EGUI texture id Managed(0)

#[notan_main]
fn main() -> Result<(), String> {
    notan::init_with(setup)
        .add_config(EguiConfig)
        .draw(draw)
        .build()
}
fn setup(gfx: &mut Graphics, plugins: &mut Plugins) -> State {
plugins.egui(|ctx| {
    let myfont = include_bytes!("../NotoSans-Regular.ttf");
   let mut eguiFont = egui::FontDefinitions::default();
        eguiFont
            .font_data
            .insert("my_font".to_owned(), egui::FontData::from_static(myfont));
        eguiFont
            .families
            .entry(FontFamily::Proportional)
            .or_default()
            .insert(0, "my_font".to_owned());
        eguiFont
            .families
            .entry(FontFamily::Monospace)
            .or_default()
            .push("my_font".to_owned());
        ctx.set_fonts(eguiFont);
    });
}

Use different types of index buffers with Pipelines

right now index buffer type is pinned to glow::UNSIGNED_INT

self.gl
.draw_elements(primitive.to_glow(), count, glow::UNSIGNED_INT, offset * 4);

I'm working with a lib that gives me back u16 buffers, which I then have to upgrade to u32 causing an extra copy!
would be nice to be able to upload them directly

do you feel this should be supported?
if yes, in terms of API I'm thinking there could be a with_info on IndexBufferBuilder and a IndexFormat enum that captures all the types, wdyt?

Unifiy nae-web and nae-native on nae-backend using winit

I was looking to the web_sys impl of winit and is really good. It would worth it move from my own impl to winit eventually, just a few notes about this:

  • I need to make a PR to winit to try to use request_animation_frame instead of set_timeout when the frame time is not set. (ControlFlow::WaitUntil(n))
  • Check how the get the chars on the event keypress, because some keys can return strings with a name like the "Enter" key, if they get the first char they will get the char "E" for the key enter and this is wrong, this keys doesn't produce any char.
  • Check if it's possible to set the canvas by id, instead of creating a new one.

Use non [u8] textures

Hey ๐Ÿ‘‹

First of all, amazing project. We're using notan for a video editing app we're building (web is our primary target) and so far it feels rather nice!

We've hit a small snag on assets. It seems current strategy is to load images into wasm memory?
Folks can upload very large / very many images on our app, and since wasm has a hard limit on memory, we might run out ๐Ÿ˜…

An alternative is to use HTMLImageElement / ImageBitmap and blit it directly, with texImage2D

Is there a way to achieve this with notan rn? Did look around but could be I missed something ๐Ÿ˜„

Possible solutions

Screen viewport / aspect ratio?

I saw this pull request while looking for other Issues:
#28
But I wasn't able to find the files / imports for Scaler and ScalerMode.
Any help appreciated!

Camera / projection interface

Hi, is there a way to get current "camera" or something like that? For example if I want to change fov / zoom level.

Problem with transparency in textures

I'd tried to make scene with several textures with different positions on axis Z.
All textures are the PNG files with transparent background.

The problem is that textures transparency does not work properly. It is the nearest texture on axis Z overrides another textures.
Here is the screenshot of the effect, the rectangles on the screenshot added to show edges of the textures
image
As screenshot shows that the texture with Etherium icon ( black rectangle ) overrides another texture.

What I tried to do:

  • use all variants of depth_stensil in pipeline setup;
  • use all variants of depth_stensil in ClearOptions;
  • use all constant variants of alpha blending in pipeline setup;
  • use all constant variants of color blending in pipeline setup;
  • mix settings.

Here is the minimal example to reproduce the problem. To run the example, use the instructions in README.

What work for me, and what I want to do not use: disable depth_stensil and sort textures manually.
It is the screeshot of the example with disabled depth_stensil:
image
The transparent areas of textures do not override another textures, but depth sorting disabled.

Every unwrap should be managed

There is some unwrap methods that don't go up on the scope (draw API I'm looking to you), this unwrap should go and log every error to make sure that the user knows what's happening.

draw.begin() without clearing?

I tried using:

draw.begin(Color::TRANSPARENT);

Sadly, this results in artifacts:

image

In comparison, if I use the following code:

pub fn begin_no_clear(&mut self) {
    let projection = match &self.gfx.render_target {
        Some(rt) => projection(rt.width(), rt.height(), true, 1.0),
        None => projection(self.gfx.width, self.gfx.height, false, self.dpi),
    };

    self.render_projection = projection;

    self.clear_options.color = None;
    self.gfx.begin(&self.clear_options);
}

The render looks like this:

image

Maybe draw.begin() should take an Option<Color>?

Rotate text?

Is there a way to rotate text? I tried something like:

draw.text(&font, "Hello World").rotate_degrees(45.0);

but the result was unexpected. The text letters are drawn upright, but the baseline follows a slant. It's odd

Screen Shot 2022-05-17 at 3 22 41 PM

.

File drop event

Hi there, and first thanks so much for this library!
I was searching a lot for a small and light multimedia / game library with possible egui integration - this seems to have it all!
I am currently planning to rewrite a small image viewer I wrote with notan. It seems the only thing I am missing is an event in case the window receives a dropped file. Since you are using winit would this be something you would consider adding or accepting a PR?
Here are the winit events: link

Thanks!

High DPI drawing

It seems that Notan provides a high dpi window. For example ,on my iMac there are 2x as many physical pixels as logical pixels, which is great. However, the drawing shapes and text appears to be in normal/logical pixels, making them look low-res, so to speak. Placing shapes/text with logical coordinates is fine, but the appearance doesn't seem to be high dpi. Is this correct and intended? Is there a way to "turn on" high dpi drawing?

One workaround, as least for text, seems to be drawing at twice the needed font size and applying a scale of 0.5. That's very awkward though, and messes up the positioning.

I know dpi matters can get complicated, but I'm trying to understand Notan's approach.

Add support for TexturePacker files (Atlas)

We've basic support for texture packer files using just Context2d.image but it is far for complete.

We need:

  • Support for trimmed images
  • Support for atlas on Context2d.pattern. It is possible that we need to create a new shader and a new batch just for patterns.
  • Support for rotated images. (Optional, this involves some matrix calculations, I'm not sure if this is something to doing in nae or by the users).

Example `game_15_puzzle` generates invalid arrangements

version: commit 6fe0506

Example game_15_puzzle generates invalid arrangements. For example, this board has two 10:

invalid-15puzzle

The problem will be this code:

fn get_bag_of_numbers() -> ShuffleBag<u8> {
let mut bag = ShuffleBag::new(NUMBERS);
(0..(NUMBERS - 1)).for_each(|n| {
bag.add(n as u8, 1);
});
bag
}

(NUMBERS - 1) will be wrong. This should be NUMBERS.

Moreover, there is a 1/2 chance of generating unsolvable arrangements. This example simply shuffles numbers, but it will have to consider a parity.

Clipboard Improvement

  • It should work on the web the same as native
  • It should work at app level, not only on for egui
  • Copypaste seems unmaintaned (at least some dependencies) egui has moved to arboard we should do the same.

Feature-Request: Ability to limit FPS

Hey!
The examples update time-dependent uniforms by adding a constant value in each frame.
Since FPS are not limited, on my machine, this results in animations that are way too fast.
Additionally, this leads to the GPU running at full capacity at all times, wasting resources.

Naive solution:

const MAX_FPS: f32 = 60.0;
const INTER_FRAME_MILLIS: u64 = (1000.0 / MAX_FPS) as u64;
fn draw(gfx: &mut Graphics, state: &mut State) {
    let start = std::time::Instant::now();

    let mut renderer = gfx.create_renderer();
    // Draw something!
    gfx.render(&renderer);

    // Update some uniform
    state.angle += 0.01;

    let elapsed_millis = start.elapsed().as_millis() as u64;
    if elapsed_millis < INTER_FRAME_MILLIS {
        std::thread::sleep(std::time::Duration::from_millis(INTER_FRAME_MILLIS - elapsed_millis));
    }
}

Maybe it'd make sense for the framework to provide the time that has elapsed since starting the program.
The solution above does not cover the case where we fall below expected FPS.
Uniforms should just depend on the time since start to make them independent from FPS anyway.

Can I capture render result?

Can I create a CPU buffer and render to it, So I can save the render result to an image? I'm not familiar with notan, and sorry if this is noob question.

Consider replace glsl-to-spirv to shaderc-rs

I failed to compile notan on macos due to glsl-to-spirv build script failure. As it is already deprecated, have you considered to replace it with shaderc-rs, which is recommended by the original author?

RenderTarget doesn't support depth test on wasm32

It just return framebuffer incomplete. Everything looks fine on code but I need to dig deep on this, maybe I'm missing something or maybe could be an error mapping the texture types, on nae, glow, or maybe web-sys.

The next step should be to try to create a framebuffer using depth test with just glow and wasm-bindgen to see if it works. This example from webgl2fundamentals works an can be cloned and ported to glow easily: https://jsfiddle.net/api/mdn/

Web target: Error message in console if no logs are sent by the app

Environment:
notan = "0.7.1" on Ubuntu 22.04

Issue:
If I don't explicitly set a log message in the app, then I get the following error in the browser console:

Web target: Error initializing logs: attempted to set a logger after the logging system was already initialized

Screenshot:
QBEChmZ

Here is how I am building:

cargo build --release --example eg_notan --target wasm32-unknown-unknown

wasm-bindgen --out-dir www/wasms --target web target/wasm32-unknown-unknown/release/examples/eg_notan.wasm

For example, in the code below, the error occurs unless I comment out the lines in the starting_logs function:

use notan::draw::*;
use notan::log;
use notan::prelude::*;


#[notan_main]
fn main() -> Result<(), String> {
    notan::init()
        .initialize(starting_logs)
        .draw(draw)
        .add_config(log::LogConfig::debug())
        .add_config(DrawConfig)
        .build()
}


fn starting_logs() {
    // log::debug!("Hello, this is a debug log...");
    // log::info!("And this is a info log!");
    // log::warn!("I'm warning you");
    // log::error!("I'm an error, I told you...");
}

fn draw(gfx: &mut Graphics) {
    let mut draw = gfx.create_draw();
    draw.clear(Color::BLACK);
    draw.triangle((400.0, 100.0), (100.0, 500.0), (700.0, 500.0));
    gfx.render(&draw);
}

Add builder methods that take values to WindowConfig

I noticed that the following methods do not have variants that take values as arguments.

Screenshot_20220730_193509

I was expecting to be allowed to do:

let window_config = WindowConfig::new()
    .title("Lament")
    .size(1280, 720)
    .vsync(true)
    .resizable(true);

I believe this is much more clear. The alternative currently is to:

let window_config = WindowConfig {
    title: String::from("Lament"),
    width: 1280,
    height: 720,
    vsync: true,
    resizable: true,
    ..Default::default()
};

SDL2 not working examples

Some of the examples are not working with SDL2 or not works exactly in the same way that using winit.

  • fullscreen (Resize wrong, could be related to the DPI render_projection)
  • mask (Not working at all)
  • mask2 (Not working at all)
  • mask3 (Not working at all)
  • mouse4 (Movement speeds is way slower than winit)
  • screen_scale (not rendering while the user resize, maybe its something about sdl that cannot be fixed)

These errors are not from the examples but from the renderer or the sdl impl.

Uneeded warning? (recursing into entrypoint `main`)

Hi there, this is rather a minor issue but just one of slight annoyance for those of us trying to clear up cargo clippy warnings. This pops up when #[notan_main] is applied to my main function...

~$ cargo clippy
warning: recursing into entrypoint `main`
  --> src/main.rs:__:__
   |
31 | fn main() -> Result<(), String> {
   |    ^^^^
   |
   = note: `#[warn(clippy::main_recursion)]` on by default
   = help: consider using another function for this recursion
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion

I just wondered if there was a way we could remedy this?

I have tried putting a #[allow(clippy::main_recursion)] before and after #[notan_main] but to no avail.

Just wondered if anyone could help, if we find a good solution I could open some kind of PR?

Edit: I have found a solution and opened a PR

[Question/Enhancement] Are different backends coming soon?

I remember you mentioning on Reddit that you plan to add support for more backends in the future.

Are you planning on doing this soon? I have been looking to learn more rust by contributing to some libraries and this seems like a good place to start for that as well.

Cannot compile for wasm

Basically the title. I followed the directions in the notan README to compile my notan app to wasm, and I got an error (shown below). I'm running this on a Linux system. Native compilation works fine. Additionally, I already have glslangValidator installed.

error: proc macro panicked
  --> /home/tt/.cargo/registry/src/github.com-1ecc6299db9ec823/notan_glyph-0.5.1/src/pipeline.rs:45:36
   |
45 |   const GLYPH_VERTEX: ShaderSource = vertex_shader! {
   |  ____________________________________^
46 | |     r#"
47 | |     #version 450
48 | |
...  |
95 | |     "#
96 | | };
   | |_^
   |
   = help: message: Failed to execute glslangValidator: Os { code: 2, kind: NotFound, message: "No such file or directory" }

error: proc macro panicked
   --> /home/tt/.cargo/registry/src/github.com-1ecc6299db9ec823/notan_glyph-0.5.1/src/pipeline.rs:99:38
    |
99  |   const GLYPH_FRAGMENT: ShaderSource = fragment_shader! {
    |  ______________________________________^
100 | |     r#"
101 | |     #version 450
102 | |     precision mediump float;
...   |
120 | |     "#
121 | | };
    | |_^
    |
    = help: message: Failed to execute glslangValidator: Os { code: 2, kind: NotFound, message: "No such file or directory" }```

Vulkan support

It is widely accepted that Vulkan performs better than OpenGL (currently used).

I want to enquire about whether Vulkan will be supported.

Notan won't build

I created a new project with cargo and added Notan as a dependency to Cargo.toml, but I get an error message upon trying to build the project. I tried both 0.2.0 and 0.2.1. I have an iMac.

...
Compiling lyon_path v0.17.7
Compiling glsl-to-spirv v0.1.7
error: failed to run custom build command for glsl-to-spirv v0.1.7

Caused by:
process didn't exit successfully: <PATH DELETED> .../notan/target/debug/build/glsl-to-spirv-86dc8c8efd4cd674/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=build/glslangValidator.exe
CMAKE_TOOLCHAIN_FILE_x86_64-apple-darwin = None
CMAKE_TOOLCHAIN_FILE_x86_64_apple_darwin = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_GENERATOR_x86_64-apple-darwin = None
CMAKE_GENERATOR_x86_64_apple_darwin = None
HOST_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
CMAKE_PREFIX_PATH_x86_64-apple-darwin = None
CMAKE_PREFIX_PATH_x86_64_apple_darwin = None
HOST_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_x86_64-apple-darwin = None
CMAKE_x86_64_apple_darwin = None
HOST_CMAKE = None
CMAKE = None
running: "cmake" "/Users/jim/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang" "-DCMAKE_INSTALL_PREFIX=//notan/target/debug/build/glsl-to-spirv-63c20502889b8cb9/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"

--- stderr
fatal: not a git repository (or any of the parent directories): .git
thread 'main' panicked at '
failed to execute command: No such file or directory (os error 2)
is cmake not installed?

build script failed, must exit now', /Users/jim/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

EGUI text and images doesn't look great in some environments.

I'm having some trouble integrating EGUI. It doesn't look quite well in different situations:

Using WebGL2 on a screen with device pixel ratio = 1 looks like this:
Screenshot 2021-10-09 at 00 18 33

While it should look like this:
Screenshot 2021-10-09 at 00 19 10

And using UserTextures in any platform (web or desktop) it looks like this:
Screenshot 2021-10-09 at 00 16 52

While it should look like this:
Screenshot 2021-10-09 at 00 17 12

I think that it's related to the blend mode. But the impl is almost 1 = 1 to egui glium. The main differences between both implementations are that Notan only supports f32 VBO so the color is passed as a normalized float and then converted back to bytes on the shader:
https://github.com/Nazariglez/nae/blob/main/notan/crates/notan_egui/src/extension.rs#L48

And that the DPI is managed internally by Notan's graphic implementation (glow) so the EGUIi implementation know nothing about pixels per point. While on the glium implementation the dpi is used to calculate the uniforms and the clip rects.

Pipeline configuration used: https://github.com/Nazariglez/nae/blob/main/notan/crates/notan_egui/src/extension.rs#L110-L124
EGUI texture configuration used: https://github.com/Nazariglez/nae/blob/main/notan/crates/notan_egui/src/extension.rs#L159-L175

I would like to have EGUI fully working with Notan because I see so much potential in this combination. Any help with this issue will be really welcome.

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.