Compare commits
No commits in common. "main" and "feat/universal_pch" have entirely different histories.
main
...
feat/unive
303 changed files with 869 additions and 57636 deletions
|
@ -25,7 +25,6 @@ readability-avoid-const-params-in-decls,
|
|||
readability-avoid-nested-conditional-operator,
|
||||
readability-avoid-return-with-void-value,
|
||||
readability-avoid-unconditional-preprocessor-if,
|
||||
readability-braces-around-statements,
|
||||
readability-const-return-type,
|
||||
readability-container-contains,
|
||||
readability-container-data-pointdr,
|
||||
|
@ -129,6 +128,7 @@ cppcoreguidelines-pro-type-cstyle-cast,
|
|||
cppcoreguidelines-pro-type-member-init,
|
||||
cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
cppcoreguidelines-pro-type-union-access,
|
||||
cppcoreguidelines-pro-type-vararg,
|
||||
cppcoreguidelines-rvalue-reference-param-not-moved,
|
||||
cppcoreguidelines-slicing,
|
||||
|
@ -235,10 +235,12 @@ misc-new-delete-overloads,
|
|||
misc-misplaced-const,
|
||||
misc-misleading-identifier,
|
||||
misc-misleading-bidirectional,
|
||||
misc-include-cleaner,
|
||||
misc-header-include-cycle,
|
||||
misc-definitions-in-headers,
|
||||
misc-coroutine-hostile-raii,
|
||||
misc-const-correctness,
|
||||
misc-confusable-identifiers,
|
||||
|
||||
hicpp-signed-bitwise,
|
||||
hicpp-no-assembler,
|
||||
|
|
7
.cmake-format.yaml
Normal file
7
.cmake-format.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
dangle_parens: true
|
||||
line_ending: unix
|
||||
line_width: 120
|
||||
max_pargs_hwrap: 3
|
||||
separate_ctrl_name_with_space: true
|
||||
separate_fn_name_with_space: false
|
||||
tab_size: 4
|
143
.drone.yml
143
.drone.yml
|
@ -1,140 +1,13 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: amd64 — msvc
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
type: docker
|
||||
name: linux_amd64
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: unit tests
|
||||
shell: powershell
|
||||
commands:
|
||||
- ./tools/ci/amd64/msvc/unit_tests.ps1
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: amd64 — gcc
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
||||
steps:
|
||||
- name: unit tests
|
||||
image: amd64_gcc_unit_tests:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- ./tools/ci/amd64/gcc/unit_tests.sh
|
||||
|
||||
- name: valgrind
|
||||
image: amd64_gcc_valgrind:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- ./tools/ci/amd64/gcc/valgrind.sh
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: amd64 — clang
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
||||
steps:
|
||||
- name: code coverage
|
||||
image: amd64_clang_coverage:latest
|
||||
pull: if-not-exists
|
||||
environment:
|
||||
CODECOV_TOKEN:
|
||||
from_secret: CODECOV_TOKEN
|
||||
commands:
|
||||
- ./tools/ci/amd64/clang/coverage.sh
|
||||
|
||||
- name: leak sanitizer
|
||||
image: amd64_clang_lsan:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- ./tools/ci/amd64/clang/lsan.sh
|
||||
|
||||
- name: memory sanitizer
|
||||
image: amd64_clang_msan:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- ./tools/ci/amd64/clang/msan.sh
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: static analysis
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
||||
steps:
|
||||
- name: clang tidy
|
||||
image: clang_tidy:latest
|
||||
pull: if-not-exists
|
||||
privileged: true
|
||||
commands:
|
||||
- ./tools/ci/static_analysis/clang_tidy.sh
|
||||
|
||||
- name: clang format
|
||||
image: clang_format:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- ./tools/ci/static_analysis/clang_format.sh
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: documentation — development
|
||||
node:
|
||||
environment: ryali
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
||||
steps:
|
||||
- name: build and deploy
|
||||
image: documentation:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- pwd
|
||||
- cd docs
|
||||
- mkdir generated
|
||||
- touch generated/changelogs.rst
|
||||
- touch generated/api.rst
|
||||
- sphinx-build -M html . .
|
||||
|
||||
- rm -rf /light_docs_dev/*
|
||||
- mv ./html/* /light_docs_dev/
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: documentation — production
|
||||
node:
|
||||
environment: ryali
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
steps:
|
||||
- name: build and deploy
|
||||
image: documentation:latest
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- pwd
|
||||
- cd docs
|
||||
- mkdir generated
|
||||
- touch generated/changelogs.rst
|
||||
- touch generated/api.rst
|
||||
- sphinx-build -M html . .
|
||||
|
||||
- rm -rf /light_docs/*
|
||||
- mv ./html/* /light_docs/
|
||||
- name: clang format
|
||||
image: alpine_amd64__clang_format
|
||||
pull: if-not-exists
|
||||
commands: $(git rev-parse --show-toplevel)/tools/ci/alpine_amd64/script.sh
|
||||
|
|
88
.gitignore
vendored
88
.gitignore
vendored
|
@ -1,37 +1,65 @@
|
|||
# Temp directories
|
||||
.vs/
|
||||
bin/
|
||||
bin-obj/
|
||||
build/
|
||||
.cache/
|
||||
|
||||
# VS Files
|
||||
**.vcxproj**
|
||||
**.sln
|
||||
# ---> C++
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
.codelite/
|
||||
.build-debug/
|
||||
.vimspector.json
|
||||
**.workspace
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# ---> Rust
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# ---> CMake
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
|
||||
**/**.mk
|
||||
|
||||
**/**.project
|
||||
|
||||
**/Engine.txt
|
||||
**/GLAD.txt
|
||||
**/Sandbox.txt
|
||||
|
||||
**/Logs/**
|
||||
**/logs/**
|
||||
**.ini
|
||||
!**/default_gui_layout.ini
|
||||
|
||||
CMake/
|
||||
CMakeUserPresets.json
|
||||
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
|
||||
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
|
|
|
@ -1,43 +1,21 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(Light)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake)
|
||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||
project("light" LANGUAGES CXX)
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(${CMAKE_DIR}/functions.cmake)
|
||||
include(${CMAKE_DIR}/definitions.cmake)
|
||||
include(${CMAKE_DIR}/dependencies.cmake)
|
||||
include(tools/cmake/preliminary.cmake)
|
||||
include(tools/cmake/module_macros.cmake)
|
||||
|
||||
add_option(ENABLE_UNIT_TESTS "Enables the building of the unit test modules")
|
||||
add_option(ENABLE_FUZZ_TESTS "Enables the building of the fuzz test modules")
|
||||
set(CMAKE_CXX_STANDARD 26)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_option(ENABLE_STATIC_ANALYSIS "Makes clang-tidy checks mandatory for compilation")
|
||||
if (ENABLE_STATIC_ANALYSIS)
|
||||
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;--warnings-as-errors=*;--allow-no-checks")
|
||||
endif ()
|
||||
add_option(ENABLE_SANITIZERS "Enables fsan sanitizers")
|
||||
add_option(ENABLE_STATIC_ANALYSIS "Enables clang-tidy static analysis")
|
||||
|
||||
add_option(ENABLE_LLVM_COVERAGE "Enables the code coverage instrumentation for clang")
|
||||
if(ENABLE_LLVM_COVERAGE)
|
||||
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
message(FATAL_ERROR "ENABLE_LLVM_COVERAGE only supports the clang compiler")
|
||||
endif ()
|
||||
find_package(benchmark REQUIRED)
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
# Check for libc++
|
||||
check_cxx_source_compiles("
|
||||
#include <string>
|
||||
#ifdef _LIBCPP_VERSION
|
||||
int main() { return 0; }
|
||||
#else
|
||||
#error Not using libc++
|
||||
#endif
|
||||
" USING_LIBCXX)
|
||||
if(NOT USING_LIBCXX)
|
||||
message(FATAL_ERROR "ENABLE_LLVM_COVERAGE requires libc++, please compile with -stdlib=libc++")
|
||||
endif()
|
||||
if(ENABLE_STATIC_ANALYSIS)
|
||||
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED)
|
||||
endif()
|
||||
|
||||
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
add_link_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/modules)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/glad)
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(modules)
|
||||
|
|
9
CMakeUserPresets.json
Normal file
9
CMakeUserPresets.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/Debug/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
Discord: Light7734#4652.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
|
@ -1,14 +0,0 @@
|
|||
# How to contribute to Light Engine
|
||||
|
||||
Thanks for putting in the time to contribute to this project <3
|
||||
|
||||
## Coding conventions
|
||||
|
||||
For the time being, don't worry too much about the conventions...
|
||||
|
||||
Try to read other parts of the code and you'll get the hang of it
|
||||
|
||||
I have to learn clang-format, then everyone contributing can use it to format their code
|
||||
|
||||
|
||||
###### happy coding-
|
369
LICENSE
369
LICENSE
|
@ -1,201 +1,232 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
1. Definitions.
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
Preamble
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
0. Definitions.
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
light
|
||||
Copyright (C) 2024 light7734
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
light Copyright (C) 2024 light7734
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# Light
|
||||
See docs.light7734.com for a comprehensive project documentation
|
||||
# light
|
||||
|
||||
<!---FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUCK
|
||||
MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!!!!!!-->
|
||||
Monorepo for a cross-platform, cross-graphics-api, high-performance, modular, and modern game-engine.
|
||||
|
|
60
conanfile.py
60
conanfile.py
|
@ -2,63 +2,57 @@ from conan import ConanFile
|
|||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
|
||||
import shutil
|
||||
import os
|
||||
import git
|
||||
|
||||
class LightRecipe(ConanFile):
|
||||
name = "Light Engine"
|
||||
name = "light"
|
||||
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "CMakeDeps"
|
||||
|
||||
requires = [
|
||||
"benchmark/1.8.4",
|
||||
"gtest/1.14.0",
|
||||
]
|
||||
|
||||
tool_requires = [
|
||||
"cmake/3.30.0"
|
||||
]
|
||||
|
||||
options = {
|
||||
"enable_unit_tests": [True, False],
|
||||
"enable_fuzz_tests": [True, False],
|
||||
"enable_llvm_coverage": [True, False],
|
||||
"enable_static_analysis": [True, False],
|
||||
"use_mold": [True, False],
|
||||
"export_compile_commands": [True, False],
|
||||
"enable_sanitizers": [True, False],
|
||||
}
|
||||
|
||||
default_options = {
|
||||
"enable_unit_tests": True,
|
||||
"enable_fuzz_tests": False,
|
||||
"enable_llvm_coverage": False,
|
||||
"enable_static_analysis": False,
|
||||
"use_mold": False,
|
||||
"export_compile_commands": True,
|
||||
"enable_static_analysis": True,
|
||||
"enable_sanitizers": False,
|
||||
}
|
||||
|
||||
def requirements(self):
|
||||
self.requires("imgui/1.92.0-docking")
|
||||
self.requires("entt/3.15.0")
|
||||
self.requires("glfw/3.4")
|
||||
self.requires("stb/cci.20240531")
|
||||
self.requires("yaml-cpp/0.8.0")
|
||||
self.requires("lz4/1.10.0")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
|
||||
tc.variables["CMAKE_BUILD_TYPE"] = self.settings.build_type
|
||||
|
||||
if self.options.use_mold:
|
||||
tc.cache_variables["CMAKE_LINKER_TYPE"] = "MOLD"
|
||||
|
||||
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = self.options.export_compile_commands
|
||||
tc.cache_variables["ENABLE_UNIT_TESTS"] = self.options.enable_unit_tests
|
||||
tc.cache_variables["ENABLE_FUZZ_TESTS"] = self.options.enable_fuzz_tests
|
||||
tc.cache_variables["ENABLE_LLVM_COVERAGE"] = self.options.enable_llvm_coverage
|
||||
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
|
||||
tc.cache_variables["ENABLE_SANITIZERS"] = self.options.enable_sanitizers
|
||||
tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis
|
||||
|
||||
repo = git.Repo(search_parent_directories=True)
|
||||
tc.cache_variables["GIT_HASH"] = repo.head.object.hexsha
|
||||
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
self.copy_compile_commands()
|
||||
|
||||
def copy_compile_commands(self):
|
||||
build_folder = self.build_folder
|
||||
source_file = os.path.join(build_folder, "compile_commands.json")
|
||||
destination_file = os.path.join(self.source_folder, "compile_commands.json")
|
||||
|
||||
if os.path.isfile(source_file):
|
||||
shutil.copy(source_file, destination_file)
|
||||
self.output.info(f"Copied compile_commands.json to {destination_file}")
|
||||
else:
|
||||
self.output.warn("compile_commands.json not found!")
|
||||
|
|
Binary file not shown.
|
@ -1,202 +0,0 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,10 +0,0 @@
|
|||
#version 440 core
|
||||
|
||||
in vec4 vso_FragmentColor;
|
||||
|
||||
out vec4 fso_FragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fso_FragmentColor = vso_FragmentColor;
|
||||
}
|
Binary file not shown.
|
@ -1,17 +0,0 @@
|
|||
#version 440 core
|
||||
|
||||
layout(location = 0) in vec4 a_Position;
|
||||
layout(location = 1) in vec4 a_Color;
|
||||
|
||||
layout(std140, binding = 0) uniform ub_ViewProjection
|
||||
{
|
||||
mat4 viewProjection;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 vso_FragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = viewProjection * a_Position;
|
||||
vso_FragmentColor = a_Color;
|
||||
}
|
Binary file not shown.
|
@ -1,12 +0,0 @@
|
|||
#version 450 core
|
||||
|
||||
in vec2 vso_TexCoord;
|
||||
|
||||
uniform sampler2D u_Texture;
|
||||
|
||||
out vec4 fso_FragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fso_FragmentColor = texture(u_Texture, vso_TexCoord);
|
||||
}
|
Binary file not shown.
|
@ -1,19 +0,0 @@
|
|||
#version 450 core
|
||||
|
||||
layout(location = 0) in vec4 a_Position;
|
||||
layout(location = 1) in vec2 a_TexCoord;
|
||||
|
||||
layout(std140, binding = 0) uniform ub_ViewProjection
|
||||
{
|
||||
mat4 u_ViewProjection;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec2 vso_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ViewProjection * a_Position;
|
||||
|
||||
vso_TexCoord = a_TexCoord;
|
||||
}
|
||||
|
Binary file not shown.
|
@ -1,14 +0,0 @@
|
|||
#version 450 core
|
||||
|
||||
in vec4 vso_Tint;
|
||||
in vec2 vso_TexCoord;
|
||||
|
||||
uniform sampler2D u_Texture;
|
||||
|
||||
out vec4 fso_FragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fso_FragmentColor = texture(u_Texture, vso_TexCoord) * vso_Tint;
|
||||
}
|
||||
|
Binary file not shown.
|
@ -1,21 +0,0 @@
|
|||
#version 450 core
|
||||
|
||||
layout(location = 0) in vec4 a_Position;
|
||||
layout(location = 1) in vec4 a_Tint;
|
||||
layout(location = 2) in vec2 a_TexCoord;
|
||||
|
||||
layout(std140, binding = 0) uniform ub_ViewProjection
|
||||
{
|
||||
mat4 u_ViewProjection;
|
||||
};
|
||||
|
||||
out vec4 vso_Tint;
|
||||
out vec2 vso_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ViewProjection * a_Position;
|
||||
|
||||
vso_Tint = a_Tint;
|
||||
vso_TexCoord = a_TexCoord;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 79 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB |
|
@ -1,48 +0,0 @@
|
|||
[Window][Dockspace]
|
||||
Pos=0,0
|
||||
Size=1595,720
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
ViewportPos=2078,721
|
||||
ViewportId=0x9F5F46A1
|
||||
Size=848,1408
|
||||
Collapsed=0
|
||||
|
||||
[Window][Dear ImGui Demo]
|
||||
Pos=836,24
|
||||
Size=759,696
|
||||
Collapsed=0
|
||||
DockId=0x00000003,1
|
||||
|
||||
[Window][Hierarchy]
|
||||
Pos=0,24
|
||||
Size=184,696
|
||||
Collapsed=0
|
||||
DockId=0x00000001,0
|
||||
|
||||
[Window][Properties]
|
||||
Pos=836,24
|
||||
Size=759,696
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
|
||||
[Window][Game]
|
||||
Pos=186,24
|
||||
Size=648,696
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Window][Content Browser]
|
||||
ViewportPos=1359,621
|
||||
ViewportId=0x371352B7
|
||||
Size=1274,1296
|
||||
Collapsed=0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0x1ED03EE2 Window=0x5B816B74 Pos=516,375 Size=1595,696 Split=X
|
||||
DockNode ID=0x00000006 Parent=0x1ED03EE2 SizeRef=834,696 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000006 SizeRef=184,696 Selected=0x29EABFBD
|
||||
DockNode ID=0x00000002 Parent=0x00000006 SizeRef=648,696 CentralNode=1 Selected=0x26816F31
|
||||
DockNode ID=0x00000003 Parent=0x1ED03EE2 SizeRef=759,696 Selected=0x199AB496
|
||||
|
3
docs/.gitignore
vendored
3
docs/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
_build/
|
||||
generated/
|
||||
|
1
docs/CMakeLists.txt
Normal file
1
docs/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
message("TODO: implement doc generation")
|
198
docs/architecture.rst
Normal file
198
docs/architecture.rst
Normal file
|
@ -0,0 +1,198 @@
|
|||
Architecture
|
||||
=========================
|
||||
**Light** is a **modular** and feature rich engine with emphasis on the **entity component system** architectural design.
|
||||
It is composed of numerous **modules** and prefers **composition over inheritance**.
|
||||
|
||||
Building Blocks
|
||||
------------------------
|
||||
Modules are the **building blocks** of Light.
|
||||
Each module can provide one, and only one of the following:
|
||||
|
||||
- Library
|
||||
These modules provide some form of functionality.
|
||||
They may depend on library modules.
|
||||
|
||||
For instance, they may provide: asset parsing, logging, string functions,
|
||||
math functions, containers, etc.
|
||||
|
||||
Library modules may also **wrap** a third-party library and provide an interface following Light's coding guidelines.
|
||||
|
||||
This way:
|
||||
|
||||
* Unsafe libraries, often native C libraries, can be made safer (without sacrificing performance).
|
||||
* Coding conventions can be consistent across all lines of code in other modules.
|
||||
* Deprecated and confusing conventions (eg. out parameters) can be wrapped away and replaced by simpler interfaces.
|
||||
* It may be possible to provide only the required symbols from a library.
|
||||
|
||||
- Tool
|
||||
These modules compile as executables that provide tooling.
|
||||
They may depend on any other module type.
|
||||
|
||||
An example of a **tool** module is the "AssetBaker" that relieves other modules
|
||||
from linking to large third-party asset readers (and optimizers) and bakes assets' content
|
||||
in a common, and often optimized, format.
|
||||
|
||||
- Component
|
||||
These modules specify POD structures to be used as components of one or more systems.
|
||||
They shall not depend on any other module. This separation (of components and system modules) is for 2 reasons:
|
||||
|
||||
First, for simple re-usability of **components** between multiple **systems** as it is quite likely
|
||||
for more than 1 **system** to depend on a component.
|
||||
For instance, **physics simulation** and **rendering** both depend on the **TransformationComponent**
|
||||
|
||||
Second, even if a component is used solely by **1 system**, decoupling the **component** from the
|
||||
**system's implementation** allows us to provide alternative implementations for
|
||||
a system. For instance, we can have a **polygon-renderer** and a **raytracer** for our
|
||||
rendering system.
|
||||
|
||||
- System
|
||||
System modules may depend on any number of modules but must depend on at least one component module.
|
||||
|
||||
These modules implement an aspect of the engine, e.g. physics system, rendering system,
|
||||
audio system, networking system, script system, etc.
|
||||
They implement a common **system interface** and may periodically **tick** to execute their logic
|
||||
and **mutate** different components while doing so.
|
||||
|
||||
- Main
|
||||
**Light** is the stock implementation of the **main** module. It's basically our engine.
|
||||
You may design and use an alternative implementation.
|
||||
|
||||
The main module acts as the **aggregator** and **synchronizer** of a required module list.
|
||||
It synchronizes between multiple modules using a concept called **tick dependencies**.
|
||||
|
||||
Since we want to maximally utilize our hardware, we need to have as much concurrency as possible.
|
||||
One obvious way to increase concurrency is to make multiple systems tick (execute their logic)
|
||||
in parallel.
|
||||
|
||||
But we can't just tick haphazardly, we need proper **synchronization**.
|
||||
Let's break down how synchronization works with **tick dependencies** by briefly going
|
||||
through different module types:
|
||||
|
||||
**Tool** modules are executables (eg. AssetBaker). They don't need any external synchronization.
|
||||
|
||||
**Library** modules simply provide reusable functionality for **tool** and **system** modules.
|
||||
|
||||
**Component** modules, even more simply, provide a set of POD structures.
|
||||
|
||||
**System** modules, however, bring about a bit of complexity.
|
||||
They need to execute a piece of code periodically, which may cause **mutations**.
|
||||
|
||||
For instance, a **physics simulation system** needs to tick every frame (or multiple times
|
||||
a frame at fixed intervals) to simulate physics, this simulation may **mutate** one
|
||||
or more components, such as the **TransformationComponents**.
|
||||
|
||||
Meanwhile, the **rendering system** might use the **TransformationComponent** for vertex shader operations
|
||||
to determine where things should end up on the screen.
|
||||
We can't be **mutating** a component in one thread while **reading** it in another, this causes all sorts
|
||||
of nasty problems. Hence why we need synchronization.
|
||||
|
||||
Systems can think of synchronization of their logic to be done in one of 3 ways:
|
||||
**external**, **internal**, and **unsynchronized**.
|
||||
|
||||
- **Unsynchronized**:
|
||||
As evident from the name, no syncing needs to be done for these parts of a system.
|
||||
|
||||
- **Internal**:
|
||||
This type of synchronization is handled internally by the module and does
|
||||
not concern other systems.
|
||||
|
||||
- **External**:
|
||||
This is the synchronization done by the main module (Light). And can be achieved
|
||||
by specifying a list of tick dependencies.
|
||||
|
||||
The system interface provides 3 tick functions:
|
||||
|
||||
- **tick_pre_unsync**:
|
||||
This gets called for all **active systems** at the same time before the frame starts.
|
||||
Light waits for the execution of all **tick_pre_unsync** functions to finish before proceeding to **tick_sync**.
|
||||
This is usually for systems to handle internally synchronized pre-frame logic.
|
||||
|
||||
- **tick_sync**:
|
||||
This relies on the tick dependencies of a system.
|
||||
A tick dependency simply marks a **type of component** as a **mutable** or **immutable** dependency for
|
||||
a particular **system**. If system **A** shares only **immutable** dependencies with system **B**, or
|
||||
if system **A** shares no dependencies with system **B**, they can tick together.
|
||||
|
||||
If system **A** has a **mutable** dependency with a component, then all systems that have either
|
||||
**mutable** or **immutable** dependency with that component need to tick before or after system **A's**
|
||||
tick.
|
||||
|
||||
- **tick_post_unsync**:
|
||||
Same as **tick_pre_unsync**, but happens after all **tick_sync** calls
|
||||
have been executed.
|
||||
|
||||
You might be wondering why we're bothering with specifying tick dependencies between
|
||||
such high-level concepts as **systems** where we could manually do the external synchronization
|
||||
between them.
|
||||
|
||||
There may be truth in that claim, but our intention here is to free **Light** from knowing
|
||||
about the implementation details of our systems and instead make it simply provide a framework for setting up
|
||||
and running multiple systems together.
|
||||
|
||||
Furthermore, now our **systems** don't need to know anything about the existence of other systems either
|
||||
and their logic is completely isolated.
|
||||
|
||||
Performance
|
||||
----------------
|
||||
**Light** engine aims to keep a high-performant design on all levels of the engine, from the grand architecture to the low-level implementations.
|
||||
It also tries to ensure a consistent performance across platforms and APIs.
|
||||
We achieve this by not thinking of performance as a concern for later times and put it as one
|
||||
of our first priorities.
|
||||
|
||||
Some of the main techniques **Light** utilizes to ensure optimal code performance:
|
||||
|
||||
- Hardware Friendly Architecture
|
||||
|
||||
- Native Support
|
||||
Light provides native support for the supported platforms and architectures.
|
||||
It also provides native graphics API support for all the supported operating systems:
|
||||
Metal for MacOS, DirectX12 for Windows and Vulkan for the rest.
|
||||
|
||||
- Baking
|
||||
Light bakes and optimizes anything that can be baked as soon as it can.
|
||||
|
||||
For assets, this will significantly decrease our load times because optimized (and specialized) data can be directly
|
||||
streamed to RAM/VRAM without intermediate processing.
|
||||
|
||||
We don't only bake assets like models, images and audio. We also bake anything about the scene
|
||||
that's bake-able in any sense.
|
||||
|
||||
- Low Memory Footprint
|
||||
Memory is sacred! That's my personal philosophy. I always use low memory-footprint applications.
|
||||
I value and respect memory. I worship memory. I pray to the memory gods, so that I may never run
|
||||
out of memory.
|
||||
|
||||
Games and simulations naturally have high memory consumption. But that fact should not give us
|
||||
a free pass for ignoring our memory footprint. Light engine respects its user's hardware by
|
||||
not being wasteful and always optimizing its memory consumption (alongside its performance).
|
||||
|
||||
Every byte matters!
|
||||
|
||||
- Minimal Indirection
|
||||
Light minimizes unnecessary indirections and makes friends with the compilers by
|
||||
providing them as much context as possible. It uses compile-time paradigms and principles before
|
||||
considering (necessary) indirections.
|
||||
|
||||
All problems in programming can be solved by another level of indirection. But perhaps not performance
|
||||
problems.
|
||||
|
||||
- Rigorous Testing
|
||||
|
||||
State
|
||||
----------------
|
||||
The data in Light engine can be coarsely divided into 4 types:
|
||||
|
||||
- Shared
|
||||
Components are the only way for our systems to have data shared between themselves.
|
||||
They are laid out in the most reasonably efficient way possible by our ECS implementation.
|
||||
Currently we use **EnTT**, however we **may** roll our own implementation in the future if needs be.
|
||||
|
||||
- Internal
|
||||
Systems can hold any amount of internal state as they wish. Light however won't go over-board
|
||||
and respects the hardware's cache locality when it's iterating over a set of components.
|
||||
|
||||
- Transient
|
||||
Mostly just the stack.
|
||||
|
||||
- Cold
|
||||
Cold state is everything that lives on the disk, saved game-state, baked assets, etc.
|
|
@ -1,72 +0,0 @@
|
|||
Asset Management
|
||||
===================================================================================================
|
||||
|
||||
On Disk (file) Layout
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block:: md
|
||||
|
||||
{version} | 4 bytes, ie. uint32_t
|
||||
{general metadata} | sizeof(AssetMetadata)
|
||||
{specialized metadata} | sizeof(XXXAssetMetadata), eg. TextureAssetMetadata
|
||||
{n} | 4 bytes, ie. uint32_t
|
||||
{blob_0...n metadata} | n * sizeof(BlobMetadata)
|
||||
{blob_0...n data} | variable size based on actual data
|
||||
{end marker} | 8 byte, ie size_t for marking the END
|
||||
|
||||
Sections
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block:: md
|
||||
|
||||
version -> The version of the asset for forward compatibility
|
||||
general metadata -> Common asset metadata such as file-path, asset-type, creator, etc.
|
||||
specialized metadata -> Metadata specific to the asset, eg. texture dimensions for Textures.
|
||||
n -> The number of blobs.
|
||||
blob_0...n metadata -> Metadata specifying how the actual data is packed, required for unpacking.
|
||||
blob_0...n data -> The actual data, packed and compressed to be reacdy for direct engine consumption.
|
||||
|
||||
Loading
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Loading pre-baked asset files (like .png files) for baking:
|
||||
|
||||
|
||||
Each **Loader** has ONE OR MORE supported input file types (detected via the file extension): eg. StbLoader -> Can read in .jpg, .png, .bmp, etc.... files
|
||||
|
||||
Each **Loader** has ONLY ONE supported output asset type:
|
||||
eg. StbLoader -> outputs TextureAsset
|
||||
|
||||
Multiple **Loader**\s MAY have as output the same asset type:
|
||||
eg. StbLoader -> outputs TextureAsset
|
||||
eg. SomeOtherImgLoader -> outputs TextureAsset
|
||||
|
||||
Multiple **Loader**\s SHOULD NOT have as input same extension types
|
||||
eg. .jpg, .png -> if supported, should only be supported by 1 **Loader** class
|
||||
|
||||
Each **Loader** SHOULD read and turn the data from a file (eg. .png for textures) into something
|
||||
understandable by a **Packer** (not the engine itself).
|
||||
|
||||
A **Loader** SHOULD NOT be responsible for packing the parsed file data into asset data,
|
||||
as that implies direct understanding of the layout required by the engine.
|
||||
|
||||
And if that layout changes, ALL **Loader**s should change accordingly;
|
||||
which makes a class that's responsible for reading files dependant on the engine's (potentially frequent) internal changes.
|
||||
The logic is to reduce many-to-one dependency into a one-to-one dependency by redirecting the packing process to **Packer** classes
|
||||
|
||||
Packing
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Each **Packer** is responsible for packing ONLY ONE asset type:
|
||||
eg. TexturePacker for packing texture assets from parsed image files.
|
||||
eg. ModelPacker for packing model assets from parsed model files.
|
||||
|
||||
Each **Packer** will output ONE OR MORE blobs of data,
|
||||
and for EACH blob of data, it'll write a BlobMetadata, AFTER the specialized metadata (eg. TextureAssetMetadata)
|
||||
|
||||
A **Packer** will make use of the **Compressor** classes to compress the data,
|
||||
and lay it out in a way that is suitable for the engine's consumption.
|
||||
|
||||
Unpacking
|
||||
---------------------------------------------------------------------------------------------------
|
||||
A **Parser** is responsible for parsing ONLY ONE asset type:
|
||||
eg. TextureParser for parsing texture assets for direct engine consumption.
|
||||
eg. ModelParser for parsing model assets for direct engine consumption.
|
|
@ -1,5 +0,0 @@
|
|||
.. architecture/resources
|
||||
|
||||
Resource Management
|
||||
===================================================================================================
|
||||
|
40
docs/conf.py
40
docs/conf.py
|
@ -1,27 +1,25 @@
|
|||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# For the full list of built-in configuration values, see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
# Project information
|
||||
project = 'Light'
|
||||
copyright = '2024, Light7734'
|
||||
author = 'Light7734'
|
||||
release = '1'
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
# General configuration
|
||||
extensions = [
|
||||
"sphinx.ext.intersphinx",
|
||||
"sphinx_copybutton",
|
||||
"sphinx_design"
|
||||
]
|
||||
|
||||
project = 'light'
|
||||
copyright = '2025, light7734'
|
||||
author = 'light7734'
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = []
|
||||
|
||||
templates_path = ['_templates']
|
||||
source_suffix = '.rst'
|
||||
default_role = 'cpp:any'
|
||||
pygments_style = 'sphinx'
|
||||
highlight_language = 'c++'
|
||||
primary_domain = 'cpp'
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
templates_path = ["_templates"]
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
# Theme configuration
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_static_path = ['_static']
|
||||
# html_favicon = ''
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
from git import Repo
|
||||
import re
|
||||
|
||||
repo = Repo(search_parent_directories=True)
|
||||
assert not repo.bare
|
||||
|
||||
file_path = "generated/changelog.rst"
|
||||
|
||||
messages = []
|
||||
short_shas = []
|
||||
hex_shas = []
|
||||
logs = []
|
||||
|
||||
remote_url = "https://git.light7734.com/light7734/light/commit"
|
||||
def format_log(commit_type, message, major, minor, patch, short_sha, hex_sha):
|
||||
href = f"{remote_url}/{hex_sha}"
|
||||
version = f"{major}.{minor}.{patch}-kitten+{short_sha}";
|
||||
link = f"`{version} <{remote_url}/{hex_sha}>`__"
|
||||
return f"| **{message}** ({link})"
|
||||
|
||||
for commit in repo.iter_commits():
|
||||
messages.append(commit.summary)
|
||||
short_shas.append(repo.git.rev_parse(commit.hexsha, short=5))
|
||||
hex_shas.append(commit.hexsha)
|
||||
|
||||
ver_major = 0
|
||||
ver_minor = 0
|
||||
ver_patch = 0
|
||||
|
||||
idx = len(messages)
|
||||
for message in reversed(messages):
|
||||
idx = idx - 1;
|
||||
|
||||
commit_type = re.match("^(feat|fix|refactor|perf|build|asset|test|chore|ci|docs)", message)
|
||||
if not commit_type:
|
||||
continue
|
||||
|
||||
match commit_type.group(0):
|
||||
case "feat":
|
||||
ver_minor = ver_minor + 1
|
||||
ver_patch = 0
|
||||
|
||||
case "fix":
|
||||
ver_patch = ver_patch + 1
|
||||
|
||||
case "refactor":
|
||||
ver_patch = ver_patch + 1
|
||||
|
||||
case "perf":
|
||||
ver_patch = ver_patch + 1
|
||||
|
||||
case "build":
|
||||
ver_patch = ver_patch + 1
|
||||
|
||||
case "asset":
|
||||
ver_patch = ver_patch + 1
|
||||
|
||||
logs.append(format_log(commit_type, message, ver_major, ver_minor, ver_patch, short_shas[idx], hex_shas[idx]))
|
||||
|
||||
with open(file_path, "w") as f:
|
||||
f.write(".. changelogs\n\n\n")
|
||||
f.write("Changelogs\n")
|
||||
f.write("==================================================\n\n")
|
||||
|
||||
f.write("KITTEN\n")
|
||||
f.write("--------------------------------------------------\n\n")
|
||||
for log in reversed(logs):
|
||||
f.write(log + '\n')
|
|
@ -1,10 +0,0 @@
|
|||
.. guidelines/conventions
|
||||
|
||||
Coding Conventions
|
||||
===================================================================================================
|
||||
Any line of code added to the engine, must abide by following conventions.
|
||||
They may seem arbitrary, and sometimes they are. But to achieve **consistency**, which is not an arbitrary goal, is to
|
||||
follow these guidelines.
|
||||
|
||||
AAA
|
||||
--------------------
|
|
@ -1,147 +0,0 @@
|
|||
.. guidelines/development
|
||||
|
||||
Development
|
||||
===================================================================================================
|
||||
As a solo-project, I am not only the **developer**, but also the **manager**.
|
||||
Therefore there is a need, if this project is to succeed, to have a development plan.
|
||||
|
||||
Such a plan should:
|
||||
|
||||
- Define a way to **distribute work** (across time, since there's only 1 developer).
|
||||
- Define what is a **unit of work** (cycles).
|
||||
- Provide a way to **track productivity**, which helps projecting the future and **detecting patterns** early on.
|
||||
- Provide a **pipeline** for the work to go through and **minimize ambiguity**.
|
||||
|
||||
These are the **management** aspects of the project, which help the development goals to be more **pragmatic**
|
||||
---by pulling my mind out of its **engineering dreamland**, and make it focus on the **broader picture**.
|
||||
|
||||
Cycle
|
||||
---------------------------------------------------------------------------------------------------
|
||||
A cycle is one **step** in development, one cycle = one ticket, and it consists of 4 stages:
|
||||
|
||||
1 - Make it known
|
||||
- Write the commit message.
|
||||
- This limits the **scope of changes** and gives you a very specific **goal** to work towards.
|
||||
- If something outside of this scope really bothers you, fix and stash for a future cycle.
|
||||
- Make a ticket if stash-fix is implausible ---**DO NOT** write **todo** comments.
|
||||
- The message should follow the project's **commit message specifications**.
|
||||
|
||||
- Make a ticket.
|
||||
- Version control (git) is a **development-tool**, not a **management-tool**.
|
||||
- Provide a very brief description ---This may be used in the commit message's body.
|
||||
|
||||
2 - Make it work
|
||||
- Write high-level tests that confirms the cycle's requirements are met.
|
||||
- That is, specify requirements in a programming language instead of English.
|
||||
- You're done when all the tests pass.
|
||||
- Preferably write the tests first, but it's okay to start with the interface.
|
||||
- Tests may not be necessary depending on the requirements and commit type.
|
||||
|
||||
- "Make it work" doesn't mean liberally producing shit code, you should:
|
||||
- Follow project's **conventions**.
|
||||
- Follow **best practices** and **proven swe principles**.
|
||||
- Enable **warnings as errors**.
|
||||
- Enable **static analysis**.
|
||||
- Don't break any pre-existing-tests.
|
||||
- Have the over-all picture in mind.
|
||||
|
||||
3 - Make it right
|
||||
- Test driven refactoring
|
||||
- Now you have a better picture of how things relate and work.
|
||||
- Switch to a TDD-style development to do the refactoring while following swe best-practices and proven-principles.
|
||||
|
||||
4 - Make it fast
|
||||
- This is an engine, at the end of the day, **performance** is king.
|
||||
- Get a performance and/or memory profile and try to alleviate the bottlenecks.
|
||||
- Avoid premature optimizations, be certain what you change has performance benefits.
|
||||
|
||||
|
||||
Sprint
|
||||
---------------------------------------------------------------------------------------------------
|
||||
A sprint is the collection of all the finished cycles in one week.
|
||||
It's meant to provide insight on development speed and help projecting the future.
|
||||
|
||||
|
||||
Commit Message Specification
|
||||
---------------------------------------------------------------------------------------------------
|
||||
The project follows the `Conventional Commits Specification <https://www.conventionalcommits.org/en/v1.0.0-beta.4>`_.
|
||||
|
||||
.. code-block:: md
|
||||
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer]
|
||||
|
||||
With the following commit types:
|
||||
|
||||
- feat
|
||||
- For adding a new feature.
|
||||
- Causes a **minor** bump in version.
|
||||
|
||||
- fix
|
||||
- For changes that fix one or more bug.
|
||||
- Causes a **patch** bump in version.
|
||||
|
||||
- refactor
|
||||
- For non feat/fix changes that improve the implementation and/or the interface.
|
||||
- Causes a **patch** bump in version.
|
||||
|
||||
- perf
|
||||
- For changes that (hopefully) improve the performance.
|
||||
- Causes a **patch** bump in version.
|
||||
|
||||
- build
|
||||
- For changes that affect the build system or external dependencies.
|
||||
- Causes a **patch** bump in version.
|
||||
|
||||
- asset
|
||||
- For changes to the files under the ``/data`` directory.
|
||||
- Causes a **patch** bump in version.
|
||||
|
||||
- test
|
||||
- For adding missing tests or correcting the existing tests.
|
||||
- Does not affect the version.
|
||||
|
||||
- chore
|
||||
- For releases, .gitignore changes, deleting unused files, etc.
|
||||
- Does not affect the version.
|
||||
|
||||
- ci
|
||||
- For changes to our CI configuration files and scripts, including files under ``/tools/ci``.
|
||||
- Does not affect the version.
|
||||
|
||||
- docs
|
||||
- For changes to the documentations.
|
||||
- Does not affect the version.
|
||||
|
||||
Semantic Versioning
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Coupled with conventional commit style messages, we can automajically version the project following
|
||||
the **Semantic Versioning 2.0.0** specifications.
|
||||
|
||||
The full version identifier consits of a version core (major.minor.patch) + label + hexsha of the commit.
|
||||
Using the following format:
|
||||
|
||||
|
||||
.. code-block:: md
|
||||
|
||||
<major>.<minor>.<patch>-<label>+<short_hexsha>
|
||||
|
||||
eg.
|
||||
0.8.1-kitten+ea898
|
||||
0.5.0-kitten+01d85
|
||||
1.5.0-akasha+7de53
|
||||
|
||||
kitten refers to all pre-release (1.0.0) versions
|
||||
|
||||
|
||||
The shortened hexsha of a commit is obtained by:
|
||||
``git rev-parse --short=5 <commit_hexsha>``
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
.. guidelines/philosophy
|
||||
|
||||
Philosophy
|
||||
===================================================================================================
|
||||
|
||||
| **A theory or attitude that acts as a guiding principle for behaviour.**
|
||||
| --- Oxford Languages
|
|
@ -1,32 +1,4 @@
|
|||
.. light documentation
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Light Engine
|
||||
|
||||
light/showcase.rst
|
||||
light/features.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Software Architecture
|
||||
|
||||
architecture/assets.rst
|
||||
architecture/resource.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Development Guidelines
|
||||
|
||||
guidelines/philosophy.rst
|
||||
guidelines/development.rst
|
||||
guidelines/conventions.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Generated Docs
|
||||
|
||||
generated/api.rst
|
||||
generated/changelog.rst
|
||||
|
||||
./architecture.rst
|
||||
./philosophy.rst
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
.. light/features
|
||||
|
||||
Features
|
||||
===================================================================================================
|
|
@ -1,4 +0,0 @@
|
|||
.. light/demos
|
||||
|
||||
Showcase
|
||||
===================================================================================================
|
|
@ -1,35 +0,0 @@
|
|||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
6
docs/philosophy.rst
Normal file
6
docs/philosophy.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
Philosophy
|
||||
=========================
|
||||
|
||||
|
||||
Code is documentation
|
||||
------------------------
|
3
external/.clang-tidy
vendored
3
external/.clang-tidy
vendored
|
@ -1,3 +0,0 @@
|
|||
# Disable all checks in this subdirectory
|
||||
Checks: '-*'
|
||||
|
3
external/glad/CMakeLists.txt
vendored
3
external/glad/CMakeLists.txt
vendored
|
@ -1,3 +0,0 @@
|
|||
add_library(glad ${CMAKE_CURRENT_SOURCE_DIR}/src/gl.c)
|
||||
target_include_directories(glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(glad PUBLIC opengl::opengl)
|
311
external/glad/include/KHR/khrplatform.h
vendored
311
external/glad/include/KHR/khrplatform.h
vendored
|
@ -1,311 +0,0 @@
|
|||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
8319
external/glad/include/glad/gl.h
vendored
8319
external/glad/include/glad/gl.h
vendored
File diff suppressed because it is too large
Load diff
7841
external/glad/include/glad/vulkan.h
vendored
7841
external/glad/include/glad/vulkan.h
vendored
File diff suppressed because it is too large
Load diff
84
external/glad/include/vk_platform.h
vendored
84
external/glad/include/vk_platform.h
vendored
|
@ -1,84 +0,0 @@
|
|||
/* */
|
||||
/* File: vk_platform.h */
|
||||
/* */
|
||||
/*
|
||||
** Copyright 2014-2025 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Platform-specific directives and type declarations
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
||||
* with the same calling conventions that the Vulkan implementation expects.
|
||||
*
|
||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
/* On Windows, Vulkan commands use the stdcall convention */
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL __stdcall
|
||||
#define VKAPI_PTR VKAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
||||
#error "Vulkan is not supported for the 'armeabi' NDK ABI"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
||||
/* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */
|
||||
/* calling convention, i.e. float parameters are passed in registers. This */
|
||||
/* is true even if the rest of the application passes floats on the stack, */
|
||||
/* as it does by default when compiling for the armeabi-v7a NDK ABI. */
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR VKAPI_ATTR
|
||||
#else
|
||||
/* On other platforms, use the default calling convention */
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR
|
||||
#endif
|
||||
|
||||
#if !defined(VK_NO_STDDEF_H)
|
||||
#include <stddef.h>
|
||||
#endif /* !defined(VK_NO_STDDEF_H) */
|
||||
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif /* !defined(VK_NO_STDINT_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
17892
external/glad/src/gl.c
vendored
17892
external/glad/src/gl.c
vendored
File diff suppressed because it is too large
Load diff
5537
external/glad/src/vulkan.c
vendored
5537
external/glad/src/vulkan.c
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,3 @@
|
|||
# engine
|
||||
add_subdirectory(./base)
|
||||
add_subdirectory(./time)
|
||||
add_subdirectory(./logger)
|
||||
add_subdirectory(./debug)
|
||||
add_subdirectory(./math)
|
||||
#
|
||||
add_subdirectory(./asset_baker)
|
||||
add_subdirectory(./asset_parser)
|
||||
# add_subdirectory(./asset_manager)
|
||||
#
|
||||
add_subdirectory(./camera)
|
||||
# add_subdirectory(./input)
|
||||
# add_subdirectory(./ui)
|
||||
#
|
||||
add_subdirectory(./surface)
|
||||
# add_subdirectory(./renderer)
|
||||
add_subdirectory(./ecs)
|
||||
#
|
||||
add_subdirectory(./app)
|
||||
add_subdirectory(pch)
|
||||
|
||||
# apps
|
||||
add_subdirectory(./mirror)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(engine)
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
add_library_module(app application.cpp)
|
||||
target_link_libraries(app PRIVATE lt_debug)
|
|
@ -1,48 +0,0 @@
|
|||
#include <app/application.hpp>
|
||||
#include <app/system.hpp>
|
||||
|
||||
namespace lt::app {
|
||||
|
||||
void Application::game_loop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
for (auto &system : m_systems)
|
||||
{
|
||||
if (system->tick())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &system : m_systems_to_be_registered)
|
||||
{
|
||||
m_systems.emplace_back(system)->on_register();
|
||||
}
|
||||
|
||||
for (auto &system : m_systems_to_be_unregistered)
|
||||
{
|
||||
m_systems.erase(
|
||||
std::remove(m_systems.begin(), m_systems.end(), system),
|
||||
m_systems.end()
|
||||
);
|
||||
}
|
||||
|
||||
if (m_systems.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::register_system(Ref<app::ISystem> system)
|
||||
{
|
||||
m_systems.emplace_back(std::move(system));
|
||||
}
|
||||
|
||||
void Application::unregister_system(Ref<app::ISystem> system)
|
||||
{
|
||||
m_systems_to_be_unregistered.emplace_back(std::move(system));
|
||||
}
|
||||
|
||||
} // namespace lt::app
|
|
@ -1,44 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
namespace lt::app {
|
||||
|
||||
class ISystem;
|
||||
|
||||
extern Scope<class Application> create_application();
|
||||
|
||||
/** The main application class.
|
||||
* Think of this like an aggregate of systems, you register systems through this interface.
|
||||
* Then they'll tick every "application frame".
|
||||
*/
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
Application(const Application &) = delete;
|
||||
|
||||
Application(Application &&) = delete;
|
||||
|
||||
auto operator=(const Application &) -> Application & = delete;
|
||||
|
||||
auto operator=(Application &&) -> Application & = delete;
|
||||
|
||||
virtual ~Application() = default;
|
||||
|
||||
void game_loop();
|
||||
|
||||
void register_system(Ref<app::ISystem> system);
|
||||
|
||||
void unregister_system(Ref<app::ISystem> system);
|
||||
|
||||
protected:
|
||||
Application() = default;
|
||||
|
||||
private:
|
||||
std::vector<Ref<app::ISystem>> m_systems;
|
||||
|
||||
std::vector<Ref<app::ISystem>> m_systems_to_be_unregistered;
|
||||
|
||||
std::vector<Ref<app::ISystem>> m_systems_to_be_registered;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lt::app
|
|
@ -1,27 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <app/application.hpp>
|
||||
|
||||
auto main(int argc, char *argv[]) -> int32_t
|
||||
try
|
||||
{
|
||||
std::ignore = argc;
|
||||
std::ignore = argv;
|
||||
|
||||
auto application = lt::Scope<lt::app::Application> {};
|
||||
|
||||
application = lt::app::create_application();
|
||||
if (!application)
|
||||
{
|
||||
throw std::runtime_error { "Failed to create application\n" };
|
||||
}
|
||||
|
||||
application->game_loop();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
catch (const std::exception &exp)
|
||||
{
|
||||
log_crt("Terminating due to uncaught exception:");
|
||||
log_crt("\texception.what(): {}", exp.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
namespace lt::app {
|
||||
|
||||
class ISystem
|
||||
{
|
||||
public:
|
||||
ISystem() = default;
|
||||
|
||||
virtual ~ISystem() = default;
|
||||
|
||||
ISystem(ISystem &&) = default;
|
||||
|
||||
ISystem(const ISystem &) = delete;
|
||||
|
||||
auto operator=(ISystem &&) -> ISystem & = default;
|
||||
|
||||
auto operator=(const ISystem &) -> ISystem & = delete;
|
||||
|
||||
virtual void on_register() = 0;
|
||||
|
||||
virtual void on_unregister() = 0;
|
||||
|
||||
virtual auto tick() -> bool = 0;
|
||||
};
|
||||
|
||||
} // namespace lt::app
|
|
@ -1,10 +0,0 @@
|
|||
add_executable_module(
|
||||
asset_baker entrypoint/baker.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
asset_baker
|
||||
PRIVATE asset_parser
|
||||
PRIVATE stb::stb
|
||||
PRIVATE logger
|
||||
)
|
|
@ -1,100 +0,0 @@
|
|||
#include <asset_baker/bakers.hpp>
|
||||
#include <asset_parser/assets/text.hpp>
|
||||
#include <asset_parser/assets/texture.hpp>
|
||||
#include <asset_parser/parser.hpp>
|
||||
#include <filesystem>
|
||||
#include <logger/logger.hpp>
|
||||
|
||||
void try_packing_texture(
|
||||
const std::filesystem::path &in_path,
|
||||
const std::filesystem::path &out_path
|
||||
)
|
||||
{
|
||||
auto texture_loader = lt::TextureLoaderFactory::create(in_path.extension().string());
|
||||
if (!texture_loader)
|
||||
{
|
||||
// Don't log anything; this is expected.
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Assets::TextureAsset::pack(texture_loader->load(in_path), out_path);
|
||||
|
||||
log_inf("Packed a texture asset:");
|
||||
log_inf("\tloader : {}", texture_loader->get_name());
|
||||
log_inf("\tin path: {}", in_path.string());
|
||||
log_inf("\tout path: {}", out_path.string());
|
||||
}
|
||||
catch (const std::exception &exp)
|
||||
{
|
||||
log_err("Failed to pack texture asset:");
|
||||
log_err("\tloader : {}", texture_loader->get_name());
|
||||
log_err("\tin path : {}", in_path.string());
|
||||
log_err("\tout path: {}", out_path.string());
|
||||
log_err("\texp.what: {}", exp.what());
|
||||
}
|
||||
}
|
||||
|
||||
void try_packing_text(const std::filesystem::path &in_path, const std::filesystem::path &out_path)
|
||||
{
|
||||
auto text_loader = lt::TextLoaderFactory::create(in_path.extension().string());
|
||||
if (!text_loader)
|
||||
{
|
||||
// Don't log anything; this is expected.
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Assets::TextAsset::pack(text_loader->load(in_path), out_path);
|
||||
|
||||
log_inf("Packed a text asset:");
|
||||
log_inf("\tloader : {}", text_loader->get_name());
|
||||
log_inf("\tin path: {}", in_path.string());
|
||||
log_inf("\tout path: {}", out_path.string());
|
||||
}
|
||||
catch (const std::exception &exp)
|
||||
{
|
||||
log_err("Failed to pack a text asset:");
|
||||
log_err("\tloader : {}", text_loader->get_name());
|
||||
log_err("\tin path : {}", in_path.string());
|
||||
log_err("\tout path: {}", out_path.string());
|
||||
log_err("\texp.what: {}", exp.what());
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char *argv[]) -> int32_t
|
||||
try
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
throw std::logic_error("Argc should be 2 -- exe dir (implicit) and target dir");
|
||||
}
|
||||
|
||||
for (const auto &directory_iterator :
|
||||
std::filesystem::recursive_directory_iterator(argv[1])) // NOLINT
|
||||
{
|
||||
if (directory_iterator.is_directory())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto &in_path = directory_iterator.path();
|
||||
|
||||
auto out_path = in_path;
|
||||
out_path.replace_extension(".asset");
|
||||
|
||||
try_packing_texture(in_path, out_path);
|
||||
try_packing_text(in_path, out_path);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
catch (const std::exception &exp)
|
||||
{
|
||||
log_crt("Terminating due to uncaught exception:");
|
||||
log_crt("\texception.what: {}:", exp.what());
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
|
@ -1,184 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <asset_parser/assets/text.hpp>
|
||||
#include <asset_parser/assets/texture.hpp>
|
||||
#include <filesystem>
|
||||
#include <logger/logger.hpp>
|
||||
#include <string_view>
|
||||
#include <unordered_set>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <stb_image.h>
|
||||
|
||||
namespace lt {
|
||||
|
||||
class Loader
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] virtual auto get_name() const -> std::string_view = 0;
|
||||
|
||||
Loader() = default;
|
||||
|
||||
Loader(Loader &&) = default;
|
||||
|
||||
Loader(const Loader &) = delete;
|
||||
|
||||
auto operator=(Loader &&) -> Loader & = default;
|
||||
|
||||
auto operator=(const Loader &) -> Loader & = delete;
|
||||
|
||||
virtual ~Loader() = default;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class TextureLoader: public Loader
|
||||
{
|
||||
public:
|
||||
TextureLoader() = default;
|
||||
|
||||
[[nodiscard]] virtual auto load(std::filesystem::path file_path) const
|
||||
-> Assets::TextureAsset::PackageData
|
||||
= 0;
|
||||
};
|
||||
|
||||
|
||||
class StbLoader: public TextureLoader
|
||||
{
|
||||
public:
|
||||
StbLoader() = default;
|
||||
|
||||
void load(std::filesystem::path path);
|
||||
|
||||
[[nodiscard]] static auto get_supported_extensions() -> std::unordered_set<std::string_view>
|
||||
{
|
||||
return { ".png" };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override
|
||||
{
|
||||
return "StbLoader";
|
||||
}
|
||||
|
||||
[[nodiscard]] auto load(std::filesystem::path file_path) const
|
||||
-> Assets::TextureAsset::PackageData override
|
||||
{
|
||||
auto width = int {};
|
||||
auto height = int {};
|
||||
auto channels = int {};
|
||||
|
||||
auto *pixels = stbi_load(file_path.string().c_str(), &width, &height, &channels, 4);
|
||||
if (!pixels)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to load image file at: {} using stbi_load", file_path.string()),
|
||||
};
|
||||
}
|
||||
|
||||
const auto metadata = Assets::Asset::Metadata {
|
||||
.type = Assets::Asset::Type::Texture,
|
||||
};
|
||||
|
||||
const auto texture_metadata = Assets::TextureAsset::Metadata {
|
||||
.format = Assets::TextureAsset::Format::RGBA8,
|
||||
.num_components = static_cast<uint32_t>(channels),
|
||||
.pixel_size = {
|
||||
static_cast<uint32_t>(width),
|
||||
static_cast<uint32_t>(height),
|
||||
{},
|
||||
},
|
||||
};
|
||||
|
||||
auto pixels_blob = Assets::Blob {};
|
||||
pixels_blob.resize(static_cast<size_t>(width) * height * channels);
|
||||
|
||||
// TODO(Light): figure out if it's possible to directly populate a blob with stbi functions
|
||||
memcpy(pixels_blob.data(), pixels, pixels_blob.size());
|
||||
stbi_image_free(pixels);
|
||||
|
||||
return Assets::TextureAsset::PackageData {
|
||||
.metadata = metadata,
|
||||
.texture_metadata = texture_metadata,
|
||||
.pixels = std::move(pixels_blob),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class TextureLoaderFactory
|
||||
{
|
||||
public:
|
||||
static auto create(std::string_view file_extension) -> std::unique_ptr<TextureLoader>
|
||||
{
|
||||
if (StbLoader::get_supported_extensions().contains(file_extension))
|
||||
{
|
||||
return std::make_unique<StbLoader>();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
class TextLoader: Loader
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] static auto get_supported_extensions() -> std::unordered_set<std::string_view>
|
||||
{
|
||||
return { ".glsl", ".txt", ".hlsl" };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override
|
||||
{
|
||||
return "TextLoader";
|
||||
}
|
||||
|
||||
[[nodiscard]] auto load(const std::filesystem::path &file_path) const
|
||||
-> Assets::TextAsset::PackageData
|
||||
{
|
||||
auto stream = std::ifstream { file_path, std::ios::binary };
|
||||
if (!stream.good())
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format(
|
||||
"Failed to open ifstream for text loading of file: {}",
|
||||
file_path.string()
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
auto file_size = std::filesystem::file_size(file_path);
|
||||
|
||||
auto text_blob = Assets::Blob(file_size);
|
||||
|
||||
stream.read((char *)(text_blob.data()), static_cast<long>(file_size)); // NOLINT
|
||||
|
||||
const auto metadata = Assets::Asset::Metadata {
|
||||
.type = Assets::Asset::Type::Text,
|
||||
};
|
||||
|
||||
const auto text_metadata = Assets::TextAsset::Metadata {
|
||||
.lines = {},
|
||||
};
|
||||
|
||||
return Assets::TextAsset::PackageData {
|
||||
.metadata = metadata,
|
||||
.text_metadata = {},
|
||||
.text_blob = std::move(text_blob),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class TextLoaderFactory
|
||||
{
|
||||
public:
|
||||
static auto create(std::string_view file_extension) -> std::unique_ptr<TextLoader>
|
||||
{
|
||||
if (TextLoader::get_supported_extensions().contains(file_extension))
|
||||
{
|
||||
return std::make_unique<TextLoader>();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace lt
|
|
@ -1,9 +0,0 @@
|
|||
add_library_module(asset_manager
|
||||
asset_manager.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
asset_manager
|
||||
PUBLIC asset_parser
|
||||
PRIVATE logger
|
||||
)
|
|
@ -1,92 +0,0 @@
|
|||
#include <asset_manager/asset_manager.hpp>
|
||||
#include <asset_parser/assets/text.hpp>
|
||||
#include <asset_parser/assets/texture.hpp>
|
||||
#include <logger/logger.hpp>
|
||||
#include <renderer/graphics_context.hpp>
|
||||
#include <renderer/shader.hpp>
|
||||
#include <renderer/texture.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
/* static */ auto AssetManager::instance() -> AssetManager &
|
||||
{
|
||||
static auto instance = AssetManager {};
|
||||
return instance;
|
||||
}
|
||||
|
||||
void AssetManager::load_shader_impl(
|
||||
const std::string &name,
|
||||
const std::filesystem::path &vertex_path,
|
||||
const std::filesystem::path &pixel_path
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
log_trc("Loading shader:");
|
||||
log_trc("\tname : {}", name);
|
||||
log_trc("\tvertex path: {}", vertex_path.string());
|
||||
log_trc("\tpixel path : {}", pixel_path.string());
|
||||
|
||||
m_shaders[name] = Ref<Shader>(Shader::create(
|
||||
get_or_load_text_asset(vertex_path.string()),
|
||||
get_or_load_text_asset(pixel_path),
|
||||
GraphicsContext::get_shared_context()
|
||||
));
|
||||
}
|
||||
catch (const std::exception &exp)
|
||||
{
|
||||
log_err("Failed to load shader:");
|
||||
log_err("\tname : {}", name);
|
||||
log_err("\tvertex path: {}", vertex_path.string());
|
||||
log_err("\tpixel path : {}", pixel_path.string());
|
||||
log_err("\texception : {}", exp.what());
|
||||
}
|
||||
}
|
||||
|
||||
void AssetManager::load_texture_impl(const std::string &name, const std::filesystem::path &path)
|
||||
{
|
||||
try
|
||||
{
|
||||
log_trc("Loading texture:");
|
||||
log_trc("\tname: {}", name);
|
||||
log_trc("\tpath: {}", path.string());
|
||||
|
||||
m_textures[name] = Ref<Texture>(
|
||||
Texture::create(get_or_load_texture_asset(path), GraphicsContext::get_shared_context())
|
||||
);
|
||||
}
|
||||
catch (const std::exception &exp)
|
||||
{
|
||||
log_err("Failed to load texture:");
|
||||
log_err("\tname : {}", name);
|
||||
log_err("\tpath : {}", path.string());
|
||||
log_err("\texception: {}", exp.what());
|
||||
}
|
||||
}
|
||||
|
||||
auto AssetManager::get_or_load_text_asset(const std::filesystem::path &path)
|
||||
-> Ref<Assets::TextAsset>
|
||||
{
|
||||
const auto key = std::filesystem::canonical(path).string();
|
||||
if (!m_text_assets.contains(key))
|
||||
{
|
||||
m_text_assets.emplace(key, create_ref<Assets::TextAsset>(path));
|
||||
}
|
||||
|
||||
return m_text_assets[key];
|
||||
}
|
||||
|
||||
auto AssetManager::get_or_load_texture_asset(const std::filesystem::path &path)
|
||||
-> Ref<Assets::TextureAsset>
|
||||
{
|
||||
const auto key = std::filesystem::canonical(path).string();
|
||||
if (!m_texture_assets.contains(key))
|
||||
{
|
||||
m_texture_assets.emplace(key, create_ref<Assets::TextureAsset>(path));
|
||||
}
|
||||
|
||||
return m_texture_assets[key];
|
||||
}
|
||||
|
||||
|
||||
} // namespace lt
|
|
@ -1,78 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
class TextAsset;
|
||||
|
||||
class TextureAsset;
|
||||
|
||||
} // namespace Assets
|
||||
|
||||
namespace lt {
|
||||
|
||||
class Shader;
|
||||
class Texture;
|
||||
|
||||
/**
|
||||
* Asset is the data on the disk.
|
||||
* Resource is the data on the gpu/cpu
|
||||
*
|
||||
* eg. TextureAsset is the file on the disk
|
||||
* eg. Texture is the representation of it in the GPU
|
||||
*/
|
||||
class AssetManager
|
||||
{
|
||||
public:
|
||||
static void load_shader(
|
||||
const std::string &name,
|
||||
const std::filesystem::path &vertex_path,
|
||||
const std::filesystem::path &pixel_path
|
||||
)
|
||||
{
|
||||
instance().load_shader_impl(name, vertex_path, pixel_path);
|
||||
}
|
||||
|
||||
static void load_texture(const std::string &name, const std::filesystem::path &path)
|
||||
{
|
||||
instance().load_texture_impl(name, path);
|
||||
}
|
||||
|
||||
static auto get_shader(const std::string &name) -> Ref<Shader>
|
||||
{
|
||||
return instance().m_shaders[name];
|
||||
}
|
||||
|
||||
static auto get_texture(const std::string &name) -> Ref<Texture>
|
||||
{
|
||||
return instance().m_textures[name];
|
||||
}
|
||||
|
||||
private:
|
||||
AssetManager() = default;
|
||||
|
||||
static auto instance() -> AssetManager &;
|
||||
|
||||
void load_shader_impl(
|
||||
const std::string &name,
|
||||
const std::filesystem::path &vertex_path,
|
||||
const std::filesystem::path &pixel_path
|
||||
);
|
||||
|
||||
void load_texture_impl(const std::string &name, const std::filesystem::path &path);
|
||||
|
||||
auto get_or_load_text_asset(const std::filesystem::path &path) -> Ref<Assets::TextAsset>;
|
||||
|
||||
auto get_or_load_texture_asset(const std::filesystem::path &path) -> Ref<Assets::TextureAsset>;
|
||||
|
||||
std::unordered_map<std::string, Ref<Assets::TextAsset>> m_text_assets;
|
||||
|
||||
std::unordered_map<std::string, Ref<Assets::TextureAsset>> m_texture_assets;
|
||||
|
||||
std::unordered_map<std::string, Ref<Shader>> m_shaders;
|
||||
|
||||
std::unordered_map<std::string, Ref<Texture>> m_textures;
|
||||
};
|
||||
|
||||
} // namespace lt
|
|
@ -1,11 +0,0 @@
|
|||
add_library_module(asset_parser
|
||||
parser.cpp
|
||||
assets/texture.cpp
|
||||
assets/text.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
asset_parser
|
||||
PRIVATE LZ4::lz4_static
|
||||
PRIVATE logger
|
||||
)
|
|
@ -1,163 +0,0 @@
|
|||
#include <asset_parser/assets/text.hpp>
|
||||
#include <lz4.h>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
/* static */ void TextAsset::pack(const PackageData &data, const std::filesystem::path &out_path)
|
||||
{
|
||||
const auto &[metadata, text_metadata, text] = data;
|
||||
|
||||
auto stream = std::ofstream { out_path, std::ios::binary | std::ios::trunc };
|
||||
if (!stream.is_open())
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to open ofstream for packing Text at: {}", out_path.string())
|
||||
};
|
||||
}
|
||||
stream.seekp(0);
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
stream.write((char *)¤t_version, sizeof(current_version));
|
||||
stream.write((char *)&metadata, sizeof(metadata));
|
||||
stream.write((char *)&text_metadata, sizeof(text_metadata));
|
||||
|
||||
constexpr auto number_of_blobs = uint32_t { 1 };
|
||||
stream.write((char *)&number_of_blobs, sizeof(number_of_blobs));
|
||||
|
||||
auto textblob_metadata = BlobMetadata {
|
||||
.tag = BlobMetadata::Tag::text,
|
||||
.offset = static_cast<size_t>(stream.tellp()) + sizeof(BlobMetadata),
|
||||
.compression_type = CompressionType::None,
|
||||
.compressed_size = text.size(),
|
||||
.uncompressed_size = text.size(),
|
||||
};
|
||||
|
||||
stream.write((char *)&textblob_metadata, sizeof(textblob_metadata));
|
||||
stream.write((char *)text.data(), static_cast<long>(text.size()));
|
||||
// NOLINTEND(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
}
|
||||
|
||||
TextAsset::TextAsset(const std::filesystem::path &path)
|
||||
{
|
||||
m_stream = std::ifstream { path, std::ios::binary };
|
||||
if (!m_stream.is_open())
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to open ifstream for loading Text asset at: {}", path.string())
|
||||
};
|
||||
}
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
m_stream.read((char *)&version, sizeof(version));
|
||||
m_stream.read((char *)&m_asset_metadata, sizeof(m_asset_metadata));
|
||||
m_stream.read((char *)&m_metadata, sizeof(m_metadata));
|
||||
|
||||
auto num_blobs = uint32_t {};
|
||||
m_stream.read((char *)&num_blobs, sizeof(num_blobs));
|
||||
if (num_blobs != 1)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to load Text asset: invalid number of blobs: {}", num_blobs)
|
||||
};
|
||||
}
|
||||
|
||||
m_stream.read((char *)&m_text_blob_metadata, sizeof(m_text_blob_metadata));
|
||||
if (m_text_blob_metadata.tag != BlobMetadata::Tag::text)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format(
|
||||
"Failed to load Text asset: invalid blob tag, expected {}, got {}",
|
||||
std::to_underlying(BlobMetadata::Tag::text),
|
||||
std::to_underlying(m_text_blob_metadata.tag)
|
||||
),
|
||||
};
|
||||
}
|
||||
// NOLINTEND(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
}
|
||||
|
||||
void TextAsset::unpack_blob(
|
||||
BlobMetadata::Tag tag,
|
||||
std::byte *destination,
|
||||
size_t destination_capacity
|
||||
) const
|
||||
{
|
||||
if (tag != BlobMetadata::Tag::text)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Invalid tag for unpack_blob of TextAsset: {}", std::to_underlying(tag))
|
||||
};
|
||||
}
|
||||
|
||||
m_stream.seekg(static_cast<long>(m_text_blob_metadata.offset));
|
||||
switch (m_text_blob_metadata.compression_type)
|
||||
{
|
||||
case Assets::CompressionType::None:
|
||||
if (m_text_blob_metadata.uncompressed_size != m_text_blob_metadata.compressed_size)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Failed to unpack blob from TextAsset: "
|
||||
"compressed/uncompressed size mismatch for no compression "
|
||||
"type"
|
||||
);
|
||||
}
|
||||
|
||||
if (m_text_blob_metadata.uncompressed_size > destination_capacity)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Failed to unpack blob from TextAsset: "
|
||||
"uncompressed_size > destination_capacity, unpacking "
|
||||
"would result in segfault"
|
||||
);
|
||||
}
|
||||
|
||||
if (!m_stream.is_open())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Failed to unpack blob from TextAsset: ifstream is "
|
||||
"closed"
|
||||
);
|
||||
}
|
||||
|
||||
m_stream.read(
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
(char *)destination,
|
||||
static_cast<long>(m_text_blob_metadata.uncompressed_size)
|
||||
);
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
throw std::runtime_error(
|
||||
std::format(
|
||||
"Failed to unpack blob from TextAsset: unsupported "
|
||||
"compression type: {}",
|
||||
std::to_underlying(m_text_blob_metadata.compression_type)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] auto TextAsset::get_asset_metadata() const -> const Asset::Metadata &
|
||||
{
|
||||
return m_asset_metadata;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto TextAsset::get_metadata() const -> const Metadata &
|
||||
{
|
||||
return m_metadata;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto TextAsset::get_blob_metadata(BlobMetadata::Tag tag) const -> const BlobMetadata &
|
||||
{
|
||||
if (tag != BlobMetadata::Tag::text)
|
||||
{
|
||||
throw std::runtime_error { std::format(
|
||||
"Invalid tag for get_blob_metadata of TextAsset: {}",
|
||||
std::to_underlying(tag)
|
||||
) };
|
||||
}
|
||||
|
||||
return m_text_blob_metadata;
|
||||
}
|
||||
|
||||
} // namespace Assets
|
|
@ -1,165 +0,0 @@
|
|||
#include <asset_parser/assets/texture.hpp>
|
||||
#include <lz4.h>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
/* static */ void TextureAsset::pack(const PackageData &data, const std::filesystem::path &out_path)
|
||||
{
|
||||
const auto &[metadata, texture_metadata, pixels] = data;
|
||||
|
||||
auto stream = std::ofstream { out_path, std::ios::binary | std::ios::trunc };
|
||||
if (!stream.is_open())
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to open ofstream for packing texture at: {}", out_path.string())
|
||||
};
|
||||
}
|
||||
stream.seekp(0);
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
stream.write((char *)¤t_version, sizeof(current_version));
|
||||
|
||||
stream.write((char *)&metadata, sizeof(metadata));
|
||||
stream.write((char *)&texture_metadata, sizeof(texture_metadata));
|
||||
|
||||
constexpr auto number_of_blobs = uint32_t { 1 };
|
||||
stream.write((char *)&number_of_blobs, sizeof(number_of_blobs));
|
||||
|
||||
auto pixels_metadata = BlobMetadata {
|
||||
.tag = BlobMetadata::Tag::color,
|
||||
.offset = static_cast<size_t>(stream.tellp()) + sizeof(BlobMetadata),
|
||||
.compression_type = CompressionType::None,
|
||||
.compressed_size = pixels.size(),
|
||||
.uncompressed_size = pixels.size(),
|
||||
};
|
||||
|
||||
stream.write((char *)&pixels_metadata, sizeof(pixels_metadata));
|
||||
stream.write((char *)&pixels[0], static_cast<long>(pixels.size()));
|
||||
// NOLINTEND(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
}
|
||||
|
||||
TextureAsset::TextureAsset(const std::filesystem::path &path)
|
||||
{
|
||||
m_stream = std::ifstream { path, std::ios::binary };
|
||||
if (!m_stream.is_open())
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to open ifstream for loading texture asset at: {}", path.string())
|
||||
};
|
||||
}
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
m_stream.read((char *)&version, sizeof(version));
|
||||
m_stream.read((char *)&m_asset_metadata, sizeof(m_asset_metadata));
|
||||
m_stream.read((char *)&m_metadata, sizeof(m_metadata));
|
||||
|
||||
auto num_blobs = uint32_t {};
|
||||
m_stream.read((char *)&num_blobs, sizeof(num_blobs));
|
||||
if (num_blobs != 1)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Failed to load texture asset: invalid number of blobs: {}", num_blobs)
|
||||
};
|
||||
}
|
||||
|
||||
m_stream.read((char *)&m_pixel_blob_metadata, sizeof(m_pixel_blob_metadata));
|
||||
if (m_pixel_blob_metadata.tag != BlobMetadata::Tag::color)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format(
|
||||
"Failed to load texture asset: invalid blob tag, expected {}, got {}",
|
||||
std::to_underlying(BlobMetadata::Tag::color),
|
||||
std::to_underlying(m_pixel_blob_metadata.tag)
|
||||
),
|
||||
};
|
||||
}
|
||||
// NOLINTEND(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
}
|
||||
|
||||
void TextureAsset::unpack_blob(
|
||||
BlobMetadata::Tag tag,
|
||||
std::byte *destination,
|
||||
size_t destination_capacity
|
||||
)
|
||||
{
|
||||
if (tag != BlobMetadata::Tag::color)
|
||||
{
|
||||
throw std::runtime_error {
|
||||
std::format("Invalid tag for unpack_blob of TextureAsset: {}", std::to_underlying(tag))
|
||||
};
|
||||
}
|
||||
|
||||
m_stream.seekg(static_cast<long>(m_pixel_blob_metadata.offset));
|
||||
switch (m_pixel_blob_metadata.compression_type)
|
||||
{
|
||||
case Assets::CompressionType::None:
|
||||
if (m_pixel_blob_metadata.uncompressed_size != m_pixel_blob_metadata.compressed_size)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Failed to unpack blob from TextureAsset: "
|
||||
"compressed/uncompressed size mismatch for no compression "
|
||||
"type"
|
||||
);
|
||||
}
|
||||
|
||||
if (m_pixel_blob_metadata.uncompressed_size > destination_capacity)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Failed to unpack blob from TextureAsset: "
|
||||
"uncompressed_size > destination_capacity, unpacking "
|
||||
"would result in segfault"
|
||||
);
|
||||
}
|
||||
|
||||
if (!m_stream.is_open())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Failed to unpack blob from TextureAsset: ifstream is "
|
||||
"closed"
|
||||
);
|
||||
}
|
||||
|
||||
m_stream.read(
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
(char *)destination,
|
||||
static_cast<long>(m_pixel_blob_metadata.uncompressed_size)
|
||||
);
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
throw std::runtime_error(
|
||||
std::format(
|
||||
"Failed to unpack blob from TextureAsset: unsupported "
|
||||
"compression type: {}",
|
||||
std::to_underlying(m_pixel_blob_metadata.compression_type)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] auto TextureAsset::get_asset_metadata() const -> const Asset::Metadata &
|
||||
{
|
||||
return m_asset_metadata;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto TextureAsset::get_metadata() const -> const Metadata &
|
||||
{
|
||||
return m_metadata;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto TextureAsset::get_blob_metadata(BlobMetadata::Tag tag) const
|
||||
-> const BlobMetadata &
|
||||
{
|
||||
if (tag != BlobMetadata::Tag::color)
|
||||
{
|
||||
throw std::runtime_error { std::format(
|
||||
"Invalid tag for get_blob_metadata of TextureAsset: {}",
|
||||
std::to_underlying(tag)
|
||||
) };
|
||||
}
|
||||
|
||||
return m_pixel_blob_metadata;
|
||||
}
|
||||
|
||||
} // namespace Assets
|
|
@ -1,62 +0,0 @@
|
|||
#include <asset_parser/parser.hpp>
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
// void Asset::unpack(std::byte *destination)
|
||||
// {
|
||||
// if (!m_stream.is_open())
|
||||
// {
|
||||
// throw std::logic_error {
|
||||
// "Failed to unpack asset: "
|
||||
// "ifstream is closed",
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// switch (m_metadata.blob_compression_type)
|
||||
// {
|
||||
// case CompressionType::None:
|
||||
// if (m_metadata.packed_size != m_metadata.unpacked_size)
|
||||
// {
|
||||
// throw std::logic_error {
|
||||
// "Failed to unpack asset: "
|
||||
// "compression type set to none but packed/unpacked sizes differ",
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// m_stream.read(
|
||||
// std::bit_cast<char *>(destination),
|
||||
// static_cast<long>(m_metadata.packed_size)
|
||||
// );
|
||||
// m_stream.close();
|
||||
//
|
||||
// case CompressionType::LZ4:
|
||||
// m_stream.close();
|
||||
// throw std::logic_error {
|
||||
// "Failed to unpack asset: "
|
||||
// "LZ4 compression is not implemented yet",
|
||||
// };
|
||||
//
|
||||
//
|
||||
// case CompressionType::LZ4HC:
|
||||
// m_stream.close();
|
||||
// throw std::logic_error {
|
||||
// "Failed to unpack asset: "
|
||||
// "LZ4HC compression is not implemented yet",
|
||||
// };
|
||||
//
|
||||
// default:
|
||||
// m_stream.close();
|
||||
// throw std::logic_error {
|
||||
// std::format(
|
||||
// "Failed to unpack asset: "
|
||||
// "Compression type was not recognized: {}",
|
||||
// std::to_underlying(m_metadata.blob_compression_type)
|
||||
// ),
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
} // namespace Assets
|
|
@ -1,58 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <asset_parser/compressors/compressors.hpp>
|
||||
#include <asset_parser/parser.hpp>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <logger/logger.hpp>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
class TextAsset: public Asset
|
||||
{
|
||||
public:
|
||||
struct Metadata
|
||||
{
|
||||
uint32_t lines {};
|
||||
};
|
||||
|
||||
/** Data required to pack a text asset */
|
||||
struct PackageData
|
||||
{
|
||||
Asset::Metadata metadata;
|
||||
|
||||
Metadata text_metadata;
|
||||
|
||||
Blob text_blob;
|
||||
};
|
||||
|
||||
static void pack(const PackageData &data, const std::filesystem::path &out_path);
|
||||
|
||||
TextAsset(const std::filesystem::path &path);
|
||||
|
||||
void unpack_blob(
|
||||
BlobMetadata::Tag tag,
|
||||
std::byte *destination,
|
||||
size_t destination_capacity
|
||||
) const;
|
||||
|
||||
[[nodiscard]] auto get_asset_metadata() const -> const Asset::Metadata &;
|
||||
|
||||
[[nodiscard]] auto get_metadata() const -> const Metadata &;
|
||||
|
||||
[[nodiscard]] auto get_blob_metadata(BlobMetadata::Tag tag) const -> const BlobMetadata &;
|
||||
|
||||
private:
|
||||
uint32_t version {};
|
||||
|
||||
Asset::Metadata m_asset_metadata {};
|
||||
|
||||
Metadata m_metadata {};
|
||||
|
||||
BlobMetadata m_text_blob_metadata {};
|
||||
|
||||
mutable std::ifstream m_stream;
|
||||
};
|
||||
|
||||
} // namespace Assets
|
|
@ -1,64 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <asset_parser/compressors/compressors.hpp>
|
||||
#include <asset_parser/parser.hpp>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <logger/logger.hpp>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
class TextureAsset: public Asset
|
||||
{
|
||||
public:
|
||||
enum class Format : uint32_t // NOLINT(performance-enum-size)
|
||||
{
|
||||
None = 0,
|
||||
RGBA8,
|
||||
};
|
||||
|
||||
struct Metadata
|
||||
{
|
||||
Format format;
|
||||
|
||||
uint32_t num_components;
|
||||
|
||||
std::array<uint32_t, 3> pixel_size;
|
||||
};
|
||||
|
||||
/** Data required to pack a texture asset */
|
||||
struct PackageData
|
||||
{
|
||||
Asset::Metadata metadata;
|
||||
|
||||
Metadata texture_metadata;
|
||||
|
||||
Blob pixels;
|
||||
};
|
||||
|
||||
static void pack(const PackageData &data, const std::filesystem::path &out_path);
|
||||
|
||||
TextureAsset(const std::filesystem::path &path);
|
||||
|
||||
void unpack_blob(BlobMetadata::Tag tag, std::byte *destination, size_t destination_capacity);
|
||||
|
||||
[[nodiscard]] auto get_asset_metadata() const -> const Asset::Metadata &;
|
||||
|
||||
[[nodiscard]] auto get_metadata() const -> const Metadata &;
|
||||
|
||||
[[nodiscard]] auto get_blob_metadata(BlobMetadata::Tag tag) const -> const BlobMetadata &;
|
||||
|
||||
private:
|
||||
uint32_t version {};
|
||||
|
||||
Asset::Metadata m_asset_metadata {};
|
||||
|
||||
Metadata m_metadata {};
|
||||
|
||||
BlobMetadata m_pixel_blob_metadata {};
|
||||
|
||||
std::ifstream m_stream;
|
||||
};
|
||||
|
||||
} // namespace Assets
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
enum class CompressionType : uint32_t // NOLINT(performance-enum-size)
|
||||
{
|
||||
None,
|
||||
LZ4,
|
||||
LZ4HC,
|
||||
};
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <asset_parser/compressors/compressors.hpp>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <logger/logger.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Assets {
|
||||
|
||||
constexpr auto current_version = uint32_t { 1 };
|
||||
|
||||
struct BlobMetadata
|
||||
{
|
||||
enum class Tag : uint8_t
|
||||
{
|
||||
text,
|
||||
color,
|
||||
depth,
|
||||
vertices,
|
||||
indices,
|
||||
};
|
||||
|
||||
Tag tag;
|
||||
|
||||
size_t offset;
|
||||
|
||||
CompressionType compression_type;
|
||||
|
||||
size_t compressed_size;
|
||||
|
||||
size_t uncompressed_size;
|
||||
};
|
||||
|
||||
|
||||
using Blob = std::vector<std::byte>;
|
||||
|
||||
class Asset
|
||||
{
|
||||
public:
|
||||
enum class Type : uint32_t // NOLINT(performance-enum-size)
|
||||
{
|
||||
None,
|
||||
Texture,
|
||||
Text,
|
||||
Mesh,
|
||||
Material,
|
||||
};
|
||||
|
||||
struct Metadata
|
||||
{
|
||||
Type type;
|
||||
};
|
||||
|
||||
Asset() = default;
|
||||
|
||||
/** Directly unpacks from disk to the destination.
|
||||
*
|
||||
* @note The destination MUST have at least blob_metadata.unpacked_size bytes available for
|
||||
* writing, otherwise segfault could occur!
|
||||
*/
|
||||
void unpack_blob(BlobMetadata::Tag blob_tag, std::byte *destination);
|
||||
};
|
||||
|
||||
|
||||
} // namespace Assets
|
|
@ -1,2 +0,0 @@
|
|||
add_library_module(base)
|
||||
target_precompile_headers(base INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/private/pch.hpp)
|
|
@ -1,36 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <base/base.hpp>
|
||||
|
||||
/* windows */
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#undef NOMINMAX
|
||||
#endif
|
||||
|
||||
/** Stdlib */
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <bitset>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <math.h>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <span>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <time.h>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
|
@ -1,91 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace lt {
|
||||
|
||||
// Ref (Ref)
|
||||
template<typename t>
|
||||
using Ref = std::shared_ptr<t>;
|
||||
|
||||
template<typename t, typename... Args>
|
||||
constexpr Ref<t> create_ref(Args &&...args)
|
||||
{
|
||||
return std::make_shared<t>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename t>
|
||||
constexpr Ref<t> make_ref(t *rawPointer)
|
||||
{
|
||||
return std::shared_ptr<t>(rawPointer);
|
||||
}
|
||||
|
||||
// Scope (std::unique_ptr)
|
||||
template<typename t>
|
||||
using Scope = std::unique_ptr<t>;
|
||||
|
||||
template<typename t, typename... Args>
|
||||
constexpr std::unique_ptr<t> create_scope(Args &&...args)
|
||||
{
|
||||
return std::make_unique<t>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename t>
|
||||
constexpr std::unique_ptr<t> make_scope(t *rawPointer)
|
||||
{
|
||||
return std::unique_ptr<t>(rawPointer);
|
||||
}
|
||||
|
||||
} // namespace lt
|
||||
|
||||
#define lt_win(x) // windows
|
||||
#define lt_lin(x) // linux
|
||||
#define lt_mac(x) // mac
|
||||
|
||||
enum class Platform : uint8_t
|
||||
{
|
||||
windows,
|
||||
|
||||
/** Named like so because "linux" is a built-in identifier. */
|
||||
gnu,
|
||||
|
||||
mac,
|
||||
};
|
||||
|
||||
namespace constants {
|
||||
|
||||
#if defined(LIGHT_PLATFORM_WINDOWS)
|
||||
#define lt_win(x)
|
||||
constexpr auto platform = Platform::windows;
|
||||
constexpr auto platform_name = "windows";
|
||||
|
||||
#undef LIGHT_PLATFORM_WINDOWS
|
||||
|
||||
#elif defined(LIGHT_PLATFORM_LINUX)
|
||||
#define lt_lin(x) x
|
||||
constexpr auto platform = Platform::gnu;
|
||||
constexpr auto platform_name = "linux";
|
||||
|
||||
#elif defined(LIGHT_PLATFORM_MAC)
|
||||
#define lt_mac(x) x
|
||||
constexpr auto platform = Platform::mac;
|
||||
constexpr auto platform_name = "mac";
|
||||
|
||||
#else
|
||||
#error "Unsupported platform: Unknown"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace constants
|
||||
|
||||
/* bit-wise */
|
||||
constexpr auto bit(auto x)
|
||||
{
|
||||
return 1 << x;
|
||||
}
|
||||
|
||||
/* token */
|
||||
#define lt_pair_token_value_to_name(token) { token, #token }
|
||||
#define lt_pair_token_name_to_value(token) { #token, token }
|
||||
#define lt_token_name(token) #token
|
|
@ -1,3 +0,0 @@
|
|||
add_library_module(camera camera.cpp scene.cpp)
|
||||
|
||||
target_link_libraries(camera PUBLIC math)
|
|
@ -1,6 +0,0 @@
|
|||
#include <camera/camera.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
#include <camera/scene.hpp>
|
||||
#include <math/algebra.hpp>
|
||||
#include <math/trig.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
SceneCamera::SceneCamera()
|
||||
: m_orthographic_specification { .size = 1000.0f, .near_plane = -1.0f, .far_plane = 10000.0f }
|
||||
, m_perspective_specification { .vertical_fov = math::radians(45.0f),
|
||||
.near_plane = 0.01f,
|
||||
.far_plane = 10000.0f }
|
||||
, m_aspect_ratio(16.0f / 9.0f)
|
||||
|
||||
{
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_viewport_size(unsigned int width, unsigned int height)
|
||||
{
|
||||
m_aspect_ratio = static_cast<float>(width) / static_cast<float>(height);
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_projection_type(ProjectionType projection_type)
|
||||
{
|
||||
m_projection_type = projection_type;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_orthographic_size(float size)
|
||||
{
|
||||
m_orthographic_specification.size = size;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_orthographic_far_plane(float far_plane)
|
||||
{
|
||||
m_orthographic_specification.far_plane = far_plane;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_orthographic_near_plane(float near_plane)
|
||||
{
|
||||
m_orthographic_specification.near_plane = near_plane;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_perspective_vertical_fov(float vertical_fov)
|
||||
{
|
||||
m_perspective_specification.vertical_fov = vertical_fov;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_perspective_far_plane(float far_plane)
|
||||
{
|
||||
m_perspective_specification.far_plane = far_plane;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::set_perspective_near_plane(float near_plane)
|
||||
{
|
||||
m_perspective_specification.near_plane = near_plane;
|
||||
calculate_projection();
|
||||
}
|
||||
|
||||
void SceneCamera::calculate_projection()
|
||||
{
|
||||
// TODO(Light): implement ortho perspective
|
||||
if (m_projection_type == ProjectionType::Orthographic)
|
||||
{
|
||||
// throw std::runtime_error { "ortho perspective not supported yet" };
|
||||
}
|
||||
|
||||
// defaults to perspective for now...
|
||||
m_projection = math::perspective(
|
||||
m_perspective_specification.vertical_fov,
|
||||
m_aspect_ratio,
|
||||
m_perspective_specification.near_plane,
|
||||
m_perspective_specification.far_plane
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace lt
|
|
@ -1,35 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <math/mat4.hpp>
|
||||
#include <math/vec4.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
Camera() = default;
|
||||
|
||||
[[nodiscard]] auto get_projection() const -> const math::mat4 &
|
||||
{
|
||||
return m_projection;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_background_color() const -> const math::vec4 &
|
||||
{
|
||||
return m_background_color;
|
||||
}
|
||||
|
||||
void set_background_color(const math::vec4 &color)
|
||||
{
|
||||
m_background_color = color;
|
||||
}
|
||||
|
||||
protected:
|
||||
math::mat4 m_projection;
|
||||
|
||||
private:
|
||||
math::vec4 m_background_color = math::vec4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
};
|
||||
|
||||
} // namespace lt
|
|
@ -1,29 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <camera/scene.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
struct CameraComponent
|
||||
{
|
||||
CameraComponent() = default;
|
||||
|
||||
CameraComponent(const CameraComponent &) = default;
|
||||
|
||||
CameraComponent(SceneCamera _camera, bool _isPrimary = false)
|
||||
: camera(_camera)
|
||||
, isPrimary(_isPrimary)
|
||||
{
|
||||
}
|
||||
|
||||
operator SceneCamera() const
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
|
||||
SceneCamera camera;
|
||||
|
||||
bool isPrimary {};
|
||||
};
|
||||
|
||||
} // namespace lt
|
|
@ -1,100 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <camera/camera.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
class SceneCamera: public Camera
|
||||
{
|
||||
public:
|
||||
enum class ProjectionType
|
||||
{
|
||||
Orthographic = 0,
|
||||
Perspetcive = 1
|
||||
};
|
||||
|
||||
struct OrthographicSpecification
|
||||
{
|
||||
float size;
|
||||
|
||||
float near_plane;
|
||||
|
||||
float far_plane;
|
||||
};
|
||||
|
||||
struct PerspectiveSpecification
|
||||
{
|
||||
float vertical_fov;
|
||||
|
||||
float near_plane;
|
||||
|
||||
float far_plane;
|
||||
};
|
||||
|
||||
SceneCamera();
|
||||
|
||||
void set_viewport_size(unsigned int width, unsigned int height);
|
||||
|
||||
void set_projection_type(ProjectionType projection_type);
|
||||
|
||||
void set_orthographic_size(float size);
|
||||
|
||||
void set_orthographic_far_plane(float far_plane);
|
||||
|
||||
void set_orthographic_near_plane(float near_plane);
|
||||
|
||||
void set_perspective_vertical_fov(float vertical_fov);
|
||||
|
||||
void set_perspective_far_plane(float far_plane);
|
||||
|
||||
void set_perspective_near_plane(float near_plane);
|
||||
|
||||
[[nodiscard]] auto get_orthographic_size() const -> float
|
||||
{
|
||||
return m_orthographic_specification.size;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_orthographic_far_plane() const -> float
|
||||
{
|
||||
return m_orthographic_specification.far_plane;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_orthographic_near_plane() const -> float
|
||||
{
|
||||
return m_orthographic_specification.near_plane;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_perspective_vertical_fov() const -> float
|
||||
{
|
||||
return m_perspective_specification.vertical_fov;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_perspective_far_plane() const -> float
|
||||
{
|
||||
return m_perspective_specification.far_plane;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_perspective_near_plane() const -> float
|
||||
{
|
||||
return m_perspective_specification.near_plane;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_projection_type() const -> ProjectionType
|
||||
{
|
||||
return m_projection_type;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
OrthographicSpecification m_orthographic_specification;
|
||||
|
||||
PerspectiveSpecification m_perspective_specification;
|
||||
|
||||
float m_aspect_ratio;
|
||||
|
||||
ProjectionType m_projection_type { ProjectionType::Orthographic };
|
||||
|
||||
void calculate_projection();
|
||||
};
|
||||
|
||||
} // namespace lt
|
|
@ -1,3 +0,0 @@
|
|||
add_library_module(lt_debug instrumentor.cpp)
|
||||
target_link_libraries(lt_debug PUBLIC logger)
|
||||
target_precompile_headers(lt_debug PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/private/pch.hpp)
|
|
@ -1,71 +0,0 @@
|
|||
#include <logger/logger.hpp>
|
||||
#include <lt_debug/instrumentor.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
||||
void Instrumentor::begin_session_impl(const std::string &outputPath)
|
||||
{
|
||||
std::filesystem::create_directory(outputPath.substr(0, outputPath.find_last_of('/') + 1));
|
||||
|
||||
m_output_file_stream.open(outputPath);
|
||||
m_output_file_stream << "{\"traceEvents\":[";
|
||||
}
|
||||
|
||||
void Instrumentor::end_session_impl()
|
||||
{
|
||||
if (m_current_session_count == 0u)
|
||||
{
|
||||
log_wrn("0 profiling for the ended session");
|
||||
}
|
||||
|
||||
m_current_session_count = 0u;
|
||||
|
||||
m_output_file_stream << "]}";
|
||||
m_output_file_stream.flush();
|
||||
m_output_file_stream.close();
|
||||
}
|
||||
|
||||
void Instrumentor::submit_scope_profile_impl(const ScopeProfileResult &profileResult)
|
||||
{
|
||||
if (m_current_session_count++ == 0u)
|
||||
{
|
||||
m_output_file_stream << "{";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_output_file_stream << ",{";
|
||||
}
|
||||
|
||||
m_output_file_stream << R"("name":")" << profileResult.name << "\",";
|
||||
m_output_file_stream << R"("cat": "scope",)";
|
||||
m_output_file_stream << R"("ph": "X",)";
|
||||
m_output_file_stream << "\"ts\":" << profileResult.start << ",";
|
||||
m_output_file_stream << "\"dur\":" << profileResult.duration << ",";
|
||||
m_output_file_stream << "\"pid\":0,";
|
||||
m_output_file_stream << "\"tid\":" << profileResult.threadID << "";
|
||||
m_output_file_stream << "}";
|
||||
}
|
||||
|
||||
InstrumentorTimer::InstrumentorTimer(const std::string &scopeName)
|
||||
: m_result({ .name = scopeName, .start = 0, .duration = 0, .threadID = 0 })
|
||||
, m_start(std::chrono::steady_clock::now())
|
||||
{
|
||||
}
|
||||
|
||||
InstrumentorTimer::~InstrumentorTimer()
|
||||
{
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
|
||||
m_result.start = std::chrono::time_point_cast<std::chrono::microseconds>(m_start)
|
||||
.time_since_epoch()
|
||||
.count();
|
||||
|
||||
m_result.duration = std::chrono::time_point_cast<std::chrono::microseconds>(end)
|
||||
.time_since_epoch()
|
||||
.count()
|
||||
- m_result.start;
|
||||
|
||||
Instrumentor::submit_scope_profile(m_result);
|
||||
}
|
||||
|
||||
} // namespace lt
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue