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

Upgrade to latest piston-graphics #111

Closed
bvssvni opened this issue Apr 18, 2016 · 4 comments
Closed

Upgrade to latest piston-graphics #111

bvssvni opened this issue Apr 18, 2016 · 4 comments
Labels

Comments

@bvssvni
Copy link
Member

bvssvni commented Apr 18, 2016

The draw state has been simplified, which requires a different mapping to Glium draw state.

Convert from sRGB to linear color space.

@gaborigloi
Copy link

gaborigloi commented Apr 21, 2016

I had a go at this (but not the sRGB conversion): https://github.com/gaborigloi/glium_graphics/tree/latest-graphics, this compiles with the latest piston2d-graphics.
To upgrade, most of the time I just followed what the opengl_graphics backend does.
I also updated piston-texture to the latest version.

I noticed two things:

  • The definition of alpha blending in Piston is different from alpha blending in glium for the alpha channel.
    piston2d-graphics says new_dest_alpha = src_alpha + dest_alpha, but what glium does is
    new_dest_alpha = src_alpha * src_alpha + dest_alpha * (1 - src_alpha).
    Therefore I could not use glium::Blend::alpha_blending(), had to construct the Blend manually.

  • For graphics::draw_state::Blend::Invert, I used this blending:

    new_dest_color = (ref_color - dst_color) * src_color,

    but the equation in the rustdoc of Invert is different, it says

    new_dest_color = ref_color - src_color.

Also, I'm not sure what formatting to use, I'm still new to Rust. Should I just run rustfmt to format the code, or is the current formatting ok?

@gaborigloi
Copy link

Opened a pull request: #112

@bvssvni
Copy link
Member Author

bvssvni commented Apr 21, 2016

I think piston-graphics used the alpha equation from Gfx, but after doing some research it seems neither Glium or Gfx use the correct one. Opened PistonDevelopers/graphics#1042

@bvssvni
Copy link
Member Author

bvssvni commented Apr 21, 2016

For now, we could use new_dest_alpha = src_alpha + dest_alpha.

@bvssvni bvssvni removed the draft label Apr 21, 2016
bvssvni added a commit to bvssvni/glium_graphics that referenced this issue Apr 21, 2016
Closes PistonDevelopers#111

- Bumped to 0.21.0
- Updated dependencies
- Fix sRGB to linear conversion
- Use `SrgbTexture2d`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants