/* Copyright 2015, Michele Santullo * This file is part of "Jumping in D". * * "Jumping in D" is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * "Jumping in D" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with "Jumping in D". If not, see . */ module main; import std.stdio; import std.string; import std.conv; import derelict.sdl2.sdl; import gameobj; void run_main_loop (ref GameObj parGame) { parGame.prepare(); do { parGame.exec(); } while (!parGame.wants_to_quit()); parGame.destroy(); } int main() { writeln("Hello world!"); DerelictSDL2.load(); if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { throw new Exception(format("Error initializing SDL: %s", text(SDL_GetError()))); } scope(exit) { writeln("Destroying SDL..."); SDL_Quit(); } SDL_Window* win = SDL_CreateWindow("hello_d", 100, 100, 120, 120, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); scope(exit) { writeln("Destroying window..."); SDL_DestroyWindow(win); } SDL_Renderer* renderer = SDL_CreateRenderer(win, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); scope(exit) { writeln("Destroying renderer..."); SDL_DestroyRenderer(renderer); } GameObj game = GameObj(renderer); run_main_loop(game); return 0; }