Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Jan 18, 2025
1 parent 3fce1f7 commit 792d29b
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 89 deletions.
17 changes: 17 additions & 0 deletions Docs/Namespaces.dox
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ See also @ref third-party for the licenses of the libraries used.
Afterwards, it removes the definitions that cause the most collisions using @cpp #undef @ce.
*/

/** @dir Shared/Base
@brief Basic utilities for memory management and type information
*/

/** @dir Shared/Containers
@brief Namespace @ref Death::Containers, @ref Death::Containers::Literals
*/
Expand All @@ -90,9 +94,22 @@ See also @ref third-party for the licenses of the libraries used.

Literals for easy construction of string views.
*/
/** @file Shared/Containers/StringUtils.h
@brief Namespace @ref Death::Containers::StringUtils
*/
/** @namespace Death::Containers::StringUtils
@brief String utilities
*/
/** @file Shared/Containers/Tags.h
@brief Tag @ref Death::Containers::DefaultInit, @ref Death::Containers::ValueInit, @ref Death::Containers::NoInit, @ref Death::Containers::NoCreate, @ref Death::Containers::DirectInit, @ref Death::Containers::InPlaceInit
*/

/** @dir Shared/Core
@brief Namespace @ref Death::Backward, @ref Death::Trace
*/
/** @namespace Death::Backward
@brief Exception handling implementation
*/

/** @namespace Death::Cpu
@brief Compile-time and runtime CPU instruction set detection and dispatch
Expand Down
6 changes: 5 additions & 1 deletion Sources/Shared/Containers/SequenceHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#ifndef DOXYGEN_GENERATING_OUTPUT

#include "../Common.h"

namespace Death { namespace Containers { namespace Implementation {
Expand All @@ -41,4 +43,6 @@ namespace Death { namespace Containers { namespace Implementation {
template<> struct GenerateSequence<1> { typedef Sequence<0> Type; };
template<> struct GenerateSequence<0> { typedef Sequence<> Type; };

}}}
}}}

#endif
8 changes: 4 additions & 4 deletions Sources/Shared/Containers/SmallVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Death { namespace Containers {
void* BeginX;
Size_T Size = 0, Capacity;

/** @brief The maximum value of the `Size_T` used */
/** @brief Maximum value of the `Size_T` used */
static constexpr std::size_t SizeTypeMax() {
return std::numeric_limits<Size_T>::max();
}
Expand Down Expand Up @@ -71,10 +71,10 @@ namespace Death { namespace Containers {
}
};

#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
using SmallVectorSizeType = typename std::conditional<sizeof(T) < 4 && sizeof(void*) >= 8, std::uint64_t, std::uint32_t>::type;

#ifndef DOXYGEN_GENERATING_OUTPUT

