Commit graph

283 commits

Author SHA1 Message Date
Gered 7cff580bcb helper trait for imgui helper functions
only one for now. i am assuming i will want more in the future.
2023-04-11 22:12:55 -04:00
Gered 424c63d414 imgui_integration example initial commit, work in progress
mostly working, but the imgui ui part is only a placeholder.

also this example project is kind of overly complicated, but i really
wanted this to be something that somewhat resembles a real tool that
i'd want to build.
2023-04-10 19:40:46 -04:00
Gered d85293d9bf remove need to pass a system struct to prepare a new imgui frame
just needed the destination bitmap dimensions and we don't need the
whole system struct for that
2023-04-08 21:04:45 -04:00
Gered 0f4ed2965c add wrapper struct to simplify imgui init and usage
rather than forcing use of 3 separate structs
2023-04-08 20:52:38 -04:00
Gered 3befd786ca adjust default imgui style's rounding settings 2023-04-07 14:46:17 -04:00
Gered eeee7ed67b cleanup 2023-04-07 14:31:50 -04:00
Gered 89be7f5e89 minor simplifications
sort of
2023-04-07 14:30:22 -04:00
Gered e3d585ec90 initial commit of ggdt_imgui library
fairly basic at this stage, but working
2023-04-07 14:21:27 -04:00
Gered cf6b7e5e3c minor crate import cleanups 2023-04-06 21:50:34 -04:00
Gered df31483cbd set opt-level = 1 on the dev profile by default 2023-04-06 21:15:17 -04:00
Gered 231ba10f1e remove Copy trait from these event enums to be consistent with the rest
since the TextInput event cannot implement Copy, necessitating the
removal of the Copy trait from KeyboardEvent, it feels wrong to me to
have the other event enums implement Copy, because it is inconsistent.

so while this is less convenient potentially, it feels consistent.

probably not a big deal in the future one way or the other.
2023-04-05 12:45:09 -04:00
Gered 1c39832801 add keyboard TextInput event mapping 2023-04-05 12:42:57 -04:00
Gered f3b6ca46e1 move all of the triangle_2d draw implementations to their own functions
keeping the original single triangle_2d function taking the enum, but
also allowing separate functions to be called without the need for an
enum, which might be useful.

plus this also feels a bit better organized and easier to read when you
just need to look at one or two different triangle drawing
implementations.
2023-04-05 12:37:26 -04:00
Gered 097147c568 update visual reference test image affected by some recent changes 2023-04-04 21:06:41 -04:00
Gered 29e5a8b080 some similar changes in indexed triangle_2d drawing 2023-04-04 21:06:10 -04:00
Gered a0c1199264 changes for a bit more floating-point stability in triangle_2d rendering
in truth, there's a lot of per-pixel color munging going on in these
triangle renderers. maybe too much? we're doing a lot of operations that
are constantly deconstructing argb32 colors and then reconstructing, and
then deconstructing+reconstructing again. and some of the time we were
doing this as floats, via the "normalized" conversion functions. this
seemed to be adding a bit of "color jitter" that could be visible
at run-time when triangles were being animated somehow (e.g. resized).

