Commit graph

157 commits

Author SHA1 Message Date
Simon Hausmann
8b854c32c3 Add Text::font_family and font_pixel_size properties
We can fine-tune the API, this works for now to change :-)
2020-05-21 21:04:07 +02:00
Simon Hausmann
4d26fe6674 Implement support for selecting the font family and pixel size in the GL renderer
The public API in the properties is still missing.
2020-05-21 20:55:34 +02:00
Simon Hausmann
8e8943b8fe Clean up texture atlas allocation code
Let each atlas texture know its index, so that it can return the final
allocation result right away.
2020-05-21 18:54:46 +02:00
Simon Hausmann
86eaf027d4 Implement glyph runs grouped by texture
In order to support multiple font sizes, etc. we have to deal with the
fact that the glyphs for a string may not end up all in the same atlas
texture. Therefore splitting of glyph runs by texture is necessary.

This works but could be improved further by sharing the vertex arrays
and just re-binding to a different texture and drawing the run's
triangles by index.
2020-05-21 15:51:09 +02:00
Simon Hausmann
66c91ef658 Prepare for supporting multiple glyph runs
A glyphs primitive may end up requiring multiple draw commands in the future,
so prepare for that.
2020-05-21 15:51:09 +02:00
Simon Hausmann
de923131ee Remove dummy test code
It's not testing anything :-)
2020-05-20 13:27:07 +02:00
Simon Hausmann
994d47a529 Shader module cleanup
Move the specific shaders into the shaders module and then hide the Shader
type. It's not necessary to export it anymore.
2020-05-20 13:27:07 +02:00
Simon Hausmann
f7dfb030a0 Improve shader setup code
Determine the locations of the uniforms and attributes once instead of on every use.
This makes the code easier to read and faster.
2020-05-20 13:27:07 +02:00
Simon Hausmann
b7fd9658d3 More shader code cleanup
Move the uniform and attribute binding into the shader encapsulating types.
2020-05-20 13:27:07 +02:00
Simon Hausmann
036c1aae38 Begin shader code cleanup
Start by a bit of encapsulation of the specific shaders we use.
2020-05-20 13:27:07 +02:00
Simon Hausmann
5acb8e7bdd Minor glyph handling cleanup
When laying out glyphs, don't require a slice, just an iterator.
2020-05-20 11:02:48 +02:00
Simon Hausmann
9b9a29e03d Clean up glyph handling
Avoid calling glyph_for_char twice for each character.
Instead do the conversion once explicitly. That needs to be done anyway for shaping.
2020-05-20 10:50:49 +02:00
Simon Hausmann
e0cc9aef2a Cleanup text rendering code a bit
Move the text related code into a separate file.
2020-05-20 10:50:49 +02:00
Simon Hausmann
f29aa0a302 GL buffer handling cleanup
Move the buffer handling code into a separate file.
2020-05-20 10:50:49 +02:00
Simon Hausmann
4834de04f9 Shader code cleanup
Move the shader code into a separate file
2020-05-20 10:50:49 +02:00
Simon Hausmann
f27a715b30 GL texture handling cleanup
Move the gl texture handling code into a separate file/module.
2020-05-20 08:52:20 +02:00
Simon Hausmann
527525f733 Another issue created for tracking 2020-05-19 22:16:08 +02:00
Simon Hausmann
d7b742d082 Created issue for comment 2020-05-19 22:14:27 +02:00
Simon Hausmann
3f813808f1 Small comment fix 2020-05-19 22:13:11 +02:00
Simon Hausmann
81b5f70718 Implement colored text rendering 2020-05-19 21:58:01 +02:00
Simon Hausmann
ddf137221a Implement glyph rendering using atlas texturing
This means duplicate glyphs are rendered only once and we store glyphs
in the atlas texture globally instead of a texture per text primitive.
2020-05-19 21:47:47 +02:00
Simon Hausmann
3c2ad7b275 Add support for atlas textures in the GL renderer
... and place images in there by default. This improves locality.

The atlasing is also needed for individual glyph rendering, which is
coming soon.
2020-05-19 20:38:28 +02:00
Simon Hausmann
cbd28bf745 Simplify image primitives API
Removed the source rectangle as that can also be done on the source image side,
if necessary.
2020-05-19 20:37:36 +02:00
Simon Hausmann
23d3964a0d Add boilerplate for text items
Forward the text and color properties to the rendering backend, where
right now we just rendering all the glyphs into a dedicated texture.

