How to setup D with SFML? (using bindbc-sfml)

Salih Dincer salihdb at hotmail.com
Sun Apr 9 01:04:38 UTC 2023


On Saturday, 8 April 2023 at 23:40:32 UTC, Mike Parker wrote:
> Not without error messages. The first thing you should do is 
> use the error API in bindbc.loader to print them out. That 
> should tell you what the problem is.

I installed it on my Linux system without using a loader and with 
static SFML. I just used apt-get and dub. I did the following in 
order:

1. sudo apt-get install libsfml-dev libcsfml-dev
2. dub init dsfml bindbc-sfml
3. cd dsfml
4. edit dub.json and add:
```java
   "libs": [
		"csfml-audio",
		"csfml-graphics"
	],
   "subConfigurations": {
		"bindbc-sfml": "staticBC"
	},
   "versions": [
		"SFML_Audio",
		"SFML_Graphics"
	],
```
5. dub

**app.d**
```d
import bindbc.sfml;

void main()
{
   sfContextSettings* settings;
   sfEvent event;

   auto window = sfRenderWindow_create(
     sfVideoMode(750, 500),
     "Japanese Flag",
     sfWindowStyle.sfDefaultStyle,
     settings
   );

   auto flag = sfCircleShape_create();
        flag.sfCircleShape_setRadius(150);
        flag.sfCircleShape_setPosition(sfVector2f(225, 100));
        flag.sfCircleShape_setFillColor(sfRed);

   while(window.sfRenderWindow_isOpen())
   {
     while(window.sfRenderWindow_pollEvent(&event))
     {
       if(event.type == sfEventType.sfEvtClosed)
       {
         window.sfRenderWindow_close();
       }
     }

     window.sfRenderWindow_clear(sfWhite);
     window.sfRenderWindow_drawCircleShape(flag, null);
     window.sfRenderWindow_display();
   }
}
```

SDB at 79


More information about the Digitalmars-d-learn mailing list