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

Respect opacity when drawing annotations #238

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

Carifio24
Copy link
Member

This PR resolves #237, allowing the engine to respect the opacity value of annotations when drawing them.

The implementation here is meant to work with the way that the engine handles drawing annotations (which I hadn't really understood when I opened the original issue). Basically, the primitives for each annotation don't get passed into the relevant shader(s) separately - what happens is that they get added to global collections of the relevant primitive type ("global" here meaning static member values of the Annotation base class). Then the shader calls for each "list of primitives" type are made inside of the drawing methods in DrawBatch.

What this means is that we can't use the opacity argument of each annotation in the Draw/DrawLines calls (e.g. here and similar calls), because these calls are made in a static method without access to a particular annotation's opacity. Thus, I think the only good way to do this is to inject the opacity into the passed color - basically, if an annotation has color (A,R,G,B) and opacity α, we pass the shader (A*α,R,G,B). This is the approach taken here. Note that I had to round the values for this to work correctly - Color.A is typed as a float, but only seemed to work when I gave it an integer.

For testing this, I used the example code I gave in #237, plus some similar code for Poly and Circle annotations.

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

Successfully merging this pull request may close these issues.

Opacity setting for annotations is not respected
2 participants