1 /** Module for including all D2DGame components. 2 * Examples: 3 * --- 4 * import D2D; 5 * 6 * void main() 7 * { 8 * Window window = new Window(); 9 * 10 * Event event; // Or WindowEvent 11 * while(window.open) 12 * { 13 * while (window.pollEvent(event)) 14 * { 15 * if(event.type == Event.Type.Quit) 16 * window.close(); 17 * } 18 * window.clear(); 19 * 20 * // Update & Render here 21 * 22 * window.display(); 23 * } 24 * } 25 * --- 26 */ 27 module d2d; 28 29 public 30 { 31 import derelict.sdl2.sdl; 32 import derelict.sdl2.image; 33 import derelict.sdl2.mixer; 34 import derelict.sdl2.ttf; 35 import derelict.opengl3.gl3; 36 37 import gl3n.aabb; 38 import gl3n.frustum; 39 import gl3n.interpolate; 40 import gl3n.linalg; 41 import gl3n.plane; 42 import gl3n.util; 43 import gl3n.ext.matrixstack; 44 45 import std.math; 46 47 import d2d.core.bytestream; 48 import d2d.core.iverifiable; 49 import d2d.core.idisposable; 50 import d2d.core.transformable; 51 import d2d.core.color3; 52 import d2d.core.fpslimiter; 53 54 import d2d.window.window; 55 import d2d.window.windowevent; 56 import d2d.window.windowflags; 57 58 import d2d.rendering.irendertarget; 59 import d2d.rendering.mesh; 60 import d2d.rendering.idrawable; 61 import d2d.rendering.texture; 62 import d2d.rendering.bitmap; 63 import d2d.rendering.color; 64 import d2d.rendering.shader; 65 import d2d.rendering.shaderprogram; 66 import d2d.rendering.shape; 67 import d2d.rendering.rectangleshape; 68 69 import d2d.audio.music; 70 import d2d.audio.sound; 71 72 import d2d.font.ifont; 73 import d2d.font.itext; 74 import d2d.font.ttffont; 75 import d2d.font.ttftext; 76 import d2d.font.bmfont; 77 import d2d.font.bmtext; 78 79 import d2d.toolkit.game; 80 81 import std..string; 82 import std.typecons : AliasSeq; 83 } 84 85 /// 2D rotation on a mat4. 86 pure mat4 rotate2d(mat4 mat, float alpha) 87 { 88 mat = mat.rotatez(alpha); 89 return mat; 90 } 91 92 /// 2D scale on a mat4. 93 pure mat4 scale2d(mat4 mat, float x, float y) 94 { 95 mat = mat.scale(x, y, 1); 96 return mat; 97 } 98 99 /// 2D translation on a mat4. 100 pure mat4 translate2d(mat4 mat, float x, float y) 101 { 102 mat = mat.translate(x, y, 0); 103 return mat; 104 } 105 106 /// Matrix stack for modelview (like glPopMatrix, glPushMatrix). 107 MatrixStack!mat4 matrixStack = gl3n.ext.matrixstack.matrixStack!mat4(); 108 /// Matrix stack for projection. 109 MatrixStack!mat4 projectionStack = gl3n.ext.matrixstack.matrixStack!mat4(); 110 111 /// Initializes matrix stacks 112 static this() 113 { 114 matrixStack.set(mat4.identity); 115 projectionStack.set(mat4.orthographic(0, 1, 1, 0, -1, 1)); 116 }