A sample program that shows D beginners how to get started writing an SDL program.
Find a file
2015-09-18 17:33:50 +02:00
lib First commit of libs - forgot to commit them :S 2015-08-20 17:55:15 +02:00
src Add the ObjRef wrapper. 2015-09-18 17:33:50 +02:00
.gitignore I don't know :/ 2015-09-16 14:56:36 +02:00
bcruiser_normal.bpg First commit 2015-08-20 15:14:22 +02:00
CMakeLists.txt Add the ObjRef wrapper. 2015-09-18 17:33:50 +02:00
COPYING First commit 2015-08-20 15:14:22 +02:00
README.md Add readme file. 2015-09-16 18:05:26 +02:00

Jumping in D

Purpose

Target audience

If you are getting close to D there are a number of resources you can count on: the official documentation on dlang.org, books, the friendly folks on the IRC Freenode channel. However, as you open your text editor and start typing code, you will face common issues that will raise questions and doubts, in spite of what you have already learned. This small projects aims to show you how a simple SDL project can tackle some of those issues, hopefully getting you started into designing you code in D.

What's in this code?

This sample program is not an all-you-need-to-learn-D kind of reference. I'm assuming you already know a bit about D, but you're still fresh enough to be confused at some basic topics. Among the other things, this program demonstrates:

  • creating a mixed C and D project with CMake
  • writing an SDL program in D
  • calling C functions and managing the acquired resources
  • managing your custom resources
  • inheriting from a base class providing both an abstract interface and a default implementation for some methods
  • loading textures in SDL using the new BPG image format
  • struct vs class

More examples could be added in the future, although I don't want to clutter this project with too much code.

Dude, is this an hello world app or what?

If you found this example trivial, then maybe you're coding skills in D are above that of my target audience :) But if you have suggestions or you spot any mistake, please do get in touch!

Compiling

Required tools

I've only tested this code with gdc 5.2.0 on Linux. It might work with other compilers but please consider it untested. On my system I'm using:

Compiling instructions

  1. In a new directory, type cmake -DCMAKE_BUILD_TYPE=Debug <path_to_jumping-in-d_code>
  2. Run make
  3. To run the program, type ./hello_d