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 * window.display(); 21 * } 22 * } 23 * --- 24 */ 25 module D2D; 26 27 public 28 { 29 import derelict.sdl2.sdl; 30 import derelict.sdl2.image; 31 import derelict.sdl2.ttf; 32 import derelict.opengl3.gl3; 33 34 import gl3n.aabb; 35 import gl3n.frustum; 36 import gl3n.interpolate; 37 import gl3n.linalg; 38 import gl3n.plane; 39 import gl3n.util; 40 import gl3n.ext.matrixstack; 41 42 import std.math; 43 44 import D2DGame.Core.IVerifiable; 45 import D2DGame.Core.IDisposable; 46 import D2DGame.Core.Transformable; 47 import D2DGame.Core.Color3; 48 import D2DGame.Core.FPSLimiter; 49 50 import D2DGame.Window.Window; 51 import D2DGame.Window.WindowEvent; 52 import D2DGame.Window.WindowFlags; 53 54 import D2DGame.Rendering.IRenderTarget; 55 import D2DGame.Rendering.Mesh; 56 import D2DGame.Rendering.IDrawable; 57 import D2DGame.Rendering.Texture; 58 import D2DGame.Rendering.Bitmap; 59 import D2DGame.Rendering.Color; 60 import D2DGame.Rendering.Shader; 61 import D2DGame.Rendering.ShaderProgram; 62 import D2DGame.Rendering.Shape; 63 import D2DGame.Rendering.RectangleShape; 64 65 import D2DGame.Toolkit.Game; 66 67 import std..string; 68 import std.typecons; 69 } 70 71 /// 2D rotation on a mat4. 72 pure mat4 rotate2d(mat4 mat, float alpha) 73 { 74 mat = mat.rotatez(alpha); 75 return mat; 76 } 77 78 /// 2D scale on a mat4. 79 pure mat4 scale2d(mat4 mat, float x, float y) 80 { 81 mat = mat.scale(x, y, 1); 82 return mat; 83 } 84 85 /// 2D translation on a mat4. 86 pure mat4 translate2d(mat4 mat, float x, float y) 87 { 88 mat = mat.translate(x, y, 0); 89 return mat; 90 } 91 92 /// Matrix stack for modelview (like glPopMatrix, glPushMatrix). 93 MatrixStack!mat4 matrixStack; 94 /// Matrix stack for projection. 95 MatrixStack!mat4 projectionStack; 96 97 /// Initializes matrix stacks 98 static this() 99 { 100 matrixStack.set(mat4.identity); 101 projectionStack.set(mat4.orthographic(0, 1, 1, 0, -1, 1)); 102 }