also, the whole "inverse area" thing, while probably a bit of a
micro-optimization at best, was causing its own little bit of visible
"color jitter" sometimes, probably due to an increased level of
floating-point inaccuracy when representing the area as a fraction
like that.
2023-04-04 21:05:33 -04:00
Gered 8aefdd6f0d update triangle_2d benchmarks
- switch to use RgbaBitmaps
- add more, particularly some with blending. not all are here though.
2023-04-04 20:30:42 -04:00
Gered 4f58b68012 cleanup imports 2023-04-04 20:29:53 -04:00
Gered 7a631e6088 make both 2d triangle enums derive Copy 2023-04-04 18:37:10 -04:00
Gered 2b39f6ae88 add indexed triangle 2d visual reference tests 2023-04-04 18:26:38 -04:00
Gered f564721e46 add blended triangle_2d drawing operations for IndexedBitmaps 2023-04-04 18:25:38 -04:00
Gered d1fb0c6b2e add new blend function and rgba triangle 2d visual reference tests 2023-04-04 17:52:00 -04:00
Gered 1985afe040 add triangle_list_2d method for rendering lists of triangles 2023-04-04 17:50:48 -04:00
Gered 380bff59eb add BlendFunction::MultipliedBlend 2023-04-04 15:34:33 -04:00
Gered 173aaa2579 rename blend_source_by_value to blend_argb32_source_by
which is probably not objectively better or worse ...
2023-04-04 15:27:13 -04:00
Gered 30e7be38db add a bunch of color function tests
also moved the argb to/from conversion tests from the palette module
over to the color module
2023-04-04 13:02:38 -04:00
Gered 700f650561 add Display trait to our Pixel trait 2023-04-04 08:42:38 -04:00
Gered ce7d8edc6d slightly improve some primitive drawing operations
improve in the readability sense, not performance i don't think, since
this style of iterator looping is what the slice fill method does
anyway i'm pretty sure
2023-04-04 08:41:57 -04:00
Gered 725dc12424 fix 2d triangle inner loop behaviour when applying fill rule
we can't just do a `continue` as we need to ensure that we always update
the barycentric coordinates on every single iteration
2023-04-03 16:19:25 -04:00
Gered 39b788c564 fix 2d triangle clipping 2023-04-03 14:41:14 -04:00
Gered 4b91d494d0 add some #[inline] attributes to various math stuff
also switch away from #[inline(always)] to just #[inline]
2023-04-03 14:40:40 -04:00
Gered e5fda9cb25 small enhancement to nearly_equal 2023-04-03 13:50:41 -04:00
Gered ac9393d3a4 include alpha component in triangle per-vertex-color blending modes
otherwise the blend is wrong (basically doesn't blend at all)
2023-04-03 13:50:00 -04:00
Gered f8d00135b2 re-add middle-of-pixel triangle sampling, which got mistakenly dropped 2023-04-02 15:06:07 -04:00
Gered 68bbd8c13c implement top-left fill rules in triangle rendering 2023-04-02 15:03:45 -04:00
Gered 49a8b23568 should be testing with '<=' so that we also draw edge pixels
'< 0' gives us pixels inside the triangle. '== 0' gives us pixels on
the edges of the triangle
2023-04-02 15:03:17 -04:00
Gered 2280578904 add a bunch of extra RgbaBitmap textured triangle rendering options
variations on texturing with single-color/multi-color/blending/tinted
2023-04-01 22:17:34 -04:00
Gered 2695bf4679 add helper function to multiply two argb colors together 2023-04-01 22:10:39 -04:00
Gered 2c7d78f0d1 add RgbaBitmap triangle blending options 2023-04-01 21:37:00 -04:00
Gered a41fca5640 rename triangle SolidSingleColor enum variant to Solid 2023-04-01 21:36:19 -04:00
Gered 3e4b9affa0 redo triangle 2d drawing api to use enums. split indexed+rgba variants
i'm not *entirely* sold on this particular enum-based api, but i think
it could work. in the future i'd likely ALSO want something that could
work with triangle data as an offset from a larger buffer, but we can
solve that problem later when it comes up.

mainly i just didn't want to have a bunch of different triangle_2d
function variants exposed. same justification as with the blit enums,
basically.
2023-04-01 18:48:54 -04:00
Gered 7a5ea75e1f add color-component-to/from-packed functions for normalized components 2023-04-01 18:45:58 -04:00
Gered eef0b4f7a4 important comment documenting a difference in this triangle algorithm
the difference is important to note since most articles discussing
implementations of barycentric triangle rasterization show a test
for positive w0/w1/w2 to determine if you're inside the triangle or not.
they also usually use a slightly different formula in the `cross`
function if they assume counter-clockwise vertex winding.

since i'll admit i still don't *fully* grasp the math behind the edge
functions and that stuff that is used to calculate the a01/b01/a12/...
values, i wasn't sure how to adjust these for counter-clockwise winding
to keep a positive w0/w1/w2 check. so the simple solution is to use
the `cross` function as it is now, calculate a01/b01/a12/b12/a20/b20
as we are now, and do a negative w0/w1/w2 check and we get to keep
counter-clockwise vertex winding which i prefer. hooray!
2023-04-01 14:57:17 -04:00
Gered 6689f31146 implement triangle drawing "optimizations"
these don't actually improve performance at all judging from the
criterion benchmarks. lol.
2023-04-01 14:24:29 -04:00
Gered 67bcbec69b hack-fixes to triangle_2d_custom and bitmap texcoord sampling. ugh!
this is terrible but i do not currently know what the fuck is going on
2023-04-01 11:09:30 -04:00
Gered 80d3ae91e7 use bitmap sampling method instead of manually calculating it 2023-04-01 00:50:56 -04:00
Gered ed58dc39cd add Bitmap texture coordinate sampling convenience method
his has some off-by-one issues ... ? looks like it mostly works fine,
but i need to investigate more
2023-04-01 00:49:52 -04:00
Gered a106228517 sample in the middle of pixels, instead of the top-left 2023-04-01 00:40:05 -04:00
Gered 832daefbda add initial triangle_2d_textured method 2023-03-31 23:27:15 -04:00
Gered 69bb0c4830 this should be a mutable reference argument
to be honest, i'm not sure how this compiled successfully before, since
the value being passed in via Bitmap::triangle_2d_custom is clearly of
type `&mut PixelType` ... ? either way, this is now written consistently
and we get to remove an unnecessary unsafe block
2023-03-31 22:16:32 -04:00