summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-01-14 18:17:54 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-01-14 18:17:54 -0500
commit5a7b4a65a1d93744e4a5e6cc6df4244f61b81f68 (patch)
tree4b59cb1d6e513c1caefdc7e4c35955741bcfe206 /src
parent80a67230fe192287503092a3d256aea3a494409c (diff)
chore: fix compiler warnings + extra includes
Diffstat (limited to 'src')
-rw-r--r--src/arg-handler.cpp1
-rw-r--r--src/array.hpp16
-rw-r--r--src/asset-manager.cpp12
-rw-r--r--src/asset-manager.hpp2
-rw-r--r--src/camera.cpp27
-rw-r--r--src/camera.hpp9
-rw-r--r--src/components.hpp2
-rw-r--r--src/dynamic-array.hpp14
-rw-r--r--src/ecs.cpp9
-rw-r--r--src/ecs.hpp6
-rw-r--r--src/entities.cpp14
-rw-r--r--src/entities.hpp6
-rw-r--r--src/event.cpp10
-rw-r--r--src/event.hpp6
-rw-r--r--src/game.cpp33
-rw-r--r--src/game.hpp1
-rw-r--r--src/player-input.cpp74
-rw-r--r--src/player-input.hpp15
-rw-r--r--src/project-settings.hpp1
-rw-r--r--src/project.cpp15
-rw-r--r--src/project.hpp2
-rw-r--r--src/thread-pool.cpp5
-rw-r--r--src/thread-pool.hpp1
-rw-r--r--src/vendor-stb-image-include.c (renamed from src/vendor-stb-image-include.cpp)2
-rw-r--r--src/vendor-stb-image-include.h7
-rw-r--r--src/vendor-stb-image-include.hpp7
-rw-r--r--src/window.cpp117
-rw-r--r--src/window.hpp17
28 files changed, 212 insertions, 219 deletions
diff --git a/src/arg-handler.cpp b/src/arg-handler.cpp
index 3bd1ac3..24695fe 100644
--- a/src/arg-handler.cpp
+++ b/src/arg-handler.cpp
@@ -1,7 +1,6 @@
#include "arg-handler.hpp"
#include "game-settings.hpp"
-#include "level.hpp"
#include <cstdio>
#include <getopt.h>
diff --git a/src/array.hpp b/src/array.hpp
index a1fa69f..c8a9cb6 100644
--- a/src/array.hpp
+++ b/src/array.hpp
@@ -45,9 +45,21 @@ inline void PkeArray_Add(PkeArray_Base *arrIn, const D &val, struct pk_membucket
diff = arr->reserved - originalCount;
}
auto *newData = pk_new<D>(arr->reserved, bkt);
- memset(newData + (sizeof(D) * originalCount), 0xFF, sizeof(D) * diff);
+ if constexpr (std::is_trivial<D>::value) {
+ memset(newData + (sizeof(D) * originalCount), 0x00, sizeof(D) * diff);
+ } else {
+ for (int64_t i = originalCount; i < arr->reserved; ++i) {
+ newData[i] = {};
+ }
+ }
if (arr->data != nullptr && arr->data != CAFE_BABE(D)) {
- memcpy(newData, arr->data, sizeof(D) * originalCount);
+ if constexpr (std::is_trivial<D>::value) {
+ memcpy(newData, arr->data, sizeof(D) * originalCount);
+ } else {
+ for (int64_t i = 0; i < diff; ++i) {
+ newData[i] = arr->data[i];
+ }
+ }
pk_delete<D>(arr->data, originalCount, bkt);
}
arr->data = newData;
diff --git a/src/asset-manager.cpp b/src/asset-manager.cpp
index dbc74ca..b280361 100644
--- a/src/asset-manager.cpp
+++ b/src/asset-manager.cpp
@@ -4,7 +4,7 @@
#include "bucketed-array.hpp"
#include "thread-pool.hpp"
-#include <chrono>
+#include <cstring>
#include <filesystem>
#include <fstream>
#include <future>
@@ -46,14 +46,14 @@ void AM_Load_Task(Asset &asset) {
}
inline Asset *AM_Get_Inner(AssetKey key) {
- for (long b = 0; b <= Asset_BucketContainer.pkeHandle.bucketIndex; ++b) {
- uint64_t count = 0;
+ for (pk_handle_bucket_index_T b = 0; b <= Asset_BucketContainer.pkeHandle.bucketIndex; ++b) {
+ pk_handle_item_index_T count = 0;
if (b == Asset_BucketContainer.pkeHandle.bucketIndex) {
count = Asset_BucketContainer.pkeHandle.itemIndex;
} else {
count = maxAssetItemsPerBucket;
}
- for (long i = 0; i < count; ++i) {
+ for (pk_handle_item_index_T i = 0; i < count; ++i) {
if (strncmp(key, Asset_BucketContainer.buckets[b][i].key, 16) == 0) {
return &Asset_BucketContainer.buckets[b][i];
}
@@ -195,7 +195,7 @@ uint64_t AM_GetBucketCount() {
return Asset_BucketContainer.pkeHandle.bucketIndex + 1;
}
-Asset *AM_GetAssets(uint64_t bucketIndex, uint64_t &itemCount) {
+Asset *AM_GetAssets(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount) {
if (bucketIndex == Asset_BucketContainer.pkeHandle.bucketIndex) {
itemCount = Asset_BucketContainer.pkeHandle.itemIndex;
} else {
@@ -220,7 +220,7 @@ void AM_DebugPrint() {
if (asset.basePath != nullptr) {
printf("\tbasePath: %s\n", asset.basePath);
} else {
- printf("\tbasePath: %p\n", nullptr);
+ printf("\tbasePath: %p\n", (void *)nullptr);
}
printf("\tsize: %ld\n", asset.size);
printf("\tptr %p\n", asset.ptr);
diff --git a/src/asset-manager.hpp b/src/asset-manager.hpp
index 25ebffb..9129ceb 100644
--- a/src/asset-manager.hpp
+++ b/src/asset-manager.hpp
@@ -51,7 +51,7 @@ void AM_Release(AssetHandle assetHandle);
const Asset *AM_Get(AssetHandle assetHandle);
const AssetHandle AM_GetHandle(AssetKey key);
uint64_t AM_GetBucketCount();
-Asset *AM_GetAssets(uint64_t bucketIndex, uint64_t &itemCount);
+Asset *AM_GetAssets(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount);
void AM_Teardown();
void AM_DebugPrint();
diff --git a/src/camera.cpp b/src/camera.cpp
index 7ee9408..eadea85 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -8,18 +8,8 @@
#include "physics.hpp"
#include <glm/ext/quaternion_geometric.hpp>
-PkeCamera NullCamera {
- .camHandle = CameraHandle_MAX,
- .type = PKE_CAMERA_TYPE_ORTHOGONAL,
- .view = PKE_CAMERA_VIEW_TARGET,
- .stale = PKE_CAMERA_STALE_ALL,
- .phys = {
- .instHandle = InstanceHandle_MAX,
- .targetInstHandle = InstanceHandle_MAX,
- .constraint = nullptr,
- },
-};
-CompInstance NullCameraInstance;
+PkeCamera NullCamera {};
+CompInstance NullCameraInstance{};
PkeCamera *ActiveCamera = &NullCamera;
const pk_handle_item_index_T MAX_CAMERAS_PER_BUCKET = 32;
@@ -93,8 +83,7 @@ void PkeCamera_TargetInstance(CameraHandle cameraHandle, CompInstance *inst) {
CompInstance *selfInstance = ECS_GetInstance(cam.phys.instHandle);
if (cam.phys.constraint != nullptr && cam.phys.constraint != CAFE_BABE(btTypedConstraint)) {
- CompInstance *activeInst = reinterpret_cast<CompInstance *>(cam.phys.constraint->getRigidBodyB().getUserIndex());
- PkeCamera_UntargetInstance(cameraHandle, activeInst);
+ PkeCamera_UntargetInstance(cameraHandle);
}
btVector3 cameraOffset(0.f, -10.f, -10.f);
@@ -137,7 +126,7 @@ void PkeCamera_TargetInstance(CameraHandle cameraHandle, CompInstance *inst) {
cam.stale = PKE_CAMERA_STALE_POSROT;
}
-void PkeCamera_UntargetInstance(CameraHandle cameraHandle, CompInstance *inst) {
+void PkeCamera_UntargetInstance(CameraHandle cameraHandle) {
assert(cameraHandle != CameraHandle_MAX);
auto &cam = Camera_BucketContainer.buckets[cameraHandle.bucketIndex][cameraHandle.itemIndex];
BtDynamicsWorld->removeConstraint(cam.phys.constraint);
@@ -187,7 +176,7 @@ int64_t PkeCamera_GetBucketCount() {
return Camera_BucketContainer.pkeHandle.bucketIndex + 1;
}
-PkeCamera *PkeCamera_GetCameras(int64_t bucketIndex, int64_t &count) {
+PkeCamera *PkeCamera_GetCameras(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &count) {
if (Camera_BucketContainer.pkeHandle.bucketIndex == bucketIndex) {
count = Camera_BucketContainer.pkeHandle.itemIndex;
} else {
@@ -198,8 +187,11 @@ PkeCamera *PkeCamera_GetCameras(int64_t bucketIndex, int64_t &count) {
void PkeCamera_Init() {
Buckets_Init(Camera_BucketContainer, MAX_CAMERAS_PER_BUCKET);
- memset(&NullCameraInstance, 0, sizeof(NullCameraInstance));
+ NullCamera.type = PKE_CAMERA_TYPE_ORTHOGONAL;
+ NullCamera.view = PKE_CAMERA_VIEW_TARGET;
+ NullCamera.stale = PKE_CAMERA_STALE_ALL;
InstPos instPos{
+ .posRot = {},
.scale = btVector3(1.f, 1.f, 1.f),
.mass = 1.f,
};
@@ -226,6 +218,7 @@ void PkeCamera_Tick(double delta) {
* could be that removing pos and rot from the camera would make this unnecessary?
* See the camera serializer for more.
*/
+ (void)delta;
for (pk_handle_bucket_index_T b = 0; b <= Camera_BucketContainer.pkeHandle.bucketIndex; ++b) {
auto &bkt = Camera_BucketContainer.buckets[b];
long itemCount = Camera_BucketContainer.pkeHandle.bucketIndex == b ? Camera_BucketContainer.pkeHandle.itemIndex : Camera_BucketContainer.limits.itemIndex;
diff --git a/src/camera.hpp b/src/camera.hpp
index 82712fe..884f0b8 100644
--- a/src/camera.hpp
+++ b/src/camera.hpp
@@ -3,7 +3,6 @@
#include "pk.h"
#include "components.hpp"
-#include "vendor-glm-include.hpp"
#include <cstdint>
@@ -33,8 +32,8 @@ struct PkeCamera : public Entity_Base {
PkeCameraView view = PkeCameraView_MAX;
PkeCameraStaleFlags stale = PkeCameraStaleFlags_MAX;
struct Phys {
- InstanceHandle instHandle;
- InstanceHandle targetInstHandle;
+ InstanceHandle instHandle = InstanceHandle_MAX;
+ InstanceHandle targetInstHandle = InstanceHandle_MAX;
btTypedConstraint *constraint = nullptr;
} phys;
bool isPrimary = false;
@@ -48,9 +47,9 @@ PkeCamera &PkeCamera_Register(const InstPos &instPos);
PkeCamera *PkeCamera_Get(CameraHandle handle);
PkeCamera *PkeCamera_Get(EntityHandle handle);
void PkeCamera_TargetInstance(CameraHandle cameraHandle, CompInstance *inst);
-void PkeCamera_UntargetInstance(CameraHandle cameraHandle, CompInstance *inst);
+void PkeCamera_UntargetInstance(CameraHandle cameraHandle);
int64_t PkeCamera_GetBucketCount();
-PkeCamera *PkeCamera_GetCameras(int64_t bucketIndex, int64_t &count);
+PkeCamera *PkeCamera_GetCameras(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &count);
void PkeCamera_SetPrimary(CameraHandle handle);
void PkeCamera_Destroy(CameraHandle handle);
void PkeCamera_Teardown();
diff --git a/src/components.hpp b/src/components.hpp
index 50d1487..6b99a8b 100644
--- a/src/components.hpp
+++ b/src/components.hpp
@@ -84,7 +84,7 @@ struct CompInstance {
uint32_t index = ECS_UNSET_VAL_32;
PhysicsCollision physicsLayer = PhysicsCollision{1};
PhysicsCollision physicsMask = PhysicsCollision{1};
- InstBt bt;
+ InstBt bt{};
PkeCallback collisionCallback{};
bool isNeedingUpdated = false;
};
diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp
index 06479db..900a684 100644
--- a/src/dynamic-array.hpp
+++ b/src/dynamic-array.hpp
@@ -28,16 +28,16 @@ struct DynArray: DynArrayBase {
DynArray &operator=(const DynArray<T> &other);
DynArray &operator=(DynArray<T> &&other);
~DynArray();
- T &operator[](std::size_t index);
+ T &operator[](int64_t index);
T *GetPtr();
- const int64_t Count();
+ int64_t Count() const;
bool Has(const T &val);
template <typename T2>
int64_t FindFirstIndex(bool fn(const T&, const T2&), const T2 &val);
T& Push();
void Push(const T &val);
T Pop();
- void Remove(std::size_t index, int64_t count = 1);
+ void Remove(int64_t index, int64_t count = 1);
void Reserve(int64_t count);
void Resize(int64_t count);
protected:
@@ -115,10 +115,10 @@ template <typename T> inline DynArray<T>::~DynArray() {
DynArrayDestroy(this);
}
-template <typename T> inline T &DynArray<T>::operator[](std::size_t index) {
+template <typename T> inline T &DynArray<T>::operator[](int64_t index) {
assert(index < this->elementCount && "Invalid DynArray<T>[] index - out of bounds");
assert(index < this->reservedCount && "Invalid DynArray<T>[] index - out of reserved bounds");
- assert(index < 0xF000000000000000 && "Invalid DynArray<T>[] index - unlikely value");
+ assert(index >= 0 && "Invalid DynArray<T>[] index - unlikely value");
return *reinterpret_cast<T *>((this->ptr + (sizeof(T) * index)));
}
@@ -126,7 +126,7 @@ template <typename T> inline T *DynArray<T>::GetPtr() {
return reinterpret_cast<T *>(reinterpret_cast<void *>(this->ptr));
}
-template <typename T> inline const int64_t DynArray<T>::Count() {
+template <typename T> inline int64_t DynArray<T>::Count() const {
return this->elementCount;
}
@@ -180,7 +180,7 @@ template <typename T> inline T DynArray<T>::Pop() {
return *reinterpret_cast<T *>((this->ptr + (sizeof(T) * this->elementCount)));
}
-template <typename T> inline void DynArray<T>::Remove(std::size_t index, int64_t count) {
+template <typename T> inline void DynArray<T>::Remove(int64_t index, int64_t count) {
assert(index <= this->elementCount && "Invalid DynArray<T>::Remove() - Out of bounds");
int64_t moveCount = (this->elementCount - index - count);
assert(moveCount >= 0 && "Invalid DynArray<T>::Remove() - Removing too many elements");
diff --git a/src/ecs.cpp b/src/ecs.cpp
index 7f3410d..09eb725 100644
--- a/src/ecs.cpp
+++ b/src/ecs.cpp
@@ -6,7 +6,6 @@
#include "game-settings.hpp"
#include "math-helpers.hpp"
#include "physics.hpp"
-#include "vendor-glm-include.hpp"
#include "window.hpp"
#include <btBulletDynamicsCommon.h>
@@ -97,6 +96,7 @@ void ECS_MarkForRemoval(Entity_Base *entity) {
void ECS_Tick_Early(double delta) {
// these reserves might happen 1 tick early, but that's fine
+ (void)delta;
bool shouldRun = entitiesMarkedForRemoval.Count() > 0 || EntitiesToBeRemoved.Count() > 0 || entitiesYetToBeRemoved.Count() > 0;
entitiesYetToBeRemoved.Reserve(entitiesMarkedForRemoval.Count());
EntitiesToBeRemoved.Resize(entitiesMarkedForRemoval.Count());
@@ -239,6 +239,7 @@ struct InstanceBufferCopy {
};
void ECS_Tick_Late(double delta) {
// using a pointer here avoids calling the destructor when the object goes out of scope
+ (void)delta;
DynArray<InstanceBufferCopy> *bufferUpdatesPtr = pk_new<DynArray<InstanceBufferCopy>>(pkeSettings.mem.bkt);
new (bufferUpdatesPtr) DynArray<InstanceBufferCopy>(0, pkeSettings.mem.bkt);
DynArray<InstanceBufferCopy> &bufferUpdates = *bufferUpdatesPtr;
@@ -283,6 +284,8 @@ void ECS_Tick_Late(double delta) {
bfrUpdate->chunks->Push({
.startingIndex = inst.index,
.endingIndex = inst.index,
+ .mats = nullptr,
+ .dstBufferCopy = {},
});
chunk = &(*bfrUpdate->chunks)[bfrUpdate->chunks->Count() - 1];
chunk->dstBufferCopy.dstOffset = sizeof(glm::mat4) * inst.index;
@@ -424,7 +427,7 @@ uint64_t ECS_GetGrBinds_BucketCount() {
return ecs.bc.grBinds.pkeHandle.bucketIndex + 1;
}
-CompGrBinds *ECS_GetGrBinds(uint64_t bucketIndex, uint64_t &itemCount) {
+CompGrBinds *ECS_GetGrBinds(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount) {
if (bucketIndex == ecs.bc.grBinds.pkeHandle.bucketIndex) {
itemCount = ecs.bc.grBinds.pkeHandle.itemIndex;
} else {
@@ -497,7 +500,7 @@ uint64_t ECS_GetInstances_BucketCount() {
return ecs.bc.instances.pkeHandle.bucketIndex + 1;
}
-CompInstance *ECS_GetInstances(uint64_t bucketIndex, uint64_t &itemCount) {
+CompInstance *ECS_GetInstances(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount) {
if (bucketIndex == ecs.bc.instances.pkeHandle.bucketIndex) {
itemCount = ecs.bc.instances.pkeHandle.itemIndex;
} else {
diff --git a/src/ecs.hpp b/src/ecs.hpp
index 6a8ad8f..8cfdb4c 100644
--- a/src/ecs.hpp
+++ b/src/ecs.hpp
@@ -6,8 +6,6 @@
#include "pk.h"
#include "components.hpp"
-#include "glm/vec3.hpp"
-
extern DynArray<Entity_Base *> EntitiesToBeRemoved;
extern DynArray<Entity_Base *> EntitiesWithExcessInstances;
@@ -28,13 +26,13 @@ CompGrBinds *ECS_CreateGrBinds(Entity_Base *);
CompGrBinds *ECS_GetGrBinds(GrBindsHandle grBindsHandle);
void ECS_GetGrBinds(Entity_Base *entity, PkeArray<CompGrBinds *> &arr);
uint64_t ECS_GetGrBinds_BucketCount();
-CompGrBinds *ECS_GetGrBinds(uint64_t bucketIndex, uint64_t &itemCount);
+CompGrBinds *ECS_GetGrBinds(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount);
CompInstance *ECS_CreateInstance(Entity_Base *entity, CompGrBinds *entityTypeGrBinds);
CompInstance *ECS_GetInstance(InstanceHandle instanceHandle);
void ECS_GetInstances(Entity_Base *entity, PkeArray<CompInstance *> &arr);
void ECS_UpdateInstance(CompInstance *instance, const InstPos &instPos, bool overridePhysics = false);
uint64_t ECS_GetInstances_BucketCount();
-CompInstance *ECS_GetInstances(uint64_t bucketIndex, uint64_t &itemCount);
+CompInstance *ECS_GetInstances(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount);
#endif /* PKE_ECS_HPP */
diff --git a/src/entities.cpp b/src/entities.cpp
index 0fa5cf2..75a506f 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -7,6 +7,8 @@
#include "physics.hpp"
#include "plugins.hpp"
#include "static-missing-texture.hpp"
+#include "vendor-cgltf-include.hpp"
+#include "vendor-stb-image-include.h"
#include "window.hpp"
#include <BulletCollision/CollisionShapes/btConvexHullShape.h>
@@ -40,7 +42,7 @@ Entity_Base *EntityType_CreateGenericInstance(EntityType *et, Entity_Base *level
Entity_Base *genericEntity = ECS_CreateGenericEntity();
ECS_CreateEntity(genericEntity, levelEnt);
- for (size_t i = 0; i < et->detailsCount; ++i) {
+ for (int64_t i = 0; i < et->detailsCount; ++i) {
auto &etd = et->details[i];
auto *compInst = ECS_CreateInstance(genericEntity, etd.grBinds);
@@ -135,7 +137,7 @@ void CalculateCombinedMemReqs(uint64_t memReqsCount, VkMemoryRequirements *memRe
combinedMemReqs.size = 0;
combinedMemReqs.alignment = memReqs[0].alignment;
combinedMemReqs.memoryTypeBits = memReqs[0].memoryTypeBits;
- for (long i = 1; i < memReqsCount; ++i) {
+ for (uint64_t i = 1; i < memReqsCount; ++i) {
combinedMemReqs.memoryTypeBits |= memReqs[i].memoryTypeBits;
if (combinedMemReqs.alignment == memReqs[i].alignment) {
continue;
@@ -158,7 +160,7 @@ void CalculateCombinedMemReqs(uint64_t memReqsCount, VkMemoryRequirements *memRe
}
combinedMemReqs.alignment = combined;
}
- for (long i = 0; i < memReqsCount; ++i) {
+ for (uint64_t i = 0; i < memReqsCount; ++i) {
uint32_t alignmentPadding = memReqs[i].size % combinedMemReqs.alignment;
memReqs[i].size += (alignmentPadding == 0 ? 0 : combinedMemReqs.alignment - alignmentPadding);
combinedMemReqs.size += memReqs[i].size;
@@ -1050,10 +1052,10 @@ void EntityType_Load(EntityType &et) {
assert(gltfData->buffers_count == 1);
// make sure cgltf can interpret our model
- for (long i = 0; i < gltfData->accessors_count; ++i) {
+ for (unsigned long i = 0; i < gltfData->accessors_count; ++i) {
assert(gltfData->accessors[i].type != cgltf_type_invalid);
}
- for (long i = 0; i < gltfData->buffers_count; ++i) {
+ for (unsigned long i = 0; i < gltfData->buffers_count; ++i) {
assert(gltfData->buffer_views[i].type != cgltf_buffer_view_type_invalid);
}
@@ -1226,6 +1228,7 @@ void EntityType_Unload(EntityType &et, CompGrBinds *grBindsArr[1]) {
}
void EntityType_Tick(double delta) {
+ (void)delta;
const auto count = EntitiesToBeRemoved.Count();
for (long i = 0; i < count; ++i) {
auto *entTypePtr = EntityType_FindByEntityHandle(EntitiesToBeRemoved[i]->handle);
@@ -1242,6 +1245,7 @@ void EntityType_Tick(double delta) {
}
void EntityType_Tick_Late(double delta) {
+ (void)delta;
while (EntitiesWithExcessInstances.Count() != 0) {
auto *entity = EntitiesWithExcessInstances.Pop();
auto *etPtr = EntityType_FindByEntityHandle(entity->handle);
diff --git a/src/entities.hpp b/src/entities.hpp
index b711935..a885e7f 100644
--- a/src/entities.hpp
+++ b/src/entities.hpp
@@ -1,18 +1,14 @@
#ifndef PKE_ENTITIES_HPP
#define PKE_ENTITIES_HPP
-#include "vendor-cgltf-include.hpp"
-#include "vendor-stb-image-include.hpp"
-#include "ecs.hpp"
#include "components.hpp"
#include "asset-manager.hpp"
-#include "window.hpp"
#include "pk.h"
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
#include <vulkan/vulkan_core.h>
-const size_t EntityTypeDetails_MAX = 1;
+const int64_t EntityTypeDetails_MAX = 1;
struct EntityTypeDetails {
AssetKey textureAssetKey;
CompGrBinds *grBinds = nullptr;
diff --git a/src/event.cpp b/src/event.cpp
index fdea2f4..21d8bf0 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -1,5 +1,7 @@
#include "event.hpp"
+#include "dynamic-array.hpp"
+
#include <type_traits>
struct BaseEventBucket {
@@ -75,7 +77,7 @@ void Event_UnregisterCallback<EventHandler>(const char *name, EventHandler handl
BaseEventBucket *bkt = nullptr;
EventBucketFind<EventHandler>(name, bkt);
EventBucket<EventHandler> *tBkt = reinterpret_cast<EventBucket<EventHandler> *>(bkt);
- for (uint64_t i = 0; i < tBkt->callbacks.Count(); ++i) {
+ for (int64_t i = 0; i < tBkt->callbacks.Count(); ++i) {
if (tBkt->callbacks[i] == handler) {
tBkt->callbacks.Remove(i);
break;
@@ -88,7 +90,7 @@ void Event_Dispatch<EventHandler>(const char *name) {
BaseEventBucket *bkt = nullptr;
EventBucketFind<EventHandler>(name, bkt);
EventBucket<EventHandler> *tBkt = reinterpret_cast<EventBucket<EventHandler> *>(bkt);
- for (long i = 0; i < tBkt->callbacks.Count(); ++i) {
+ for (int64_t i = 0; i < tBkt->callbacks.Count(); ++i) {
tBkt->callbacks[i]();
}
}
@@ -108,7 +110,7 @@ void Event_UnregisterCallback<TickEvent>(const char *name, TickEvent handler) {
BaseEventBucket *bkt = nullptr;
EventBucketFind<TickEvent>(name, bkt);
EventBucket<TickEvent> *tBkt = reinterpret_cast<EventBucket<TickEvent> *>(bkt);
- for (uint64_t i = 0; i < tBkt->callbacks.Count(); ++i) {
+ for (int64_t i = 0; i < tBkt->callbacks.Count(); ++i) {
if (tBkt->callbacks[i] == handler) {
tBkt->callbacks.Remove(i);
break;
@@ -121,7 +123,7 @@ void Event_Dispatch<TickEvent, double>(const char *name, double d) {
BaseEventBucket *bkt = nullptr;
EventBucketFind<TickEvent>(name, bkt);
EventBucket<TickEvent> *tBkt = reinterpret_cast<EventBucket<TickEvent> *>(bkt);
- for (long i = 0; i < tBkt->callbacks.Count(); ++i) {
+ for (int64_t i = 0; i < tBkt->callbacks.Count(); ++i) {
tBkt->callbacks[i](d);
}
}
diff --git a/src/event.hpp b/src/event.hpp
index d8f41be..3f19bba 100644
--- a/src/event.hpp
+++ b/src/event.hpp
@@ -1,12 +1,6 @@
#ifndef PKE_EVENT_HPP
#define PKE_EVENT_HPP
-#include "dynamic-array.hpp"
-
-#include <cassert>
-#include <cstdint>
-#include <cstring>
-
typedef void (*EventHandler)();
typedef void (*TickEvent)(double);
diff --git a/src/game.cpp b/src/game.cpp
index be4bb25..0fb2ccd 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -7,18 +7,18 @@
#include "dynamic-array.hpp"
#include "ecs.hpp"
#include "entities.hpp"
+#include "event.hpp"
#include "game-settings.hpp"
+#include "game-type-defs.hpp"
#include "helpers.hpp"
#include "imgui.h"
#include "level-types.hpp"
#include "level.hpp"
-#include "math-helpers.hpp"
#include "physics.hpp"
#include "player-input.hpp"
#include "plugins.hpp"
#include "project.hpp"
#include "thread-pool.hpp"
-#include "vendor-glm-include.hpp"
#include "window.hpp"
#include "pk.h"
@@ -254,6 +254,7 @@ void ParseInstance(Entity_Base *parentEntity, std::ifstream &stream) {
.newEntHandle = EntityHandle_MAX,
.newInstHandle = InstanceHandle_MAX,
.newInstance = {
+ .posRot = {},
.scale = btVector3(1.f, 1.f, 1.f),
.mass = 1.f,
},
@@ -413,11 +414,11 @@ void Game_SaveSceneFile(const char *sceneFilePath) {
stream << PKE_FILE_VERSION << std::endl;
stream << "" << std::endl;
- int64_t instanceBucketCount = ECS_GetInstances_BucketCount();
- for (long b = 0; b < instanceBucketCount; ++b) {
- uint64_t count;
+ pk_handle_bucket_index_T instanceBucketCount = ECS_GetInstances_BucketCount();
+ for (pk_handle_bucket_index_T b = 0; b < instanceBucketCount; ++b) {
+ pk_handle_item_index_T count;
auto *instances = ECS_GetInstances(b, count);
- for (long i = 0; i < count; ++i) {
+ for (pk_handle_item_index_T i = 0; i < count; ++i) {
const auto &instance = instances[i];
if (instance.entHandle == EntityHandle_MAX)
continue;
@@ -427,11 +428,11 @@ void Game_SaveSceneFile(const char *sceneFilePath) {
}
}
- int64_t cameraBucketCount = PkeCamera_GetBucketCount();
- for (long b = 0; b < cameraBucketCount; ++b) {
- int64_t count;
+ pk_handle_bucket_index_T cameraBucketCount = PkeCamera_GetBucketCount();
+ for (pk_handle_bucket_index_T b = 0; b < cameraBucketCount; ++b) {
+ pk_handle_item_index_T count;
auto *cameras = PkeCamera_GetCameras(b, count);
- for (long i = 0; i < count; ++i) {
+ for (pk_handle_item_index_T i = 0; i < count; ++i) {
const auto &cam = cameras[i];
if (cam.handle == CameraHandle_MAX)
continue;
@@ -498,10 +499,10 @@ void Game_LoadSceneFile(PkeLevel *level, const char *sceneFilePath) {
PkeArray_SoftReset(&loadFileInstanceMappings);
}
-const uint64_t consoleBufferCount = 30;
-const uint64_t consoleLineLength = 128;
+const int64_t consoleBufferCount = 30;
+const int64_t consoleLineLength = 128;
char consoleBuffer[consoleBufferCount][consoleLineLength];
-long consoleBufferIndex = 0;
+int64_t consoleBufferIndex = 0;
void Game_RecordImGui() {
static bool scrollToBottom = true;
if (!ImGui::Begin("Console", &pkeSettings.editorSettings.isShowingConsole)) {
@@ -511,10 +512,10 @@ void Game_RecordImGui() {
ImVec2 region = ImGui::GetContentRegionAvail();
region.y -= 27;
if (ImGui::BeginListBox("##ConsoleHistory", region)) {
- for (long i = consoleBufferIndex + 1; i < consoleBufferCount; ++i) {
+ for (int64_t i = consoleBufferIndex + 1; i < consoleBufferCount; ++i) {
ImGui::Text("%s", consoleBuffer[i]);
}
- for (long i = 0; i < consoleBufferIndex; ++i) {
+ for (int64_t i = 0; i < consoleBufferIndex; ++i) {
ImGui::Text("%s", consoleBuffer[i]);
}
if (scrollToBottom) ImGui::SetScrollHereY(1);
@@ -716,7 +717,7 @@ void Game_Main(PKEWindowProperties windowProps, const char *executablePath) {
void Game_Init() {
pkeSettings.mem.bkt = pk_bucket_create("game", 1UL << 26, true);
- for (long i = 0; i < consoleBufferCount; ++i) {
+ for (uint64_t i = 0; i < consoleBufferCount; ++i) {
memset(consoleBuffer[i], '\0', consoleLineLength);
}
}
diff --git a/src/game.hpp b/src/game.hpp
index b575376..95d010c 100644
--- a/src/game.hpp
+++ b/src/game.hpp
@@ -1,7 +1,6 @@
#ifndef PKE_GAME_HPP
#define PKE_GAME_HPP
-#include "game-settings.hpp"
#include "level-types.hpp"
#include "window-types.hpp"
diff --git a/src/player-input.cpp b/src/player-input.cpp
index 84f5898..a75daa3 100644
--- a/src/player-input.cpp
+++ b/src/player-input.cpp
@@ -2,11 +2,9 @@
#include "player-input.hpp"
#include "dynamic-array.hpp"
-#include "game-settings.hpp"
#include "window.hpp"
#include <GLFW/glfw3.h>
-#include <chrono>
struct CursorEnterEvent {
bool entered;
@@ -68,8 +66,7 @@ DynArray<PkeInputSet> registeredInputSets{0, nullptr};
DynArray<InputActionSetHandle> activeInputSetStack{0, nullptr};
PkeInputAction *FindActionByName(const char *actionName) {
- int64_t count = 0;
- count = activeInputSetStack.Count();
+ int64_t count = activeInputSetStack.Count();
for (int64_t i = count - 1; i >= 0; --i) {
InputActionSetHandle handle = activeInputSetStack[i];
InputActionSetHandle_T index = static_cast<InputActionSetHandle_T>(handle);
@@ -260,15 +257,16 @@ constexpr auto FindActivePkeInputAction_MouseButton_ByType = FindActivePkeInputA
constexpr auto FindActivePkeInputAction_Scroll_ByType = FindActivePkeInputAction_ByType<PKE_INPUT_HASH_EVENT_TYPE_SCROLL, PkeScrollEvent>;
constexpr auto FindActivePkeInputAction_WindowFocus_ByType = FindActivePkeInputAction_ByType<PKE_INPUT_HASH_EVENT_TYPE_WINDOW_FOCUS, PkeWindowFocusEvent>;
-constexpr auto FindActivePkeInputAction_CursorEnter_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_CURSOR_ENTER, PkeCursorEnterEvent>;
-constexpr auto FindActivePkeInputAction_CursorPos_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_CURSOR_POS, PkeCursorPosEvent>;
-constexpr auto FindActivePkeInputAction_Key_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_KEY, PkeKeyEvent>;
-constexpr auto FindActivePkeInputAction_MouseButton_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_MOUSE_BUTTON, PkeMouseButtonEvent>;
-constexpr auto FindActivePkeInputAction_Scroll_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_SCROLL, PkeScrollEvent>;
-constexpr auto FindActivePkeInputAction_WindowFocus_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_WINDOW_FOCUS, PkeWindowFocusEvent>;
+// constexpr auto FindActivePkeInputAction_CursorEnter_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_CURSOR_ENTER, PkeCursorEnterEvent>;
+// constexpr auto FindActivePkeInputAction_CursorPos_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_CURSOR_POS, PkeCursorPosEvent>;
+// constexpr auto FindActivePkeInputAction_Key_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_KEY, PkeKeyEvent>;
+// constexpr auto FindActivePkeInputAction_MouseButton_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_MOUSE_BUTTON, PkeMouseButtonEvent>;
+// constexpr auto FindActivePkeInputAction_Scroll_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_SCROLL, PkeScrollEvent>;
+// constexpr auto FindActivePkeInputAction_WindowFocus_ByName = FindActivePkeInputAction_ByName<PKE_INPUT_HASH_EVENT_TYPE_WINDOW_FOCUS, PkeWindowFocusEvent>;
void PkeInput_Tick(double delta) {
+ (void)delta;
// reset everything
// @performance could happen concurrently
{
@@ -575,50 +573,50 @@ void PkeInput_ActivateSet(InputActionSetHandle handle) {
// Maybe you just have to restrict certain actions to certain input types
if ((action.primaryHash.computedHash & PKE_INPUT_HASH_EVENT_TYPE_CURSOR_ENTER) != InputEventHash{0}) {
action.eventIndex = registeredCursorEnterEvents.Count();
- registeredCursorEnterEvents.Push(PkeCursorEnterEvent {
- .sourceSet = handle,
- .isEntered = lastCursorEntered,
- });
+ PkeCursorEnterEvent ev{};
+ ev.sourceSet = handle;
+ ev.isEntered = lastCursorEntered;
+ registeredCursorEnterEvents.Push(ev);
}
if ((action.primaryHash.computedHash & PKE_INPUT_HASH_EVENT_TYPE_CURSOR_POS) != InputEventHash{0}) {
action.eventIndex = registeredCursorPosEvents.Count();
- registeredCursorPosEvents.Push(PkeCursorPosEvent {
- .sourceSet = handle,
- .xMotion = 0,
- .yMotion = 0,
- });
+ PkeCursorPosEvent ev {};
+ ev.sourceSet = handle;
+ ev.xMotion = 0;
+ ev.yMotion = 0;
+ registeredCursorPosEvents.Push(ev);
glfwGetCursorPos(window, &lastMousePos.x, &lastMousePos.y);
}
if ((action.primaryHash.computedHash & PKE_INPUT_HASH_EVENT_TYPE_KEY) != InputEventHash{0}) {
action.eventIndex = registeredKeyEvents.Count();
- registeredKeyEvents.Push(PkeKeyEvent {
- .sourceSet = handle,
- .button = action.primaryHash.button,
- .mods = action.primaryHash.mods,
- });
+ PkeKeyEvent ev{};
+ ev.sourceSet = handle;
+ ev.button = action.primaryHash.button;
+ ev.mods = action.primaryHash.mods;
+ registeredKeyEvents.Push(ev);
}
if ((action.primaryHash.computedHash & PKE_INPUT_HASH_EVENT_TYPE_MOUSE_BUTTON) != InputEventHash{0}) {
action.eventIndex = registeredMouseButtonEvents.Count();
- registeredMouseButtonEvents.Push(PkeMouseButtonEvent {
- .sourceSet = handle,
- .button = action.primaryHash.button,
- .mods = action.primaryHash.mods,
- });
+ PkeMouseButtonEvent ev{};
+ ev.sourceSet = handle;
+ ev.button = action.primaryHash.button;
+ ev.mods = action.primaryHash.mods;
+ registeredMouseButtonEvents.Push(ev);
}
if ((action.primaryHash.computedHash & PKE_INPUT_HASH_EVENT_TYPE_SCROLL) != InputEventHash{0}) {
action.eventIndex = registeredScrollEvents.Count();
- registeredScrollEvents.Push(PkeScrollEvent {
- .sourceSet = handle,
- .xMotion = 0,
- .yMotion = 0,
- });
+ PkeScrollEvent ev{};
+ ev.sourceSet = handle;
+ ev.xMotion = 0;
+ ev.yMotion = 0;
+ registeredScrollEvents.Push(ev);
}
if ((action.primaryHash.computedHash & PKE_INPUT_HASH_EVENT_TYPE_WINDOW_FOCUS) != InputEventHash{0}) {
action.eventIndex = registeredWindowFocusEvents.Count();
- registeredWindowFocusEvents.Push(PkeWindowFocusEvent {
- .sourceSet = handle,
- .isFocused = lastWindowFocus,
- });
+ PkeWindowFocusEvent ev{};
+ ev.sourceSet = handle;
+ ev.isFocused = lastWindowFocus;
+ registeredWindowFocusEvents.Push(ev);
}
}
}
diff --git a/src/player-input.hpp b/src/player-input.hpp
index b8bd9a4..f67e966 100644
--- a/src/player-input.hpp
+++ b/src/player-input.hpp
@@ -1,7 +1,6 @@
#ifndef PKE_PLAYER_INPUT_HPP
#define PKE_PLAYER_INPUT_HPP
-#include "game-type-defs.hpp"
#include "pk.h"
#include <cstdint>
@@ -55,41 +54,37 @@ const InputEventHash PKE_INPUT_HASH_ALL_WINDOW_FOCUS_EVENTS =
| PKE_INPUT_HASH_WINDOW_FOCUSED_FALSE
| PKE_INPUT_HASH_WINDOW_FOCUSED_FALSE;
-struct PkeInputEventBase { };
+struct PkeInputEventBase {
+ InputActionSetHandle sourceSet;
+};
struct PkeInputEventHolder {
InputEventHash type = InputEventHash{0};
PkeInputEventBase *ptr = nullptr;
};
struct PkeCursorEnterEvent : public PkeInputEventBase {
- InputActionSetHandle sourceSet;
bool isEntered;
};
struct PkeCursorPosEvent : public PkeInputEventBase {
- InputActionSetHandle sourceSet;
double xMotion;
double yMotion;
};
struct PkeKeyEvent : public PkeInputEventBase {
- InputActionSetHandle sourceSet;
bool isPressed;
bool thisTick;
int32_t button;
int32_t mods;
};
struct PkeMouseButtonEvent : public PkeInputEventBase {
- InputActionSetHandle sourceSet;
bool isPressed;
bool thisTick;
int32_t button;
int32_t mods;
};
struct PkeScrollEvent : public PkeInputEventBase {
- InputActionSetHandle sourceSet;
double xMotion;
double yMotion;
};
struct PkeWindowFocusEvent : public PkeInputEventBase {
- InputActionSetHandle sourceSet;
bool isFocused;
};
@@ -99,7 +94,7 @@ struct PkeInputEventMask {
int32_t mods = 0;
};
-constexpr uint64_t PKE_INPUT_ACTION_MASK_COUNT = 1;
+constexpr int64_t PKE_INPUT_ACTION_MASK_COUNT = 1;
struct PkeInputAction {
const char *name;
union {
@@ -110,7 +105,7 @@ struct PkeInputAction {
};
struct PkeInputSet {
const char *title;
- uint64_t actionCount;
+ int64_t actionCount;
PkeInputAction *actions;
};
diff --git a/src/project-settings.hpp b/src/project-settings.hpp
index 14005a5..c1873c4 100644
--- a/src/project-settings.hpp
+++ b/src/project-settings.hpp
@@ -3,7 +3,6 @@
#include "dynamic-array.hpp"
#include "pk.h"
-#include <cstdint>
struct PkeProjectSettings {
const char *defaultSceneName = "default";
diff --git a/src/project.cpp b/src/project.cpp
index 48c511b..ee8a0b1 100644
--- a/src/project.cpp
+++ b/src/project.cpp
@@ -7,7 +7,6 @@
#include <fstream>
#include <ostream>
-#include <iomanip>
const long projReadLineLength = 128;
char projReadLine[projReadLineLength];
@@ -64,10 +63,10 @@ void Proj_SerializeProjectSettings(std::ofstream &stream) {
*/
void Proj_SerializeEntityType(std::ofstream &stream, const EntityType &et) {
- NULL_CHAR_ARR(handleStr, 19);
+ NULL_CHAR_ARR(handleStr, 23);
NULL_CHAR_ARR(modelAssetKey, AssetKeyLength + 1);
NULL_CHAR_ARR(textureAssetKey, AssetKeyLength + 1);
- snprintf(handleStr, 19, "0x%08X 0x%08X", et.handle.bucketIndex, et.handle.itemIndex);
+ snprintf(handleStr, 22, "0x%08X 0x%08X", et.handle.bucketIndex, et.handle.itemIndex);
snprintf(modelAssetKey, AssetKeyLength + 1, "%s", et.modelAssetKey);
EntityType e{};
if (modelAssetKey[0] != '\0')
@@ -79,7 +78,7 @@ void Proj_SerializeEntityType(std::ofstream &stream, const EntityType &et) {
if (et.createInstanceCallback.name[0] != '\0') {
stream << PKE_PROJ_FILE_ENTITY_TYPE_CREATE_INSTANCE_CALLBACK_SIGNATURE << et.createInstanceCallback.name << std::endl;
}
- for (size_t i = 0; i < et.detailsCount; ++i) {
+ for (int64_t i = 0; i < et.detailsCount; ++i) {
const EntityTypeDetails &etd = et.details[i];
snprintf(textureAssetKey, AssetKeyLength + 1, "%s", etd.textureAssetKey);
@@ -356,11 +355,11 @@ void PkeProject_Save(const char *filePath) {
f << PKE_PROJ_FILE_OBJ_END << std::endl;
*/
- auto assetB = AM_GetBucketCount();
- for (long b = 0; b < assetB; ++b) {
- uint64_t assetI = 0;
+ pk_handle_bucket_index_T assetB = AM_GetBucketCount();
+ for (pk_handle_bucket_index_T b = 0; b < assetB; ++b) {
+ pk_handle_item_index_T assetI = 0;
auto *assets = AM_GetAssets(b, assetI);
- for (long i = 0; i < assetI; ++i) {
+ for (pk_handle_item_index_T i = 0; i < assetI; ++i) {
bool isGlobalAsset = false;
for (long k = 0; k < EngineDefinedAssetCount; ++k) {
if (strncmp(EngineDefinedAssets[k], assets[i].key, AssetKeyLength) == 0) {
diff --git a/src/project.hpp b/src/project.hpp
index 54dff33..ba678db 100644
--- a/src/project.hpp
+++ b/src/project.hpp
@@ -1,8 +1,6 @@
#ifndef PKE_PROJECT_HPP
#define PKE_PROJECT_HPP
-#include "project-settings.hpp"
-
const char* const PKE_PROJ_DEFAULT_FILENAME = "project.pptf";
void PkeProject_Load(const char *filePath = nullptr);
diff --git a/src/thread-pool.cpp b/src/thread-pool.cpp
index 061ae68..b6ff97e 100644
--- a/src/thread-pool.cpp
+++ b/src/thread-pool.cpp
@@ -2,6 +2,7 @@
#include "thread-pool.hpp"
#include "bucketed-array.hpp"
+#include "dynamic-array.hpp"
#include <functional>
#include <future>
@@ -106,8 +107,8 @@ void inline PkeThreads_Pause_Inner(ThreadPool &tp) {
void inline PkeThreads_Resume_Inner(ThreadPool &tp) {
tp.mutex.lock();
tp.isPaused = false;
- long count = tp.threads->Count();
- for (size_t i = 0; i < count; i++) {
+ int64_t count = tp.threads->Count();
+ for (int64_t i = 0; i < count; i++) {
(*tp.threads)[i] = std::thread(std::bind(ThreadRun, &tp));
}
tp.mutex.unlock();
diff --git a/src/thread-pool.hpp b/src/thread-pool.hpp
index dcb7a13..aabb9ee 100644
--- a/src/thread-pool.hpp
+++ b/src/thread-pool.hpp
@@ -1,7 +1,6 @@
#ifndef PKE_THREADING_HPP
#define PKE_THREADING_HPP
-#include "dynamic-array.hpp"
#include "pk.h"
#include <cstdint>
diff --git a/src/vendor-stb-image-include.cpp b/src/vendor-stb-image-include.c
index 5583564..7e02327 100644
--- a/src/vendor-stb-image-include.cpp
+++ b/src/vendor-stb-image-include.c
@@ -2,4 +2,4 @@
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
-#include "vendor-stb-image-include.hpp"
+#include "vendor-stb-image-include.h"
diff --git a/src/vendor-stb-image-include.h b/src/vendor-stb-image-include.h
new file mode 100644
index 0000000..c6cb971
--- /dev/null
+++ b/src/vendor-stb-image-include.h
@@ -0,0 +1,7 @@
+#ifndef PKE_STB_IMAGE_INCLUDE_H
+#define PKE_STB_IMAGE_INCLUDE_H
+
+#include "stb_image.h"
+#include "stb_image_write.h"
+
+#endif /* PKE_STB_IMAGE_INCLUDE_H */
diff --git a/src/vendor-stb-image-include.hpp b/src/vendor-stb-image-include.hpp
deleted file mode 100644
index bd8658c..0000000
--- a/src/vendor-stb-image-include.hpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef PKE_STB_IMAGE_INCLUDE_HPP
-#define PKE_STB_IMAGE_INCLUDE_HPP
-
-#include "stb_image.h"
-#include "stb_image_write.h"
-
-#endif /* PKE_STB_IMAGE_INCLUDE_HPP */
diff --git a/src/window.cpp b/src/window.cpp
index e44b498..0b9de86 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1,27 +1,24 @@
-#include "backends/imgui_impl_vulkan.h"
-#include "math-helpers.hpp"
-#include "static-missing-texture.hpp"
#define GLFW_INCLUDE_NONE
#define GLFW_INCLUDE_VULKAN
+#include "backends/imgui_impl_glfw.h"
+#include "backends/imgui_impl_vulkan.h"
+
#include "window.hpp"
#include "asset-manager.hpp"
#include "camera.hpp"
#include "ecs.hpp"
-#include "entities.hpp"
-#include "event.hpp"
#include "game-settings.hpp"
-#include "helpers.hpp"
+#include "math-helpers.hpp"
#include "plugins.hpp"
#include "static-cube.hpp"
+#include "static-missing-texture.hpp"
#include "window-types.hpp"
#include "glm/ext/matrix_transform.hpp"
-#include "glm/gtc/matrix_transform.hpp"
#include <cstdint>
-#include <fstream>
struct pk_membucket *MemBkt_Vulkan = nullptr;
struct pke_vkAllocData {
@@ -135,6 +132,9 @@ VkBool32 UserDebugCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData) {
+ (void)messageSeverity;
+ (void)messageType;
+ (void)pUserData;
printf("Validation Layer: %s\n", pCallbackData->pMessage);
return VK_FALSE;
}
@@ -210,7 +210,7 @@ void EndTransferBuffer(VkBuffer &buffer, VkDeviceMemory &deviceMemory) {
vkFreeMemory(vkDevice, deviceMemory, vkAllocator);
}
-unsigned int FindQueueFamilyIndex(VkPhysicalDevice device, short hasPresentSupport = -1, VkQueueFlagBits includeBits = (VkQueueFlagBits)0U, VkQueueFlagBits excludeBits = (VkQueueFlagBits)0U) {
+unsigned int FindQueueFamilyIndex(VkPhysicalDevice device, char hasPresentSupport = -1, VkQueueFlagBits includeBits = (VkQueueFlagBits)0U, VkQueueFlagBits excludeBits = (VkQueueFlagBits)0U) {
if (hasPresentSupport == -1 && includeBits == 0 && excludeBits == 0) {
return 0U;
@@ -232,7 +232,7 @@ unsigned int FindQueueFamilyIndex(VkPhysicalDevice device, short hasPresentSuppo
VkBool32 presentSupport;
VkResult vkResult = vkGetPhysicalDeviceSurfaceSupportKHR(device, i, vkSurfaceKHR, &presentSupport);
assert(vkResult == VK_SUCCESS);
- if (presentSupport != hasPresentSupport) {
+ if (presentSupport != (VkBool32)hasPresentSupport) {
continue;
}
}
@@ -245,11 +245,12 @@ unsigned int FindQueueFamilyIndex(VkPhysicalDevice device, short hasPresentSuppo
}
void PKE_vkFreeFunction(void *pUserData, void *pMemory) {
+ (void)pUserData;
if (pMemory == nullptr) return;
pke_vkAllocData *chunk = nullptr;
size_t index = -1;
- size_t count = vulkanAllocs->Count();
- for (long i = 0; i < count; ++i) {
+ int64_t count = vulkanAllocs->Count();
+ for (int64_t i = 0; i < count; ++i) {
if ((*vulkanAllocs)[i].data == pMemory) {
chunk = &(*vulkanAllocs)[i];
index = i;
@@ -266,6 +267,8 @@ void PKE_vkFreeFunction(void *pUserData, void *pMemory) {
}
void *PKE_vkAllocateFunction(void *pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocScope) {
+ (void)pUserData;
+ (void)allocScope;
if (size == 0) {
return nullptr;
}
@@ -278,6 +281,7 @@ void *PKE_vkAllocateFunction(void *pUserData, size_t size, size_t alignment, VkS
}
void *PKE_vkReallocationFunction(void *pUserData, void *pOriginal, size_t size, size_t alignment, VkSystemAllocationScope allocScope) {
+ (void)pUserData;
if (pOriginal == nullptr) {
return PKE_vkAllocateFunction(pUserData, size, alignment, allocScope);
}
@@ -287,8 +291,8 @@ void *PKE_vkReallocationFunction(void *pUserData, void *pOriginal, size_t size,
}
pke_vkAllocData *chunk = nullptr;
size_t index = -1;
- size_t count = vulkanAllocs->Count();
- for (long i = 0; i < count; ++i) {
+ int64_t count = vulkanAllocs->Count();
+ for (int64_t i = 0; i < count; ++i) {
if ((*vulkanAllocs)[i].data == pOriginal) {
chunk = &((*vulkanAllocs)[i]);
index = i;
@@ -312,10 +316,18 @@ void *PKE_vkReallocationFunction(void *pUserData, void *pOriginal, size_t size,
}
void PKE_vkInternalAllocationNotification(void *pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope) {
+ (void)pUserData;
+ (void)size;
+ (void)allocationType;
+ (void)allocationScope;
return;
}
void PKE_vkInternalFreeNotification(void *pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope) {
+ (void)pUserData;
+ (void)size;
+ (void)allocationType;
+ (void)allocationScope;
return;
}
@@ -646,39 +658,41 @@ void InitVulkan() {
}
void CreateImageResources_Inner(VkImageCreateInfo *imageCreateInfo, VkImageViewCreateInfo *imageViewCreateInfo, VkBufferUsageFlagBits bufferUsageFlagBits, VkBuffer *imagesBuffer, VkImage *images, VkImageView *imageViews, VkDeviceMemory *deviceMemory) {
- VkImage tmpImage;
- VkResult vkResult;
- vkResult = vkCreateImage(vkDevice, imageCreateInfo, vkAllocator, &tmpImage);
- assert(vkResult == VK_SUCCESS);
+ (void)bufferUsageFlagBits;
+ (void)imagesBuffer;
+ VkImage tmpImage;
+ VkResult vkResult;
+ vkResult = vkCreateImage(vkDevice, imageCreateInfo, vkAllocator, &tmpImage);
+ assert(vkResult == VK_SUCCESS);
- VkMemoryRequirements imageMemoryRequirements;
- vkGetImageMemoryRequirements(vkDevice, tmpImage, &imageMemoryRequirements);
+ VkMemoryRequirements imageMemoryRequirements;
+ vkGetImageMemoryRequirements(vkDevice, tmpImage, &imageMemoryRequirements);
- VkDeviceSize paddedImageSize = imageMemoryRequirements.size + (imageMemoryRequirements.alignment - (imageMemoryRequirements.size % imageMemoryRequirements.alignment));
- assert(paddedImageSize % imageMemoryRequirements.alignment == 0);
+ VkDeviceSize paddedImageSize = imageMemoryRequirements.size + (imageMemoryRequirements.alignment - (imageMemoryRequirements.size % imageMemoryRequirements.alignment));
+ assert(paddedImageSize % imageMemoryRequirements.alignment == 0);
- vkDestroyImage(vkDevice, tmpImage, vkAllocator);
+ vkDestroyImage(vkDevice, tmpImage, vkAllocator);
- VkMemoryAllocateInfo vkMemoryAllocateInfo{};
- vkMemoryAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- vkMemoryAllocateInfo.pNext = nullptr;
- vkMemoryAllocateInfo.allocationSize = paddedImageSize * MAX_FRAMES_IN_FLIGHT;
- vkMemoryAllocateInfo.memoryTypeIndex = FindMemoryTypeIndex(imageMemoryRequirements.memoryTypeBits,
- VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
+ VkMemoryAllocateInfo vkMemoryAllocateInfo{};
+ vkMemoryAllocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ vkMemoryAllocateInfo.pNext = nullptr;
+ vkMemoryAllocateInfo.allocationSize = paddedImageSize * MAX_FRAMES_IN_FLIGHT;
+ vkMemoryAllocateInfo.memoryTypeIndex = FindMemoryTypeIndex(imageMemoryRequirements.memoryTypeBits,
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
- vkResult = vkAllocateMemory(vkDevice, &vkMemoryAllocateInfo, vkAllocator, deviceMemory);
- assert(vkResult == VK_SUCCESS);
+ vkResult = vkAllocateMemory(vkDevice, &vkMemoryAllocateInfo, vkAllocator, deviceMemory);
+ assert(vkResult == VK_SUCCESS);
- for (long i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
- vkResult = vkCreateImage(vkDevice, imageCreateInfo, vkAllocator, &images[i]);
- assert(vkResult == VK_SUCCESS);
- vkResult = vkBindImageMemory(vkDevice, images[i], *deviceMemory, paddedImageSize * i);
- assert(vkResult == VK_SUCCESS);
+ for (long i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+ vkResult = vkCreateImage(vkDevice, imageCreateInfo, vkAllocator, &images[i]);
+ assert(vkResult == VK_SUCCESS);
+ vkResult = vkBindImageMemory(vkDevice, images[i], *deviceMemory, paddedImageSize * i);
+ assert(vkResult == VK_SUCCESS);
- imageViewCreateInfo->image = images[i];
- vkResult = vkCreateImageView(vkDevice, imageViewCreateInfo, vkAllocator, &imageViews[i]);
- assert(vkResult == VK_SUCCESS);
- }
+ imageViewCreateInfo->image = images[i];
+ vkResult = vkCreateImageView(vkDevice, imageViewCreateInfo, vkAllocator, &imageViews[i]);
+ assert(vkResult == VK_SUCCESS);
+ }
}
void CreateSwapchain() {
@@ -715,10 +729,8 @@ void CreateSwapchain() {
Extent.width = width;
Extent.height = height;
// clamp
- width = Extent.width < surfaceCapabilities.minImageExtent.width ? surfaceCapabilities.minImageExtent.width : Extent.width;
- Extent.width = width > surfaceCapabilities.maxImageExtent.width ? surfaceCapabilities.maxImageExtent.width : width;
- height = Extent.height < surfaceCapabilities.minImageExtent.height ? surfaceCapabilities.minImageExtent.height : Extent.height;
- Extent.height = height > surfaceCapabilities.maxImageExtent.height ? surfaceCapabilities.maxImageExtent.height : height;
+ Extent.width = PK_CLAMP(Extent.width, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width);
+ Extent.height = PK_CLAMP(Extent.height, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height);
vkPresentModeKHR = VK_PRESENT_MODE_FIFO_KHR;
if (pkeSettings.graphicsSettings.isWaitingForVsync == false || pkeSettings.graphicsSettings.isFramerateUnlocked == true) {
@@ -728,8 +740,8 @@ void CreateSwapchain() {
VkPresentModeKHR *presentModes = pk_new<VkPresentModeKHR>(presentModeCount);
vkResult = vkGetPhysicalDeviceSurfacePresentModesKHR(vkPhysicalDevice, vkSurfaceKHR, &presentModeCount, presentModes);
assert(vkResult == VK_SUCCESS);
- uint32_t immediateIndex = -1;
- uint32_t fifoRelaxedIndex = -1;
+ int32_t immediateIndex = -1;
+ int32_t fifoRelaxedIndex = -1;
/*
uint32_t mailboxIndex = -1;
uint32_t fifoIndex = -1;
@@ -2376,11 +2388,11 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) {
VkDeviceSize offsets[1] = {0U};
- const uint64_t bindBucketCount = ECS_GetGrBinds_BucketCount();
- for (long b = 0; b < bindBucketCount; ++b) {
- uint64_t itemCount;
+ pk_handle_bucket_index_T bindBucketCount = ECS_GetGrBinds_BucketCount();
+ for (pk_handle_bucket_index_T b = 0; b < bindBucketCount; ++b) {
+ pk_handle_item_index_T itemCount;
CompGrBinds *items = ECS_GetGrBinds(b, itemCount);
- for (long i = 0; i < itemCount; ++i) {
+ for (pk_handle_item_index_T i = 0; i < itemCount; ++i) {
CompGrBinds *binder = &items[i];
if (binder->grBindsHandle == GrBindsHandle_MAX)
continue;
@@ -2571,7 +2583,10 @@ void RecreateSwapchain() {
}
void FramebufferResizeCallback(GLFWwindow *window, int width, int height) {
- if (Extent.width == width && Extent.height != height) {
+ (void)window;
+ assert(width > -1);
+ assert(height > -1);
+ if (Extent.width == (uint32_t)width && Extent.height != (uint32_t)height) {
return;
}
shouldRecreateSwapchain = true;
diff --git a/src/window.hpp b/src/window.hpp
index 1af7eed..29f7140 100644
--- a/src/window.hpp
+++ b/src/window.hpp
@@ -2,19 +2,10 @@
#define PKE_WINDOW_HPP
#include "asset-manager.hpp"
-#include "backends/imgui_impl_glfw.h"
-#include "backends/imgui_impl_vulkan.h"
-#include "event.hpp"
-#include "imgui.h"
-#include "ecs.hpp"
#include "window-types.hpp"
#include "pk.h"
+#include "vendor-glm-include.hpp"
-#include "glm/mat4x4.hpp"
-#include <cstring>
-#include <cstdio>
-#include <vector>
-#include <cassert>
#include <GLFW/glfw3.h>
#include <vulkan/vulkan.h>
@@ -80,10 +71,8 @@ struct ImplementedPipelines {
VkSampler vkSampler_Texture = VK_NULL_HANDLE;
union {
VkPipeline arr[2] = { VK_NULL_HANDLE, VK_NULL_HANDLE };
- struct {
- VkPipeline Texture;
- VkPipeline TextureWireframe;
- };
+ VkPipeline Texture;
+ VkPipeline TextureWireframe;
} pipelines;
};
extern ImplementedPipelines pkePipelines;