Help making a game with transparency

Mike Parker aldacron at gmail.com
Sat Sep 28 05:57:55 UTC 2019


On Friday, 27 September 2019 at 22:55:22 UTC, Murilo wrote:

> Ahhh, that clears everything up. I will then leave the program 
> without the transparency and wait until you get around to 
> implement the fixes to it, I am not a developer, I am a 
> scientist, I only use libraries, I don't know how to make them 
> properly.

You might consider using SDL and SDL_image:

https://libsdl.org/download-2.0.php
https://www.libsdl.org/projects/SDL_image/

D bindings for both are available here:

https://code.dlang.org/packages/bindbc-sdl

You don't actually *need* SDL_image, as core SDL can load images 
in the BITMAP format, and you can then use the API to create 
transparency from a specific color. But if you want to load PNG 
files with alpha, you'll want SDL_image.

There are numerous tutorials online for SDL, though if you're 
searching, make sure to look for SDL 2 tutorials and ignore 
anything for SDL 1.x.

The tutorials will all be in either C or C++, but the SDL API 
using the D bindings is the same. The Lazy Foo tutorials are 
often recommended:

https://lazyfoo.net/tutorials/SDL/

But again, these are C++, so you have to consider the differences 
in D and C++ when porting the code over. For example, he uses 
class destructors to free resources. Do that in D and you'll run 
into trouble. So just ignore how he structures his programs and 
focus on the main concepts of using SDL: how to acquire/release 
resources, how to render, etc. You can adapt that to any 
architecture you want. There's no need for classes at all, for 
example.

Some tutorials out there will show you how to use SDL with 
OpenGL. Please ignore those. SDL's 2D Rendering API is what you 
want when you're learning, so focus on tutorials tat show you how 
to use it.

The SDL Wiki has API documentation:

http://wiki.libsdl.org/APIByCategory






More information about the Digitalmars-d-learn mailing list