/** @brief Figure out the offset of the first element */
template<class T, typename = void> struct SmallVectorAlignmentAndSize {
alignas(SmallVectorBase<SmallVectorSizeType<T>>) char Base[sizeof(
Expand Down Expand Up @@ -1111,7 +1111,6 @@ namespace Death { namespace Containers {

#ifndef DOXYGEN_GENERATING_OUTPUT
template<typename T> struct alignas(T) SmallVectorStorage<T, 0> {};
#endif

template<typename T, unsigned N> class SmallVector;

Expand Down Expand Up @@ -1162,6 +1161,7 @@ namespace Death { namespace Containers {
static constexpr std::size_t NumElementsThatFit = PreferredInlineBytes / sizeof(T);
static constexpr std::size_t value = (NumElementsThatFit == 0 ? 1 : NumElementsThatFit);
};
#endif

/**
@brief Memory-optimized vector
Expand Down
69 changes: 32 additions & 37 deletions Sources/nCine/AppConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,102 +9,97 @@ using namespace Death::Containers;

namespace nCine
{
/// Stores initialization settings for an nCine application
/** @brief Stores initialization settings for an nCine application */
class AppConfiguration
{
public:
/** @brief Specifies uninitialized window position coordinate */
static constexpr std::int32_t WindowPositionIgnore = INT32_MAX;

AppConfiguration();

// User configurable compile-time variables
/// Interval for frame timer accumulation average and log
/** @brief Interval for frame timer accumulation average and log */
float frameTimerLogInterval;

/// The screen resolution
/*! \note If either `x` or `y` are zero then the screen resolution will not be changed. */
/** @brief The screen resolution */
Vector2i resolution;

/// Window position coordinates in the virtual screen made of all the connected monitors
/*! \note It can also be used to go full screen on a monitor that is not the primary one of the system. */
/*! \note The `WindowPositionIgnore` value can be used in either or both dimensions when a specific position is not needed. */
/** @brief Window position coordinates in the virtual screen made of all the connected monitors */
Vector2i windowPosition;

/// Whether the screen is going to be in fullscreen mode
/** @brief Whether the screen is going to be in fullscreen mode */
bool fullscreen;
/// Whether the window is going to be resizable
/** @brief Whether the window is going to be resizable */
bool resizable;
/// Whether the window size is automatically scaled by the display factor
/** @brief Whether the window size is automatically scaled by the display factor */
bool windowScaling;
/// Maximum number of frames to render per second or 0 for no limit
/** @brief Maximum number of frames to render per second or 0 for no limit */
unsigned int frameLimit;

/// Window title
/** @brief Window title */
String windowTitle;
/// Window icon filename
/** @brief Window icon filename */
String windowIconFilename;

/// Whether mapping is used to update OpenGL buffers
/** @brief Whether mapping is used to update OpenGL buffers */
bool useBufferMapping;
/// Fixed size of render commands to be collected for batching on Emscripten and ANGLE
/*! \note Increasing this value too much might negatively affect batching shaders compilation time.
A value of zero restores the default behavior of non fixed size for batches. */
/** @brief Fixed size of render commands to be collected for batching on Emscripten and ANGLE */
unsigned int fixedBatchSize;
/// Path for the binary shaders cache (or empty to disable binary shader cache)
/*! \note Even if the path is set the functionality might still not be supported by the OpenGL context */
/** @brief Path for the binary shaders cache (or empty to disable binary shader cache) */
String shaderCachePath;

/// Maximum size in bytes for each VBO collecting geometry data
/** @brief Maximum size in bytes for each VBO collecting geometry data */
unsigned long vboSize;
/// Maximum size in bytes for each IBO collecting index data
/** @brief Maximum size in bytes for each IBO collecting index data */
unsigned long iboSize;
/// Maximum size for the pool of VAOs
/** @brief Maximum size for the pool of VAOs */
unsigned int vaoPoolSize;
/// Initial size for the pool of render commands
/** @brief Initial size for the pool of render commands */
unsigned int renderCommandPoolSize;

#if defined(WITH_IMGUI) || defined(DOXYGEN_GENERATING_OUTPUT)
/// Whether the debug overlay is enabled
/** @brief Whether the debug overlay is enabled */
bool withDebugOverlay;
#endif
/// Whether the audio subsystem is enabled
/** @brief Whether the audio subsystem is enabled */
bool withAudio;
/// Whether the threading subsystem is enabled
/** @brief Whether the threading subsystem is enabled */
bool withThreads;
/// Whether the scenegraph based rendering is enabled
/** @brief Whether the scenegraph based rendering is enabled */
bool withScenegraph;
/// Whether the vertical synchronization is enabled
/** @brief Whether the vertical synchronization is enabled */
bool withVSync;
/// Whether the OpenGL debug context is enabled
/** @brief Whether the OpenGL debug context is enabled */
bool withGlDebugContext;

/// Returns path for the application to load data from
/** @brief Returns path for the application to load data from */
const String& dataPath() const;
/// @overload
/** @overload */
String& dataPath();

/// Returns `true` if the OpenGL profile is going to be core
/** @brief Returns `true` if the OpenGL profile is going to be core */
inline bool glCoreProfile() const {
return glCoreProfile_;
}
/// Returns `true` if the OpenGL context is going to be forward compatible
/** @brief Returns `true` if the OpenGL context is going to be forward compatible */
inline bool glForwardCompatible() const {
return glForwardCompatible_;
}
/// Returns major version number of the OpenGL context
/** @brief Returns major version number of the OpenGL context */
inline unsigned int glMajorVersion() const {
return glMajorVersion_;
}
/// Returns minor version number of the OpenGL context
/** @brief Returns minor version number of the OpenGL context */
inline unsigned int glMinorVersion() const {
return glMinorVersion_;
}

/// Returns number of arguments passed on the command-line
/** @brief Returns number of arguments passed on the command-line */
inline std::size_t argc() const {
return argv_.size();
}
/// Returns selected argument from the ones passed on the command-line
/** @brief Returns selected argument from the ones passed on the command-line */
const StringView argv(int index) const;

private:
Expand Down
1 change: 1 addition & 0 deletions Sources/nCine/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace nCine
};
#endif

/** @brief Timings for profiling */
enum class Timings
{
PreInit,
Expand Down
2 changes: 1 addition & 1 deletion Sources/nCine/Base/Clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace nCine
#endif
}

uint64_t Clock::counter() const
std::uint64_t Clock::counter() const
{
#if defined(DEATH_TARGET_WINDOWS)
if (_hasPerfCounter) {
Expand Down
12 changes: 4 additions & 8 deletions Sources/nCine/Base/Clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ namespace nCine
class Clock
{
public:
inline uint64_t now() const {
inline std::uint64_t now() const {
return counter();
}

/// Returns current value of the counter
uint64_t counter() const;
std::uint64_t counter() const;

/// Returns the counter frequency in counts per second
inline uint32_t frequency() const {
inline std::uint32_t frequency() const {
return _frequency;
}

Expand All @@ -26,17 +26,13 @@ namespace nCine
#elif !defined(DEATH_TARGET_APPLE)
bool _hasMonotonicClock;
#endif
std::uint32_t _frequency;

/// Counter frequency in counts per second
uint32_t _frequency;

/// Private constructor
Clock();

friend Clock& clock();
};

// Meyers' Singleton
extern Clock& clock();

}
4 changes: 0 additions & 4 deletions Sources/nCine/Base/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ namespace nCine
/// Removes an object from the index and then destroys it
virtual ~Object() = 0;

/// Move constructor
Object(Object&& other) noexcept;
/// Move assignment operator
Object& operator=(Object&& other) noexcept;

/// Returns the object identification number
Expand All @@ -58,10 +56,8 @@ namespace nCine
private:
static std::uint32_t _lastId;

/// Object identification in the indexer
std::uint32_t _id;

/// Deleted assignment operator
Object& operator=(const Object&) = delete;
};

Expand Down
6 changes: 1 addition & 5 deletions Sources/nCine/Base/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ using namespace Death;

namespace nCine
{
/// PCG32 random number generator
/*!
* Based on the Apache License 2.0 code from pcg-random.org
*/
/// Random number generator
class RandomGenerator
{
public:
Expand Down Expand Up @@ -54,7 +51,6 @@ namespace nCine
std::uint64_t _increment;
};

// Meyers' Singleton
extern RandomGenerator& Random() noexcept;

}
4 changes: 2 additions & 2 deletions Sources/nCine/Base/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace nCine
private:
bool _isRunning;
/// Start time mark
uint64_t _startTime;
std::uint64_t _startTime;
/// Accumulated time ticks over multiple start and stop
uint64_t _accumulatedTime;
std::uint64_t _accumulatedTime;
};
}
25 changes: 11 additions & 14 deletions Sources/nCine/IAppEventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,31 @@ namespace nCine
class AppConfiguration;
class Viewport;

/// The interface class for handling nCine application events
/** @brief Interface for handling nCine application events */
class IAppEventHandler
{
public:
/// Pure virtual destructor in order to make the class abstract
virtual ~IAppEventHandler() = 0;

/// Called once before initialization to setup the application
/*! \warning At this stage it is only safe to modify the `config` object.
* No other engine API calls should be made. */
/** @brief Called once before initialization to setup the application */
virtual void OnPreInitialize(AppConfiguration& config) {}
/// Called once on application initialization
/** @brief Called once on application initialization */
virtual void OnInitialize() {}
/// Called at the start of each frame
/** @brief Called at the start of each frame */
virtual void OnBeginFrame() {}
/// Called every time the scenegraph has been traversed and all nodes have been transformed
/** @brief Called every time the scenegraph has been traversed and all nodes have been transformed */
virtual void OnPostUpdate() {}
/// Called every time a viewport is going to be drawn
/** @brief Called every time a viewport is going to be drawn */
virtual void OnDrawViewport(Viewport& viewport) {}
/// Called at the end of each frame, just before swapping buffers
/** @brief Called at the end of each frame, just before swapping buffers */
virtual void OnEndFrame() {}
/// Called every time the window is resized (by the system or the user)
/** @brief Called every time the window is resized (by the system or the user) */
virtual void OnResizeWindow(std::int32_t width, std::int32_t height) {}
/// Called once on application shutdown
/** @brief Called once on application shutdown */
virtual void OnShutdown() {}
/// Called every time the application needs to be suspended
/** @brief Called every time the application needs to be suspended */
virtual void OnSuspend() {}
/// Called every time the application resumes from suspension
/** @brief Called every time the application resumes from suspension */
virtual void OnResume() {}
};

Expand Down
2 changes: 2 additions & 0 deletions Sources/nCine/MainApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

namespace nCine
{
#ifndef DOXYGEN_GENERATING_OUTPUT
#if defined(DEATH_TARGET_WINDOWS)
typedef wchar_t* NativeArgument;
#else
typedef char* NativeArgument;
#endif
#endif

#if defined(WITH_QT5)
class Qt5Widget;
Expand Down
Loading

0 comments on commit 792d29b

Please sign in to comment.