-
Notifications
You must be signed in to change notification settings - Fork 33
Project structure
##Folder structure
Papaya's code is present in the src
folder in the project folder, while the build scripts are present in the build
folder.
##Code structure
Code is split into the following logical units:
###Platform This is the unit that is responsible for most of the platform-specific code such as Window handling, OpenGL context creation, and other interactions with the operating system.
The papaya_platform.h
file contains the declarations of the platform-specific functions that each target platform has to implement. The papaya_platform_linux.cpp
and papaya_platform_win32.cpp
files contain the actual definitions of those functions on the respective platforms. On any given target operating system, only its own platform cpp file is compiled. This platform cpp file also contains the main()
function, which is the entry point for Papaya.
###Core The Core is responsible for the platform-independent application logic. This includes Papaya-specific OpenGL shaders, UI and other interaction logic.
The interface between the Platform and the Core is the application-platform separation boundary. In other words, the Core remains the same regardless of which operating system you are compiling for. This separation is what makes Papaya portable across different platforms. The bulk of the Core is located in the src/papaya_core.cpp
file.
The Core contains further units which are separated for readability. For instance, the code relating to the color-picker is located in the picker.h/.cpp
files, and the logic for storing and displaying preferences is located in the prefs.h/.cpp
files All of these sub-units are present in the src/core
folder.
###Libs
This is a collection of libraries that Papaya uses. We use a bunch of single-header libraries, which are collectively compiled in the single_header_libs.cpp
file. Other compilation units selectively include the headers of these libraries individually as required. Larger libraries like imgui or glew are placed in their own folder and are compiled as their own compilation unit. All of the library code is present in the src/lib
folder.
Papaya is written in C++, but without object-oriented programming. Namespaces and C++ enums are used wherever appropriate. Sparse contiguous memory allocations are preferred over frequent smaller allocations. Have a look at the code to get a general idea of naming conventions. Inlined scopes with comments on top are preferred for their linear flow and readability.