Next steps are a glyph atlas texture, blending the specified color with
the alpha of the glyphs, configurable size and family, shaping with
Harfbuzz and may more things.
2020-05-18 19:04:12 +02:00
Olivier Goffart
686f4c9591 More work on the vtable macro to adapt the Component
This does not work yet
2020-05-18 11:04:54 +02:00
Olivier Goffart
4b19818f6c WIP: port Component to vtable 2020-05-18 11:04:54 +02:00
Simon Hausmann
c26a2a1562 Fix GL context state handling
Make our GL context not current when done with the initialization
and make it current for the duration fo primitive creation and frame
rendering.

Fixes #4
2020-05-12 21:42:34 +02:00
Simon Hausmann
0b807190c7 GL Renderer cleanup
Get rid of the vertex array object that's not really used. We do bind the binding
manually right now anyway and this can be reintroduced later.
2020-05-12 19:22:01 +02:00
Simon Hausmann
93bb21f082 Fix dead code warning when targeting wasm 2020-05-12 16:24:56 +02:00
Simon Hausmann
7efcbd5816 Simplify geometry handing
Replace the use of kurbo's primitives with lyon/euclid. This means less data copying,
conversion and also no annoying precision
casts.
2020-05-11 19:23:03 +02:00
Olivier Goffart
471dd0f778 Make run_component safe 2020-05-11 15:35:17 +02:00
Simon Hausmann
83eb00b080 Run the C++ generated component through the GL backend
... which in turn forward to the corelib, but with the GL renderer attached.
2020-05-11 15:05:33 +02:00
Simon Hausmann
3a954e4cea Move window system creation and other GL related code into the GL backend 2020-05-11 13:11:55 +02:00
Simon Hausmann
e4ce0bcd7e Prepare for exposing the rendering backend to C
... by building a cdylib.
2020-05-11 10:56:33 +02:00
Simon Hausmann
35831c57c7 Use glow without glutin
We don't need the dependency for glow
2020-05-09 14:29:07 +02:00
Simon Hausmann
8843f655eb Reduce the binary size
Only use the png loader from image
2020-05-07 21:02:46 +02:00
Simon Hausmann
50b7b753e8 Minor GL renderer cleanups
Rename GLVertexBuffer to GLArrayBuffer, as that's what it is. Also added TODO
issue reference.
2020-05-07 20:50:01 +02:00
Simon Hausmann
f55c4e50f0 Track the issue of keeping the GL context current 2020-05-07 20:42:28 +02:00
Simon Hausmann
3d1df6178e Track the issue of releaseing GL resources 2020-05-07 20:38:10 +02:00
Simon Hausmann
cf37242952 Implement image rendering with glow 2020-05-07 15:07:29 +02:00
Simon Hausmann
14f807ac21 Implement path filling with glow 2020-05-07 15:07:29 +02:00
Simon Hausmann
12626472c4 Fix wasm build
Get rid of the glutin dependency in the GL renderer -- the caller is now responsible for swapping buffers.
2020-05-07 15:07:29 +02:00
Simon Hausmann
e0b024d2cf Some work towards implementing the gl renderer
... in plain GL(ow). swapbuffers and clearing the color buffer is working.
2020-05-07 15:07:29 +02:00
Simon Hausmann
da57d6be04 Start the switch to glow, comment out all renderer code 2020-05-07 15:07:29 +02:00
Simon Hausmann
c41cb3e179 Fix alpha blending in the gl renderer 2020-05-06 09:51:21 +02:00
Simon Hausmann
17d3d49a83 Use cgmath throughout
And remove usage of kurbo::Affine. That avoids extra translations.
2020-05-05 23:00:03 +02:00
Simon Hausmann
e8f30b6444 Fix coordinate system in the gl renderer
Apply the correct orthographic projection matrix in the position calculations,
which includes the y-flip.
2020-05-05 22:47:27 +02:00
Simon Hausmann
bfac827ec7 Start with image rendering
These are the basics. Still to do are fixing the alpha channel blending, the rect handling,
a texture type to avoid consuming  the image over and over again. And more :-)
2020-05-05 18:20:21 +02:00
Simon Hausmann
f3a4f75e17 Allow specifying a clear color for the frame
... and default it to white.
2020-05-05 13:51:48 +02:00
Simon Hausmann
8dff1967ad Hide data structures of the GL renderer
Don't leak this accidentally to the outside
2020-05-05 13:38:28 +02:00