Commit Graph

168 Commits

Author SHA1 Message Date
Martin Fouilleul 7b2ef080e8 [util, formatting] shorten list loop names to for_list_xxx 2023-03-08 12:03:33 +01:00
Martin Fouilleul 3682605f97 [util, formatting] changed list api to snakecase for consistency with the rest of the codebase 2023-03-08 12:00:10 +01:00
Martin Fouilleul bfc19665ce [util]
- shorten str8_lit macro to STR8
- use strlen() in STR8 and remove str8_from_cstring(). Usage with string literal seem to always be optimized by compile-time constant, so there's little need for a confusing macro that only works with literals and breaks with pointers.
- replaced str8_unbox() with str8_lp/str8_ip
2023-03-08 11:40:40 +01:00
Martin Fouilleul f07f56948d [ui] shorten ui styling api names 2023-03-08 11:13:32 +01:00
Martin Fouilleul 8b06cb31ba [ui, styling]
- Put all styling calls _before_ the styled box.
- Renamed full pattern matching API to ui_style_match_next_before/after
- Helper to style next box only (ui_style_next())
2023-03-08 11:09:28 +01:00
Martin Fouilleul c551135933 [ui] remove the need to pass a default style to ui_frame() 2023-03-07 19:44:22 +01:00
Martin Fouilleul 2466241b1e [ui, styling] finished first pass on core layout/styling system 2023-03-07 19:27:01 +01:00
Martin Fouilleul 8032c7340b [ui, styling] revisiting layout/sizing 2023-03-07 19:06:04 +01:00
Martin Fouilleul d3a8a651e5 [ui, styling] make layout and floating properties part of styling system 2023-03-07 10:33:22 +01:00
Martin Fouilleul 7b10a99a8c [ui, styling] First draft of rule-based styling to replace old stack-based system 2023-03-06 19:33:01 +01:00
Martin Fouilleul b52a35c753 [ui, textbox] Fixed selection background rectangle 2023-03-05 17:03:00 +01:00
Martin Fouilleul 1af132352a [ui, textbox] Scroll text inside text box to always show edit cursor. 2023-03-05 16:35:55 +01:00
Martin Fouilleul 592f4cdecd end of line renormalization 2023-03-05 16:05:43 +01:00
Martin Fouilleul 4359bdaa3c [ui, textbox] position cursor at mouse position / extend selection on shift + mouse press or drag 2023-03-05 15:59:57 +01:00
Martin Fouilleul e95efe85e8 [wip, input system] Fixed bug on macOS, where keyUp events are not received when the command modifier key is down and makes a meaningful combination with the pressed key (note this is normal macOS event handling behaviour, but we still want all events to arrive to track key states).
Fixed by overloading the sendEvent method of our derived NSApplication class. There we check if modifier is down and send the event.
Note glfw solves that by adding a block handler for the keyUp event with addLocalMonitorForEventsMatchingMask.
2023-03-04 19:24:30 +01:00
Martin Fouilleul c04e8639ab [wip, ui] re-integrating UI subsystem and completing text box 2023-03-03 20:09:44 +01:00
Martin Fouilleul d21e737733 [wip] re-introducing UI subsystem 2023-03-03 17:13:03 +01:00
martinfouilleul 653ddec978 [win32 surface sharing] win32 surface sharing using window reparenting 2023-03-03 12:41:09 +01:00
Martin Fouilleul 731e5b1ae8 [surface] pull mp_layer into the generic mg_surface_data struct, out of each backend-specific implementation 2023-03-03 11:50:12 +01:00
martinfouilleul ac00cc9def [wip, win32 surface sharing] simplifyin the surface sharing API 2023-03-02 19:21:39 +01:00
martinfouilleul ee87976429 [win32 surface sharing] hacky proof of concept 2023-03-02 18:24:15 +01:00
martinfouilleul 3ada8ece9a [wip, win32 surface sharing] in surface sharing example, terminate child process when parent exits 2023-03-02 12:23:10 +01:00
martinfouilleul e58ae3ef52 [surface sharing] first draft for win32 using window reparenting 2023-03-02 09:54:12 +01:00
martinfouilleul 1dfc5dd684 [graphics, win32] applying changes to surface backend API 2023-03-01 17:41:39 +01:00
Martin Fouilleul 43d413dbbc [surface] graphics surface sharing API + osx implementation 2023-03-01 16:15:36 +01:00
Martin Fouilleul 28f5af32fa [graphics] Allocate canvases and fonts from graphics subsystem's arena 2023-03-01 11:37:33 +01:00
Martin Fouilleul 6bf989564d [graphics] use a single handle arena for all graphics subsystem handles 2023-02-28 20:33:55 +01:00
Martin Fouilleul 5a19c03ad6 [canvas] removing unused old atlasing api 2023-02-28 18:47:45 +01:00
Martin Fouilleul 3615775168 [canvas] decompose image atlas API into simple rect atlas API + image atlas helpers. This avoids creating a bunch of new types/handles, and exposes the underlying image/sourceRegion so that user code can freely use these for more complex scenarios (eg drawing only a sub-region of an atlased image, or using an atlas image for arbitrary path filling) 2023-02-28 16:54:39 +01:00
Martin Fouilleul d4bceba7e9 [canvas] basic image atlas API 2023-02-28 13:16:36 +01:00
martinfouilleul 9cb4aedbc5 [canvas, gl] use pre-multiplied alpha in draw shader and when compositing batches 2023-02-27 19:50:18 +01:00
martinfouilleul 8f834fa1a5 [wip, canvas, gl] implementing basic image API 2023-02-27 19:25:41 +01:00
Martin Fouilleul 30aa6a4a48 [canvas] Put primitive's transform in the attributes struct. When rendering, set current transform at the beginning of mg_next_shape(). (This avoid using an additional prevTransform matrix to correctly setup uvTransform when mg_finalize_shape() at the beginning of mg_next_shape()) 2023-02-27 15:01:44 +01:00
Martin Fouilleul d195fb1f61 [canvas, mtl backend] Compute each layer with pre-multiplied alpha, starting from transparent color. Composite them to surface with premultiplied alpha too. 2023-02-27 14:24:59 +01:00
Martin Fouilleul 9ed630fc55 [canvas]
- Clear final surface to clear color, and enable blending layers onto it
- Fixed Batching bug where we were writing to vertex/shape buffers while the previous batch is using them
- Fixed bug where uvTransform uses transform of next shape instead of that of shape being finalized
2023-02-27 11:56:04 +01:00
Martin Fouilleul e66932e624 [canvas] Set command attributes to canvas->attributes by default in mg_push_command() 2023-02-25 15:35:24 +01:00
Martin Fouilleul 193afb61fd [canvas] move canvas structs decl from graphics_internal.h to graphics.c, keep only surface/canvas backend interface stuff in graphics_internal.h 2023-02-25 15:23:15 +01:00
Martin Fouilleul 074b17b743 [canvas] Set transform matrix as part of primitive and don't replay push/pop during render 2023-02-25 14:20:07 +01:00
Martin Fouilleul b24de5d969 [canvas] Allow setting image source region 2023-02-25 12:59:49 +01:00
Martin Fouilleul 50569a1427 Allow setting texture on arbitrary path fills 2023-02-24 23:06:39 +01:00
Martin Fouilleul 4333ed02b0 [canvas] remove image draw commands, replace with rect/rounded rects + image source 2023-02-24 22:59:33 +01:00
Martin Fouilleul 1b62ec568c [canvas, mtl backend] Handle image rotation 2023-02-24 20:40:16 +01:00
Martin Fouilleul bb106b717f Build user-space bounding box of shape in mg_push_vertex() _before_ transforming vertices 2023-02-24 19:20:05 +01:00
Martin Fouilleul 11c25bf001 Make transform implicit in mg_push_vertex() 2023-02-24 19:11:03 +01:00
Martin Fouilleul 5be019d166 [canvas, metal] compute uv coords in shader using uvTransformed computed in canvas backend, using shape bounding box, image dimension, source and dest regions 2023-02-24 18:50:46 +01:00
Martin Fouilleul fd4c4e7be3 [canvas] simple image API 2023-02-24 12:01:00 +01:00
Martin Fouilleul d1b71110bb - Fixed metal canvas backend's drawBatch argument order
- Removed texturing in metal shader while we work on image API
- Started working on simple image API
2023-02-23 18:30:47 +01:00
Martin Fouilleul 2b60db292a [wip] image api 2023-02-23 17:07:41 +01:00
martinfouilleul 1250dfd7c1 hardcode GL/GLES versions per-platform for now 2023-02-22 18:30:10 +01:00
martinfouilleul 665c63c3d0 [win32 build/link]
- Build milepost as a dynamic library
- Add import/export directives to public API symbols
- Change example build scripts accordingly
2023-02-21 18:43:30 +01:00
Martin Fouilleul 94373d12ae [surface] extracted common layer functionality from osx surfaces. Use layer in platform-agnostic egl surface. 2023-02-21 13:40:30 +01:00
martinfouilleul 9ea9ea7636 [surface] abstracted child window layer from win32 surfaces 2023-02-21 12:35:22 +01:00
martinfouilleul 5ac512c15e [wgl] Keep dummy window/context around for gl context creation, and don't reload wgl functions every time 2023-02-20 20:20:52 +01:00
martinfouilleul 64d7b31e5c destroy gles surfaces resources 2023-02-20 19:38:24 +01:00
martinfouilleul 2dccfa5547 [win32 surfaces] Backing win32 surfaces with child window and implementing frame/hidding control 2023-02-20 18:34:29 +01:00
Martin Fouilleul 4306d0a01c back osx surfaces by CALayer 2023-02-20 16:49:44 +01:00
Martin Fouilleul 2232b647ed reintroduced GLES backend to osx 2023-02-20 11:05:01 +01:00
martinfouilleul 333d3e9f9c [gles, wip] reintroducing egl surface (for win32 at first) 2023-02-17 18:56:16 +01:00
martinfouilleul 20e425494f Use a custom GL loader to allow different versions of GL/GLES APIs to co-exist. The loader fills an api struct with GL functions pointers.
We have a per-thread pointer to select which api struct is used, and GL functions are pound-defined to call the versions in that struct.
GL/GLES surfaces can use one of the loader function to load their api, and the prepare proc of the surface sets its api as the current one
before gl calls are issued.
2023-02-16 19:35:01 +01:00
martinfouilleul 80ea8db687 [surface/canvas cleanup]
- Make build-time and runtime backend selection a bit easier
- Reorganized backend-specific files with slightly more coherent naming scheme
2023-02-10 16:56:10 +01:00
martinfouilleul f54f639db5 properly destroying windows and fonts 2023-02-10 12:05:52 +01:00
martinfouilleul 08d3521b61 [canvas/surface cleanup]
- properly destroy gl canvas backend
- properly destroy gl surface
2023-02-09 18:40:42 +01:00
martinfouilleul af7cbae1fa [canvas cleanup] cleanup canvas resources on creation failure 2023-02-09 18:18:12 +01:00
martinfouilleul 35e396e4c4 [canvas cleanup]
- Remove attributes/color arguments in functions where we don't need them anymore (since they're defined when calling mg_next_shape())
- Renamed "_with_zindex" functions with "_path" -> these function only fill a path (eg rect), but don't increment the current shape
2023-02-09 17:02:58 +01:00
martinfouilleul 09a18419e4 [canvas] make shapeIndex implicit in calls to mg_push_vertex 2023-02-09 16:42:02 +01:00
martinfouilleul 4e816a838b [Clean canvas/shaders]
- Simplified shader names, prefix embedded strings by "glsl_"
- Extracted shader compilation in common function
- Add shader version string and common structs in canvas code rather than in every shader file
- Renamed zIndex with shapeIndex everywhere
2023-02-09 16:14:15 +01:00
martinfouilleul 4a8c77f023 - Move and Zoom perf_text example with the mouse
- Reverted to using 4 bits of subpixel precision and computing cross products with 32 bits integers, for perf reasons
- Fixed some confusion in tile array size vs number of elements (could still clean-up naming a bit though)
- Fixed bug where triangles on the left or below canvas boundaries where bucketted to the first colum/row of tiles
- Fixed bug in mouse button message handling (was always sending press on left button)
2023-02-09 13:09:41 +01:00
martinfouilleul 833767d6e2 move text with the mouse in perf_text example 2023-02-09 09:50:53 +01:00
martinfouilleul 21c604104f fix mp_app_get_resource_path() 2023-02-08 20:40:48 +01:00
martinfouilleul c0601961f1 Reposition window when changing dpi 2023-02-08 20:40:48 +01:00
martinfouilleul 3f58b2ac3d glsl canvas shader: do cross products in 64 bits fixed point to avoid overflow 2023-02-08 20:36:39 +01:00
martinfouilleul 7cf4c3d925 opengl surface/renderer: set surface scaling according to dpi of first monitor. Use that dpi to scale backing texture of canvas renderer. Note: changing monitor isn't handled yet! 2023-02-08 18:22:54 +01:00
martinfouilleul 7fbc4ba270 canvas renderer: Use clip rects to cull tiles/pixels in tiling and drawing passes 2023-02-08 12:59:31 +01:00
martinfouilleul e6e674ee04 Allow setting surface swap interval in opengl surface 2023-02-08 11:49:00 +01:00
martinfouilleul c982b524c0 Merge branch 'gl_canvas' of ssh://git.forkingpaths.dev/martinfouilleul/milepost into gl_canvas 2023-02-08 10:47:20 +01:00
martinfouilleul 38c27f21d6 canvas: allow flushing externally built commands with mg_flush_commands() 2023-02-08 10:46:12 +01:00
Martin Fouilleul afaa95fe07 applied canvas changes to metal backend 2023-02-08 10:42:21 +01:00
martinfouilleul 2419ab7889 opengl canvas renderer: splitting vertex data and shape data 2023-02-07 18:59:51 +01:00
martinfouilleul f0bc88c4fb gl canvas renderer with buffer re-specification 2023-02-07 17:00:59 +01:00
martinfouilleul 5788cdbcda Desktop opengl 4.3 canvas 2023-02-07 13:24:14 +01:00
martinfouilleul 91780b12c7 reorder fields in glsl vertex struct to be less wasteful 2023-02-06 17:01:32 +01:00
martinfouilleul 5754fc1ad2 using temporary buffer to build canvas verex data and use glBufferData with exact number of vertices to submit buffer to gpu 2023-02-06 16:14:43 +01:00
martinfouilleul 3dfaea1bba temporarily reducing vertex buffer size to test perf impact 2023-02-06 09:20:52 +01:00
martinfouilleul fd836c00dd canvas renderer: parallel tiling pass and sorting pass 2023-02-05 21:03:16 +01:00
martinfouilleul e59f2b152b simple gles tiled renderer 2023-02-03 18:44:28 +01:00
martinfouilleul 8faf588bee Added text rendering in win_canvas test app and confirm it's slow as is... 2023-02-02 20:36:03 +01:00
martinfouilleul 19988d045e breaking triangle buffer into batches each time the current image changes 2023-02-02 18:57:57 +01:00
Martin Fouilleul 9cadc2f23f added notes on bindless textures indexing 2023-02-02 17:02:55 +01:00
martinfouilleul 28e2a3648e Multisampling in gles canvas shader 2023-02-02 13:34:06 +01:00
martinfouilleul f73241e4a6 set background clear color correctly 2023-02-02 12:08:04 +01:00
martinfouilleul 0796b2cbcd Switched to fixed point in gles triangle rasterization, and fixed wrong offset curve check collapsing the internal control points 2023-02-02 11:40:22 +01:00
martinfouilleul e0300e9e3c Fixed indexing in gles_canvas_fragment shaders and fixed native keys buffer 2023-02-01 16:23:51 +01:00
martinfouilleul 8e87837fcc working on gles 3.1 canvas on windows 2023-01-31 15:51:50 +01:00
martinfouilleul c5ae556f22 [wip] win32 gles surface using angle 2023-01-29 01:04:24 +01:00
Martin Fouilleul bd7e1a15f1 - Conflating mp_views and surfaces
- Implicit canvas context in canvas API
- GLES window surface on mac
2023-01-28 17:24:43 +01:00
Martin Fouilleul 9bf62d2218 re-working graphics surfaces 2022-12-26 18:33:31 +01:00
Martin Fouilleul db5b4966e9 - Restructure osx version to use mp_app_internal.h/mp_app.c
- test new run loop structure on osx
2022-12-24 15:33:32 +01:00
martinfouilleul 72338b1a25 Extracted commonalities from platform specific app backends 2022-12-23 20:46:42 +01:00
martinfouilleul 30bd704af2 win32 opengl loader nonsense 2022-12-22 18:24:43 +01:00
martinfouilleul a696c2ba2b Added platform detection macros and atomic/thread_local abstraction 2022-12-22 15:29:07 +01:00