Commit graph

359 commits

Author SHA1 Message Date
Gered 8557c24d48 add image_region ui widget which allows specifying a texture sub-region 2023-05-30 18:51:29 -04:00
Gered d80720f772 update image ui widget to return a bool with its clicked state 2023-05-30 18:50:20 -04:00
Gered d903ca59b3 add methods to get current ImGui display size
i suppose there is not much benefit to using this versus equivalent
functionality on SystemResources (for example). however the dimensions
returned by these new methods do respect whatever display scaling is
being used by ImGui. and these are technically more convenient to use
in whatever place you're building up a UI in. meh.
2023-05-30 18:49:14 -04:00
Gered df62205e41 add convenience method for getting uv coords for BitmapAtlas tiles 2023-05-30 18:46:40 -04:00
Gered ad8d1f9ae3 i have no idea why this decided to throw a compile error now? wtf?
my wild-ass guess is this is somehow related to the serde dependency
being included now, but who the fuck knows. what a joke.
2023-05-29 14:30:00 -04:00
Gered f5291a4d60 add support for loading and saving BitmapAtlas "descriptor" json files
as well as support for directly instantiating a BitmapAtlas from
such a descriptor.

saving a BitmapAtlas to a descriptor file directly is not added (yet?)
as my gut feeling is that these files would probably be hand-written?
saving from a BitmapAtlas directly would (in a simple/naive impl)
always result in a long-ish list of "tiles" anyway, since grids are
turned into tiles. this further reinforces me feeling that you'd either
write these files by hand, or at the very least, just construct a
descriptor instance in code somehow and save that
2023-05-29 14:29:12 -04:00
Gered afa7a92709 add checks for valid rect dimensions in BitmapAtlas 2023-05-26 13:22:26 -04:00
Gered b03b8f4915 add tests for BitmapAtlas.add_grid which were apparently forgotten 2023-05-26 13:21:25 -04:00
Gered ec6d0f1b73 convenience method for creating a basic image widget 2023-05-26 12:12:45 -04:00
Gered 3bb12fdcee update imgui example with image widgets showing slime colors/bitmaps 2023-05-26 12:04:02 -04:00
Gered 73e64946f7 convenience method to clone single BitmapAtlas tiles as new bitmaps 2023-05-26 11:58:30 -04:00
Gered 4257985962 access to the imgui texture map from our own imgui wrapper struct 2023-05-26 11:20:58 -04:00
Gered f6ef1ee22e add support for resetting the imgui renderer's texture map 2023-05-26 11:11:27 -04:00
Gered 457aa757cf simplify 2023-05-05 18:15:55 -04:00
Gered 3a56926345 the big switch from ARGB to RGBA format for 32-bit color pixels 2023-05-05 18:14:37 -04:00
Gered 78d8102a23 rename color types to somewhat less "noisy" names
plus these are easier to type.

