1 module main; 2 immutable generate = 3 ` 4 module app; 5 6 import sapp = sokol.app; 7 import log = sokol.log; 8 9 void main() 10 { 11 sapp.Desc runner = { 12 window_title: "sokol-app", 13 init_cb: &init, 14 frame_cb: &frame, 15 cleanup_cb: &cleanup, 16 width: 640, 17 height: 480, 18 icon: {sokol_default: true}, 19 logger: {func: &log.func} 20 }; 21 sapp.run(runner); 22 } 23 24 extern (C) 25 { 26 static void init() 27 { 28 // TODO: init code goes here 29 } 30 31 static void frame() 32 { 33 // TODO: frame code goes here 34 } 35 36 static void cleanup() 37 { 38 // TODO: cleanup code goes here 39 } 40 } 41 `; 42 43 int main(string[] args) 44 { 45 import std; 46 47 auto sourceFolder = buildPath(getcwd(), "source"); 48 auto appFilePath = buildPath(sourceFolder, "app.d"); 49 if (exists(sourceFolder)) 50 { 51 writefln!"[ERROR] A dub package already exists in the directory %s."(getcwd()); 52 writeln( 53 "[ERROR] Please choose an empty directory to initialize your new sokol-d app."); 54 return -1; 55 } 56 mkdir(sourceFolder); 57 std.file.write(appFilePath, generate); 58 return 0; 59 }