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

feature request: custom vertex format #321

Open
nowakf opened this issue Nov 25, 2021 · 1 comment
Open

feature request: custom vertex format #321

nowakf opened this issue Nov 25, 2021 · 1 comment

Comments

@nowakf
Copy link

nowakf commented Nov 25, 2021

I figured this would solve #256 in a somewhat elegant way, and from looking at the stuff in quad_gl.rs and in graphics.rs (in miniquad) it seems that it should be straightforward to do something like make Quadgl generic over vertex type (since Buffer is generic over vertex type anyway).

It feels to me that normals are quite important for 3d objects, so if it isn't so straightforward, it's still probably a nice thing to have :)

@Vrixyz
Copy link

Vrixyz commented Aug 5, 2024

From my understanding, you're suggesting modifications to the hardcoded type of Vertex stored within DrawCall:

macroquad/src/quad_gl.rs

Lines 20 to 21 in 305d472

struct DrawCall {
vertices: Vec<Vertex>,

in order to pass something different later to the buffer there:

BufferSource::slice(dc.vertices()),

I think it's a good approach.

Alternatives

I´d like to discuss alternative or next steps (also helps with verifying my understanding):

Would another option be to allow to add more binding groups (so we´d be able to add our custom informations to it. The implementation might not be completely different, but might help with separating "custom data" from official macroquad information.

So feed different types within

macroquad/src/quad_gl.rs

Lines 749 to 753 in 305d472

let bindings = Bindings {
vertex_buffers: vec![vertex_buffer],
index_buffer,
images: vec![white_texture, white_texture],
};

And rather than hardcoding 0, loop over their data to update them.

macroquad/src/quad_gl.rs

Lines 787 to 790 in 305d472

ctx.buffer_update(
bindings.vertex_buffers[0],
BufferSource::slice(dc.vertices()),
);

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

2 participants