Indexed graphics for retro engine?
rikki at cattermole.co.nz
Thu Sep 19 23:12:48 UTC 2019
On 20/09/2019 8:47 AM, Shadowblitz16 wrote:
> On Thursday, 19 September 2019 at 19:16:03 UTC, Mike Parker wrote:
>> On Thursday, 19 September 2019 at 18:25:05 UTC, Shadowblitz16 wrote:
>>> I wanted to do 4bpp 16 color graphics.
>>> and I didn't want to load anything unnecessary in the image like the
>>> palette but instead supply it myself as a Color;
>> I see. In that case, I suggest you find some tutorials on software
>> rendering in C or C++ and adapt them to D. Most of the modern stuff
>> out there is going to be targeting 24-bit or 32-bit graphics. You
>> might find some older tutorials on indexed 8-bit rendering that you
>> can adapt to 4-bit. Nothing to it but storing the palette indices in a
>> byte array.
> can I do this in D and draw them to a 32bpp bitmap pixel by pixel?
> I would prefer do do this on the gpu but I don't know how.
I've done a quick lookup in my red book (seventh edition so 3.1).
For OpenGL the choice between RGBA mode vs indexed happens by the system
windowing library (context creation) not OpenGL itself. This means
without writing a windowing library yourself, you won't get indexed mode
and even then you would be stuck with it for whatever window you draw to.
Also for x86 cpu's anything less than 32bpp is going to be inefficient.
You may as well map your indexed image straight into RGBA8 on load.
As for book recommendations here is one for DOS:
You will only want the first five chapters or so, but it should cover
the material you need and have some more for when you are interested in 3d.
More information about the Digitalmars-d-learn