diff --git a/dub.json b/dub.json new file mode 100644 index 0000000..ace5e5c --- /dev/null +++ b/dub.json @@ -0,0 +1,22 @@ +{ + "name": "aurorafw", + "description": "A Powerful General Purpose Framework", + "copyright": "Copyright © 2018, Aurora Framework", + "license": "LGPL-3.0", + "authors": [ + "Luís Ferreira" + ], + "targetType": "library", + "targetPath": "out/bin", + "targetName": "aurorafw", + "sourcePaths": [ "src/source" ], + "importPaths": [ "src/source" ], + "dependencies": { + ":math": "*", + ":core": "*" + }, + "subPackages": [ + "src/core", + "src/math" + ] +} \ No newline at end of file diff --git a/src/core/.gitignore b/src/core/.gitignore new file mode 100644 index 0000000..3a20e50 --- /dev/null +++ b/src/core/.gitignore @@ -0,0 +1,2 @@ +.dub +out/ \ No newline at end of file diff --git a/src/core/dub.json b/src/core/dub.json new file mode 100644 index 0000000..c0d757f --- /dev/null +++ b/src/core/dub.json @@ -0,0 +1,7 @@ +{ + "name": "core", + "targetType": "library", + "targetPath": "out/bin", + "sourcePaths": [ "source" ], + "importPaths": [ "source" ] +} \ No newline at end of file diff --git a/src/core/source/aurorafw/core/appcontext.d b/src/core/source/aurorafw/core/appcontext.d new file mode 100644 index 0000000..3e89375 --- /dev/null +++ b/src/core/source/aurorafw/core/appcontext.d @@ -0,0 +1,76 @@ +module aurorafw.core.appcontext; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +import aurorafw.core.opt; +import aurorafw.core.debugmanager; + +abstract class ApplicationContext { +public: + final this(string name = "AuroraFW Application", string[] args = null) + { + _name = name; + _opts = OptionHandler(args); + _opts.add("afw-debug", "Enable the aurora built-in debug logger"); + if(_opts.option("afw-debug").active) + { + afwDebugFlag = true; + debug trace(afwDebugFlag, "Debug is now enabled"); + } + + debug trace(afwDebugFlag, "creating new application"); + debug trace(afwDebugFlag, "application is created."); + } + + pure ~this() @safe + { + debug trace(afwDebugFlag, "application is destroyed."); + } + + void onStart() @safe; + void onClose() @safe; + + final void start() @safe + { + debug trace(afwDebugFlag, "application is starting"); + _internalStart(); + onStart(); + debug trace(afwDebugFlag, "application started"); + } + + final void close() @safe + { + debug trace(afwDebugFlag, "application is closing"); + _internalClose(); + onClose(); + debug trace(afwDebugFlag, "application closed"); + } + + pure @property string name() @safe { return _name; } + pure @property string name(string name) @safe { return _name = name; } + +protected: + void _internalSetName(string ) @safe; + void _internalStart() @safe; + void _internalClose() @safe; + +private: + string _name; + OptionHandler _opts; +} \ No newline at end of file diff --git a/src/core/source/aurorafw/core/application.d b/src/core/source/aurorafw/core/application.d new file mode 100644 index 0000000..a40021c --- /dev/null +++ b/src/core/source/aurorafw/core/application.d @@ -0,0 +1,52 @@ +module aurorafw.core.application; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +import core.stdc.stdlib : exit, EXIT_SUCCESS, EXIT_FAILURE; +import aurorafw.core.debugmanager; + +struct Application { +public: + this(immutable shared string[] args, immutable void function(Application) func) + { + this.args = args; + foreach(string str; this.args) + if(str == "--afw-debug") + { + afwDebugFlag = true; + debug trace(afwDebugFlag, "Debug is now enabled"); + } + + func(this); + } + + static void exitSuccess() @trusted + { + debug trace(afwDebugFlag, "application return success code: ", EXIT_SUCCESS); + exit(EXIT_SUCCESS); + } + + static void exitFail() @trusted + { + debug trace(afwDebugFlag, "application return error code: ", EXIT_FAILURE); + exit(EXIT_FAILURE); + } + + immutable shared string[] args; +} \ No newline at end of file diff --git a/src/core/source/aurorafw/core/debugmanager.d b/src/core/source/aurorafw/core/debugmanager.d new file mode 100644 index 0000000..9ec5b87 --- /dev/null +++ b/src/core/source/aurorafw/core/debugmanager.d @@ -0,0 +1,28 @@ +module aurorafw.core.debugmanager; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +public import aurorafw.core.logger : trace; + +enum string debugMsgPrefix(string f = __FILE__, size_t l = __LINE__) { + import std.conv : to; + return f ~ ":" ~ l.to!string ~ ": "; +} + +__gshared bool afwDebugFlag; \ No newline at end of file diff --git a/src/core/source/aurorafw/core/inputlistener.d b/src/core/source/aurorafw/core/inputlistener.d new file mode 100644 index 0000000..60dda04 --- /dev/null +++ b/src/core/source/aurorafw/core/inputlistener.d @@ -0,0 +1,59 @@ +module aurorafw.core.inputlistener; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +pure @safe abstract class InputListener { + struct KeyboardEvent { + int key, scancode; + ushort mods; + } + + struct MouseButtonEvent { + int btn; + ushort mods; + } + + struct MouseMotionEvent { + double xpos, ypos; + } + + struct MouseScrollEvent { + double xoffset, yoffset; + } + + ~this() {} + + bool keyPressed(immutable ref KeyboardEvent ) + { return true; } + + bool keyReleased(immutable ref KeyboardEvent ) + { return true; } + + bool mousePressed(immutable ref MouseButtonEvent ) + { return true; } + + bool mouseReleased(immutable ref MouseButtonEvent ) + { return true; } + + bool mouseMoved(immutable ref MouseMotionEvent ) + { return true; } + + bool mouseScrolled(immutable ref MouseScrollEvent ) + { return true; } +} \ No newline at end of file diff --git a/src/core/source/aurorafw/core/logger.d b/src/core/source/aurorafw/core/logger.d new file mode 100644 index 0000000..9ddfbdf --- /dev/null +++ b/src/core/source/aurorafw/core/logger.d @@ -0,0 +1,21 @@ +module aurorafw.core.logger; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +public import std.experimental.logger; \ No newline at end of file diff --git a/src/core/source/aurorafw/core/opt.d b/src/core/source/aurorafw/core/opt.d new file mode 100644 index 0000000..bbfefbf --- /dev/null +++ b/src/core/source/aurorafw/core/opt.d @@ -0,0 +1,165 @@ +module aurorafw.core.opt; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +import aurorafw.core.debugmanager : debugMsgPrefix; +import std.algorithm.searching : find; +import std.range.primitives : empty; + +@safe pure struct OptionHandler { + struct Element { + string opt; + string desc; + } + + struct SplitedElement { + bool active; + size_t count; + + private: + string optLong; + string optShort; + string desc; + + ptrdiff_t valpos; + } + + enum OptionType { + Posix, + Windows, + None + } + + this(string[] args, OptionType type = __currentType) + { + _args = args; + _type = type; + } + + void add(Element opte) + { + import std.array : split; + immutable string[] elems = split(opte.opt, "|"); + SplitedElement sopte; + + assert(elems.length == 1, "Blank option elements not allowed!"); + + switch(_type) + { + case OptionType.Posix: + if(elems.length > 1) + { + sopte.optShort = "-" ~ ((elems[0].length < elems[1].length) ? elems[0] : elems[1]); + sopte.optLong = "--" ~ ((elems[0].length > elems[1].length) ? elems[0] : elems[1]); + } + else if (elems[0].length > 1) + { + sopte.optLong = "--" ~ elems[0]; + } + else + { + sopte.optShort = "-" ~ elems[0]; + } + break; + + case OptionType.Windows: + if (elems.length > 1) + { + sopte.optShort = "/" ~ ((elems[0].length < elems[1].length) ? elems[0] : elems[1]); + sopte.optLong = "/" ~ ((elems[0].length > elems[1].length) ? elems[0] : elems[1]); + } + else + { + sopte.optLong = "/" ~ elems[0]; + } + break; + + case OptionType.None: + default: + if(elems.length > 1) + { + sopte.optShort = ((elems[0].length < elems[1].length) ? elems[0] : elems[1]); + sopte.optLong = ((elems[0].length > elems[1].length) ? elems[0] : elems[1]); + } + else + { + sopte.optLong = elems[0]; + } + break; + } + sopte.desc = opte.desc; + + foreach(size_t i, string arg; _args) + if((find(arg, sopte.optLong).empty && + ((arg.length == sopte.optLong.length) || + ((arg.length > sopte.optLong.length) && (arg[sopte.optLong.length .. arg.length][0] == '=')) )) + || (find(arg, sopte.optShort).empty && (arg.length == sopte.optShort.length )) ) + { + if(arg.length > sopte.optLong.length) sopte.valpos = sopte.optLong.length; + else sopte.valpos = -1; + sopte.active = true; + sopte.count = i; + } + else { + sopte.active = false; + } + + _opts ~= sopte; + } + + pragma(inline, true) void add(string opt, string desc) { add(Element(opt, desc)); } + + void add(Element[] mopte) + { + foreach(Element opte; mopte) + add(opte); + } + + SplitedElement option(string opt) + { + foreach(SplitedElement sopte; _opts) + if(!find(sopte.optLong, opt).empty || !find(sopte.optShort, opt).empty) + return sopte; + + assert(0, "Invalid option name!"); + } + + string value(SplitedElement sopte) + { + if(sopte.valpos == -1) + return _args[sopte.count+1]; + else + return _args[sopte.count][sopte.valpos .. _args[sopte.count].length]; + } + + pragma(inline, true) string value(string opt) { return value(option(opt)); } + + void print(string fmt = " %s\t%s\t\t%s") @safe + { + pragma(msg, debugMsgPrefix, "FIXME: Need to be implemented"); + } + +private: + string[] _args; + SplitedElement[] _opts; + OptionType _type; + + version(Windows) enum OptionType __currentType = OptionType.Windows; + else enum OptionType __currentType = OptionType.Posix; +} \ No newline at end of file diff --git a/src/core/source/aurorafw/core/package.d b/src/core/source/aurorafw/core/package.d new file mode 100644 index 0000000..1155af8 --- /dev/null +++ b/src/core/source/aurorafw/core/package.d @@ -0,0 +1,27 @@ +module aurorafw.core; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +public: + import aurorafw.core.appcontext; + import aurorafw.core.application; + import aurorafw.core.debugmanager; + import aurorafw.core.inputlistener; + import aurorafw.core.logger; + import aurorafw.core.opt; \ No newline at end of file diff --git a/src/math/.gitignore b/src/math/.gitignore new file mode 100644 index 0000000..3a20e50 --- /dev/null +++ b/src/math/.gitignore @@ -0,0 +1,2 @@ +.dub +out/ \ No newline at end of file diff --git a/src/math/dub.json b/src/math/dub.json new file mode 100644 index 0000000..6ea771a --- /dev/null +++ b/src/math/dub.json @@ -0,0 +1,7 @@ +{ + "name": "math", + "targetType": "library", + "targetPath": "out/bin", + "sourcePaths": [ "source" ], + "importPaths": [ "source" ] +} \ No newline at end of file diff --git a/src/math/source/aurorafw/math/matrix.d b/src/math/source/aurorafw/math/matrix.d new file mode 100644 index 0000000..f19eb46 --- /dev/null +++ b/src/math/source/aurorafw/math/matrix.d @@ -0,0 +1,146 @@ +module aurorafw.math.matrix; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +/** @file aurorafw/math/matrix.d + * Variable Matrix file. This contains a variable matrix struct that + * represents a grid with size of M * N. + * @author Luís Ferreira + * @since snapshot20180509 + */ + +/** A struct that represents a variable matrix. A struct that store's + * N*M array, allows to manipulate it. + * @since snapshot20190930 + */ +@nogc pure @safe struct mat(T, size_t M, size_t N) { + this(T num) + in { + static assert(M == N, "invalid diagonal matrix"); + } + body { + foreach(size_t i; 0..M) + matrix[i * M + i] = num; + } + + this(immutable ref mat!(T, M, N) mat) + { + this = mat; + } + + this(T[M*N] arr) + { + matrix[] = arr; + } + + this(T[] arr) + in { + assert(arr.length == M * N, "array doesn't have the same size"); + } + body { + matrix = arr; + } + + pragma(inline) static mat!(T, M, N) zero() + { + mat!(T, M, N) ret; + ret.matrix[0..N*M] = 0; + return ret; + } + + pragma(inline) static mat!(T, M, N) identity() + { + mat!(T, M, N) ret; + ret.setIdentity(); + return ret; + } + + void setIdentity() @property + { + foreach(size_t x; 0 .. M) + foreach(size_t y; 0 .. N) + if (y == x) + matrix[x * M + y] = 1; + else + matrix[x * M + y] = 0; + } + + bool opEquals(mat!(T, M, N) mat) const + { + return matrix == mat.matrix; + } + + T opIndex(in size_t m, in size_t n) const + in + { + assert (n < N && m < M, "index out of bounds"); + } + body + { + return matrix[m * M + n]; + } + + T opIndex(in size_t i) const + in + { + assert (i < N * M, "index out of bounds"); + } + body + { + return matrix[i]; + } + + T opIndexAssign(in T val, in size_t m, in size_t n) + in + { + assert (n < N && m < M, "index out of bounds"); + } + body + { + return (matrix[m * M + n] = val); + } + + T[] opSliceAssign(in T val, in size_t i1, in size_t i2) + in + { + assert (i1 < N * M && i2 < N * M, "index out of bounds"); + } + body + { + return (matrix[i1..i2] = val); + } + + T[] opSliceAssign(in T val) + { + return (matrix[] = val); + } + + T[M*N] matrix; +} + +alias mat!(float, 2, 2) Matrix2x2f, Matrix2f; +alias mat!(float, 3, 3) Matrix3x3f, Matrix3f; +alias mat!(float, 4, 4) Matrix4x4f, Matrix4f; +alias mat!(double, 2, 2) Matrix2x2d, Matrix2d; +alias mat!(double, 3, 3) Matrix3x3d, Matrix3d; +alias mat!(double, 4, 4) Matrix4x4d, Matrix4d; + +alias Matrix2x2f mat2; +alias Matrix3x3f mat3; +alias Matrix4x4f mat4; \ No newline at end of file diff --git a/src/math/source/aurorafw/math/package.d b/src/math/source/aurorafw/math/package.d new file mode 100644 index 0000000..bd1ccd1 --- /dev/null +++ b/src/math/source/aurorafw/math/package.d @@ -0,0 +1,5 @@ +module aurorafw.math; + +public: + import aurorafw.math.vector; + import aurorafw.math.matrix; \ No newline at end of file diff --git a/src/math/source/aurorafw/math/vector.d b/src/math/source/aurorafw/math/vector.d new file mode 100644 index 0000000..64a8c65 --- /dev/null +++ b/src/math/source/aurorafw/math/vector.d @@ -0,0 +1,72 @@ +module aurorafw.math.vector; + +/**************************************************************************** +** ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─ +** ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐ +** ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴ +** A Powerful General Purpose Framework +** More information in: https://aurora-fw.github.io/ +** +** Copyright (C) 2018 Aurora Framework, All rights reserved. +** +** This file is part of the Aurora Framework. This framework is free +** software; you can redistribute it and/or modify it under the terms of +** the GNU Lesser General Public License version 3 as published by the +** Free Software Foundation and appearing in the file LICENSE included in +** the packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +****************************************************************************/ + +@nogc pure @safe struct vec(T, size_t N) { + private static enum string _elements(string[4] l) + { + string ret; + foreach (size_t i; 0 .. N) + { + ret ~= "T " ~ l[i] ~ "; "; + } + return ret; + } + + union + { + T[N] vec; + static if (N < 5) + { + struct { mixin(_elements(["x", "y", "z", "w"])); } + struct { mixin(_elements(["r", "g", "b", "a"])); } + struct { mixin(_elements(["s", "t", "p", "q"])); } + } + } +} + +alias vec!(int, 2) Vector2i; +alias vec!(uint, 2) Vector2u; +alias vec!(float, 2) Vector2f; +alias vec!(double, 2) Vector2d; + +alias vec!(int, 3) Vector3i; +alias vec!(uint, 3) Vector3u; +alias vec!(float, 3) Vector3f; +alias vec!(double, 3) Vector3d; + +alias vec!(int, 4) Vector4i; +alias vec!(uint, 4) Vector4u; +alias vec!(float, 4) Vector4f; +alias vec!(double, 4) Vector4d; + +alias Vector2i ivec2; +alias Vector2u uvec2; +alias Vector2f vec2; +alias Vector2d dvec2; + +alias Vector3i ivec3; +alias Vector3u uvec3; +alias Vector3f vec3; +alias Vector3d dvec3; + +alias Vector4i ivec4; +alias Vector4u uvec4; +alias Vector4f vec4; +alias Vector4d dvec4; \ No newline at end of file diff --git a/src/source/aurorafw/package.d b/src/source/aurorafw/package.d new file mode 100644 index 0000000..6310fdd --- /dev/null +++ b/src/source/aurorafw/package.d @@ -0,0 +1,5 @@ +module aurorafw; + +public: + import aurorafw.core; + import aurorafw.math; \ No newline at end of file