i do not anticipate needing structured color types for any other
type of components (e.g. i don't see a need for an ARGBu16x4, etc).
so i am fine with just having `ARGB` being associated with four u8's
with no real indication of this in the type name itself.
2023-05-05 15:56:29 -04:00
Gered ae178e1fa0 remove old argb color functions 2023-05-05 15:32:57 -04:00
Gered 02447867a9 add doc comments for the new color types 2023-05-05 14:41:27 -04:00
Gered 09dbb913a5 convert RgbaBitmap to use ARGBu8x4 as its pixel type 2023-05-04 18:54:37 -04:00
Gered cf92d42b84 update Pixel trait to just the bare minimum requirements
our target is IndexedBitmap's will use PixelType=u8 and
RgbaBitmap's will use PixelType=ARGBu8x4

thus, restricting the Pixel trait to primitive unsigned numerics won't
work anymore, but we do still need to support basic stuff like
equality testing and copy/clone support for our generic bitmap
operations
2023-05-03 16:57:13 -04:00
Gered 579398ea5e use manual impls of Debug and Display for ARGBu8x4 and ARGBf32x4
simply because i wanted a specific format, mostly for ARGBu8x4 and
the barebones hex format string
2023-05-03 16:42:26 -04:00
Gered 0eac3ad7a3 make ARGBu8x4 and ARGBf32x4 derive Default 2023-05-03 16:09:30 -04:00
Gered d12d7035ca add ARGBu8x4 to u32 conversion 2023-05-03 16:06:13 -04:00
Gered ae07b9cd37 add ARGBu8x4 -> byte casting helper traits/methods 2023-05-02 18:52:10 -04:00
Gered a7567b8c0f Merge branch 'master' into color_types 2023-05-01 16:25:02 -04:00
Gered 3b159a61b8 add inline annotations to some methods where i probably forgot before
these don't really affect performance in any meaningful way, according
to the benchmarks i just added. lol
2023-05-01 16:24:51 -04:00
Gered a0ec2f4826 add very simple benchmarks for drawing primitives with RgbaBitmaps
will need these for simple comparisons in the very near future
2023-05-01 16:23:44 -04:00
Gered 836e577bac add missing inline annotation 2023-04-30 17:15:22 -04:00
Gered 2843f87bdc add luminance and greyscale methods to ARGBu8x4 2023-04-30 17:14:36 -04:00
Gered 351a6c7e03 add u32 to ARGBf32x4 conversion 2023-04-30 17:08:01 -04:00
Gered 34c64cd1f9 use #[repr(transparent)] for both color types 2023-04-30 17:03:36 -04:00
Gered 1667ae2c43 add color tinting for ARGBu8x4 2023-04-30 16:59:24 -04:00
Gered 033081a49e add color blending for ARGBu8x4 2023-04-30 16:57:19 -04:00
Gered 448ce11dbc add color interpolation for ARGBu8x4 2023-04-30 16:41:38 -04:00
Gered 0112e99fc7 add color multiplication via operator overload for ARGBu8x4
of course, here we immediately must question whether this is abuse
of operator overloading or not. since you cannot otherwise multiply
these types together, i think this is fine. plus we are not providing
any other math operations via operator overloading, so this feels like
a very explicit thing to do
2023-04-30 16:38:04 -04:00
Gered 9ba65a9e37 remove ARGBu32 struct and color type traits 2023-04-30 16:26:20 -04:00
Gered 53ba5cdb65 doesn't seem like we actually need to use wrapping_shl here
i think i used it here due to a misunderstanding
2023-04-28 15:21:50 -04:00
Gered b5072bcb0f add traits for color type argb component access 2023-04-28 15:15:01 -04:00
Gered 4bef45dc6d add initial color types
this time via the "new type" idiom. the type aliasing i previously did
was, in retrospect, not a great idea
2023-04-27 18:31:41 -04:00
Gered 3a27994091 add simd f32x4 nearly_equal helper function 2023-04-26 18:29:02 -04:00
Gered b4a9b82bf8 update triangle graphics ref tests with yet a few more variations 2023-04-22 21:08:07 -04:00
Gered dde2c314ae update triangle graphics reference tests with more variations
two primary goals with this change:

1. test triangle dimensions of varying widths, in preparation for
   upcoming simd per_pixel_triangle_2d changes. we want to ensure that
   scenarios where `width < 4` and `width % 4 != 0` continue to work
   fine after simd changes are done
2. test triangle rendering at various rotations, because i remember
   while testing fill rule changes, sometimes issues would only be
   visible at certain rotations. so this is mostly just useful for
   blended rendering methods, but still, is probably generally useful
   too ...
2023-04-21 18:20:08 -04:00
Gered 83b5e1eabe move updating graphics ref test images under conditional compilation 2023-04-21 16:19:15 -04:00
Gered 865801a62b add comment explaining reason for nightly use 2023-04-21 14:58:14 -04:00
Gered 9cea60ebc4 specify nightly toolchain by date
i did not expect this to be problematic so soon, based on what i'd
read in various places about the stability of nightly (especially so
for the most common platforms like x86_64, etc)

as i write this commit message, all nightly versions past this date
fail to build ggdt, failing with an "illegal instruction" error.

sigh. this makes me question whether trying to use simd right now is
actually worth it ...
2023-04-20 23:00:51 -04:00
Gered 11d9225e5e refactor triangle rendering logic a bit 2023-04-20 17:46:49 -04:00
Gered ba4792575e convert RgbaBitmap triangle rendering pixel functions to use simd
some noticeable performance gains from this, mostly just for the
blended triangle rendering variants
2023-04-19 21:52:08 -04:00
Gered da4345e3e5 add simd color types and color function variants 2023-04-19 21:47:29 -04:00
Gered c289bbdd71 refactor remaining BlendFunction operations into standalone functions 2023-04-19 21:46:05 -04:00
Gered 174fe3a93d switch to nightly and enable portable_simd feature
i really did not want to use nightly, but i think it is worth it for
portable_simd which is still nightly-only (and i'm guessing will be
for a long while still). i was not particularly enthusiastic about any
of the alternative libraries that exist for stable rust simd, as it
always seemed like something small was missing from what i knew i would
want longer term.
2023-04-19 17:31:48 -04:00