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

Shape rendering support #32

Closed
JohnDoneth opened this issue May 25, 2019 · 2 comments · Fixed by #50
Closed

Shape rendering support #32

JohnDoneth opened this issue May 25, 2019 · 2 comments · Fixed by #50
Assignees
Labels
feature New feature or request
Milestone

Comments

@JohnDoneth
Copy link
Contributor

Something I have enjoyed in other game frameworks is the ability to debug ideas by first using shape primitives such as circles, rectangles, lines, etc, using some sort of shape renderer. Off the top of my head LibGDX, as well as Love2D support this feature.

I propose a similar API for prototyping with Coffee.

A ShapeBatch type and possibly rename Batch to SpriteBatch to avoid confusion.

Some possible methods:

impl ShapeBatch {
    color(&mut self, color: Color) -> &mut self;
    circle(&mut self, x: f32, y: f32, radius: f32) -> &mut self;
    line(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> &mut self;
    rectangle(&mut self, x: f32, y: f32, width: f32, height: f32) -> &mut self;
}

Where each method returns self, or ShapeBatch for method chaining if desired.

The implementation would likely require a separate render pass, shader set, and a different per-vertex definition with just position and color. Fill vs Line drawing per shape would need to change the primitive type from lines to triangles and generate slightly different geometry.

Of course, this is just a rough idea and can use much improvement and could be improved by debate. Let me know what you think of the idea.

@hecrj
Copy link
Owner

hecrj commented May 25, 2019

Yes! This is a planned feature for 0.3.0!

The implementation would likely require a separate render pass, shader set, and a different per-vertex definition with just position and color.

Yes, the idea is to create another pipeline module inside each graphics backend (and probably rename the current one to quad_pipeline or something).

Fill vs Line drawing per shape would need to change the primitive type from lines to triangles and generate slightly different geometry.

Hmm... Interesting. I guess that changing the primitive type mid-batch would need an additional draw call.

It looks like lyon always produces triangles even when tesellating shape strokes. We could always render triangles as a first iteration.

I am currently working on something cool for Coffee, I will open a PR soon... 🤓 After that, I had plans to tackle this. Once we are able to render meshes, then we can try to tackle #17.

PS: I wrote some thoughts about this in #4, but do not worry about duplicated issues. I am totally fine with it, any discussion is welcome. Wherever it is. It does not matter.

@hecrj hecrj added the feature New feature or request label May 25, 2019
@hecrj hecrj added this to the 0.3.0 milestone May 25, 2019
@hecrj hecrj self-assigned this Jun 11, 2019
@hecrj hecrj mentioned this issue Jun 12, 2019
@hecrj
Copy link
Owner

hecrj commented Jun 12, 2019

Take a look at #50 and let me know what you think.

@hecrj hecrj closed this as completed in #50 Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants