├── .clang-format ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── Doc └── ThirdParties.md ├── LICENSE ├── Phoenix ├── CMakeLists.txt ├── Client │ ├── CMakeLists.txt │ ├── Include │ │ ├── CMakeLists.txt │ │ └── Client │ │ │ ├── CMakeLists.txt │ │ │ └── Main.hpp │ └── Source │ │ ├── CMakeLists.txt │ │ └── main.cpp ├── Core │ ├── CMakeLists.txt │ ├── Include │ │ ├── CMakeLists.txt │ │ └── Core │ │ │ ├── CMakeLists.txt │ │ │ └── Voxels │ │ │ ├── Blocks.hpp │ │ │ └── CMakeLists.txt │ └── Source │ │ ├── CMakeLists.txt │ │ └── Voxels │ │ ├── Blocks.cpp │ │ └── CMakeLists.txt └── Server │ ├── CMakeLists.txt │ ├── Include │ ├── CMakeLists.txt │ └── Server │ │ ├── CMakeLists.txt │ │ └── Main.hpp │ └── Source │ ├── CMakeLists.txt │ └── main.cpp ├── Quartz ├── CMakeLists.txt ├── Documentation │ ├── Doxyfile │ └── doxy-boot-theme │ │ ├── LICENSE │ │ ├── README.md │ │ ├── addons │ │ ├── bootstrap │ │ │ ├── jquery.smartmenus.bootstrap.css │ │ │ ├── jquery.smartmenus.bootstrap.js │ │ │ └── jquery.smartmenus.bootstrap.min.js │ │ └── keyboard │ │ │ ├── jquery.smartmenus.keyboard.js │ │ │ └── jquery.smartmenus.keyboard.min.js │ │ ├── customdoxygen.css │ │ ├── doxy-boot.js │ │ ├── footer.html │ │ ├── header.html │ │ ├── jquery.smartmenus.js │ │ └── jquery.smartmenus.min.js ├── Engine │ ├── CMakeLists.txt │ ├── Include │ │ ├── CMakeLists.txt │ │ ├── Quartz.hpp │ │ └── Quartz │ │ │ ├── CMakeLists.txt │ │ │ ├── Core.hpp │ │ │ ├── Math │ │ │ ├── CMakeLists.txt │ │ │ ├── Math.hpp │ │ │ ├── MathUtils.hpp │ │ │ ├── Matrix4x4.hpp │ │ │ ├── Ray.hpp │ │ │ ├── Rect.hpp │ │ │ ├── Vector2.hpp │ │ │ └── Vector3.hpp │ │ │ ├── QuartzPCH.hpp │ │ │ ├── UniversalDoxygenComments.hpp │ │ │ ├── Utilities │ │ │ ├── CMakeLists.txt │ │ │ ├── EnumTools.hpp │ │ │ ├── FileIO.hpp │ │ │ ├── HandleAllocator.hpp │ │ │ ├── Logger.hpp │ │ │ ├── Plugin.hpp │ │ │ ├── Singleton.hpp │ │ │ └── Threading │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── SingleWorker.hpp │ │ │ │ └── ThreadPool.hpp │ │ │ └── Voxels │ │ │ ├── Blocks.hpp │ │ │ ├── CMakeLists.txt │ │ │ └── Terrain.hpp │ └── Source │ │ ├── CMakeLists.txt │ │ ├── Math │ │ ├── CMakeLists.txt │ │ ├── Matrix4x4.cpp │ │ ├── Ray.cpp │ │ ├── Vector2.cpp │ │ └── Vector3.cpp │ │ ├── QuartzPCH.cpp │ │ ├── Utilities │ │ ├── CMakeLists.txt │ │ ├── FileIO.cpp │ │ ├── Logger.cpp │ │ ├── Plugin.cpp │ │ └── Threading │ │ │ ├── CMakeLists.txt │ │ │ ├── SingleWorker.cpp │ │ │ └── ThreadPool.cpp │ │ └── Voxels │ │ ├── Blocks.cpp │ │ ├── CMakeLists.txt │ │ └── Terrain.cpp ├── Tests │ └── .gitkeep ├── ThirdParty │ ├── CMakeLists.txt │ ├── lua │ │ ├── CMakeLists.txt │ │ ├── all │ │ ├── bugs │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lbitlib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── lctype.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lfunc.h │ │ ├── lgc.c │ │ ├── lgc.h │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── lmem.h │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lobject.h │ │ ├── lopcodes.c │ │ ├── lopcodes.h │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lparser.h │ │ ├── lprefix.h │ │ ├── lstate.c │ │ ├── lstate.h │ │ ├── lstring.c │ │ ├── lstring.h │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltable.h │ │ ├── ltablib.c │ │ ├── ltests.c │ │ ├── ltests.h │ │ ├── ltm.c │ │ ├── ltm.h │ │ ├── lua.c │ │ ├── lua.h │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lutf8lib.c │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ ├── lzio.h │ │ ├── makefile │ │ ├── manual │ │ │ ├── 2html │ │ │ └── manual.of │ │ └── testes │ │ │ ├── all.lua │ │ │ ├── api.lua │ │ │ ├── attrib.lua │ │ │ ├── big.lua │ │ │ ├── bitwise.lua │ │ │ ├── bwcoercion.lua │ │ │ ├── calls.lua │ │ │ ├── closure.lua │ │ │ ├── code.lua │ │ │ ├── constructs.lua │ │ │ ├── coroutine.lua │ │ │ ├── db.lua │ │ │ ├── errors.lua │ │ │ ├── events.lua │ │ │ ├── files.lua │ │ │ ├── gc.lua │ │ │ ├── goto.lua │ │ │ ├── heavy.lua │ │ │ ├── libs │ │ │ ├── lib1.c │ │ │ ├── lib11.c │ │ │ ├── lib2.c │ │ │ ├── lib21.c │ │ │ └── makefile │ │ │ ├── literals.lua │ │ │ ├── locals.lua │ │ │ ├── main.lua │ │ │ ├── math.lua │ │ │ ├── nextvar.lua │ │ │ ├── pm.lua │ │ │ ├── sort.lua │ │ │ ├── strings.lua │ │ │ ├── tpack.lua │ │ │ ├── utf8.lua │ │ │ ├── vararg.lua │ │ │ └── verybig.lua │ └── stb_image │ │ └── stb_image.hpp └── Tools │ ├── CMake │ └── CMakePCH.cmake │ ├── licenseText.txt │ └── licensor.py ├── QuartzSandbox ├── CMakeLists.txt ├── Include │ ├── CMakeLists.txt │ └── Sandbox │ │ ├── CMakeLists.txt │ │ ├── DebugOverlay.hpp │ │ └── Sandbox.hpp ├── Source │ ├── CMakeLists.txt │ ├── DebugOverlay.cpp │ └── Sandbox.cpp └── assets │ ├── CMakeLists.txt │ ├── example_configs │ ├── Client.ini │ └── Controls.ini │ ├── scripts │ ├── .gitkeep │ ├── PerlinNoise.lua │ └── index.lua │ ├── shaders │ ├── basic.shader │ └── tests │ │ ├── test.frag │ │ ├── test.shader │ │ └── test.vert │ └── textures │ ├── dirt.png │ ├── grass_side.png │ └── grass_top.png ├── README.md └── appveyor.yml /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: true 6 | AlignConsecutiveDeclarations: true 7 | AlignEscapedNewlines: Left 8 | AlignOperands: true 9 | AlignTrailingComments: true 10 | AllowAllParametersOfDeclarationOnNextLine: true 11 | AllowShortBlocksOnASingleLine: false 12 | AllowShortCaseLabelsOnASingleLine: false 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: false 15 | AllowShortLoopsOnASingleLine: false 16 | AlwaysBreakAfterDefinitionReturnType: None 17 | AlwaysBreakAfterReturnType: None 18 | AlwaysBreakBeforeMultilineStrings: false 19 | AlwaysBreakTemplateDeclarations: Yes 20 | BinPackArguments: true 21 | BinPackParameters: true 22 | BraceWrapping: 23 | AfterClass: false 24 | AfterControlStatement: true 25 | AfterEnum: true 26 | AfterFunction: true 27 | AfterNamespace: true 28 | AfterObjCDeclaration: false 29 | AfterStruct: true 30 | AfterUnion: true 31 | AfterExternBlock: true 32 | BeforeCatch: true 33 | BeforeElse: true 34 | IndentBraces: false 35 | SplitEmptyFunction: true 36 | SplitEmptyRecord: true 37 | SplitEmptyNamespace: true 38 | BreakBeforeBinaryOperators: None 39 | BreakBeforeBraces: Allman 40 | BreakBeforeInheritanceComma: false 41 | BreakInheritanceList: BeforeColon 42 | BreakBeforeTernaryOperators: true 43 | BreakConstructorInitializersBeforeComma: false 44 | BreakConstructorInitializers: BeforeColon 45 | BreakAfterJavaFieldAnnotations: false 46 | BreakStringLiterals: true 47 | ColumnLimit: 80 48 | CompactNamespaces: true 49 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 50 | ConstructorInitializerIndentWidth: 4 51 | ContinuationIndentWidth: 4 52 | Cpp11BracedListStyle: true 53 | DerivePointerAlignment: false 54 | DisableFormat: false 55 | ExperimentalAutoDetectBinPacking: false 56 | FixNamespaceComments: true 57 | IncludeBlocks: Preserve 58 | IncludeCategories: 59 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 60 | Priority: 2 61 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 62 | Priority: 3 63 | - Regex: '.*' 64 | Priority: 1 65 | IncludeIsMainRegex: '(Test)?$' 66 | IndentCaseLabels: false 67 | IndentPPDirectives: AfterHash 68 | IndentWidth: 4 69 | IndentWrappedFunctionNames: false 70 | JavaScriptQuotes: Leave 71 | JavaScriptWrapImports: true 72 | KeepEmptyLinesAtTheStartOfBlocks: true 73 | MacroBlockBegin: '' 74 | MacroBlockEnd: '' 75 | MaxEmptyLinesToKeep: 1 76 | NamespaceIndentation: All 77 | ObjCBinPackProtocolList: Auto 78 | ObjCBlockIndentWidth: 2 79 | ObjCSpaceAfterProperty: false 80 | ObjCSpaceBeforeProtocolList: true 81 | PenaltyBreakAssignment: 2 82 | PenaltyBreakBeforeFirstCallParameter: 19 83 | PenaltyBreakComment: 300 84 | PenaltyBreakFirstLessLess: 120 85 | PenaltyBreakString: 1000 86 | PenaltyBreakTemplateDeclaration: 10 87 | PenaltyExcessCharacter: 1000000 88 | PenaltyReturnTypeOnItsOwnLine: 1000000 89 | PointerAlignment: Left 90 | ReflowComments: true 91 | SortIncludes: true 92 | SortUsingDeclarations: true 93 | SpaceAfterCStyleCast: true 94 | SpaceAfterTemplateKeyword: true 95 | SpaceBeforeAssignmentOperators: true 96 | SpaceBeforeCpp11BracedList: true 97 | SpaceBeforeCtorInitializerColon: true 98 | SpaceBeforeInheritanceColon: true 99 | SpaceBeforeParens: ControlStatements 100 | SpaceBeforeRangeBasedForLoopColon: true 101 | SpaceInEmptyParentheses: false 102 | SpacesBeforeTrailingComments: 1 103 | SpacesInAngles: false 104 | SpacesInContainerLiterals: true 105 | SpacesInCStyleCastParentheses: false 106 | SpacesInParentheses: false 107 | SpacesInSquareBrackets: false 108 | 109 | Standard: Cpp11 110 | StatementMacros: 111 | - Q_UNUSED 112 | - QT_REQUIRE_VERSION 113 | TabWidth: 4 114 | UseTab: ForIndentation 115 | ... 116 | 117 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Build folders 35 | build/* 36 | BUILD/* 37 | Build/* 38 | **/Quartz/Documentation/html 39 | **/cmake-build-debug 40 | CMakeFiles/ 41 | CMakeCache.txt 42 | # CLion 43 | **/.idea/ 44 | 45 | # QtCreator 46 | *.autosave 47 | 48 | # QtCreator CMake 49 | CMakeLists.txt.user* 50 | 51 | *.swp 52 | *.log 53 | 54 | # Visual Studio 55 | .vs**/ 56 | # VSCode 57 | .vscode/* 58 | 59 | glew.pc 60 | imgui.ini 61 | todo.txt 62 | .vimrc 63 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Quartz/ThirdParty/SDL2"] 2 | path = Quartz/ThirdParty/SDL2 3 | url = https://github.com/spurious/SDL-mirror.git 4 | [submodule "Quartz/ThirdParty/sol2"] 5 | path = Quartz/ThirdParty/sol2 6 | url = https://github.com/ThePhD/sol2.git 7 | [submodule "Quartz/ThirdParty/bgfx.cmake"] 8 | path = Quartz/ThirdParty/bgfx.cmake 9 | url = https://github.com/GentenStudios/bgfx.cmake.git 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: trusty 3 | sudo: required 4 | os: 5 | - linux 6 | - osx 7 | 8 | compiler: 9 | - gcc 10 | - clang 11 | 12 | script: 13 | - cmake -H. -Bbuild 14 | - cmake --build build -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(Quartz) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_EXTENSIONS OFF) 7 | 8 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 9 | 10 | add_subdirectory(Quartz) 11 | add_subdirectory(QuartzSandbox) 12 | add_subdirectory(Phoenix) 13 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @GentenStudios/lead-developers 2 | 3 | /README.md @apachano 4 | /CODE_OF_CONDUCT.md @apachano 5 | /Doc/ @apachano 6 | 7 | /QuartzSandbox/assets/textures/ @tobyplowy 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at genten.studios@gmail.com . All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /Doc/ThirdParties.md: -------------------------------------------------------------------------------- 1 | # This is a list of all third parties and information regarding them as outlined [here](https://github.com/GentenStudios/Genten/wiki/Third-party-requirements) 2 | 3 | ## Glad 4 | Home Page: 5 | ### What's the impact if this disappears? 6 | Critical, High, Medium, Low, Non-existant 7 | ### How frequently is this updated? If it not updated frequently, what is the impact? 8 | 9 | ### How much work is involved when it does update? 10 | 11 | ### What is the probability that this third party is abandoned 12 | 13 | ### If this is abandoned, can we take it over and maintain it (what license does it have) 14 | Low 15 | ### If we need to switch to another third party, how much work will be involved? Are there suitable alternatives now? 16 | 17 | ## ImGUI 18 | Home Page: https://github.com/ocornut/imgui 19 | ### What's the impact if this disappears? 20 | Critical, High, Medium, Low, Non-existant 21 | ### How frequently is this updated? If it not updated frequently, what is the impact? 22 | 23 | ### How much work is involved when it does update? 24 | 25 | ### What is the probability that this third party is abandoned 26 | 27 | ### If this is abandoned, can we take it over and maintain it (what license does it have) 28 | Low 29 | ### If we need to switch to another third party, how much work will be involved? Are there suitable alternatives now? 30 | 31 | ## SDL 32 | Home Page: 33 | ### What's the impact if this disappears? 34 | Critical, High, Medium, Low, Non-existant 35 | ### How frequently is this updated? If it not updated frequently, what is the impact? 36 | 37 | ### How much work is involved when it does update? 38 | 39 | ### What is the probability that this third party is abandoned 40 | 41 | ### If this is abandoned, can we take it over and maintain it (what license does it have) 42 | Low 43 | ### If we need to switch to another third party, how much work will be involved? Are there suitable alternatives now? -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Genten Studios 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Phoenix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Tools/CMake") 2 | 3 | add_subdirectory(Client) 4 | add_subdirectory(Core) 5 | add_subdirectory(Server) 6 | -------------------------------------------------------------------------------- /Phoenix/Client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(PhoenixClient) 4 | 5 | add_subdirectory(Include) 6 | add_subdirectory(Source) 7 | 8 | add_executable(${PROJECT_NAME} ${clientSources} ${clientHeaders}) 9 | target_link_libraries(${PROJECT_NAME} PRIVATE Phoenix) 10 | 11 | set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../../Quartz/ThirdParty) 12 | target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/SDL2/include ${dependencies}/../Engine/Include ${dependencies}/luamod/include ${dependencies}/imgui/include) 13 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Include) 14 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../Core/Include) 15 | 16 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD 17 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 18 | $ 19 | $/$ 20 | ) 21 | -------------------------------------------------------------------------------- /Phoenix/Client/Include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Client) 2 | 3 | set(clientHeaders 4 | ${headers} 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /Phoenix/Client/Include/Client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(headers 3 | ${currentDir}/Main.hpp 4 | 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Phoenix/Client/Include/Client/Main.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Phoenix/Client/Include/Client/Main.hpp -------------------------------------------------------------------------------- /Phoenix/Client/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(clientSources 3 | ${currentDir}/main.cpp 4 | 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Phoenix/Client/Source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #undef main 7 | 8 | using namespace phoenix; 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | 13 | // ===== Launch core ===== 14 | // Likely a single command from Quartz that launches the logger + any other critical tools 15 | 16 | // ===== Create main window + Display splash or terminal output ===== 17 | 18 | // ===== Launch connection thread pointed at server ===== 19 | // std::thread connection (Network::connection); 20 | 21 | // ===== Compare server mods.txt and local mods.txt, update if needed ===== 22 | 23 | // ===== Load lua ===== 24 | voxels::BlockRegistry::get()->registerBlock("core:dirt", "Dirt"); 25 | voxels::BlockRegistry::get()->registerBlock("core:cobble", "CobbleStone"); 26 | voxels::BlockRegistry::get()->registerBlock("core:stone", "Stone"); 27 | // TODO: Replace these manual calls to register blocks with a call to run lua files based on what modules need loaded 28 | 29 | // ===== Launch renderer outputting to main window ===== 30 | 31 | return 1; 32 | }; -------------------------------------------------------------------------------- /Phoenix/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(Phoenix) 4 | 5 | add_subdirectory(Include) 6 | add_subdirectory(Source) 7 | 8 | add_library(${PROJECT_NAME} STATIC ${phoenixSources} ${phoenixHeaders}) 9 | target_link_libraries(${PROJECT_NAME} PRIVATE QuartzEngine) 10 | 11 | set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../../Quartz/ThirdParty) 12 | target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/../Engine/Include) 13 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Include) 14 | 15 | foreach(FILE ${phoenixSources}) 16 | get_filename_component(PARENT_DIR "${FILE}" DIRECTORY) 17 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}") 18 | 19 | string(REPLACE "/" "\\" GROUP "${GROUP}") 20 | string(REPLACE "Source" "" GROUP "${GROUP}") 21 | 22 | set(GROUP "Source Files${GROUP}") 23 | source_group("${GROUP}" FILES "${FILE}") 24 | endforeach() 25 | 26 | foreach(FILE ${phoenixHeaders}) 27 | get_filename_component(PARENT_DIR "${FILE}" DIRECTORY) 28 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}") 29 | 30 | string(REPLACE "/" "\\" GROUP "${GROUP}") 31 | string(REPLACE "Include" "" GROUP "${GROUP}") 32 | 33 | set(GROUP "Header Files${GROUP}") 34 | source_group("${GROUP}" FILES "${FILE}") 35 | endforeach() 36 | -------------------------------------------------------------------------------- /Phoenix/Core/Include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Core) 2 | 3 | set(phoenixHeaders 4 | ${coreHeaders} 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /Phoenix/Core/Include/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Voxels) 2 | 3 | set(coreHeaders 4 | ${voxelHeaders} 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /Phoenix/Core/Include/Core/Voxels/Blocks.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | namespace phoenix 37 | { 38 | namespace voxels 39 | { 40 | typedef std::size_t BlockID; 41 | 42 | /// @brief Stores universal definition of a block 43 | struct RegisteredBlock 44 | { 45 | /** 46 | * @brief Stores unique ID to identify block for use in memory, 47 | * should match location in registry 48 | */ 49 | BlockID blockId; 50 | /** 51 | * @brief Stores Unique name for use duing saving, should be in 52 | * format mod:name eg "core:dirt" 53 | */ 54 | std::string uniqueName; 55 | /// @brief Stores human readable name for output to player ex "dirt" 56 | std::string displayName; 57 | 58 | RegisteredBlock(const std::string& unique, BlockID id, 59 | const std::string& display); 60 | 61 | ~RegisteredBlock(); 62 | }; 63 | 64 | /// @brief Stores universal block definitions 65 | class BlockRegistry : public qz::utils::Singleton 66 | { 67 | private: 68 | std::vector m_blocks; 69 | 70 | public: 71 | BlockRegistry(); 72 | 73 | /** 74 | * @brief Registers a block in the registry 75 | * 76 | * @param uniqueName The blocks unique name, this is unique to the block and used on saves and loading lua 77 | * @param displayName The human friendly name for the block seen ingame 78 | * @return On success, returns the blocks ID in the registry, on failure a -1 79 | */ 80 | BlockID registerBlock(const std::string& uniqueName, 81 | const std::string& displayName); 82 | /** 83 | * @brief Get the Display name for a block in the registry 84 | * 85 | * @param blockId the unique numberical block ID for the block you need 86 | * @return Returns display name of the block as a string 87 | */ 88 | const std::string& getDisplayName(std::size_t blockId); 89 | /** 90 | * @brief Get the ID for a block in the registry 91 | * 92 | * @param uniqueName The blocks unique name used during saves and lua loading 93 | * @return Returns ID number as an int 94 | */ 95 | BlockID getBlockId(const std::string& uniqueName); 96 | }; 97 | } // namespace voxels 98 | 99 | } // namespace phoenix -------------------------------------------------------------------------------- /Phoenix/Core/Include/Core/Voxels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(voxelHeaders 3 | ${currentDir}/Blocks.hpp 4 | 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Phoenix/Core/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Voxels) 2 | 3 | set(phoenixSources 4 | ${voxelSources} 5 | 6 | PARENT_SCOPE 7 | ) -------------------------------------------------------------------------------- /Phoenix/Core/Source/Voxels/Blocks.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | using namespace phoenix::voxels; 32 | 33 | RegisteredBlock::RegisteredBlock(const std::string& unique, BlockID id, 34 | const std::string& display) 35 | : uniqueName(unique), blockId(id), displayName(display) {}; 36 | 37 | RegisteredBlock::~RegisteredBlock() = default; 38 | 39 | BlockRegistry::BlockRegistry(){}; 40 | 41 | BlockID BlockRegistry::registerBlock(const std::string& uniqueName, 42 | const std::string& displayName) 43 | { 44 | BlockID exists = getBlockId(uniqueName); 45 | if (exists == -1){ 46 | m_blocks.push_back(RegisteredBlock(uniqueName, m_blocks.size(), displayName)); 47 | return m_blocks.size() - 1; 48 | } else { 49 | m_blocks[exists].displayName = displayName; 50 | m_blocks[exists].uniqueName = uniqueName; 51 | return exists; 52 | } 53 | 54 | }; 55 | 56 | const std::string& BlockRegistry::getDisplayName(BlockID blockId) 57 | { 58 | if (blockId < m_blocks.size()){ 59 | return m_blocks[blockId].displayName; 60 | }else{ 61 | static const std::string error {"ERROR"}; 62 | return error; 63 | } 64 | }; 65 | 66 | BlockID BlockRegistry::getBlockId(const std::string& uniqueName) 67 | { 68 | for (BlockID i = 0; i < m_blocks.size(); i++) 69 | { 70 | if (m_blocks[i].uniqueName == uniqueName) 71 | { 72 | return i; 73 | }; 74 | } 75 | return -1; 76 | } -------------------------------------------------------------------------------- /Phoenix/Core/Source/Voxels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(voxelSources 3 | ${currentDir}/Blocks.cpp 4 | 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Phoenix/Server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(PhoenixServer) 4 | 5 | add_subdirectory(Include) 6 | add_subdirectory(Source) 7 | 8 | add_executable(${PROJECT_NAME} ${serverSources} ${serverHeaders}) 9 | target_link_libraries(${PROJECT_NAME} PRIVATE Phoenix) 10 | 11 | set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../../Quartz/ThirdParty) 12 | target_include_directories(${PROJECT_NAME} PRIVATE ${dependencies}/SDL2/include ${dependencies}/../Engine/Include ${dependencies}/luamod/include ${dependencies}/imgui/include) 13 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Include) 14 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../Core/Include) 15 | 16 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD 17 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 18 | $ 19 | $/$ 20 | ) 21 | -------------------------------------------------------------------------------- /Phoenix/Server/Include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Server) 2 | 3 | set(serverHeaders 4 | ${headers} 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /Phoenix/Server/Include/Server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(headers 3 | ${currentDir}/Main.hpp 4 | 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Phoenix/Server/Include/Server/Main.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Phoenix/Server/Include/Server/Main.hpp -------------------------------------------------------------------------------- /Phoenix/Server/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(serverSources 3 | ${currentDir}/main.cpp 4 | 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Phoenix/Server/Source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #undef main 7 | 8 | using namespace phoenix; 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | 13 | // ===== Launch core ===== 14 | // Likely a single command from Quartz that launches the logger + any other critical tools 15 | std::cout << "Program started \n"; 16 | 17 | // ===== Load Voxel data / Load lua ===== 18 | 19 | voxels::BlockRegistry::get()->registerBlock("core:dirt", "Dirt"); 20 | voxels::BlockRegistry::get()->registerBlock("core:cobble", "CobbleStone"); 21 | voxels::BlockRegistry::get()->registerBlock("core:stone", "Stone"); 22 | // TODO: Replace these manual calls to register blocks with a call to run lua files 23 | 24 | std::cout << voxels::BlockRegistry::get()->getDisplayName(1); 25 | std::cout << voxels::BlockRegistry::get()->getDisplayName(50); 26 | std::cout << std::to_string(voxels::BlockRegistry::get()->getBlockId("core::dirt")); 27 | std::cout << std::to_string(voxels::BlockRegistry::get()->getBlockId("core:dirt")); 28 | std::cout << std::to_string(voxels::BlockRegistry::get()->getBlockId("core:stone")); 29 | std::cout << "\nCobbleStoneERROR1844674407370955161502\n"; 30 | 31 | voxels::BlockRegistry::get()->registerBlock("core:dirt", "Dirt Block"); 32 | std::cout << voxels::BlockRegistry::get()->getDisplayName(0); 33 | std::cout << "\nDirt Block\n"; 34 | 35 | // TODO: Replace these calls with unit tests 36 | 37 | // ===== Load save data ===== 38 | // Save::Load(argv[0]) //This will detect internally if a new map needs generated based on if save exists 39 | 40 | // ===== Launch network connection listener ===== 41 | // std::thread listener (Network::Listener); 42 | 43 | // ===== Enter main loop watching for CLI input ===== 44 | /*bool run = true; 45 | while (run == true){ 46 | // Listen for CLI instructions 47 | }*/ 48 | 49 | // ===== Begin shutdown ===== 50 | std::cout << "Begin Shutdown \n \n"; 51 | 52 | // Send signal for listener to terminate 53 | // Confirm map has saved 54 | 55 | return 1; 56 | }; -------------------------------------------------------------------------------- /Quartz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Tools/CMake") 2 | 3 | add_subdirectory(ThirdParty) 4 | add_subdirectory(Engine) 5 | -------------------------------------------------------------------------------- /Quartz/Documentation/doxy-boot-theme/README.md: -------------------------------------------------------------------------------- 1 | doxygen-bootstrapped 2 | =================== 3 | 4 | Customize doxygen (v1.8.13) output to use the twitter bootstrap framework (v3.3.6). 5 | 6 | *This fork is aiminig to provide support for doxygen 1.8.12+ which changed the 7 | way that the menus are structured and move to smartmenus. This is work in 8 | progress and should not be used right now.* 9 | 10 | [Demo](https://biogearsengine.com/documentation/index.html) 11 | 12 | This started as work done by CoActionOS and was extended further here. 13 | [Credit](http://coactionos.com/embedded%20design%20tips/2014/01/07/Tips-Integrating-Doxygen-and-Bootstrap/) 14 | 15 | # Customizing Doxygen 16 | Doxygen provides a handful of ways to [customize the output](http://www.stack.nl/~dimitri/doxygen/manual/customize.html). The simplest way is to customize the HTML output. 17 | 18 | Doxygen allows you to customize the HTML output by modifying a master HTML header, footer and stylesheet. You can then include additional stylesheets and javascript files. The following command will generate the default Doxygen files. 19 | 20 | `doxygen -w html header.html footer.html customdoxygen.css` 21 | 22 | Modifying these files alone is not enough to get good Twitter Bootstrap integration. Bootstrap requires that certain classes be applied within the HTML. For example, a Bootstrap “table” needs to have a class called “table” in order to apply the Bootstrap table formatting. We just need to augment the default HTML with these Bootstrap classes. To do this, we use the provided doxy-boot.js javascript file. 23 | 24 | Also, you can augment doxygen’s default stylesheet with a customdoxygen.css stylesheet. This is where you would place any custom styling such as sticky footers. 25 | 26 | # How to Integrate 27 | 28 | To integrate this into your own project tell your doxyfile to use these 4 files in the HTML section (see the example site for an example of each file): 29 | 30 | * HTML_HEADER=header.html 31 | * Adds a Bootstrap navbar 32 | * Wraps the content in a Bootstrap container/row 33 | * HTML_FOOTER=footer.html 34 | * Closes the extra divs opened in the header.html 35 | * HTML\_EXTRA_STYLESHEET=customdoxygen.css 36 | * Adds additional styling such as a sticky footer 37 | * HTML\_EXTRA_FILES=doxy-boot.js 38 | * Where the magic happens to augment the HTML with bootstrap 39 | 40 | NOTE: The header.html file needs to include the Bootstrap css/javascript for this to work. This is where you can specify your own bootstrap compilation. These files will need to be manually added to the html directory, added as additional files in the doxyfile HTML\_EXTRA_FILES section or referenced externally (see example site header.html). 41 | 42 | NOTE: If you want to use the customdoxygen.css stylesheet from this repository, then you will need to replace the customdoxygen.css style sheet generated by the doxygen command above. If your customdoxygen.css file is in the directory when you run the doxygen command, it will be moved to customdoxygen.css.bak and you can restore it by overwriting the new version with the backup. 43 | 44 | See the example-site directory for a minimal working example. 45 | 46 | ## Todo List 47 | * Menu is not correctly displayed when Doxygen sidebar is enabled. 48 | -------------------------------------------------------------------------------- /Quartz/Documentation/doxy-boot-theme/addons/bootstrap/jquery.smartmenus.bootstrap.css: -------------------------------------------------------------------------------- 1 | /* 2 | You probably do not need to edit this at all. 3 | 4 | Add some SmartMenus required styles not covered in Bootstrap 3's default CSS. 5 | These are theme independent and should work with any Bootstrap 3 theme mod. 6 | */ 7 | /* sub menus arrows on desktop */ 8 | .navbar-nav:not(.sm-collapsible) ul .caret { 9 | position: absolute; 10 | right: 0; 11 | margin-top: 6px; 12 | margin-right: 15px; 13 | border-top: 4px solid transparent; 14 | border-bottom: 4px solid transparent; 15 | border-left: 4px dashed; 16 | } 17 | .navbar-nav:not(.sm-collapsible) ul a.has-submenu { 18 | padding-right: 30px; 19 | } 20 | /* make sub menu arrows look like +/- buttons in collapsible mode */ 21 | .navbar-nav.sm-collapsible .caret, .navbar-nav.sm-collapsible ul .caret { 22 | position: absolute; 23 | right: 0; 24 | margin: -3px 15px 0 0; 25 | padding: 0; 26 | width: 32px; 27 | height: 26px; 28 | line-height: 24px; 29 | text-align: center; 30 | border-width: 1px; 31 | border-style: solid; 32 | } 33 | .navbar-nav.sm-collapsible .caret:before { 34 | content: '+'; 35 | font-family: monospace; 36 | font-weight: bold; 37 | } 38 | .navbar-nav.sm-collapsible .open > a > .caret:before { 39 | content: '-'; 40 | } 41 | .navbar-nav.sm-collapsible a.has-submenu { 42 | padding-right: 50px; 43 | } 44 | /* revert to Bootstrap's default carets in collapsible mode when the "data-sm-skip-collapsible-behavior" attribute is set to the ul.navbar-nav */ 45 | .navbar-nav.sm-collapsible[data-sm-skip-collapsible-behavior] .caret, .navbar-nav.sm-collapsible[data-sm-skip-collapsible-behavior] ul .caret { 46 | position: static; 47 | margin: 0 0 0 2px; 48 | padding: 0; 49 | width: 0; 50 | height: 0; 51 | border-top: 4px dashed; 52 | border-right: 4px solid transparent; 53 | border-bottom: 0; 54 | border-left: 4px solid transparent; 55 | } 56 | .navbar-nav.sm-collapsible[data-sm-skip-collapsible-behavior] .caret:before { 57 | content: '' !important; 58 | } 59 | .navbar-nav.sm-collapsible[data-sm-skip-collapsible-behavior] a.has-submenu { 60 | padding-right: 15px; 61 | } 62 | /* scrolling arrows for tall menus */ 63 | .navbar-nav span.scroll-up, .navbar-nav span.scroll-down { 64 | position: absolute; 65 | display: none; 66 | visibility: hidden; 67 | height: 20px; 68 | overflow: hidden; 69 | text-align: center; 70 | } 71 | .navbar-nav span.scroll-up-arrow, .navbar-nav span.scroll-down-arrow { 72 | position: absolute; 73 | top: -2px; 74 | left: 50%; 75 | margin-left: -8px; 76 | width: 0; 77 | height: 0; 78 | overflow: hidden; 79 | border-top: 7px dashed transparent; 80 | border-right: 7px dashed transparent; 81 | border-bottom: 7px solid; 82 | border-left: 7px dashed transparent; 83 | } 84 | .navbar-nav span.scroll-down-arrow { 85 | top: 6px; 86 | border-top: 7px solid; 87 | border-right: 7px dashed transparent; 88 | border-bottom: 7px dashed transparent; 89 | border-left: 7px dashed transparent; 90 | } 91 | /* add more indentation for 2+ level sub in collapsible mode - Bootstrap normally supports just 1 level sub menus */ 92 | .navbar-nav.sm-collapsible ul .dropdown-menu > li > a, 93 | .navbar-nav.sm-collapsible ul .dropdown-menu .dropdown-header { 94 | padding-left: 35px; 95 | } 96 | .navbar-nav.sm-collapsible ul ul .dropdown-menu > li > a, 97 | .navbar-nav.sm-collapsible ul ul .dropdown-menu .dropdown-header { 98 | padding-left: 45px; 99 | } 100 | .navbar-nav.sm-collapsible ul ul ul .dropdown-menu > li > a, 101 | .navbar-nav.sm-collapsible ul ul ul .dropdown-menu .dropdown-header { 102 | padding-left: 55px; 103 | } 104 | .navbar-nav.sm-collapsible ul ul ul ul .dropdown-menu > li > a, 105 | .navbar-nav.sm-collapsible ul ul ul ul .dropdown-menu .dropdown-header { 106 | padding-left: 65px; 107 | } 108 | /* fix SmartMenus sub menus auto width (subMenusMinWidth and subMenusMaxWidth options) */ 109 | .navbar-nav .dropdown-menu > li > a { 110 | white-space: normal; 111 | } 112 | .navbar-nav ul.sm-nowrap > li > a { 113 | white-space: nowrap; 114 | } 115 | .navbar-nav.sm-collapsible ul.sm-nowrap > li > a { 116 | white-space: normal; 117 | } 118 | /* fix .navbar-right subs alignment */ 119 | .navbar-right ul.dropdown-menu { 120 | left: 0; 121 | right: auto; 122 | } -------------------------------------------------------------------------------- /Quartz/Documentation/doxy-boot-theme/addons/bootstrap/jquery.smartmenus.bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! SmartMenus jQuery Plugin Bootstrap Addon - v0.3.1 - November 1, 2016 2 | * http://www.smartmenus.org/ 3 | * Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery","jquery.smartmenus"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function(t){return t.extend(t.SmartMenus.Bootstrap={},{keydownFix:!1,init:function(){var e=t("ul.navbar-nav:not([data-sm-skip])");e.each(function(){function e(){o.find("a.current").parent().addClass("active"),o.find("a.has-submenu").each(function(){var e=t(this);e.is('[data-toggle="dropdown"]')&&e.dataSM("bs-data-toggle-dropdown",!0).removeAttr("data-toggle"),e.is('[role="button"]')&&e.dataSM("bs-role-button",!0).removeAttr("role")})}function s(){o.find("a.current").parent().removeClass("active"),o.find("a.has-submenu").each(function(){var e=t(this);e.dataSM("bs-data-toggle-dropdown")&&e.attr("data-toggle","dropdown").removeDataSM("bs-data-toggle-dropdown"),e.dataSM("bs-role-button")&&e.attr("role","button").removeDataSM("bs-role-button")})}function i(t){var e=a.getViewportWidth();if(e!=n||t){var s=o.find(".caret");a.isCollapsible()?(o.addClass("sm-collapsible"),o.is("[data-sm-skip-collapsible-behavior]")||s.addClass("navbar-toggle sub-arrow")):(o.removeClass("sm-collapsible"),o.is("[data-sm-skip-collapsible-behavior]")||s.removeClass("navbar-toggle sub-arrow")),n=e}}var o=t(this),a=o.data("smartmenus");if(!a){o.smartmenus({subMenusSubOffsetX:2,subMenusSubOffsetY:-6,subIndicators:!1,collapsibleShowFunction:null,collapsibleHideFunction:null,rightToLeftSubMenus:o.hasClass("navbar-right"),bottomToTopSubMenus:o.closest(".navbar").hasClass("navbar-fixed-bottom")}).bind({"show.smapi":function(e,s){var i=t(s),o=i.dataSM("scroll-arrows");o&&o.css("background-color",t(document.body).css("background-color")),i.parent().addClass("open")},"hide.smapi":function(e,s){t(s).parent().removeClass("open")}}),e(),a=o.data("smartmenus"),a.isCollapsible=function(){return!/^(left|right)$/.test(this.$firstLink.parent().css("float"))},a.refresh=function(){t.SmartMenus.prototype.refresh.call(this),e(),i(!0)},a.destroy=function(e){s(),t.SmartMenus.prototype.destroy.call(this,e)},o.is("[data-sm-skip-collapsible-behavior]")&&o.bind({"click.smapi":function(e,s){if(a.isCollapsible()){var i=t(s),o=i.parent().dataSM("sub");if(o&&o.dataSM("shown-before")&&o.is(":visible"))return a.itemActivate(i),a.menuHide(o),!1}}});var n;i(),t(window).bind("resize.smartmenus"+a.rootId,i)}}),e.length&&!t.SmartMenus.Bootstrap.keydownFix&&(t(document).off("keydown.bs.dropdown.data-api",".dropdown-menu"),t.fn.dropdown&&t.fn.dropdown.Constructor&&t(document).on("keydown.bs.dropdown.data-api",'.dropdown-menu:not([id^="sm-"])',t.fn.dropdown.Constructor.prototype.keydown),t.SmartMenus.Bootstrap.keydownFix=!0)}}),t(t.SmartMenus.Bootstrap.init),t}); -------------------------------------------------------------------------------- /Quartz/Documentation/doxy-boot-theme/addons/keyboard/jquery.smartmenus.keyboard.min.js: -------------------------------------------------------------------------------- 1 | /*! SmartMenus jQuery Plugin Keyboard Addon - v0.3.1 - November 1, 2016 2 | * http://www.smartmenus.org/ 3 | * Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery","jquery.smartmenus"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function(t){function e(t){return t.find("> li > a:not(.disabled), > li > :not(ul) a:not(.disabled)").eq(0)}function s(t){return t.find("> li > a:not(.disabled), > li > :not(ul) a:not(.disabled)").eq(-1)}function i(t,s){var i=t.nextAll("li").find("> a:not(.disabled), > :not(ul) a:not(.disabled)").eq(0);return s||i.length?i:e(t.parent())}function o(e,i){var o=e.prevAll("li").find("> a:not(.disabled), > :not(ul) a:not(.disabled)").eq(/^1\.8\./.test(t.fn.jquery)?0:-1);return i||o.length?o:s(e.parent())}return t.fn.focusSM=function(){return this.length&&this[0].focus&&this[0].focus(),this},t.extend(t.SmartMenus.Keyboard={},{docKeydown:function(a){var n=a.keyCode;if(/^(37|38|39|40)$/.test(n)){var r=t(this),u=r.data("smartmenus"),h=t(a.target);if(u&&h.is("a")&&u.handleItemEvents(h)){var l=h.closest("li"),d=l.parent(),c=d.dataSM("level");switch(r.hasClass("sm-rtl")&&(37==n?n=39:39==n&&(n=37)),n){case 37:if(u.isCollapsible())break;c>2||2==c&&r.hasClass("sm-vertical")?u.activatedItems[c-2].focusSM():r.hasClass("sm-vertical")||o((u.activatedItems[0]||h).closest("li")).focusSM();break;case 38:if(u.isCollapsible()){var m;c>1&&(m=e(d)).length&&h[0]==m[0]?u.activatedItems[c-2].focusSM():o(l).focusSM()}else 1==c&&!r.hasClass("sm-vertical")&&u.opts.bottomToTopSubMenus?(!u.activatedItems[0]&&h.dataSM("sub")&&(u.opts.showOnClick&&(u.clickActivated=!0),u.itemActivate(h),h.dataSM("sub").is(":visible")&&(u.focusActivated=!0)),u.activatedItems[0]&&u.activatedItems[0].dataSM("sub")&&u.activatedItems[0].dataSM("sub").is(":visible")&&!u.activatedItems[0].dataSM("sub").hasClass("mega-menu")&&s(u.activatedItems[0].dataSM("sub")).focusSM()):(c>1||r.hasClass("sm-vertical"))&&o(l).focusSM();break;case 39:if(u.isCollapsible())break;1==c&&r.hasClass("sm-vertical")?(!u.activatedItems[0]&&h.dataSM("sub")&&(u.opts.showOnClick&&(u.clickActivated=!0),u.itemActivate(h),h.dataSM("sub").is(":visible")&&(u.focusActivated=!0)),u.activatedItems[0]&&u.activatedItems[0].dataSM("sub")&&u.activatedItems[0].dataSM("sub").is(":visible")&&!u.activatedItems[0].dataSM("sub").hasClass("mega-menu")&&e(u.activatedItems[0].dataSM("sub")).focusSM()):1!=c&&(!u.activatedItems[c-1]||u.activatedItems[c-1].dataSM("sub")&&u.activatedItems[c-1].dataSM("sub").is(":visible")&&!u.activatedItems[c-1].dataSM("sub").hasClass("mega-menu"))||r.hasClass("sm-vertical")?u.activatedItems[c-1]&&u.activatedItems[c-1].dataSM("sub")&&u.activatedItems[c-1].dataSM("sub").is(":visible")&&!u.activatedItems[c-1].dataSM("sub").hasClass("mega-menu")&&e(u.activatedItems[c-1].dataSM("sub")).focusSM():i((u.activatedItems[0]||h).closest("li")).focusSM();break;case 40:if(u.isCollapsible()){var p,f;if(u.activatedItems[c-1]&&u.activatedItems[c-1].dataSM("sub")&&u.activatedItems[c-1].dataSM("sub").is(":visible")&&!u.activatedItems[c-1].dataSM("sub").hasClass("mega-menu")&&(p=e(u.activatedItems[c-1].dataSM("sub"))).length)p.focusSM();else if(c>1&&(f=s(d)).length&&h[0]==f[0]){for(var v=u.activatedItems[c-2].closest("li"),b=null;v.is("li")&&!(b=i(v,!0)).length;)v=v.parent().parent();b.length?b.focusSM():e(r).focusSM()}else i(l).focusSM()}else 1!=c||r.hasClass("sm-vertical")||u.opts.bottomToTopSubMenus?(c>1||r.hasClass("sm-vertical"))&&i(l).focusSM():(!u.activatedItems[0]&&h.dataSM("sub")&&(u.opts.showOnClick&&(u.clickActivated=!0),u.itemActivate(h),h.dataSM("sub").is(":visible")&&(u.focusActivated=!0)),u.activatedItems[0]&&u.activatedItems[0].dataSM("sub")&&u.activatedItems[0].dataSM("sub").is(":visible")&&!u.activatedItems[0].dataSM("sub").hasClass("mega-menu")&&e(u.activatedItems[0].dataSM("sub")).focusSM())}a.stopPropagation(),a.preventDefault()}}}}),t(document).delegate("ul.sm, ul.navbar-nav:not([data-sm-skip])","keydown.smartmenus",t.SmartMenus.Keyboard.docKeydown),t.extend(t.SmartMenus.prototype,{keyboardSetHotkey:function(s,i){var o=this;t(document).bind("keydown.smartmenus"+this.rootId,function(a){if(s==a.keyCode){var n=!0;i&&("string"==typeof i&&(i=[i]),t.each(["ctrlKey","shiftKey","altKey","metaKey"],function(e,s){return t.inArray(s,i)>=0&&!a[s]||0>t.inArray(s,i)&&a[s]?(n=!1,!1):void 0})),n&&(e(o.$root).focusSM(),a.stopPropagation(),a.preventDefault())}})}}),t}); -------------------------------------------------------------------------------- /Quartz/Documentation/doxy-boot-theme/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Quartz/Documentation/doxy-boot-theme/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | $projectname: $title 15 | $title 16 | 17 | 18 | $treeview 19 | $search 20 | $mathjax 21 | 22 | $extrastylesheet 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 41 |
42 |
43 |
44 |
45 |
46 |
47 | 48 | -------------------------------------------------------------------------------- /Quartz/Engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(QuartzEngine LANGUAGES CXX) 4 | 5 | include(CMakePCH) 6 | 7 | add_subdirectory(Include) 8 | add_subdirectory(Source) 9 | 10 | add_library(${PROJECT_NAME} STATIC ${engineSources} ${engineHeaders}) 11 | add_precompiled_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/Include/Quartz/QuartzPCH.hpp ${CMAKE_CURRENT_LIST_DIR}/Source/QuartzPCH.cpp) 12 | 13 | target_link_libraries(${PROJECT_NAME} PRIVATE SDL2-static SDL2main liblua) 14 | 15 | set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../ThirdParty) 16 | target_include_directories(${PROJECT_NAME} PUBLIC 17 | ${dependencies}/sol2/include 18 | ${dependencies}/stb_image 19 | ${CMAKE_CURRENT_LIST_DIR}/Include 20 | ) 21 | 22 | if(WIN32) 23 | target_link_libraries(${PROJECT_NAME} PRIVATE imm32.lib ole32.lib oleaut32.lib opengl32.lib version.lib winmm.lib) 24 | endif() 25 | 26 | if(UNIX AND NOT APPLE) 27 | find_package(X11 REQUIRED) 28 | find_package(Threads REQUIRED) 29 | target_link_libraries(${PROJECT_NAME} PRIVATE ${X11_LIBRARIES} GL) 30 | endif() 31 | 32 | foreach(FILE ${engineSources}) 33 | get_filename_component(PARENT_DIR "${FILE}" DIRECTORY) 34 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}") 35 | 36 | string(REPLACE "/" "\\" GROUP "${GROUP}") 37 | string(REPLACE "Source" "" GROUP "${GROUP}") 38 | 39 | set(GROUP "Source Files${GROUP}") 40 | source_group("${GROUP}" FILES "${FILE}") 41 | endforeach() 42 | 43 | foreach(FILE ${engineHeaders}) 44 | get_filename_component(PARENT_DIR "${FILE}" DIRECTORY) 45 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}") 46 | 47 | string(REPLACE "/" "\\" GROUP "${GROUP}") 48 | string(REPLACE "Include" "" GROUP "${GROUP}") 49 | 50 | set(GROUP "Header Files${GROUP}") 51 | source_group("${GROUP}" FILES "${FILE}") 52 | endforeach() 53 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Quartz) 2 | 3 | set(engineHeaders 4 | ${engineHeaders} 5 | 6 | ${CMAKE_CURRENT_LIST_DIR}/Quartz.hpp 7 | 8 | PARENT_SCOPE 9 | ) -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Voxels) 2 | add_subdirectory(Math) 3 | add_subdirectory(Utilities) 4 | 5 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 6 | set(engineHeaders 7 | ${voxelHeaders} 8 | 9 | ${mathHeaders} 10 | ${utilityHeaders} 11 | ${eventHeaders} 12 | 13 | ${currentDir}/Core.hpp 14 | ${currentDir}/QuartzPCH.hpp 15 | ${currentDir}/UniversalDoxygenComments.hpp 16 | 17 | PARENT_SCOPE 18 | ) 19 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Core.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #if defined(_DEBUG) 32 | # define QZ_DEBUG 33 | #endif 34 | 35 | #if defined(_WIN32) || defined(_WIN64) 36 | # define QZ_PLATFORM_WINDOWS 37 | #endif 38 | 39 | #if defined(__linux__) 40 | # define QZ_PLATFORM_LINUX 41 | #endif 42 | 43 | #if defined(__APPLE__) 44 | # define QZ_PLATFORM_APPLE 45 | #endif -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Math/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | set(mathHeaders 4 | ${currentDir}/MathUtils.hpp 5 | ${currentDir}/Matrix4x4.hpp 6 | ${currentDir}/Vector3.hpp 7 | ${currentDir}/Vector2.hpp 8 | ${currentDir}/Ray.hpp 9 | ${currentDir}/Rect.hpp 10 | 11 | ${currentDir}/Math.hpp 12 | 13 | PARENT_SCOPE 14 | ) 15 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Math/Math.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace qz 39 | { 40 | typedef math::Matrix4x4 Matrix4x4; 41 | 42 | typedef math::Vector2 Vector2; 43 | typedef math::Vector3 Vector3; 44 | typedef math::TemplateVector2 Vector2i; 45 | typedef math::TemplateVector3 Vector3i; 46 | 47 | typedef math::RectAABB RectAABB; 48 | 49 | template 50 | using TVector2 = math::TemplateVector2; 51 | template 52 | using TVector3 = math::TemplateVector3; 53 | } // namespace qz 54 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Math/MathUtils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace qz 34 | { 35 | namespace math 36 | { 37 | /** 38 | * @brief A Utility providing PI to 11 decimal places. 39 | */ 40 | static constexpr float PI = 3.14159265359f; 41 | 42 | /** 43 | * @brief Converts degrees to radians. 44 | * @param degrees The number of degrees waiting to be converted. 45 | * @return The converted value, in radians. 46 | */ 47 | static float degreeToRadians(const float& degrees) 48 | { 49 | return degrees * PI / 180.f; 50 | } 51 | 52 | /** 53 | * @brief Converts radians to degrees. 54 | * @param radians The number of radians waiting to be converted. 55 | * @return The converted value, in degrees. 56 | */ 57 | static float radianToDegrees(const float& radians) 58 | { 59 | return radians * 180.f / PI; 60 | } 61 | 62 | /** 63 | * @brief 64 | * @tparam T The data type that needs to be clamped. 65 | * @param n The actual value needing to be clamped. 66 | * @param lower The lowest value the result should be allowed to be. 67 | * @param upper The highest value the results should be allowed to be. 68 | * @return Either the original number if the value is between the lower 69 | * and upper bounds, OR the upper/lower bounds dependant 70 | * on the value. 71 | */ 72 | template 73 | T clamp(const T& n, const T& lower, const T& upper) 74 | { 75 | return std::max(lower, std::min(n, upper)); 76 | } 77 | }; // namespace math 78 | } // namespace qz 79 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Math/Ray.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace qz 34 | { 35 | namespace math 36 | { 37 | /** 38 | * @brief Produces a castable ray for helping find things at 39 | * positions/intervals along the ray. 40 | */ 41 | class Ray 42 | { 43 | public: 44 | /** 45 | * @brief Constructs a Ray object. 46 | * @param start The position of the start of the ray. 47 | * @param direction The direction the ray is "traveling" in. 48 | */ 49 | Ray(const Vector3& start, const Vector3& direction); 50 | 51 | Ray(const Ray& other) = default; 52 | ~Ray() = default; 53 | 54 | /** 55 | * @brief Advances along a ray. 56 | * @param scale The distance to advance along the ray 57 | * @return The new position along the ray. 58 | */ 59 | Vector3 advance(float scale); 60 | 61 | /** 62 | * @brief Backtracks (goes backwards) along a ray. 63 | * @param scale The distance to backtrack along the ray. 64 | * @return The new position along the ray. 65 | */ 66 | Vector3 backtrace(float scale); 67 | 68 | /** 69 | * @brief Gets the current length of the ray. 70 | * @return The length of the ray. 71 | */ 72 | float getLength() const; 73 | 74 | /** 75 | * @brief Gets the current position along the ray. 76 | * @return The current position along the ray 77 | */ 78 | Vector3 getCurrentPosition() const; 79 | 80 | private: 81 | float m_length; 82 | Vector3 m_start; 83 | Vector3 m_direction; 84 | Vector3 m_currentPosition; 85 | }; 86 | } // namespace math 87 | } // namespace qz 88 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Math/Rect.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace qz 34 | { 35 | namespace math 36 | { 37 | struct RectAABB 38 | { 39 | Vector2 topLeft, topRight; 40 | Vector2 bottomLeft, bottomRight; 41 | 42 | RectAABB(Vector2 tl, Vector2 tr, Vector2 bl, Vector2 br) 43 | : topLeft(tl), topRight(tr), bottomLeft(bl), bottomRight(br) 44 | { 45 | } 46 | 47 | RectAABB() {} 48 | }; 49 | } // namespace math 50 | } // namespace qz 51 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/QuartzPCH.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #define SDL_MAIN_HANDLED 47 | #include 48 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/UniversalDoxygenComments.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | /** 32 | * @brief The universal namespace for all official Phoenix code. 33 | * 34 | * ONLY Phoenix based code should be placed inside the PHX namespace. 35 | * Things like ENUMs, Classes, Functions, Structs, and similar should be placed 36 | * inside the PHX Namespace, and in any required sub-namespaces. 37 | */ 38 | namespace qz 39 | { 40 | /** 41 | * @brief The namespace for Event related code. 42 | */ 43 | namespace events 44 | { 45 | } 46 | 47 | /** 48 | * @brief The Namespace for Graphical Related code. 49 | * 50 | * This namespace should only contain code related to the graphical part of 51 | * the engine, so things like the OpenGL Abstraction Layer should go in 52 | * here, along with something like a HUD system, etc... 53 | */ 54 | namespace gfx 55 | { 56 | /** 57 | * @brief The Namespace for Graphical API Abstraction code. 58 | */ 59 | namespace rhi 60 | { 61 | /** 62 | * @brief The Namespace for specifically OpenGL related code. 63 | * 64 | * This namespace is mainly just for the OpenGL Abstraction Layer, 65 | * nothing much else. The renderer we create later on can use this 66 | * namespace, but WON'T be in it. 67 | */ 68 | namespace gl 69 | { 70 | } 71 | } // namespace rhi 72 | } // namespace gfx 73 | } // namespace qz 74 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Threading) 2 | 3 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 4 | set(utilityHeaders 5 | ${threadingHeaders} 6 | 7 | ${currentDir}/Logger.hpp 8 | ${currentDir}/FileIO.hpp 9 | ${currentDir}/HandleAllocator.hpp 10 | ${currentDir}/EnumTools.hpp 11 | ${currentDir}/Singleton.hpp 12 | ${currentDir}/Plugin.hpp 13 | 14 | PARENT_SCOPE 15 | ) 16 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/FileIO.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace qz 34 | { 35 | namespace utils 36 | { 37 | /** 38 | * @brief File Input/Output wrapping class. 39 | */ 40 | class FileIO 41 | { 42 | public: 43 | /** 44 | * @brief Reads a whole file into a string. 45 | * @param filepath The path to the file needing to be read. 46 | * @return A string containing the contents of the file. 47 | */ 48 | static std::string readAllFile(const std::string& filepath); 49 | /** 50 | * @brief Returns the path to the directory containing the file 51 | * @param filepath The path to the file needing to be read. 52 | * @return directory path 53 | */ 54 | static std::string getDirname(const std::string& filepath); 55 | }; 56 | } // namespace utils 57 | } // namespace qz 58 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/HandleAllocator.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | namespace qz 36 | { 37 | namespace utils 38 | { 39 | class HandleBase 40 | { 41 | public: 42 | static constexpr std::uint16_t QZ_INVALID_HANDLE = 0xFFFF; 43 | 44 | void set(std::uint16_t value) { m_handle = value; } 45 | std::uint16_t get() const { return m_handle; } 46 | 47 | HandleBase() : m_handle(QZ_INVALID_HANDLE) {} 48 | 49 | private: 50 | std::uint16_t m_handle; 51 | }; 52 | 53 | template 54 | class HandleAllocator 55 | { 56 | public: 57 | HandleAllocator() : m_size(0) {} 58 | 59 | THandleType allocate() 60 | { 61 | assert(m_size < TMaxNumHandles); 62 | 63 | THandleType& handle = m_handles[m_size]; 64 | handle.set(m_size); 65 | 66 | m_size++; 67 | 68 | return handle; 69 | } 70 | 71 | bool isValid(THandleType handle) 72 | { 73 | if (handle.get() == HandleBase::QZ_INVALID_HANDLE) 74 | return false; 75 | 76 | return m_handles[handle.get()].get() != 77 | HandleBase::QZ_INVALID_HANDLE; 78 | } 79 | 80 | void free(THandleType handle) 81 | { 82 | m_handles[handle.get()].set(HandleBase::QZ_INVALID_HANDLE); 83 | } 84 | 85 | std::size_t size() { return m_size; } 86 | 87 | void reset() { m_size = 0; } 88 | 89 | private: 90 | THandleType m_handles[TMaxNumHandles]; 91 | std::uint16_t m_size; 92 | }; 93 | } // namespace utils 94 | } // namespace qz 95 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/Plugin.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | #if defined(QZ_PLATFORM_WINDOWS) 34 | #include 35 | #elif defined(QZ_PLATFORM_LINUX) || defined(QZ_PLATFORM_APPLE) 36 | #include 37 | #endif 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | namespace qz 44 | { 45 | namespace utils 46 | { 47 | class Plugin 48 | { 49 | public: 50 | Plugin(); 51 | Plugin(const std::string& path); 52 | ~Plugin(); 53 | 54 | void load(const std::string& path); 55 | void unload(); 56 | 57 | template 58 | T get(const std::string& procname) 59 | { 60 | T funcptr; 61 | 62 | #if defined(QZ_PLATFORM_WINDOWS) 63 | if (NULL == (funcptr = reinterpret_cast(GetProcAddress(m_hInstance, procname.c_str())))) 64 | { 65 | throw std::system_error( 66 | std::error_code(::GetLastError(), std::system_category()) 67 | , std::string("Couldn't find ") + procname 68 | ); 69 | } 70 | #elif defined(QZ_PLATFORM_LINUX) || defined(QZ_PLATFORM_APPLE) 71 | if (NULL == (funcptr = reinterpret_cast(dlsym(m_hInstance, procname.c_str())))) 72 | { 73 | throw std::system_error( 74 | std::error_code(errno, std::system_category()) 75 | , std::string("Couldn't find ") + procname + ", " + std::string(dlerror()) 76 | ); 77 | } 78 | #endif 79 | return funcptr; 80 | } 81 | 82 | private: 83 | #if defined(QZ_PLATFORM_WINDOWS) 84 | HINSTANCE m_hInstance; 85 | #elif defined(QZ_PLATFORM_LINUX) || defined(QZ_PLATFORM_APPLE) 86 | void* m_hInstance; 87 | #endif 88 | std::string m_path; 89 | bool m_loaded; 90 | }; 91 | 92 | } // namespace utils 93 | } // namespace qz -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/Singleton.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | namespace qz 32 | { 33 | namespace utils 34 | { 35 | template 36 | class Singleton 37 | { 38 | public: 39 | static T* get() 40 | { 41 | static T instance; 42 | return &instance; 43 | } 44 | }; 45 | } // namespace utils 46 | } // namespace qz 47 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/Threading/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | set(threadingHeaders 4 | ${currentDir}/SingleWorker.hpp 5 | ${currentDir}/ThreadPool.hpp 6 | 7 | PARENT_SCOPE 8 | ) 9 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/Threading/SingleWorker.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace qz 38 | { 39 | namespace utils 40 | { 41 | namespace threading 42 | { 43 | class SingleWorker 44 | { 45 | public: 46 | SingleWorker(); 47 | ~SingleWorker(); 48 | 49 | void addWork(std::function&& function); 50 | 51 | private: 52 | bool m_running; 53 | std::thread m_thread; 54 | std::mutex m_mutex; 55 | std::condition_variable m_condition; 56 | 57 | std::deque> m_queue; 58 | 59 | private: 60 | void threadHandle(); 61 | }; 62 | } // namespace threading 63 | } // namespace utils 64 | } // namespace qz 65 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Utilities/Threading/ThreadPool.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | namespace qz 41 | { 42 | namespace utils 43 | { 44 | namespace threading 45 | { 46 | class ThreadPool 47 | { 48 | public: 49 | ThreadPool(const std::size_t threadCount); 50 | ~ThreadPool(); 51 | 52 | void addWork(std::function fun); 53 | 54 | private: 55 | bool m_running; 56 | 57 | std::mutex m_mutex; 58 | std::condition_variable m_condition; 59 | 60 | std::vector m_threads; 61 | std::deque> m_scheduledTasks; 62 | 63 | private: 64 | void threadHandle(); 65 | }; 66 | } // namespace threading 67 | } // namespace utils 68 | } // namespace qz 69 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Voxels/Blocks.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | namespace qz 39 | { 40 | namespace voxels 41 | { 42 | class BlockTextureAtlas 43 | { 44 | public: 45 | typedef int SpriteID; 46 | const static SpriteID INVALID_SPRITE = -1; 47 | 48 | BlockTextureAtlas(std::size_t spriteWidth, 49 | std::size_t spriteHeight); 50 | BlockTextureAtlas(); 51 | ~BlockTextureAtlas(); 52 | 53 | void addTextureFile(const char* texturefilepath); 54 | void patch(); 55 | void setSpriteWidth(std::size_t w); 56 | void setSpriteHeight(std::size_t h); 57 | 58 | std::size_t getSpriteWidth() const { return m_spriteWidth; } 59 | std::size_t getSpriteHeight() const { return m_spriteHeight; } 60 | SpriteID getSpriteIDFromFilepath(const char* filepath); 61 | 62 | std::size_t getPatchedTextureWidth() const 63 | { 64 | return m_patchedTextureWidth; 65 | } 66 | 67 | std::size_t getPatchedTextureHeight() const 68 | { 69 | return m_patchedTextureHeight; 70 | } 71 | 72 | unsigned char* getPatchedTextureData() const 73 | { 74 | return m_patchedTextureData; 75 | } 76 | 77 | RectAABB getSpriteFromID(SpriteID spriteId) const; 78 | 79 | private: 80 | std::unordered_map m_textureIDMap; 81 | std::size_t m_spriteWidth, m_spriteHeight; 82 | unsigned char* m_patchedTextureData; 83 | 84 | std::size_t m_patchedTextureWidth, m_patchedTextureHeight; 85 | }; 86 | 87 | enum class BlockTypeCategory 88 | { 89 | AIR, 90 | SOLID, 91 | LIQUID 92 | }; 93 | 94 | struct BlockType 95 | { 96 | const char* displayName; 97 | const char* id; 98 | 99 | BlockTypeCategory category; 100 | 101 | struct 102 | { 103 | BlockTextureAtlas::SpriteID top, bottom, left, right, front, 104 | back; 105 | 106 | void setAll(BlockTextureAtlas::SpriteID sprite) 107 | { 108 | top = bottom = left = right = front = back = sprite; 109 | } 110 | } textures; 111 | }; 112 | 113 | class BlockRegistry : public utils::Singleton 114 | { 115 | public: 116 | BlockType* registerBlock(BlockType blockInfo); 117 | BlockType* getBlockFromID(const char* id); 118 | 119 | private: 120 | // This is a std::list as we don't want to invalidate any pointers 121 | // when resizing... #todo (bwilks): Maybe use HandleAllocator for 122 | // this as well?? 123 | std::list m_blocks; 124 | }; 125 | } // namespace voxels 126 | } // namespace qz 127 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Voxels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(voxelHeaders 3 | ${currentDir}/Terrain.hpp 4 | ${currentDir}/Blocks.hpp 5 | PARENT_SCOPE 6 | ) 7 | -------------------------------------------------------------------------------- /Quartz/Engine/Include/Quartz/Voxels/Terrain.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | namespace qz 39 | { 40 | namespace voxels 41 | { 42 | class Chunk 43 | { 44 | public: 45 | typedef std::function 47 | GeneratorFunction; 48 | 49 | private: 50 | std::vector m_voxelData; 51 | 52 | public: 53 | void fill(const std::size_t chunkSize, 54 | const Chunk::GeneratorFunction& generator); 55 | }; 56 | 57 | class Terrain 58 | { 59 | private: 60 | std::size_t m_chunkSize; 61 | Chunk::GeneratorFunction m_generatorFunction; 62 | std::vector m_loadedChunks; 63 | 64 | public: 65 | Terrain(std::size_t chunkSize, 66 | const Chunk::GeneratorFunction& generator); 67 | 68 | void tick(Vector3 streamCenter); 69 | }; 70 | 71 | } // namespace voxels 72 | } // namespace qz 73 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Voxels) 2 | add_subdirectory(Math) 3 | add_subdirectory(Utilities) 4 | 5 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 6 | set(engineSources 7 | ${voxelSources} 8 | ${mathSources} 9 | ${utilitySources} 10 | 11 | ${currentDir}/QuartzPCH.cpp 12 | 13 | PARENT_SCOPE 14 | ) 15 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Math/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | set(mathSources 4 | ${currentDir}/Vector2.cpp 5 | ${currentDir}/Vector3.cpp 6 | ${currentDir}/Matrix4x4.cpp 7 | ${currentDir}/Ray.cpp 8 | 9 | PARENT_SCOPE 10 | ) 11 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Math/Ray.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | using namespace qz::math; 33 | 34 | Ray::Ray(const Vector3& start, const Vector3& direction) 35 | : m_start(start), m_direction(direction), m_currentPosition(start), 36 | m_length(0.f) 37 | { 38 | } 39 | 40 | Vector3 Ray::advance(float scale) 41 | { 42 | m_currentPosition += m_direction * scale; 43 | m_length += scale; 44 | 45 | return m_currentPosition; 46 | } 47 | 48 | Vector3 Ray::backtrace(float scale) 49 | { 50 | m_currentPosition -= m_direction * scale; 51 | m_length -= scale; 52 | 53 | return m_currentPosition; 54 | } 55 | 56 | float Ray::getLength() const { return m_length; } 57 | 58 | Vector3 Ray::getCurrentPosition() const { return m_currentPosition; } 59 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Math/Vector2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | using namespace qz::math; 33 | 34 | void Vector2::floor() 35 | { 36 | x = std::floor(x); 37 | y = std::floor(y); 38 | } 39 | 40 | void Vector2::ceil() 41 | { 42 | x = std::ceil(x); 43 | y = std::ceil(y); 44 | } 45 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Math/Vector3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | using namespace qz::math; 33 | 34 | void Vector3::floor() 35 | { 36 | x = std::floor(x); 37 | y = std::floor(y); 38 | z = std::floor(z); 39 | } 40 | 41 | void Vector3::ceil() 42 | { 43 | x = std::ceil(x); 44 | y = std::ceil(y); 45 | z = std::ceil(z); 46 | } 47 | 48 | void Vector3::normalize() 49 | { 50 | const float len = std::sqrt(dotProduct({x, y, z}, {x, y, z})); 51 | 52 | x /= len; 53 | y /= len; 54 | z /= len; 55 | } 56 | 57 | Vector3 Vector3::cross(const Vector3& vec1, const Vector3& vec2) 58 | { 59 | return {vec1.y * vec2.z - vec1.z * vec2.y, 60 | vec1.z * vec2.x - vec1.x * vec2.z, 61 | vec1.x * vec2.y - vec1.y * vec2.x}; 62 | } 63 | 64 | Vector3 Vector3::normalize(const Vector3& vec1) 65 | { 66 | const float len = std::sqrt(dotProduct(vec1, vec1)); 67 | 68 | return {vec1.x / len, vec1.y / len, vec1.z / len}; 69 | } 70 | 71 | float Vector3::dotProduct(const Vector3& vec1, const Vector3& vec2) 72 | { 73 | return vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z; 74 | } 75 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/QuartzPCH.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Threading) 2 | 3 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 4 | set(utilitySources 5 | ${threadingSources} 6 | 7 | ${currentDir}/Logger.cpp 8 | ${currentDir}/FileIO.cpp 9 | ${currentDir}/Plugin.cpp 10 | 11 | PARENT_SCOPE 12 | ) 13 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Utilities/FileIO.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | using namespace qz::utils; 33 | 34 | std::string FileIO::readAllFile(const std::string& filepath) 35 | { 36 | std::fstream fileHandle; 37 | fileHandle.open(filepath.c_str()); 38 | 39 | std::string fileString; 40 | fileString.assign((std::istreambuf_iterator(fileHandle)), 41 | (std::istreambuf_iterator())); 42 | 43 | fileHandle.close(); 44 | 45 | return fileString; 46 | } 47 | 48 | std::string FileIO::getDirname(const std::string& filename) 49 | { 50 | std::size_t p = filename.find_last_of("\\/"); 51 | return p == std::string::npos ? "" : filename.substr(0, p + 1); 52 | }; 53 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Utilities/Plugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | using namespace qz::utils; 33 | 34 | Plugin::Plugin() : 35 | m_hInstance(NULL) 36 | , m_path("") 37 | , m_loaded(false) 38 | {} 39 | 40 | Plugin::Plugin(const std::string& path) : 41 | m_hInstance(NULL) 42 | , m_path(path) 43 | , m_loaded(false) 44 | { 45 | load(m_path); 46 | } 47 | 48 | Plugin::~Plugin() 49 | { 50 | unload(); 51 | } 52 | 53 | void Plugin::load(const std::string& path) 54 | { 55 | if (m_loaded) 56 | unload(); 57 | m_path = path; 58 | 59 | #if defined(QZ_PLATFORM_WINDOWS) 60 | if (NULL == (m_hInstance = LoadLibrary(m_path.c_str()))) 61 | { 62 | throw std::system_error( 63 | std::error_code(::GetLastError(), std::system_category()) 64 | , "Couldn't load the library" 65 | ); 66 | } 67 | #elif defined(QZ_PLATFORM_LINUX) || defined(QZ_PLATFORM_APPLE) 68 | if (NULL == (m_hInstance = dlopen(m_path.c_str(), RTLD_NOW | RTLD_GLOBAL))) 69 | { 70 | throw std::system_error( 71 | std::error_code(errno, std::system_category()) 72 | , "Couldn't load the library, " + std::string(dlerror()) 73 | ); 74 | } 75 | #endif 76 | m_loaded = true; 77 | } 78 | 79 | void Plugin::unload() 80 | { 81 | if (m_loaded) 82 | { 83 | #if defined(QZ_PLATFORM_WINDOWS) 84 | FreeLibrary(m_hInstance); 85 | #elif defined(QZ_PLATFORM_LINUX) || defined(QZ_PLATFORM_APPLE) 86 | dlclose(m_hInstance); 87 | #endif 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Utilities/Threading/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(threadingSources 3 | ${currentDir}/SingleWorker.cpp 4 | ${currentDir}/ThreadPool.cpp 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Utilities/Threading/SingleWorker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | using namespace qz::utils::threading; 32 | 33 | SingleWorker::SingleWorker () : m_running (true) 34 | { 35 | std::thread t (&SingleWorker::threadHandle, this); 36 | m_thread.swap (t); 37 | } 38 | 39 | SingleWorker::~SingleWorker () 40 | { 41 | m_running = false; 42 | m_condition.notify_all (); 43 | 44 | if (m_thread.joinable ()) 45 | m_thread.join (); 46 | } 47 | 48 | void SingleWorker::addWork (std::function&& function) 49 | { 50 | { 51 | std::unique_lock lock (m_mutex); 52 | m_queue.emplace_back (std::move (function)); 53 | } 54 | 55 | m_condition.notify_one (); 56 | } 57 | 58 | void SingleWorker::threadHandle () 59 | { 60 | while (true) 61 | { 62 | std::function task; 63 | 64 | { 65 | std::unique_lock lock (m_mutex); 66 | 67 | m_condition.wait ( 68 | lock, [this] { return !m_running || !m_queue.empty (); }); 69 | 70 | if (!m_running && m_queue.empty ()) 71 | return; 72 | 73 | task = std::move (m_queue.front ()); 74 | m_queue.pop_front (); 75 | } 76 | 77 | task (); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Utilities/Threading/ThreadPool.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | using namespace qz::utils::threading; 32 | 33 | ThreadPool::ThreadPool (const std::size_t threadCount) 34 | { 35 | for (std::size_t i = 0; i < threadCount; ++i) 36 | { 37 | m_threads.emplace_back (&ThreadPool::threadHandle, this); 38 | } 39 | } 40 | 41 | ThreadPool::~ThreadPool () 42 | { 43 | m_running = false; 44 | m_condition.notify_all (); 45 | 46 | for (std::thread& taskWorker : m_threads) 47 | taskWorker.join (); 48 | } 49 | 50 | void ThreadPool::addWork (std::function fun) 51 | { 52 | { 53 | std::lock_guard lock (m_mutex); 54 | m_scheduledTasks.emplace_back (fun); 55 | } 56 | 57 | m_condition.notify_one (); 58 | } 59 | 60 | void ThreadPool::threadHandle () 61 | { 62 | while (true) 63 | { 64 | std::function task; 65 | 66 | { 67 | std::unique_lock lock (m_mutex); 68 | 69 | m_condition.wait (lock, [this]() { 70 | return !m_running || !m_scheduledTasks.empty (); 71 | }); 72 | 73 | if (!m_running && m_scheduledTasks.empty ()) 74 | return; 75 | 76 | task = m_scheduledTasks.front (); 77 | m_scheduledTasks.pop_front (); 78 | } 79 | 80 | task (); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Voxels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | set(voxelSources 4 | ${currentDir}/Blocks.cpp 5 | ${currentDir}/Terrain.cpp 6 | 7 | PARENT_SCOPE 8 | ) 9 | -------------------------------------------------------------------------------- /Quartz/Engine/Source/Voxels/Terrain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | using namespace qz::voxels; 32 | 33 | void Chunk::fill(const std::size_t chunkSize, 34 | const std::function& generator) 36 | { 37 | m_voxelData.resize(chunkSize * chunkSize * chunkSize); 38 | 39 | for (std::size_t x = 0; x < chunkSize; ++x) 40 | { 41 | for (std::size_t y = 0; y < chunkSize; ++y) 42 | { 43 | for (std::size_t z = 0; z < chunkSize; ++z) 44 | { 45 | const std::size_t idx = x + chunkSize * (y + chunkSize * z); 46 | m_voxelData[idx] = generator(x, y, z); 47 | } 48 | } 49 | } 50 | } 51 | 52 | Terrain::Terrain(std::size_t chunkSize, 53 | const Chunk::GeneratorFunction& generator) 54 | : m_chunkSize(chunkSize), m_generatorFunction(generator) 55 | { 56 | } 57 | 58 | void Terrain::tick(qz::Vector3 streamCenter) {} 59 | -------------------------------------------------------------------------------- /Quartz/Tests/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Quartz/Tests/.gitkeep -------------------------------------------------------------------------------- /Quartz/ThirdParty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(QuartzDependencies) 4 | 5 | if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/SDL2/include) 6 | message("It seems like the Git Submodules have not been initialised and cloned, they will now be initialised and cloned as required.") 7 | execute_process(COMMAND git submodule update --init 8 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 9 | ) 10 | endif() 11 | 12 | set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) 13 | 14 | add_subdirectory(SDL2) 15 | add_subdirectory(sol2) 16 | add_subdirectory(lua) 17 | 18 | # stop SDL trying to control our main function. 19 | add_definitions(-DSDL_MAIN_HANDLED) 20 | 21 | set_target_properties(SDL2main SDL2-static uninstall PROPERTIES FOLDER QuartzDependencies/sdl2) 22 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(lua) 4 | 5 | set(lualib_SRC_CORE 6 | lapi.c 7 | lcode.c 8 | lctype.c 9 | ldebug.c 10 | ldo.c 11 | ldump.c 12 | lfunc.c 13 | lgc.c 14 | llex.c 15 | lmem.c 16 | lobject.c 17 | lopcodes.c 18 | lparser.c 19 | lstate.c 20 | lstring.c 21 | ltable.c 22 | ltm.c 23 | lundump.c 24 | lvm.c 25 | lzio.c 26 | ) 27 | 28 | set(lualib_SRC_LIB 29 | lauxlib.c 30 | lbaselib.c 31 | lbitlib.c 32 | lcorolib.c 33 | ldblib.c 34 | liolib.c 35 | lmathlib.c 36 | loslib.c 37 | lstrlib.c 38 | ltablib.c 39 | lutf8lib.c 40 | loadlib.c 41 | linit.c 42 | ) 43 | 44 | set (luacli_SRC lua.c) 45 | 46 | add_library(liblua STATIC ${lualib_SRC_CORE} ${lualib_SRC_LIB}) 47 | target_include_directories(liblua PUBLIC ${CMAKE_CURRENT_LIST_DIR}) 48 | 49 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 50 | target_link_libraries(liblua m) 51 | endif() 52 | 53 | set_target_properties (liblua PROPERTIES OUTPUT_NAME lua) 54 | 55 | add_executable(lua ${luacli_SRC}) 56 | target_link_libraries(lua liblua) 57 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/all: -------------------------------------------------------------------------------- 1 | cd testes 2 | ulimit -S -s 2000 3 | if { ../lua all.lua; } then 4 | echo -e "\n\n final OK!!!!\n\n" 5 | else 6 | echo -e "\n\n >>>> BUG!!!!\n\n" 7 | fi 8 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.64.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 28 | OPR_DIV, 29 | OPR_IDIV, 30 | OPR_BAND, OPR_BOR, OPR_BXOR, 31 | OPR_SHL, OPR_SHR, 32 | OPR_CONCAT, 33 | OPR_EQ, OPR_LT, OPR_LE, 34 | OPR_NE, OPR_GT, OPR_GE, 35 | OPR_AND, OPR_OR, 36 | OPR_NOBINOPR 37 | } BinOpr; 38 | 39 | 40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 41 | 42 | 43 | /* get (pointer to) instruction of given 'expdesc' */ 44 | #define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) 45 | 46 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 47 | 48 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 49 | 50 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 51 | 52 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 53 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 54 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 55 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 56 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 57 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 58 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 59 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 60 | LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); 61 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 62 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 63 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 64 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 65 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 66 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 67 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 68 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 69 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 70 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 71 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 72 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 73 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 74 | LUAI_FUNC int luaK_jump (FuncState *fs); 75 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 76 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 77 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 78 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 79 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 80 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 81 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 82 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 83 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 84 | expdesc *v2, int line); 85 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.29.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15.1.1 2017/04/19 17:39:34 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.79.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | } LexState; 73 | 74 | 75 | LUAI_FUNC void luaX_init (lua_State *L); 76 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 77 | TString *source, int firstchar); 78 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 79 | LUAI_FUNC void luaX_next (LexState *ls); 80 | LUAI_FUNC int luaX_lookahead (LexState *ls); 81 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 82 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.91.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 49 | int limit, const char *what) { 50 | void *newblock; 51 | int newsize; 52 | if (*size >= limit/2) { /* cannot double it? */ 53 | if (*size >= limit) /* cannot grow even a little? */ 54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 55 | newsize = limit; /* still have at least one free place */ 56 | } 57 | else { 58 | newsize = (*size)*2; 59 | if (newsize < MINSIZEARRAY) 60 | newsize = MINSIZEARRAY; /* minimum size */ 61 | } 62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 63 | *size = newsize; /* update only when everything else is OK */ 64 | return newblock; 65 | } 66 | 67 | 68 | l_noret luaM_toobig (lua_State *L) { 69 | luaG_runerror(L, "memory allocation error: block too big"); 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | void *newblock; 79 | global_State *g = G(L); 80 | size_t realosize = (block) ? osize : 0; 81 | lua_assert((realosize == 0) == (block == NULL)); 82 | #if defined(HARDMEMTESTS) 83 | if (nsize > realosize && g->gcrunning) 84 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 85 | #endif 86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 87 | if (newblock == NULL && nsize > 0) { 88 | lua_assert(nsize > realosize); /* cannot fail when shrinking a block */ 89 | if (g->version) { /* is state fully built? */ 90 | luaC_fullgc(L, 1); /* try to free some memory... */ 91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 92 | } 93 | if (newblock == NULL) 94 | luaD_throw(L, LUA_ERRMEM); 95 | } 96 | lua_assert((nsize == 0) == (newblock == NULL)); 97 | g->GCdebt = (g->GCdebt + nsize) - realosize; 98 | return newblock; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.55.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Opcodes for Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lopcodes.h" 16 | 17 | 18 | /* ORDER OP */ 19 | 20 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { 21 | "MOVE", 22 | "LOADK", 23 | "LOADKX", 24 | "LOADBOOL", 25 | "LOADNIL", 26 | "GETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "SETTABUP", 30 | "SETUPVAL", 31 | "SETTABLE", 32 | "NEWTABLE", 33 | "SELF", 34 | "ADD", 35 | "SUB", 36 | "MUL", 37 | "MOD", 38 | "POW", 39 | "DIV", 40 | "IDIV", 41 | "BAND", 42 | "BOR", 43 | "BXOR", 44 | "SHL", 45 | "SHR", 46 | "UNM", 47 | "BNOT", 48 | "NOT", 49 | "LEN", 50 | "CONCAT", 51 | "JMP", 52 | "EQ", 53 | "LT", 54 | "LE", 55 | "TEST", 56 | "TESTSET", 57 | "CALL", 58 | "TAILCALL", 59 | "RETURN", 60 | "FORLOOP", 61 | "FORPREP", 62 | "TFORCALL", 63 | "TFORLOOP", 64 | "SETLIST", 65 | "CLOSURE", 66 | "VARARG", 67 | "EXTRAARG", 68 | NULL 69 | }; 70 | 71 | 72 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 73 | 74 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 75 | /* T A B C mode opcode */ 76 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 77 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 78 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ 79 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 80 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ 81 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 82 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ 83 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 84 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ 85 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 86 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 87 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 88 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 89 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 90 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 91 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 92 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 93 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 94 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 95 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ 96 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ 97 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ 98 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ 99 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ 100 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ 101 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 102 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ 103 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 104 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 105 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 106 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 107 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 108 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 109 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 110 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ 111 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 112 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 113 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 114 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 115 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 116 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 117 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ 118 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ 119 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 120 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 121 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 122 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ 123 | }; 124 | 125 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.23.1.2 2018/05/24 19:39:05 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* true when 't' is using 'dummynode' as its hash part */ 31 | #define isdummy(t) ((t)->lastfree == NULL) 32 | 33 | 34 | /* allocated size for hash nodes */ 35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 36 | 37 | 38 | /* returns the key, given the value of a table entry */ 39 | #define keyfromval(v) \ 40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 41 | 42 | 43 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 44 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 45 | TValue *value); 46 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 47 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 48 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 49 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 50 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 51 | LUAI_FUNC Table *luaH_new (lua_State *L); 52 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 53 | unsigned int nhsize); 54 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 55 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 56 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 57 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/ltests.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltests.h,v 2.50.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Internal Header for Debugging of the Lua Implementation 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltests_h 8 | #define ltests_h 9 | 10 | 11 | #include 12 | 13 | /* test Lua with no compatibility code */ 14 | #undef LUA_COMPAT_MATHLIB 15 | #undef LUA_COMPAT_IPAIRS 16 | #undef LUA_COMPAT_BITLIB 17 | #undef LUA_COMPAT_APIINTCASTS 18 | #undef LUA_COMPAT_FLOATSTRING 19 | #undef LUA_COMPAT_UNPACK 20 | #undef LUA_COMPAT_LOADERS 21 | #undef LUA_COMPAT_LOG10 22 | #undef LUA_COMPAT_LOADSTRING 23 | #undef LUA_COMPAT_MAXN 24 | #undef LUA_COMPAT_MODULE 25 | 26 | 27 | #define LUA_DEBUG 28 | 29 | 30 | /* turn on assertions */ 31 | #undef NDEBUG 32 | #include 33 | #define lua_assert(c) assert(c) 34 | 35 | 36 | /* to avoid warnings, and to make sure value is really unused */ 37 | #define UNUSED(x) (x=0, (void)(x)) 38 | 39 | 40 | /* test for sizes in 'l_sprintf' (make sure whole buffer is available) */ 41 | #undef l_sprintf 42 | #if !defined(LUA_USE_C89) 43 | #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), snprintf(s,sz,f,i)) 44 | #else 45 | #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), sprintf(s,f,i)) 46 | #endif 47 | 48 | 49 | /* memory-allocator control variables */ 50 | typedef struct Memcontrol { 51 | unsigned long numblocks; 52 | unsigned long total; 53 | unsigned long maxmem; 54 | unsigned long memlimit; 55 | unsigned long objcount[LUA_NUMTAGS]; 56 | } Memcontrol; 57 | 58 | LUA_API Memcontrol l_memcontrol; 59 | 60 | 61 | /* 62 | ** generic variable for debug tricks 63 | */ 64 | extern void *l_Trick; 65 | 66 | 67 | 68 | /* 69 | ** Function to traverse and check all memory used by Lua 70 | */ 71 | int lua_checkmemory (lua_State *L); 72 | 73 | 74 | /* test for lock/unlock */ 75 | 76 | struct L_EXTRA { int lock; int *plock; }; 77 | #undef LUA_EXTRASPACE 78 | #define LUA_EXTRASPACE sizeof(struct L_EXTRA) 79 | #define getlock(l) cast(struct L_EXTRA*, lua_getextraspace(l)) 80 | #define luai_userstateopen(l) \ 81 | (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) 82 | #define luai_userstateclose(l) \ 83 | lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock)) 84 | #define luai_userstatethread(l,l1) \ 85 | lua_assert(getlock(l1)->plock == getlock(l)->plock) 86 | #define luai_userstatefree(l,l1) \ 87 | lua_assert(getlock(l)->plock == getlock(l1)->plock) 88 | #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) 89 | #define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0) 90 | 91 | 92 | 93 | LUA_API int luaB_opentests (lua_State *L); 94 | 95 | LUA_API void *debug_realloc (void *ud, void *block, 96 | size_t osize, size_t nsize); 97 | 98 | #if defined(lua_c) 99 | #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol) 100 | #define luaL_openlibs(L) \ 101 | { (luaL_openlibs)(L); \ 102 | luaL_requiref(L, "T", luaB_opentests, 1); \ 103 | lua_pop(L, 1); } 104 | #endif 105 | 106 | 107 | 108 | /* change some sizes to give some bugs a chance */ 109 | 110 | #undef LUAL_BUFFERSIZE 111 | #define LUAL_BUFFERSIZE 23 112 | #define MINSTRTABSIZE 2 113 | #define MAXINDEXRK 1 114 | 115 | 116 | /* make stack-overflow tests run faster */ 117 | #undef LUAI_MAXSTACK 118 | #define LUAI_MAXSTACK 50000 119 | 120 | 121 | #undef LUAI_USER_ALIGNMENT_T 122 | #define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; } 123 | 124 | 125 | #define STRCACHE_N 23 126 | #define STRCACHE_M 5 127 | 128 | #endif 129 | 130 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.22.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | 55 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 56 | 57 | 58 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 59 | 60 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 61 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 62 | TMS event); 63 | LUAI_FUNC void luaT_init (lua_State *L); 64 | 65 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 66 | const TValue *p2, TValue *p3, int hasres); 67 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 68 | StkId res, TMS event); 69 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 70 | StkId res, TMS event); 71 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 72 | const TValue *p2, TMS event); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.41.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #if !defined(LUA_NOCVTN2S) 17 | #define cvt2str(o) ttisnumber(o) 18 | #else 19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */ 20 | #endif 21 | 22 | 23 | #if !defined(LUA_NOCVTS2N) 24 | #define cvt2num(o) ttisstring(o) 25 | #else 26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */ 27 | #endif 28 | 29 | 30 | /* 31 | ** You can define LUA_FLOORN2I if you want to convert floats to integers 32 | ** by flooring them (instead of raising an error if they are not 33 | ** integral values) 34 | */ 35 | #if !defined(LUA_FLOORN2I) 36 | #define LUA_FLOORN2I 0 37 | #endif 38 | 39 | 40 | #define tonumber(o,n) \ 41 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 42 | 43 | #define tointeger(o,i) \ 44 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) 45 | 46 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 47 | 48 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 49 | 50 | 51 | /* 52 | ** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, 53 | ** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, 54 | ** return 0 (meaning it will have to check metamethod) with 'slot' 55 | ** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). 56 | ** 'f' is the raw get function to use. 57 | */ 58 | #define luaV_fastget(L,t,k,slot,f) \ 59 | (!ttistable(t) \ 60 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ 61 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ 62 | !ttisnil(slot))) /* result not nil? */ 63 | 64 | /* 65 | ** standard implementation for 'gettable' 66 | */ 67 | #define luaV_gettable(L,t,k,v) { const TValue *slot; \ 68 | if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ 69 | else luaV_finishget(L,t,k,v,slot); } 70 | 71 | 72 | /* 73 | ** Fast track for set table. If 't' is a table and 't[k]' is not nil, 74 | ** call GC barrier, do a raw 't[k]=v', and return true; otherwise, 75 | ** return false with 'slot' equal to NULL (if 't' is not a table) or 76 | ** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro 77 | ** returns true, there is no need to 'invalidateTMcache', because the 78 | ** call is not creating a new entry. 79 | */ 80 | #define luaV_fastset(L,t,k,slot,f,v) \ 81 | (!ttistable(t) \ 82 | ? (slot = NULL, 0) \ 83 | : (slot = f(hvalue(t), k), \ 84 | ttisnil(slot) ? 0 \ 85 | : (luaC_barrierback(L, hvalue(t), v), \ 86 | setobj2t(L, cast(TValue *,slot), v), \ 87 | 1))) 88 | 89 | 90 | #define luaV_settable(L,t,k,v) { const TValue *slot; \ 91 | if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ 92 | luaV_finishset(L,t,k,v,slot); } 93 | 94 | 95 | 96 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 97 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 98 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 99 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 100 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); 101 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, 102 | StkId val, const TValue *slot); 103 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 104 | StkId val, const TValue *slot); 105 | LUAI_FUNC void luaV_finishOp (lua_State *L); 106 | LUAI_FUNC void luaV_execute (lua_State *L); 107 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 108 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); 109 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 110 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 111 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/big.lua: -------------------------------------------------------------------------------- 1 | -- $Id: big.lua,v 1.32 2016/11/07 13:11:28 roberto Exp $ 2 | -- See Copyright Notice in file all.lua 3 | 4 | if _soft then 5 | return 'a' 6 | end 7 | 8 | print "testing large tables" 9 | 10 | local debug = require"debug" 11 | 12 | local lim = 2^18 + 1000 13 | local prog = { "local y = {0" } 14 | for i = 1, lim do prog[#prog + 1] = i end 15 | prog[#prog + 1] = "}\n" 16 | prog[#prog + 1] = "X = y\n" 17 | prog[#prog + 1] = ("assert(X[%d] == %d)"):format(lim - 1, lim - 2) 18 | prog[#prog + 1] = "return 0" 19 | prog = table.concat(prog, ";") 20 | 21 | local env = {string = string, assert = assert} 22 | local f = assert(load(prog, nil, nil, env)) 23 | 24 | f() 25 | assert(env.X[lim] == lim - 1 and env.X[lim + 1] == lim) 26 | for k in pairs(env) do env[k] = nil end 27 | 28 | -- yields during accesses larger than K (in RK) 29 | setmetatable(env, { 30 | __index = function (t, n) coroutine.yield('g'); return _G[n] end, 31 | __newindex = function (t, n, v) coroutine.yield('s'); _G[n] = v end, 32 | }) 33 | 34 | X = nil 35 | co = coroutine.wrap(f) 36 | assert(co() == 's') 37 | assert(co() == 'g') 38 | assert(co() == 'g') 39 | assert(co() == 0) 40 | 41 | assert(X[lim] == lim - 1 and X[lim + 1] == lim) 42 | 43 | -- errors in accesses larger than K (in RK) 44 | getmetatable(env).__index = function () end 45 | getmetatable(env).__newindex = function () end 46 | local e, m = pcall(f) 47 | assert(not e and m:find("global 'X'")) 48 | 49 | -- errors in metamethods 50 | getmetatable(env).__newindex = function () error("hi") end 51 | local e, m = xpcall(f, debug.traceback) 52 | assert(not e and m:find("'__newindex'")) 53 | 54 | f, X = nil 55 | 56 | coroutine.yield'b' 57 | 58 | if 2^32 == 0 then -- (small integers) { 59 | 60 | print "testing string length overflow" 61 | 62 | local repstrings = 192 -- number of strings to be concatenated 63 | local ssize = math.ceil(2.0^32 / repstrings) + 1 -- size of each string 64 | 65 | assert(repstrings * ssize > 2.0^32) -- it should be larger than maximum size 66 | 67 | local longs = string.rep("\0", ssize) -- create one long string 68 | 69 | -- create function to concatentate 'repstrings' copies of its argument 70 | local rep = assert(load( 71 | "local a = ...; return " .. string.rep("a", repstrings, ".."))) 72 | 73 | local a, b = pcall(rep, longs) -- call that function 74 | 75 | -- it should fail without creating string (result would be too large) 76 | assert(not a and string.find(b, "overflow")) 77 | 78 | end -- } 79 | 80 | print'OK' 81 | 82 | return 'a' 83 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/bwcoercion.lua: -------------------------------------------------------------------------------- 1 | local tonumber, tointeger = tonumber, math.tointeger 2 | local type, getmetatable, rawget, error = type, getmetatable, rawget, error 3 | local strsub = string.sub 4 | 5 | local print = print 6 | 7 | _ENV = nil 8 | 9 | -- Try to convert a value to an integer, without assuming any coercion. 10 | local function toint (x) 11 | x = tonumber(x) -- handle numerical strings 12 | if not x then 13 | return false -- not coercible to a number 14 | end 15 | return tointeger(x) 16 | end 17 | 18 | 19 | -- If operation fails, maybe second operand has a metamethod that should 20 | -- have been called if not for this string metamethod, so try to 21 | -- call it. 22 | local function trymt (x, y, mtname) 23 | if type(y) ~= "string" then -- avoid recalling original metamethod 24 | local mt = getmetatable(y) 25 | local mm = mt and rawget(mt, mtname) 26 | if mm then 27 | return mm(x, y) 28 | end 29 | end 30 | -- if any test fails, there is no other metamethod to be called 31 | error("attempt to '" .. strsub(mtname, 3) .. 32 | "' a " .. type(x) .. " with a " .. type(y), 4) 33 | end 34 | 35 | 36 | local function checkargs (x, y, mtname) 37 | local xi = toint(x) 38 | local yi = toint(y) 39 | if xi and yi then 40 | return xi, yi 41 | else 42 | return trymt(x, y, mtname), nil 43 | end 44 | end 45 | 46 | 47 | local smt = getmetatable("") 48 | 49 | smt.__band = function (x, y) 50 | local x, y = checkargs(x, y, "__band") 51 | return y and x & y or x 52 | end 53 | 54 | smt.__bor = function (x, y) 55 | local x, y = checkargs(x, y, "__bor") 56 | return y and x | y or x 57 | end 58 | 59 | smt.__bxor = function (x, y) 60 | local x, y = checkargs(x, y, "__bxor") 61 | return y and x ~ y or x 62 | end 63 | 64 | smt.__shl = function (x, y) 65 | local x, y = checkargs(x, y, "__shl") 66 | return y and x << y or x 67 | end 68 | 69 | smt.__shr = function (x, y) 70 | local x, y = checkargs(x, y, "__shr") 71 | return y and x >> y or x 72 | end 73 | 74 | smt.__bnot = function (x) 75 | local x, y = checkargs(x, x, "__bnot") 76 | return y and ~x or x 77 | end 78 | 79 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/db.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Quartz/ThirdParty/lua/testes/db.lua -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/files.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Quartz/ThirdParty/lua/testes/files.lua -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/heavy.lua: -------------------------------------------------------------------------------- 1 | -- $Id: heavy.lua,v 1.4 2016/11/07 13:11:28 roberto Exp $ 2 | -- See Copyright Notice in file all.lua 3 | 4 | print("creating a string too long") 5 | do 6 | local st, msg = pcall(function () 7 | local a = "x" 8 | while true do 9 | a = a .. a.. a.. a.. a.. a.. a.. a.. a.. a 10 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 11 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 12 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 13 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 14 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 15 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 16 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 17 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 18 | .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a 19 | print(string.format("string with %d bytes", #a)) 20 | end 21 | end) 22 | assert(not st and 23 | (string.find(msg, "string length overflow") or 24 | string.find(msg, "not enough memory"))) 25 | end 26 | print('+') 27 | 28 | 29 | local function loadrep (x, what) 30 | local p = 1<<20 31 | local s = string.rep(x, p) 32 | local count = 0 33 | local function f() 34 | count = count + p 35 | if count % (0x80*p) == 0 then 36 | io.stderr:write("(", string.format("0x%x", count), ")") 37 | end 38 | return s 39 | end 40 | local st, msg = load(f, "=big") 41 | print(string.format("\ntotal: 0x%x %s", count, what)) 42 | return st, msg 43 | end 44 | 45 | 46 | print("loading chunk with too many lines") 47 | do 48 | local st, msg = loadrep("\n", "lines") 49 | assert(not st and string.find(msg, "too many lines")) 50 | end 51 | print('+') 52 | 53 | 54 | print("loading chunk with huge identifier") 55 | do 56 | local st, msg = loadrep("a", "chars") 57 | assert(not st and 58 | (string.find(msg, "lexical element too long") or 59 | string.find(msg, "not enough memory"))) 60 | end 61 | print('+') 62 | 63 | 64 | print("loading chunk with too many instructions") 65 | do 66 | local st, msg = loadrep("a = 10; ", "instructions") 67 | print(st, msg) 68 | end 69 | print('+') 70 | 71 | 72 | print "OK" 73 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/libs/lib1.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | #include "lauxlib.h" 3 | 4 | static int id (lua_State *L) { 5 | return lua_gettop(L); 6 | } 7 | 8 | 9 | static const struct luaL_Reg funcs[] = { 10 | {"id", id}, 11 | {NULL, NULL} 12 | }; 13 | 14 | 15 | /* function used by lib11.c */ 16 | LUAMOD_API int lib1_export (lua_State *L) { 17 | lua_pushstring(L, "exported"); 18 | return 1; 19 | } 20 | 21 | 22 | LUAMOD_API int onefunction (lua_State *L) { 23 | luaL_checkversion(L); 24 | lua_settop(L, 2); 25 | lua_pushvalue(L, 1); 26 | return 2; 27 | } 28 | 29 | 30 | LUAMOD_API int anotherfunc (lua_State *L) { 31 | luaL_checkversion(L); 32 | lua_pushfstring(L, "%d%%%d\n", (int)lua_tointeger(L, 1), 33 | (int)lua_tointeger(L, 2)); 34 | return 1; 35 | } 36 | 37 | 38 | LUAMOD_API int luaopen_lib1_sub (lua_State *L) { 39 | lua_setglobal(L, "y"); /* 2nd arg: extra value (file name) */ 40 | lua_setglobal(L, "x"); /* 1st arg: module name */ 41 | luaL_newlib(L, funcs); 42 | return 1; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/libs/lib11.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | 3 | /* function from lib1.c */ 4 | int lib1_export (lua_State *L); 5 | 6 | LUAMOD_API int luaopen_lib11 (lua_State *L) { 7 | return lib1_export(L); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/libs/lib2.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | #include "lauxlib.h" 3 | 4 | static int id (lua_State *L) { 5 | return lua_gettop(L); 6 | } 7 | 8 | 9 | static const struct luaL_Reg funcs[] = { 10 | {"id", id}, 11 | {NULL, NULL} 12 | }; 13 | 14 | 15 | LUAMOD_API int luaopen_lib2 (lua_State *L) { 16 | lua_settop(L, 2); 17 | lua_setglobal(L, "y"); /* y gets 2nd parameter */ 18 | lua_setglobal(L, "x"); /* x gets 1st parameter */ 19 | luaL_newlib(L, funcs); 20 | return 1; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/libs/lib21.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | 3 | 4 | int luaopen_lib2 (lua_State *L); 5 | 6 | LUAMOD_API int luaopen_lib21 (lua_State *L) { 7 | return luaopen_lib2(L); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/libs/makefile: -------------------------------------------------------------------------------- 1 | # change this variable to point to the directory with Lua headers 2 | # of the version being tested 3 | LUA_DIR = ../../ 4 | 5 | CC = gcc 6 | 7 | # compilation should generate Dynamic-Link Libraries 8 | CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared 9 | 10 | # libraries used by the tests 11 | all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so 12 | 13 | lib1.so: lib1.c 14 | $(CC) $(CFLAGS) -o lib1.so lib1.c 15 | 16 | lib11.so: lib11.c 17 | $(CC) $(CFLAGS) -o lib11.so lib11.c 18 | 19 | lib2.so: lib2.c 20 | $(CC) $(CFLAGS) -o lib2.so lib2.c 21 | 22 | lib21.so: lib21.c 23 | $(CC) $(CFLAGS) -o lib21.so lib21.c 24 | 25 | lib2-v2.so: lib2.so 26 | mv lib2.so ./lib2-v2.so 27 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/locals.lua: -------------------------------------------------------------------------------- 1 | -- $Id: locals.lua,v 1.37 2016/11/07 13:11:28 roberto Exp $ 2 | -- See Copyright Notice in file all.lua 3 | 4 | print('testing local variables and environments') 5 | 6 | local debug = require"debug" 7 | 8 | 9 | -- bug in 5.1: 10 | 11 | local function f(x) x = nil; return x end 12 | assert(f(10) == nil) 13 | 14 | local function f() local x; return x end 15 | assert(f(10) == nil) 16 | 17 | local function f(x) x = nil; local y; return x, y end 18 | assert(f(10) == nil and select(2, f(20)) == nil) 19 | 20 | do 21 | local i = 10 22 | do local i = 100; assert(i==100) end 23 | do local i = 1000; assert(i==1000) end 24 | assert(i == 10) 25 | if i ~= 10 then 26 | local i = 20 27 | else 28 | local i = 30 29 | assert(i == 30) 30 | end 31 | end 32 | 33 | 34 | 35 | f = nil 36 | 37 | local f 38 | x = 1 39 | 40 | a = nil 41 | load('local a = {}')() 42 | assert(a == nil) 43 | 44 | function f (a) 45 | local _1, _2, _3, _4, _5 46 | local _6, _7, _8, _9, _10 47 | local x = 3 48 | local b = a 49 | local c,d = a,b 50 | if (d == b) then 51 | local x = 'q' 52 | x = b 53 | assert(x == 2) 54 | else 55 | assert(nil) 56 | end 57 | assert(x == 3) 58 | local f = 10 59 | end 60 | 61 | local b=10 62 | local a; repeat local b; a,b=1,2; assert(a+1==b); until a+b==3 63 | 64 | 65 | assert(x == 1) 66 | 67 | f(2) 68 | assert(type(f) == 'function') 69 | 70 | 71 | local function getenv (f) 72 | local a,b = debug.getupvalue(f, 1) 73 | assert(a == '_ENV') 74 | return b 75 | end 76 | 77 | -- test for global table of loaded chunks 78 | assert(getenv(load"a=3") == _G) 79 | local c = {}; local f = load("a = 3", nil, nil, c) 80 | assert(getenv(f) == c) 81 | assert(c.a == nil) 82 | f() 83 | assert(c.a == 3) 84 | 85 | -- old test for limits for special instructions (now just a generic test) 86 | do 87 | local i = 2 88 | local p = 4 -- p == 2^i 89 | repeat 90 | for j=-3,3 do 91 | assert(load(string.format([[local a=%s; 92 | a=a+%s; 93 | assert(a ==2^%s)]], j, p-j, i), '')) () 94 | assert(load(string.format([[local a=%s; 95 | a=a-%s; 96 | assert(a==-2^%s)]], -j, p-j, i), '')) () 97 | assert(load(string.format([[local a,b=0,%s; 98 | a=b-%s; 99 | assert(a==-2^%s)]], -j, p-j, i), '')) () 100 | end 101 | p = 2 * p; i = i + 1 102 | until p <= 0 103 | end 104 | 105 | print'+' 106 | 107 | 108 | if rawget(_G, "querytab") then 109 | -- testing clearing of dead elements from tables 110 | collectgarbage("stop") -- stop GC 111 | local a = {[{}] = 4, [3] = 0, alo = 1, 112 | a1234567890123456789012345678901234567890 = 10} 113 | 114 | local t = querytab(a) 115 | 116 | for k,_ in pairs(a) do a[k] = nil end 117 | collectgarbage() -- restore GC and collect dead fiels in `a' 118 | for i=0,t-1 do 119 | local k = querytab(a, i) 120 | assert(k == nil or type(k) == 'number' or k == 'alo') 121 | end 122 | end 123 | 124 | 125 | -- testing lexical environments 126 | 127 | assert(_ENV == _G) 128 | 129 | do 130 | local dummy 131 | local _ENV = (function (...) return ... end)(_G, dummy) -- { 132 | 133 | do local _ENV = {assert=assert}; assert(true) end 134 | mt = {_G = _G} 135 | local foo,x 136 | A = false -- "declare" A 137 | do local _ENV = mt 138 | function foo (x) 139 | A = x 140 | do local _ENV = _G; A = 1000 end 141 | return function (x) return A .. x end 142 | end 143 | end 144 | assert(getenv(foo) == mt) 145 | x = foo('hi'); assert(mt.A == 'hi' and A == 1000) 146 | assert(x('*') == mt.A .. '*') 147 | 148 | do local _ENV = {assert=assert, A=10}; 149 | do local _ENV = {assert=assert, A=20}; 150 | assert(A==20);x=A 151 | end 152 | assert(A==10 and x==20) 153 | end 154 | assert(x==20) 155 | 156 | 157 | print('OK') 158 | 159 | return 5,f 160 | 161 | end -- } 162 | 163 | -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/pm.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Quartz/ThirdParty/lua/testes/pm.lua -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/sort.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Quartz/ThirdParty/lua/testes/sort.lua -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/strings.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/Quartz/ThirdParty/lua/testes/strings.lua -------------------------------------------------------------------------------- /Quartz/ThirdParty/lua/testes/vararg.lua: -------------------------------------------------------------------------------- 1 | -- $Id: vararg.lua,v 1.25 2016/11/07 13:11:28 roberto Exp $ 2 | -- See Copyright Notice in file all.lua 3 | 4 | print('testing vararg') 5 | 6 | function f(a, ...) 7 | local arg = {n = select('#', ...), ...} 8 | for i=1,arg.n do assert(a[i]==arg[i]) end 9 | return arg.n 10 | end 11 | 12 | function c12 (...) 13 | assert(arg == _G.arg) -- no local 'arg' 14 | local x = {...}; x.n = #x 15 | local res = (x.n==2 and x[1] == 1 and x[2] == 2) 16 | if res then res = 55 end 17 | return res, 2 18 | end 19 | 20 | function vararg (...) return {n = select('#', ...), ...} end 21 | 22 | local call = function (f, args) return f(table.unpack(args, 1, args.n)) end 23 | 24 | assert(f() == 0) 25 | assert(f({1,2,3}, 1, 2, 3) == 3) 26 | assert(f({"alo", nil, 45, f, nil}, "alo", nil, 45, f, nil) == 5) 27 | 28 | assert(c12(1,2)==55) 29 | a,b = assert(call(c12, {1,2})) 30 | assert(a == 55 and b == 2) 31 | a = call(c12, {1,2;n=2}) 32 | assert(a == 55 and b == 2) 33 | a = call(c12, {1,2;n=1}) 34 | assert(not a) 35 | assert(c12(1,2,3) == false) 36 | local a = vararg(call(next, {_G,nil;n=2})) 37 | local b,c = next(_G) 38 | assert(a[1] == b and a[2] == c and a.n == 2) 39 | a = vararg(call(call, {c12, {1,2}})) 40 | assert(a.n == 2 and a[1] == 55 and a[2] == 2) 41 | a = call(print, {'+'}) 42 | assert(a == nil) 43 | 44 | local t = {1, 10} 45 | function t:f (...) local arg = {...}; return self[...]+#arg end 46 | assert(t:f(1,4) == 3 and t:f(2) == 11) 47 | print('+') 48 | 49 | lim = 20 50 | local i, a = 1, {} 51 | while i <= lim do a[i] = i+0.3; i=i+1 end 52 | 53 | function f(a, b, c, d, ...) 54 | local more = {...} 55 | assert(a == 1.3 and more[1] == 5.3 and 56 | more[lim-4] == lim+0.3 and not more[lim-3]) 57 | end 58 | 59 | function g(a,b,c) 60 | assert(a == 1.3 and b == 2.3 and c == 3.3) 61 | end 62 | 63 | call(f, a) 64 | call(g, a) 65 | 66 | a = {} 67 | i = 1 68 | while i <= lim do a[i] = i; i=i+1 end 69 | assert(call(math.max, a) == lim) 70 | 71 | print("+") 72 | 73 | 74 | -- new-style varargs 75 | 76 | function oneless (a, ...) return ... end 77 | 78 | function f (n, a, ...) 79 | local b 80 | assert(arg == _G.arg) -- no local 'arg' 81 | if n == 0 then 82 | local b, c, d = ... 83 | return a, b, c, d, oneless(oneless(oneless(...))) 84 | else 85 | n, b, a = n-1, ..., a 86 | assert(b == ...) 87 | return f(n, a, ...) 88 | end 89 | end 90 | 91 | a,b,c,d,e = assert(f(10,5,4,3,2,1)) 92 | assert(a==5 and b==4 and c==3 and d==2 and e==1) 93 | 94 | a,b,c,d,e = f(4) 95 | assert(a==nil and b==nil and c==nil and d==nil and e==nil) 96 | 97 | 98 | -- varargs for main chunks 99 | f = load[[ return {...} ]] 100 | x = f(2,3) 101 | assert(x[1] == 2 and x[2] == 3 and x[3] == nil) 102 | 103 | 104 | f = load[[ 105 | local x = {...} 106 | for i=1,select('#', ...) do assert(x[i] == select(i, ...)) end 107 | assert(x[select('#', ...)+1] == nil) 108 | return true 109 | ]] 110 | 111 | assert(f("a", "b", nil, {}, assert)) 112 | assert(f()) 113 | 114 | a = {select(3, table.unpack{10,20,30,40})} 115 | assert(#a == 2 and a[1] == 30 and a[2] == 40) 116 | a = {select(1)} 117 | assert(next(a) == nil) 118 | a = {select(-1, 3, 5, 7)} 119 | assert(a[1] == 7 and a[2] == nil) 120 | a = {select(-2, 3, 5, 7)} 121 | assert(a[1] == 5 and a[2] == 7 and a[3] == nil) 122 | pcall(select, 10000) 123 | pcall(select, -10000) 124 | 125 | 126 | -- bug in 5.2.2 127 | 128 | function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, 129 | p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, 130 | p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, 131 | p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, 132 | p41, p42, p43, p44, p45, p46, p48, p49, p50, ...) 133 | local a1,a2,a3,a4,a5,a6,a7 134 | local a8,a9,a10,a11,a12,a13,a14 135 | end 136 | 137 | -- assertion fail here 138 | f() 139 | 140 | 141 | print('OK') 142 | 143 | -------------------------------------------------------------------------------- /Quartz/Tools/CMake/CMakePCH.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 Vyom Fadia 2 | # 3 | # Permission is hereby granted, free of charge, to any person 4 | # obtaining a copy of this software and associated documentation files 5 | # (the 'Software') deal in the Software without restriction, 6 | # including without limitation the rights to use, copy, modify, merge, 7 | # publish, distribute, sublicense, and/or sell copies of the Software, 8 | # and to permit persons to whom the Software is furnished to do so, 9 | # subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # Usage: 24 | # add_library/executable(targetName sources/headers precompiled.hpp precompiled.cpp) 25 | # add_precompiled_header(targetName precompiled.hpp precompiled.cpp) 26 | # 27 | # - targetName can be whatever you want it to be. 28 | # 29 | # - "precompiled.hpp" and "precompiled.cpp" can be named whatever you want as well although 30 | # usually they are named the same thing, for example, the pair are called "stdafx.hpp/cpp" 31 | # in normal Visual Studio projects. 32 | # 33 | # THE PATHS MUST BE IN **FULL** (unless in the same directory as the cmake file). The use 34 | # of ${CMAKE_CURRENT_LIST_DIR} is recommended. 35 | 36 | macro(add_precompiled_header target pchHeader pchSource) 37 | if (MSVC) 38 | # /Yu is the header to USE. 39 | # /Yc is the source file used to CREATE the precompiled header. 40 | # /FI The name of the Forced Include file. This file will be included in EVERY source file. 41 | set_source_files_properties(${pchSource} PROPERTIES COMPILE_FLAGS "/Yc\"${pchHeader}\"") 42 | set_target_properties(${target} PROPERTIES COMPILE_FLAGS "/Yu\"${pchHeader}\" /FI\"${pchHeader}\"") 43 | endif() 44 | endmacro() 45 | -------------------------------------------------------------------------------- /Quartz/Tools/licenseText.txt: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 4 | // following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7 | // following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 10 | // following disclaimer in the documentation and/or other materials provided with the distribution. 11 | // 12 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote 13 | // products derived from this software without specific prior written permission. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 18 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 21 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 22 | // DAMAGE. 23 | 24 | -------------------------------------------------------------------------------- /Quartz/Tools/licensor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019 Vyom Fadia 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | import os 22 | import sys 23 | from argparse import ArgumentParser 24 | 25 | utfPrefix = chr(0xef) + chr(0xbb) + chr(0xbf) 26 | 27 | def recurseAndUpdate(dir, oldCopyright, copyright, excludeDirList): 28 | filenames = os.listdir(dir) 29 | for filename in filenames: 30 | fullFilename = os.path.realpath(os.path.join(dir, filename)) 31 | if (os.path.dirname(fullFilename) in excludeDirList): 32 | continue 33 | 34 | if (os.path.isdir(fullFilename)): 35 | recurseAndUpdate(fullFilename, oldCopyright, copyright, excludeDirList) 36 | else: 37 | if fullFilename.endswith(".cpp") or fullFilename.endswith(".hpp"): 38 | fileData = open(fullFilename, "r+").read() 39 | 40 | isUTF = False 41 | if fileData.startswith(utfPrefix): 42 | isUTF = True 43 | fileData = fileData[3:] 44 | 45 | if oldCopyright != None: 46 | if fileData.startswith(oldCopyright): 47 | fileData = fileData[len(oldCopyright):] + "\n" 48 | 49 | if not (fileData.startswith(copyright)): 50 | print("Updating " + filename) 51 | fileData = copyright + fileData 52 | 53 | if (isUTF): 54 | open(fullFilename, "w").write(utfPrefix + fileData) 55 | else: 56 | open(fullFilename, "w").write(fileData) 57 | 58 | if __name__ == '__main__': 59 | parser = ArgumentParser() 60 | parser.add_argument("-c", "--copyright-file", dest="copyright", help="The file to read the copyright from.", required = True) 61 | parser.add_argument("-o", "--old-copyright-file", dest="oldCopyright", help="The file to read the OLD copyright from.", required = False) 62 | parser.add_argument('-e','--exclude-list', nargs='*', dest="excludes", help='Set the list of directories to exclude', required = False) 63 | 64 | args = parser.parse_args() 65 | 66 | if not args.copyright: 67 | parser.error('A Copyright file is REQUIRED. Use -c or --copyright-file to get information about it. Use the -h or --help CLI parameters for more help.') 68 | 69 | try: oldCopyright = open(args.oldCopyright, "r").read() 70 | except: 71 | print("[WARNING] An old copyright file was not provided, continuing with an empty value for the old copyright.") 72 | oldCopyright = "" 73 | 74 | try: newCopyright = open(args.copyright, "r").read() 75 | except FileNotFoundError: 76 | print("[ERROR] The filename you provided for the NEW copyright to insert is incorrect, please amend the value and rerun the command.") 77 | exit() 78 | 79 | excludes = [] 80 | if args.excludes != None: 81 | for exclude in args.excludes: 82 | excludes.append(os.path.realpath(exclude)) 83 | 84 | recurseAndUpdate(os.path.dirname(os.path.abspath(__file__)) + "/../", oldCopyright, newCopyright, excludes) 85 | # QUARTZ EDIT 86 | -------------------------------------------------------------------------------- /QuartzSandbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(QuartzSandbox) 4 | 5 | add_subdirectory(Include) 6 | add_subdirectory(Source) 7 | add_subdirectory(assets) 8 | 9 | add_executable(${PROJECT_NAME} ${sandboxSources} ${sandboxHeaders}) 10 | target_link_libraries(${PROJECT_NAME} PRIVATE QuartzEngine) 11 | 12 | set(dependencies ${CMAKE_CURRENT_LIST_DIR}/../Quartz/ThirdParty) 13 | target_include_directories(${PROJECT_NAME} PRIVATE 14 | ${dependencies}/SDL2/include 15 | ${dependencies}/../Quartz/Engine/Include 16 | ${dependencies}/imgui/include 17 | ${dependencies}/luajit/include 18 | ${dependencies}/sol2/include) 19 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Include) 20 | 21 | add_dependencies(${PROJECT_NAME} QuartzSandboxAssets) 22 | -------------------------------------------------------------------------------- /QuartzSandbox/Include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Sandbox) 2 | 3 | set(sandboxHeaders 4 | ${coreSandboxHeaders} 5 | 6 | PARENT_SCOPE 7 | ) -------------------------------------------------------------------------------- /QuartzSandbox/Include/Sandbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(coreSandboxHeaders 3 | ${currentDir}/Sandbox.hpp 4 | ${currentDir}/DebugOverlay.hpp 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /QuartzSandbox/Include/Sandbox/DebugOverlay.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace sandbox 34 | { 35 | class DebugOverlay 36 | { 37 | private: 38 | public: 39 | void show(); 40 | }; 41 | } // namespace sandbox 42 | -------------------------------------------------------------------------------- /QuartzSandbox/Include/Sandbox/Sandbox.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | #include 34 | 35 | namespace sandbox 36 | { 37 | class Sandbox 38 | { 39 | public: 40 | Sandbox(); 41 | ~Sandbox(); 42 | 43 | void run(); 44 | }; 45 | } // namespace sandbox 46 | -------------------------------------------------------------------------------- /QuartzSandbox/Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(currentDir ${CMAKE_CURRENT_LIST_DIR}) 2 | set(sandboxSources 3 | ${currentDir}/Sandbox.cpp 4 | ${currentDir}/DebugOverlay.cpp 5 | 6 | PARENT_SCOPE 7 | ) 8 | -------------------------------------------------------------------------------- /QuartzSandbox/Source/DebugOverlay.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Genten Studios 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | using namespace sandbox; 32 | 33 | void DebugOverlay::show() {} 34 | -------------------------------------------------------------------------------- /QuartzSandbox/Source/Sandbox.cpp: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | using namespace sandbox; 35 | using namespace qz; 36 | 37 | Sandbox::Sandbox() 38 | { 39 | utils::Logger::instance()->initialise("Sandbox.log", 40 | utils::LogVerbosity::DEBUG); 41 | } 42 | 43 | Sandbox::~Sandbox() {} 44 | 45 | void Sandbox::run() 46 | { 47 | std::cout << "Yo waddup" << std::endl; 48 | LINFO("YO WADDUP!"); 49 | } 50 | 51 | #undef main 52 | int main(int argc, char** argv) 53 | { 54 | Sandbox sandbox; 55 | sandbox.run(); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /QuartzSandbox/assets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(QuartzSandboxAssets) 4 | 5 | set(assetsPath ${CMAKE_CURRENT_SOURCE_DIR}) 6 | 7 | file(GLOB shaders ${assetsPath}/shaders/*.vert ${assetsPath}/shaders/*.frag ${assetsPath}/shaders/*.shader) 8 | file(GLOB scripts ${assetsPath}/scripts/*.lua) 9 | file(GLOB textures ${assetsPath}/textures/*.png) 10 | 11 | source_group("Shaders" FILES ${shaders}) 12 | source_group("Scripts" FILES ${scripts}) 13 | source_group("Textures" FILES ${textures}) 14 | 15 | add_custom_target(${PROJECT_NAME} 16 | COMMAND ${CMAKE_COMMAND} -E copy_directory 17 | ${assetsPath} ${CMAKE_CURRENT_BINARY_DIR} 18 | SOURCES ${shaders} ${scripts} ${textures} 19 | ) 20 | -------------------------------------------------------------------------------- /QuartzSandbox/assets/example_configs/Client.ini: -------------------------------------------------------------------------------- 1 | ; NOTICE TO USERS: Copy this file to the same directory as the executable and then customise to your hearts extent! 2 | 3 | ; NOTICE TO DEVELOPERS: This file doesn't actually get loaded (this meaning the file in assets/example_configs/*.ini) and is merely meant as a boilerplate starter file 4 | ; Copy it to the output directory (project dir if using VS, exe directory everywhere else) and then customise. This file is checked into version control, so please don't 5 | ; override it with your preferences. Customise the copied file instead. 6 | 7 | [ClientOptions] 8 | screenResolutionW = 1280 9 | screenResolutionH = 720 -------------------------------------------------------------------------------- /QuartzSandbox/assets/example_configs/Controls.ini: -------------------------------------------------------------------------------- 1 | ; NOTICE TO USERS: Copy this file to the same directory as the executable and then customise to your hearts extent! 2 | 3 | ; NOTICE TO DEVELOPERS: This file doesn't actually get loaded (this meaning the file in assets/example_configs/*.ini) and is merely meant as a boilerplate starter file 4 | ; Copy it to the output directory (project dir if using VS, exe directory everywhere else) and then customise. This file is checked into version control, so please don't 5 | ; override it with your preferences. Customise the copied file instead. 6 | 7 | ; See https://wiki.libsdl.org/SDL_Keycode and all possible key's are listed under the `Key Name` section 8 | [CameraKeyboard] 9 | moveForward=W 10 | moveBackwards=S 11 | strafeLeft=A 12 | strafeRight=D 13 | 14 | [CameraMisc] 15 | mouseSensitivity=0.00005 16 | moveSpeed=0.1 -------------------------------------------------------------------------------- /QuartzSandbox/assets/scripts/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /QuartzSandbox/assets/scripts/PerlinNoise.lua: -------------------------------------------------------------------------------- 1 | -- script to modify the way the perlin noise world generator works 2 | -- use loadModel(script located in assets/scripts to load a model used by the world gen stuff) 3 | 4 | models = {} -- needed for tFileIO::readAllFilehe perlin noise stuff 5 | 6 | function getSmoothingFactor(x, y, z) 7 | -- (x, y, z) is the chunk position 8 | return 128.0 9 | end -------------------------------------------------------------------------------- /QuartzSandbox/assets/scripts/index.lua: -------------------------------------------------------------------------------- 1 | px_register_block("core:grass", { 2 | displayname = "Grass", 3 | type = BLOCK_AIR, 4 | textures = { 5 | "assets/textures/grass_side.png", 6 | "assets/textures/grass_side.png", 7 | "assets/textures/grass_side.png", 8 | "assets/textures/grass_side.png", 9 | "assets/textures/dirt.png", 10 | "assets/textures/grass_top.png" 11 | } 12 | }) 13 | 14 | px_register_block("core:dirt", { 15 | displayname = "Dirt", 16 | type = BLOCK_SOLID, 17 | textures = { 18 | "assets/textures/dirt.png", 19 | "assets/textures/dirt.png", 20 | "assets/textures/dirt.png", 21 | "assets/textures/dirt.png", 22 | "assets/textures/dirt.png", 23 | "assets/textures/dirt.png" 24 | } 25 | }) -------------------------------------------------------------------------------- /QuartzSandbox/assets/shaders/basic.shader: -------------------------------------------------------------------------------- 1 | #shader vertex 2 | #version 330 core 3 | 4 | layout (location = 0) in vec3 a_pos; 5 | layout (location = 1) in vec2 a_uv; 6 | layout (location = 2) in vec3 a_color; 7 | 8 | out vec2 pass_uv; 9 | out vec3 pass_position; 10 | out vec3 pass_color; 11 | 12 | uniform mat4 u_view; 13 | uniform mat4 u_projection; 14 | 15 | void main() 16 | { 17 | gl_Position = u_projection * u_view * vec4(a_pos, 1.0); 18 | pass_uv = a_uv; 19 | pass_position = a_pos; 20 | pass_color = a_color; 21 | } 22 | 23 | #shader pixel 24 | #version 330 core 25 | 26 | out vec4 out_fragcolor; 27 | 28 | in vec2 pass_uv; 29 | in vec3 pass_position; 30 | in vec3 pass_color; 31 | 32 | uniform vec3 u_color; 33 | uniform sampler2D u_sampler; 34 | 35 | void main() 36 | { 37 | out_fragcolor = texture2D(u_sampler, pass_uv) * vec4(pass_color, 1.0f); 38 | } 39 | -------------------------------------------------------------------------------- /QuartzSandbox/assets/shaders/tests/test.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | out vec4 FragColor; 4 | 5 | in vec2 pass_uv; 6 | 7 | uniform vec3 u_color; 8 | uniform sampler2D u_sampler; 9 | 10 | void main() 11 | { 12 | FragColor = texture(u_sampler, pass_uv) * vec4(u_color, 1.0f); 13 | } 14 | -------------------------------------------------------------------------------- /QuartzSandbox/assets/shaders/tests/test.shader: -------------------------------------------------------------------------------- 1 | #shader pixel 2 | #include "test.frag" 3 | #shader vertex 4 | #include "test.vert" -------------------------------------------------------------------------------- /QuartzSandbox/assets/shaders/tests/test.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec3 a_pos; 4 | layout(location = 1) in vec2 a_uv; 5 | 6 | out vec2 pass_uv; 7 | 8 | void main() 9 | { 10 | gl_Position = vec4(a_pos, 1.0); 11 | pass_uv = a_uv; 12 | } 13 | -------------------------------------------------------------------------------- /QuartzSandbox/assets/textures/dirt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/QuartzSandbox/assets/textures/dirt.png -------------------------------------------------------------------------------- /QuartzSandbox/assets/textures/grass_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/QuartzSandbox/assets/textures/grass_side.png -------------------------------------------------------------------------------- /QuartzSandbox/assets/textures/grass_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GentenStudios/QuartzEngine/1289fc74f15218d791a9558964eaef90ca10c1cc/QuartzSandbox/assets/textures/grass_top.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://ci.appveyor.com/api/projects/status/ryoqb5xj56jq0e04?svg=true)](https://ci.appveyor.com/project/GentenStudios/QuartzEngine) [![Build Status](https://api.travis-ci.org/GentenStudios/QuartzEngine.svg?branch=develop)](https://travis-ci.org/GentenStudios/QuartzEngine) 2 | # QUARTZ ENGINE 3 | ## Introduction 4 | Quartz Engine is designed to aid the creation of games with a unique approach to adding content. Quartz will provide lightweight, generic game functionality through an API. The primary feature of Quartz is its scripting functionality, allowing engines to be built so game creators can create a game using only scripts while the heavy lifting is driven in C++. The engine may also provide other useful tools to help someone creating a game. 5 | 6 | This will be what our genre specific engines (voxel sandbox, first person shooter, adventure) will be built on. 7 | 8 | Our first project is coded [Project Phoenix](https://github.com/GentenStudios/quartz-engine/wiki/Project-Phoenix) and is centered around voxels. This is what we will use to test and improve Quartz with during its initial development. 9 | 10 | ## Community 11 | [Here's a link to our public discord server](https://discord.gg/XRttqAm), where we collaborate and discuss the development of the engine. 12 | 13 | ## Components 14 | These components make up the features of Quartz 15 | ### Lua Scripting 16 | Quartz will provide the ability to load and run lua scripts to add content to a game. This is the main feature of Quartz engine that makes it unique. By design, a launcher application will pass a client or server scripts to load that provide all game content, the C++/ game engine should never provide content on its own. 17 | ### Rendering 18 | Quartz will provide an API that engines can use to implement rendering. 19 | ### Networking 20 | The library will provide an API that engines can use to implement networking capabilities. This should handle authentication and sending protocols while the specific engine. 21 | ### Logging 22 | The engine will provide basic logging functionality. 23 | ### GUI 24 | Currently we will implement ImGUI but a in house solution may be a part of our future plans. 25 | 26 | ## Dependencies 27 | - CMake (Version >= 3.0) 28 | - A C++17 compatible compiler. The following have been tested 29 | - Visual Studio 2017 & 2019 (MSVC >= 19.14) 30 | - Clang (>= 5.0.0) 31 | - GCC (>= 4.8.4) 32 | - OpenGL (Version >= 3.3) 33 | 34 | ## Build Instructions 35 | Once cloned, navigate to the projects root directory and execute the following commands in a terminal. 36 | 37 | 1. `mkdir Build` 38 | 2. `cd Build` 39 | 3. `cmake ..` 40 | 4. `cmake --build . --target QuartzSandbox` 41 | 42 | Now follow the platform specific instructions detailed below. 43 | 44 | ### Visual Studio 45 | - Open the generated solution file in the `Build/` folder in Visual Studio 46 | - Set the Startup Project to `QuartzSandbox`. 47 | - At this point you should be able to run, since the project should have already been 48 | built in step 2. above. You can always build the traditional way with Visual Studio. 49 | - And voila, all done. Now you should be able to run the project! 50 | 51 | ### Linux, Mac OS X, MSYS 52 | 53 | - Navigate to the `Build/QuartzSandbox` folder and run `./QuartzSandbox` to run the executable. 54 | 55 | ## Coding Standards 56 | [Here's a link to our Coding Standards.](https://github.com/GentenStudios/Genten/wiki/Dev:-Home) 57 | You can also have a look at our [wiki](https://github.com/GentenStudios/quartz-engine/wiki) for more information.. 58 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | matrix: 3 | fast_finish: true 4 | 5 | build_script: 6 | - cmake -H. -Bbuild 7 | - cmake --build build 8 | --------------------------------------------------------------------------------