Commit graph

361 commits

Author SHA1 Message Date
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
Gered 4fcb6a9f0f add basic triangle_2d rendering criterion benchmark
just so i have it here for when i try to implement optimizations (again)
2023-03-31 22:11:37 -04:00
Gered 2b4c4d91dc fix broken criterion benchmarks 2023-03-31 22:10:42 -04:00
Gered ff9960d325 add basic 2d triangle rendering
only solid color support so far. and using an un-optimized algorithm
2023-03-31 22:01:02 -04:00
Gered ad1dbee5fd add RgbaBitmap::from_bytes with some limited pixel format support 2023-03-30 17:56:40 -04:00
Gered 1815a2236c update examples and doc comments code to reflect recent changes 2023-03-29 15:50:30 -04:00
Gered cfd7d479ec add variable_screen_size example project
not a super exciting project. might be removed later on when i
eventually get to adding more exciting examples
2023-03-29 15:43:58 -04:00
Gered f2f1d83edf update Standard system resource with variable screen size support 2023-03-29 15:40:37 -04:00
Gered 7143430769 update DosLike system resource with variable screen size support
also re-did DosLikeConfig at the same time, making usage a bit clearer
2023-03-29 15:38:39 -04:00
Gered e18238405c
add actions workflow to do cargo check and test
not sure if this will work. first time trying github actions and this is entirely based on what github suggested for this action.
2023-03-28 21:03:09 -04:00
Gered 7f19f4e7d4 fix a bunch of clippy warnings
but not all of them. just the easy ones for now!
2023-03-28 16:29:44 -04:00
Gered aa22786d43 update dependencies 2023-03-28 14:04:48 -04:00
Gered 6973d5e039 add rustfmt.toml to the project root
rather than just relying on $HOME/.rustfmt.toml ...
2023-03-27 18:46:33 -04:00
Gered ceaefad030 lets try using rustfmt again ...
i unfortunately feel like i should really force myself to use rustfmt
even though i very much dislike it. most rust developers seem to use it
so i should probably get used to it ...

however, case-in-point for me is the amount of times i used either
#[rustfmt::skip] or adding a blank `//` comment to force separate
lines, etc, really proves how terrible basing almost all of your
formatting rules on arbitrary length thresholds really is. code
formatting is far more subjective than that.
2023-03-27 18:43:41 -04:00
Gered 36c4cc1a41 remove these two unneeded extern crate lines
i'm going to guess this was added early on automatically by clion
and i just never caught it. they'd been here since the project was
first committed to a git repo. oh well.
2023-03-27 16:59:55 -04:00
Gered e503cfb718 remove old display size constants as well as cargo feature flags
we'll be introducing variable display size features next, so these
screen dimension compile-time constants are not going to be useful.

the "low_res" and "wide" features were also tied to the idea of
compile-time constants for display sizing so these need to go too,
and will be brought back via runtime configuration
2023-03-27 16:58:37 -04:00
Gered 806725654a fix lingering compile errors in the example projects 2023-03-27 16:46:04 -04:00
Gered e4608dee82 add visual tests for RgbaBitmap color tinted blit methods 2023-03-26 18:34:58 -04:00
Gered cf021aa1de add RgbaBitmap color tinted blit methods
BlendFunction has a tinted blend that is similar, but it is also
useful to be able to color tint without blending
2023-03-26 18:34:18 -04:00
Gered 7209907193 change to a better tint color used in visual test
figure it is best to use a color that contains all different and
non-zero RGB components
2023-03-26 17:59:42 -04:00
Gered b94ef4df4e add visual tests for BlendFunction blending 2023-03-26 17:45:22 -04:00
Gered d2bc28754f add visual tests for RgbaBitmap blended drawing primitives 2023-03-26 16:57:22 -04:00
Gered f233f810e6 add RgbaBitmap blended drawing primitives 2023-03-26 16:36:53 -04:00