diff options
author | 2022-10-24 17:06:02 -0700 | |
---|---|---|
committer | 2022-11-05 03:19:38 +0100 | |
commit | 5575e6ea0897e406674e7e4239808fbf9daa07c3 (patch) | |
tree | 888f1b22926a304e7e280710312727fc4137e373 /glow/src/shader | |
parent | 2c7c42ee93a61f39562590f6a75eb2dd8b220fb8 (diff) | |
download | iced-5575e6ea0897e406674e7e4239808fbf9daa07c3.tar.gz iced-5575e6ea0897e406674e7e4239808fbf9daa07c3.tar.bz2 iced-5575e6ea0897e406674e7e4239808fbf9daa07c3.zip |
Add image/svg support to `iced_glow`
https://github.com/iced-rs/iced/issues/674
Uses image/svg support in `iced_graphics`. The is not currently using an
atlas, and uses one texture/draw per image. This should be good enough
for now; supporting images with glow is better than not supporting them,
and if something else performs better, that improvement can be made
without any change to the public API.
Diffstat (limited to 'glow/src/shader')
-rw-r--r-- | glow/src/shader/common/image.frag | 22 | ||||
-rw-r--r-- | glow/src/shader/common/image.vert | 9 |
2 files changed, 31 insertions, 0 deletions
diff --git a/glow/src/shader/common/image.frag b/glow/src/shader/common/image.frag new file mode 100644 index 00000000..5e05abdf --- /dev/null +++ b/glow/src/shader/common/image.frag @@ -0,0 +1,22 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif + +uniform sampler2D tex; +in vec2 tex_pos; + +#ifdef HIGHER_THAN_300 +out vec4 fragColor; +#define gl_FragColor fragColor +#endif +#ifdef GL_ES +#define texture texture2D +#endif + +void main() { + gl_FragColor = texture(tex, tex_pos); +} diff --git a/glow/src/shader/common/image.vert b/glow/src/shader/common/image.vert new file mode 100644 index 00000000..93e541f2 --- /dev/null +++ b/glow/src/shader/common/image.vert @@ -0,0 +1,9 @@ +uniform mat4 u_Transform; + +in vec2 i_Position; +out vec2 tex_pos; + +void main() { + gl_Position = u_Transform * vec4(i_Position, 0.0, 1.0); + tex_pos = i_Position; +} |