-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Basic wgpu
renderer
#22
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We only enable the `vulkan` feature for now.
Now it supports: - Any kind of content - Custom border radius - Custom background
- Added new `renderer::Windowed` trait. This shoud allow users to easily try different renderers by simply changing one line. - Renamed `UserInterface` traits to `Application`, as the `run` method takes total control of the current thread. - Moved `MouseCursor` back to `iced_native`. The new `renderer::Windowed` trait returns one on `draw`. - Split `iced_native` renderer in multiple modules, for consistency.
The `iced_tour` crate has become a simple example.
This was referenced Oct 15, 2019
For now, we will simply assume images will be loaded from a given path.
This will be configurable when calling `Application::run` in the future.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR sets up the foundations for:
iced_wgpu
, a renderer for Iced on top ofwgpu
. Fixes Implement a low-level renderer #8.iced_winit
, a renderer-agnostic runtime and conversion functions forwinit
.iced
, a batteries-included cross-platform GUI library usingiced_wgpu
,iced_winit
, andiced_web
.As a consequence, the
tour
example depends only oniced
now. All its previous direct dependencies, includingggez
, have been dropped and the whole example fits in a single file now! 🎉Implementation details
The most important new concepts are:
iced_native::Renderer
trait with anOutput
associated type. AWidget
returns a value of this type inWidget::draw
, instead of aMouseCursor
.iced_native::renderer::Windowed
trait, which usesraw-window-handle
to define a reusable interface for graphical renderers.Application
traits in bothiced_winit
andiced
, which can be directly used to implement a GUI application easily. It should be a matter of implementing the trait and calling itsrun
method! Theiced_winit
one allows users to choose a renderer with itsRenderer
associated type, while theiced
one choosesiced_wgpu
as the default renderer on native platforms (at least for now).iced_wgpu
iced_wgpu
implements the newRenderer
andWindowed
traits and defines itsOutput
as(Primitive, MouseCursor)
. ThePrimitive
type iniced_wgpu
is a simple enum listing the different supported primitives. Currently, three primitives are supported:Text
with a size, color, alignment, and specific boundaries.wgpu_glyph
is used to render primitives of this kind.Quad
with a background color (gradient and image backgrounds are not done yet!), border radius, and some boundaries. A pipeline with a simple fragment shader is used to render multiple instances of this primitive at once.Group
, a group of primitives.UserInterface::draw
can be used to obtain a tree describing the different primitives that comprise the GUI. These primitives can be then drawn in the next frame usingRenderer::draw
.iced_winit
iced_winit
implements a renderer-agnostic runtime on top ofwinit
in itsApplication
trait. This new trait can be implemented by simply providingRenderer
andMessage
types, and implementing the update and view logic of the GUI. Once implemented,Application::run
can be called, which will take control of the current thread, create a window, and run the application.It is important to note that using the new
Application
trait is optional.winit
users can still build their own event loop and useiced_native::UserInterface
directly. For this purpose, aconversion
module is exposed and can be used to convertwinit
events intoiced_native
events easily.Changelog
Added
iced_wgpu
crate, a simple renderer foriced_native
on top ofwgpu
.iced_winit
crate, a renderer-agnostic runtime foriced_native
on top ofwinit
.Renderer
trait iniced_native
with anOutput
associated type.renderer::Windowed
trait iniced_native
, which defines a reusable interface for graphical renderers thanks toraw-window-handle
.Background
type iniced_core
, it only supports aColor
variant for now.Button::padding
, a method to define the padding of a button.Button::background
, a method to define theBackground
of a button.Button::border_radius
, a method for displaying buttons with rounded borders.Color::WHITE
constant.Color::into_linear
, which converts aColor
into its linear values.Changed
Button
supports any element as content, instead of just a label.Widget::draw
returns aRenderer::Output
.Renderer
extends the newiced_native::Renderer
trait.Image
does not have generic handle now, it always takes aString
representing a path or URI.Removed
button::Class
enum. Given that buttons are now customizable, it is no longer necessary.Button::class
method.Pending work before merge
Image
primitive. It's the only missing piece to make thetour
work as before.iced_winit
runtime relies on the newRedrawRequested
API to handle resizes properly. As of now, it only compiles on Windows and Linux with X11.RedrawRequested
on macOS rust-windowing/winit#1235tour
example work on web usingwasm-bindgen
.