May I draw your attention to the prototype library I was working on eons ago but have only recently released publicly:
If you head into the graphics folder I have some preliminary examples of some graphics mode classes, for example:
Though I’ve recently been thinking that rather than putting the buffer in the class,
it might be better to just provide functions that manipulate a buffer passed in by the user,
then people could use the drawing functions to do things like dynamically composing images/sprites/textures.
I can’t find it at the moment but I’ve also previously discussed the idea of making an actual Pokitto
class that’s a template class which accepts a settings class as its template parameter,
e.g.
struct PokittoSettings : Pokitto::DefaultPokittoSettings
{
using GraphicsMode = Pokitto::Graphics::LowRes16ColourMode;
};
using PokittoObject = Pokitto::PokittoObject<MyPokittoSettings>;
PokittoObject pokitto;
After which PokittoObject::GraphicsMode
would be a type alias for Pokitto::LowRes16ColourMode
,
and if we went down the object route then pokitto.graphics
would be an instance of that class through which people could use the LowRes16ColourMode
functions via that object.
But something like a tile mode might not work so well with that approach unless the PokittoObject
is just a simple container that groups the various subsystems,
in which case it might be simpler for people to just do something like:
using MyGameGraphics = Pokitto::Graphics::LowRes16ColourMode;
using MyGameAudio = Pokitto::Audio::SomeSpecificAudioMode;
// If the classes need to be instantiated and aren't just containers for static functions:
MyGameGraphics graphics;
MyGameAudio audio;
While I’m at it, I’d like to draw people’s attention to the RGB888
and RGB565
classes.
Whatever we end up doing for the actual graphics mode,
I think these would be incredibly useful because they allow people to manipulate colours at compile time,
which means you don’t have to manually convert RGB888 colours to RGB565 because the compiler will do it for you at compile time.
Which makes palettes a lot easier to write, and more importantly a lot easier to read - no more playing “guess what the original colour was before it was converted to RGB565”:
// Constexpr means this is all evaluated at compile time
// no runtime cost on startup like with older methods!
constexpr RGB565 pico8[16]
{
// 0 - Black
RGB565::fromRGB(0, 0, 0),
// 1 - Dark Blue
RGB565::fromRGB(29, 43, 83),
// 2 - Dark Purple
RGB565::fromRGB(126, 37, 83),
// 3 - Dark Green
RGB565::fromRGB(0, 135, 81),
// 4 - Brown
RGB565::fromRGB(171, 82, 54),
// 5 - Dark Grey
RGB565::fromRGB(95, 87, 79),
// 6 - Light Grey
RGB565::fromRGB(194, 195, 199),
// 7 - White
RGB565::fromRGB(255, 241, 232),
// 8 - Red
RGB565::fromRGB(255, 0, 77),
// 9 - Orange
RGB565::fromRGB(255, 163, 0),
// A - Yellow
RGB565::fromRGB(255, 236, 39),
// B - Green
RGB565::fromRGB(0, 228, 54),
// C - Blue
RGB565::fromRGB(41, 173, 255),
// D - Indigo
RGB565::fromRGB(131, 118, 156),
// E - Pink
RGB565::fromRGB(255, 119, 168),
// F - Peach
RGB565::fromRGB(255, 204, 170),
};
(Example from here.)