Maintainers: @Potpourri, @kvark, @bvssvni
The implementation of a piston-graphics back-end using Gfx.
A Gfx 2D back-end for the Piston game engine
License: MIT License
Maintainers: @Potpourri, @kvark, @bvssvni
The implementation of a piston-graphics back-end using Gfx.
Can copy the imagetest example.
This needs to be supported.
Signature can be copied from https://github.com/PistonDevelopers/opengl_graphics/blob/master/src/texture.rs#L124
There's a uniform sampler2D s_texture;
missing in the 120 version of the textured fragment shader, so trying to use gfx_graphics results in a shader compilation error (when GLSL 1.50 is not supported).
(This didn't seem worth making a pull request for.)
It is no longer needed.
The y-axis points up in normalized OpenGL coordinates, but in absolute 2D coordinates it points down. This leads to triangles disappearing if not the right side is rendered.
This looks nicer and is simpler to type.
This will make it more interesting.
src/g2d.rs:324:23: 324:71 error: expected function, found `render::mesh::SliceKind`
src/g2d.rs:324 batch.slice = gfx::VertexSlice(gfx::TriangleList, 0, n as u32);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/g2d.rs:376:26: 376:74 error: expected function, found `render::mesh::SliceKind`
src/g2d.rs:376 batch_uv.slice = gfx::VertexSlice(gfx::TriangleList, 0, n as u32);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
Could not compile `gfx_graphics`.
cargo run --example imagetest
Remove Cargo.toml and move it up one level.
Add dev dependencies.
Since your data comes in separate slices, you could save a lot of code and CPU copying by just passing it through to GPU.
Trying to run example from piston-shaders https://github.com/pistondevelopers/shaders
RUST_BACKTRACE=1 cargo run --example viewer
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Vertex(ShaderCompilationFailed)', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/result.rs:743
stack backtrace:
1: 0x10503fa77 - sys::backtrace::write::h159c9303aa56d993QnB
2: 0x10506ba33 - failure::on_fail::h30a5d63a5824ccdbmFK
3: 0x104fa3da8 - rt::unwind::begin_unwind_inner::h83398b7af9be1f1fCmK
4: 0x104fa4511 - rt::unwind::begin_unwind_fmt::hfc0db89fc8ff3c8e8kK
5: 0x10506b35e - rust_begin_unwind
6: 0x1050b9757 - panicking::panic_fmt::haa2c8b833452fc7bSvw
7: 0x10182901b - result::Result<T, E>::unwrap::h12136061929040757835
8: 0x10182817f - g2d::G2D::new::h17736005757864635201
9: 0x1017f8c18 - start_gfx::h12348680618628704989
10: 0x1017f8361 - start::closure.3109
11: 0x1017ec61a - start_window::h10448440904531465193
12: 0x1017ec310 - start::h16339578277304577960
13: 0x1017ec1f0 - main::h1292a4f1ac9fc0f9iaa
14: 0x1050e31a9 - rust_try_inner
15: 0x1050e3196 - rust_try
16: 0x10506c47d - rt::lang_start::h06967cab2a70aa6bnzK
17: 0x1017ec24f - main
An unknown error occurred
Travis CI is failing because it is not installing SDL2.
Can copy code from https://github.com/PistonDevelopers/piston-examples/blob/master/.travis.yml
RUST_BACKTRACE=1 cargo run --example imagetest
Running `target/examples/imagetest`
thread '<main>' panicked at 'assertion failed: data.len() * esize + offset_bytes <= buf.get_info().size', /Users/sven/.cargo/git/checkouts/gfx-rs-93bce98024942039/master/src/render/lib.rs:255
stack backtrace:
1: 0x10e916a77 - sys::backtrace::write::h159c9303aa56d993QnB
2: 0x10e942a33 - failure::on_fail::h30a5d63a5824ccdbmFK
3: 0x10e87ada8 - rt::unwind::begin_unwind_inner::h83398b7af9be1f1fCmK
4: 0x10af498d7 - rt::unwind::begin_unwind::h12418617414705309073
5: 0x10af69020 - render::Renderer<D>::update_buffer_vec::h11957271402520406697
6: 0x10af68d3b - g2d::GraphicsBackEnd<'a, C>.BackEnd::tri_list::closure.7606
7: 0x10af70662 - extern $u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$for$LT$$u27$r$GT$$u20$core..ops..FnMut$LP$$RF$$u27$r$u20$$u5b$f32$u5d$$RP$$u20$$u2b$$u20$$u27$static$C$$u20$$LP$$RF$$u27$static$u20$$u5b$f32$u5d$$C$$RP$$RP$::object_shim.7755::hd0e0a155049dfd3b
8: 0x10af68bf2 - rectangle::Rectangle::draw::closure.7604
9: 0x10af66d27 - g2d::GraphicsBackEnd<'a, C>.BackEnd::tri_list::h10387419007337182272
10: 0x10af66904 - rectangle::Rectangle::draw::h11168062705347684041
11: 0x10af6006d - main::closure.7507
12: 0x10af5fc38 - g2d::G2D::draw::h12446179003519822330
13: 0x10af1d526 - main::h851c6c8299080913uaa
14: 0x10e9ba1a9 - rust_try_inner
15: 0x10e9ba196 - rust_try
16: 0x10e94347d - rt::lang_start::h06967cab2a70aa6bnzK
17: 0x10af1d65f - main
An unknown error occurred
Using worker: worker-linux-12-2.bb.travis-ci.org:travis-linux-8
git.1
0.26s$ git clone --depth=50 git://github.com/PistonDevelopers/gfx_graphics.git PistonDevelopers/gfx_graphics
Cloning into 'PistonDevelopers/gfx_graphics'...
remote: Counting objects: 333, done.
remote: Compressing objects: 100% (160/160), done.
remote: Total 333 (delta 151), reused 326 (delta 144)
Receiving objects: 100% (333/333), 131.54 KiB | 0 bytes/s, done.
Resolving deltas: 100% (151/151), done.
Checking connectivity... done.
$ cd PistonDevelopers/gfx_graphics
3.08s$ git fetch origin +refs/pull/78/merge:
fatal: Couldn't find remote ref refs/pull/78/merge
The command "eval git fetch origin +refs/pull/78/merge:" failed. Retrying, 2 of 3.
fatal: Couldn't find remote ref refs/pull/78/merge
The command "eval git fetch origin +refs/pull/78/merge:" failed. Retrying, 3 of 3.
fatal: Couldn't find remote ref refs/pull/78/merge
The command "eval git fetch origin +refs/pull/78/merge:" failed 3 times.
The command "git fetch origin +refs/pull/78/merge:" failed and exited with 128 during .
Your build has been stopped.
gfx
changed draw_state
over git to crates.io. Now we need to do the same in graphics
or maybe gfx
return to git. I am for the transition to crates.io.
Maybe Gfx has changed face culling?
See PistonDevelopers/opengl_graphics#61
This might make it less confusing for users.
I have a problems with this.
The main problem is ParamsUV
. TextureParam
now has type parameter and if I pass GlResources
, then can't create ParamsUV
using D: Device
, but and generic type doesn't work, #[shader_param()]
can't implement ShaderParam
to generic type.
@kvark need help
This should update the texture with an image.
Can use the shader macro from the triangle example https://github.com/gfx-rs/gfx-rs/blob/master/src/examples/triangle/main.rs
Can copy shaders from https://github.com/PistonDevelopers/opengl_graphics/blob/master/src/gl_back_end.rs
task '<main>' failed at 'called `Result::unwrap()` on an `Err` value: ErrorMesh(ErrorAttributeMissing(color))', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libcore/result.rs:620
An unknown error occurred
This will help visualizing the dependencies.
According to kvark:
create_buffer has an optional data parameter. If it's given, the buffer is considered static. If None is there - the buffer is dynamic
you then update the contents with update_buffer
Trying to get gfx_graphics working with Conrod, which uses freetype-rs to generate alpha maps. See PistonDevelopers/conrod#158
task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Invalid TextureInfo (width, height, and levels must not be zero): TextureInfo { width: 0, height: 0, depth: 1, levels: 1, kind: Texture2D, format: Unsigned(RGBA, 8, IntNormalized) }
', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libcore/result.rs:789
An unknown error occurred
Then I tried creating a texture of size 1x1 and got
task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Invalid data size provided to update the texture, expected size 4', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libcore/result.rs:789
An unknown error occurred
The following works with memory_from_alpha in opengl_graphics but not with gfx_graphics:
TEST ch `W`
TEST width 23 height 33
TEST ch `i`
TEST width 3 height 31
TEST ch `d`
TEST width 12 height 33
TEST ch `g`
TEST width 11 height 32
TEST ch `e`
TEST width 12 height 24
TEST ch `t`
TEST width 10 height 29
TEST ch ` `
TEST width 0 height 0
TEST ch `D`
TEST width 13 height 33
TEST ch `m`
TEST width 19 height 24
TEST ch `o`
TEST width 12 height 24
TEST ch `n`
TEST width 11 height 24
TEST ch `s`
TEST width 11 height 24
TEST ch `r`
TEST width 8 height 24
TEST ch `a`
TEST width 12 height 24
Add @Potpourri as first, @kvark as second and @bvssvni as third.
src/g2d.rs:146:12: 146:22 error: use of undeclared type name `OwnedBatch`
src/g2d.rs:146 batch: OwnedBatch,
^~~~~~~~~~
src/g2d.rs:147:15: 147:27 error: use of undeclared type name `OwnedBatchUV`
src/g2d.rs:147 batch_uv: OwnedBatchUV,
^~~~~~~~~~~~
error: aborting due to 2 previous errors
Could not compile `piston2d-gfx_graphics`.
This will show off the preferred way of handling events.
The name image_iter
is confusing.
The implementation of a piston-graphics back-end using Gfx.
task '<main>' failed at 'assertion failed: `(left == right) && (right == left)` (left: `48`, right: `96`)', src/gfx2d.rs:293
An unknown error occurred
48/4/2 = 6
96/2/4 = 12
For some reason, it receives 6 vertices and 12 colors.
When compiling the latest gfx_graphics, there is a compile error:
src/g2d.rs:275:26: 275:32 error: unresolved import `gfx::state::Normal`. There is no `Normal` in `gfx::state`
src/g2d.rs:275 use gfx::state::{Normal, Inverse, Factor};
^~~~~~
src/g2d.rs:275:34: 275:41 error: unresolved import `gfx::state::Inverse`. There is no `Inverse` in `gfx::state`
src/g2d.rs:275 use gfx::state::{Normal, Inverse, Factor};
^~~~~~~
Conrod needs to create glyph textures in the middle of the frame. This is not a widely supported usage pattern in gfx-rs, so we need to have some sort of workaround.
Possible solutions:
It looks like gfx::UsageDynamic
was changed to gfx::BufferUsage::Dynamic
.
src/g2d.rs:165:13: 165:30 error: unresolved name `gfx::UsageDynamic`
src/g2d.rs:165 gfx::UsageDynamic);
^~~~~~~~~~~~~~~~~
src/g2d.rs:168:13: 168:30 error: unresolved name `gfx::UsageDynamic`
src/g2d.rs:168 gfx::UsageDynamic);
^~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
Could not compile `gfx_graphics`.
Gfx2d
Texture
This will make it more consistent with glium_graphics.
This will simplify the setup for rendering 2D.
Using the width and height of the frame
argument to get absolute coordinates.
A problem is that the method render
on RenderEvent
can't be used by any other method.
Can use draw
instead, since this is both Gfx and piston-graphics terminology.
First I need a working implementation to figure out whether gfx needs some changes.
Compiling image_iter v0.0.0 (file:///home/ty/workspace/rust/gfx_graphics/examples/image_iter)
src/main.rs:24:22: 31:6 error: this function takes 2 parameters but 1 parameter was supplied [E0061]
src/main.rs:24 let mut window = GameWindowSDL2::new(
src/main.rs:25 GameWindowSettings {
src/main.rs:26 title: "Image".to_string(),
src/main.rs:27 size: [300, 300],
src/main.rs:28 fullscreen: false,
src/main.rs:29 exit_on_esc: true,
...
src/main.rs:41:21: 41:33 error: this function takes 1 parameter but 0 parameters were supplied [E0061]
src/main.rs:41 let ref mut g = Gfx2d::new();
^~~~~~~~~~~~
src/main.rs:41:21: 41:31 error: cannot determine a type for this bounded type parameter: unconstrained type
src/main.rs:41 let ref mut g = Gfx2d::new();
^~~~~~~~~~
error: aborting due to 3 previous errors
Could not compile `image_iter`.
Those are pointers to static memory and perhaps doesn't need to be static themselves.
The opengl_graphics implementation is here https://github.com/PistonDevelopers/opengl_graphics/blob/master/src/glyph_cache.rs
Use make cargo-lib
and make git-ignore
.
This is moved to https://github.com/pistondevelopers/gfx_texture
Any clues?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.