Commit graph

321 commits

Author SHA1 Message Date
Gered 75401cb5c7 move repeated 'PixelType' type constraints to new Pixel trait 2023-03-09 16:32:46 -05:00
Gered 986a2a9677 make fonts generic over GeneralBitmap types
this also includes a semi-important change where the existing
BitmaskCharacter draw implementation will now not draw anything if
FontRenderOpts::None is passed in, instead of just substituting color 0.

this probably makes more sense this way anyway
2023-03-09 16:20:44 -05:00
Gered 434bd6dbed maybe, sortof, clean up CustomMouseCursor and DefaultMouseCursorBitmaps
i like this a bit more, but this still feels a bit icky to me ... sortof
2023-03-09 15:14:38 -05:00
Gered f3d213130d revert hackfix in GeneralBlitMethod. fix CustomMouseCursor rendering
at this point i am 99% certain that the previous issues i was having
with making GeneralBlitMethod generic over the bitmap PixelType was
because i was trying to specify a constant PixelType value in generic
code (CustomMouseCursor).

whether this was actually the problem or not i think is besides the
point however because while thinking about this i suddenly realized this
was incorrect anyway!

making CustomMouseCursor generic via GeneralBitmap means that specifying
constant colours was not going to produce expected results (e.g. '255'
has a very different meaning for indexed colour rendering versus for
32-bit RGBA colour format).

so, CustomMouseCursor now figures out the correct transparent colour
to use from the DefaultMouseCursorBitmaps implementation.

this allows us to make GeneralBlitMethod be generic over a bitmap's
PixelType again and i'm sure we won't have that previous issue again as
long as we don't try to specify constant colour values in our generic
rendering code ... which we should never be doing anyway!
2023-03-09 14:51:01 -05:00
Gered 696ed0bfb3 rename "BasicImage" to "GeneralBitmap"
this feels like a much, much, much better name to me. not sure what i
was thinking before!
2023-03-09 11:57:07 -05:00
Gered 2c2cf9dacd remove now unnecessary 'todo' comment 2023-03-08 21:11:12 -05:00
Gered 09ac68df66 add placeholder 'rgb' module 2023-03-08 21:08:05 -05:00
Gered f0095cf1dc make CustomMouseCursor generic over BasicImage types
this contains an unfortunate hacky change to the BasicBlitMethod enum
which used to be generic over a PixelType (same as BasicImage is
currently). i really do not like this, but i could not find any
solution to the problem.

admittedly it's not the worst hack solution in the world, but it does
technically allow calling code to pass colour values that are outside
the supported range which may lead to odd results at runtime.
2023-03-08 21:04:03 -05:00
Gered 3e8ec9f73e make BitmapAtlas generic for its type of bitmap 2023-03-08 17:23:49 -05:00
Gered bcb21bc2ba switch BasicImage to use an associated type for the pixel type
this ends up with less repetition when using BasicImage elsewhere
which is nice
2023-03-08 17:22:02 -05:00
Gered 144d4c395b add BasicImage 2023-03-08 17:04:22 -05:00
Gered aab19ba6b3 moved indexed (256 colour) graphics stuff into new "indexed" module
in preparation for adding 32-bit graphics stuff, i want to keep things
separate using modules
2023-03-08 14:16:54 -05:00
Gered 7896146914 add doc-comments 2023-03-07 22:41:21 -05:00
Gered d437755a9f important todo comment 2023-03-07 22:34:46 -05:00
Gered 28d1b7230e move custom mouse cursor functionality to separate struct
this is to not have the main Mouse struct be tied to our indexed-colour
Bitmap graphics implementation (i'm not currently ready to try to
generify this either ...)
2023-03-07 22:33:10 -05:00
Gered 888b5057e4 add doc-comments 2023-03-07 21:57:04 -05:00
Gered 9e06a13c6d move vsync and target_framerate options back into System
since i realized there is an SDL hint that can be used to toggle this

the reason why the rust-sdl "Canvas" struct (which abstracts an
"SDL_Renderer") is not being created in System directly (which would
allow vsync to be toggled on/off via System directly without the use of
a hint) is because not all future SystemResource implementations will
need it (e.g. a future OpenGL implementation definitely won't).
2023-03-07 17:33:42 -05:00
Gered 29628bf680 remove now unused InputDevice struct
SystemResources implementations have now kind of taken that role ...
i suppose. maybe i'll think differently in the future?
2023-03-07 16:52:09 -05:00
Gered f1c04d85e3 move video, audio and input to new SystemResources trait/structs
System now uses a generic SystemResources structure to provide video,
audio and input devices

the DosLike implementation of SystemResources provides the same
functionality that this library has had to date.

this change is to prepare for future addition of things like 32-bit
Bitmap support and other possible audio device implementations, etc.
the idea is a custom SystemResources implementation can be substituted
in to configure everything with the desired functionality.
2023-03-07 16:46:16 -05:00
Gered 43b2c9df7c minor cleanup 2023-03-07 11:39:04 -05:00
Gered 57eb364654 collapse some SystemError types into SDLError
i didn't really think i was gaining anything from the separate error
types because in basically every case these were being used to just
capture and return an underlying SDL error
2023-03-07 11:38:55 -05:00
Gered 58340c03fe rename from libretrogd to ggdt
i'll admit i never totally liked the name "libretrogd"
2023-03-02 16:11:59 -05:00
Gered eb6a363afd formatting
note that i'm intentionally not using rustfmt. i've tried to like that
tool, but in the end i just really don't like it. too many edge cases
and subjectivity and not enough customization. which is probably the
intent. which makes me hate it that much more. fuck you, rustfmt.
2023-03-02 15:10:27 -05:00
Gered 43333687a8 add audio queue playing into the base main_loop wrapper 2023-02-27 15:14:30 -05:00
Gered a6f2d43009 add convenience method for playing the system audio queue 2023-02-27 15:12:07 -05:00
Gered 624ca95a97 add no_run attribute to doc comments with an infinite main loop example 2023-02-27 14:55:50 -05:00
Gered f2f7ae5dee update examples with new input device and main loop event handling stuff 2023-02-27 14:51:55 -05:00
Gered 3dfb8fe466 improve event polling / processing
- the new InputDevices struct is added to simplify input device
  updating and event processing of input events for all input devices
  now available, as well as future proofing for new ones (e.g. gamepad).
  this also helps us out with implementing better ways of doing custom
  application main loop SystemEvent handling ...
- System::do_events_with has been removed. if custom event handling
  is needed by applications, they should now implement this themselves,
  as demonstrated by the example in the doc comment for
  System::do_events.
-
2023-02-27 14:38:51 -05:00
Gered 9cb333454a add SystemEventPump to wrap the sdl2 event pump struct 2023-02-19 18:04:00 -05:00
Gered addd92c1f2 not exactly sure what happened here
i did actually successfully compile and build the previous commit ... ?
2023-02-19 17:15:34 -05:00
Gered f6ca6f150a fix wording on method usage comment
kind of an important difference in intended usage!
2023-02-19 16:20:19 -05:00
Gered 4e43e9fbdd remove possibly error returns from sdl2 Event -> SystemEvent conversion
we just use a catch-all "Unimplemented" enum for the sdl2 event types we
have not mapped / don't care about yet.

this change is mainly just so that we don't need to use TryFrom anymore
as this simplifies making our own SystemEvent iterator

as well, it felt wrong to return an error (even if silently ignored)
whenever an unmapped sdl2 event was raised (since that could happen
fairly often)
2023-02-19 16:17:11 -05:00
Gered adbc0029f4 implement base core/support traits for slimed project
for it's main app context structs
2023-02-19 15:30:35 -05:00
Gered aa3ede096f start moving slimed project to app+core+support context/state model 2023-02-19 15:19:02 -05:00
Gered 03bb4b4adc update template_complicated to use new loop/context boilerplate stuff 2023-02-19 13:16:10 -05:00
Gered 1e5930d401 long, semi-rambling, rationale/description of this boilerplate stuff 2023-02-19 13:15:32 -05:00
Gered b26eab6fb0 some cleanup and naming changes to main loop, game context boilerplate
maybe sort of better?
2023-02-19 13:15:00 -05:00
Gered 24916ae4c7 rename types. still probably confusing. naming is very hard.
especially hard when some of your types are just split up to appease
the borrow checker. ugh.
2023-02-03 18:15:46 -05:00
Gered da66e10bbd initial main loop and game state/context boilerplate helper things
work in progress stuff that will be tweaked as i convert things over to
use this and, i assume, inevitably encounter problems and/or discover
some better ways to do it
2023-02-03 17:55:11 -05:00
Gered 3d7c4f63ea match more environments
forgot about the BSDs, which i guess all have KDE available for them
too? never used BSD myself!
2023-01-30 18:51:24 -05:00
Gered 46dea2b607 add special config and defaults for SDL X11 compositor skip hint 2023-01-30 18:45:03 -05:00
Gered 2a2d8533bc specify sdl2 dep with non-windows and windows for build differences
may need to be fine-tuned still, as i've not done very thorough testing
on all platforms as of yet, but this will get things started at least
2023-01-18 17:38:46 -05:00
Gered b010c044ef remove explicit sdl2 dependency from example apps
they all still depend on sdl2 through the libretrogd dependency, but
the benefit is that future sdl2 version updates are much easier to
accomplish for most apps, since only libretrogd needs to be updated
(in theory).
2023-01-18 17:04:25 -05:00
Gered 592be161c3 update example apps to not use sdl2 event types 2023-01-18 17:03:21 -05:00
Gered a7c91adaf0 convert sdl2 events to our own equivalents
this is to not force _some_ sdl2 type usage onto applications, thus
forcing them to also include sdl2 as a dependency themselves.

that being said, this is still pretty gross feeling to me and i wish
there was a better solution.

i've not added all possible sdl2 event equivalents. only the ones that
i am currently interested in and use. i'll add more as is needed. likely
the joystick / controller events will be added in the very near future.
2023-01-18 17:02:45 -05:00
Gered 7c568fd09d update to a more recent version of sdl2. only tested on linux for now
0.35.2 is the latest version available via cargo right now, and that
version has some issues building for me that have been resolved in
subsequent commit(s). for some reason the maintainers have not pushed
a new version of sdl2 to cargo for quite some time despite numerous
fixes and updates being available ...? bah!

also the current sdl2 `features` set will probably only work for linux
builds. i will try to work out windows + mac build issues shortly
2023-01-18 13:30:25 -05:00
Gered 66bf1e40cc pin anyhow and thiserror versions
due to encountering some compile errors on a fresh system which pulled
down the newest minor versions of both. these two libraries do not seem
to follow "good" semantic versioning ... ? ugh. will try to work out
the compiler issues with the latest versions of these later ...
2023-01-18 13:26:53 -05:00
Gered f902b16d3c during lzw decoding, use a vector instead of a hashmap for the table
since the keys for the previously used hashmap all corresponded with
an index, this can obviously just be a vector where the element index
corresponds to the lzw code. simple.
2023-01-01 13:01:10 -05:00
Gered a9610a5762 add initial benchmark tests for asset loading
only for gif bitmaps right now, since i want to (eventually) clean that
up somewhat
2023-01-01 12:43:15 -05:00
Gered ed754cb9ac update example project entity system component store usage
i think i prefer this style. it's not _technically_ as safe as it was
before, but i prefer the explicitness of it (and it results in a little
bit less nesting in system functions which is nice).

i don't much like the need for an explicit `unwrap()` call however
but that's the tradeoff!
2023-01-01 12:22:03 -05:00