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

crevice import required? #1084

Open
snyball opened this issue Aug 12, 2022 · 3 comments
Open

crevice import required? #1084

snyball opened this issue Aug 12, 2022 · 3 comments

Comments

@snyball
Copy link
Contributor

snyball commented Aug 12, 2022

Used to do this with MeshBatch pre-0.8-rc0, requesting an example of how to use InstanceArray to do the same thing. Would be good to add it to the changelog for 0.8 as well I think.

It works with Image, but I don't know how to convert something like the following example to use InstanceArray:

fn silly_example(ctx: &mut Context, rad: f32) {
    let mut batch = MeshBatch::new(Mesh::new_circle(ctx,
                                                    graphics::DrawMode::fill(),
                                                    Vec2::new(0.0, 0.0),
                                                    rad,
                                                    1.0,
                                                    WHITE).unwrap()).unwrap();
    batch.clear();
    batch.add(DrawParam::default());
    batch.draw(ctx, DrawParam::default())
}
@PSteinhaus
Copy link
Member

You’re right.
We should re-add the meshbatch-example (though under a slightly different name probably), to showcase how this works.

Until then:

You can use Canvas::draw_instanced_mesh to draw the InstanceArray with an additional Mesh fed in, which will be used.

@snyball
Copy link
Contributor Author

snyball commented Aug 14, 2022

@PSteinhaus Thanks, was able to port all my code to 0.8.0-rc0!

The last hickup was that the AsStd140 proc-macro expects crevice to be available globally, and because AsStd140 is used as a re-export from ggez, Cargo.toml needs a specific version, so:

crevice = "0.8.0"

The version number is effectively a magic constant, so it should also be mentioned in the changelog. Alternatively re-export crevice as well, and update the shader example with a use ggez::crevice (that works right? idunno.)

@PSteinhaus
Copy link
Member

Good point.
Re-exporting crevice seems right to me here. (Bonus points for reminding me that I need to update the examples afterwards, which I of course forgot last time I re-exported glam ;) )

@PSteinhaus PSteinhaus linked a pull request Aug 31, 2022 that will close this issue
@PSteinhaus PSteinhaus changed the title Unclear how to use InstanceArray to draw Meshes crevice import required? Sep 26, 2022
@PSteinhaus PSteinhaus pinned this issue Oct 21, 2022
jr-josh added a commit to jr-josh/ggez.github.io that referenced this issue Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants