Skip to content

Commit

Permalink
jleAssert and jleCommon header files
Browse files Browse the repository at this point in the history
  • Loading branch information
Mormert committed Feb 18, 2024
1 parent 6a42e4f commit aca4634
Show file tree
Hide file tree
Showing 76 changed files with 161 additions and 79 deletions.
2 changes: 1 addition & 1 deletion engine/cAnimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleAnimation.h"
#include "jleComponent.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cAseprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleAseprite.h"
#include "jleComponent.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleAseprite.h"
#include "jleComponent.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cCameraFPV.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "cCamera.h"
#include "jleCamera.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleComponent.h"

Expand Down
2 changes: 1 addition & 1 deletion engine/cMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleComponent.h"
#include "jleMaterial.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cRigidbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ cRigidbody::setWorldTransform(const btTransform &centerOfMassWorldTrans)
std::unique_ptr<btRigidBody>
cRigidbody::createRigidbody(bool isDynamic, btCollisionShape *shape)
{
btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));
jleAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));

btVector3 localInertia(0, 0, 0);
if (isDynamic) {
Expand Down
2 changes: 1 addition & 1 deletion engine/cRigidbody.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleComponent.h"
#include "jleMaterial.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cSpriteDepth.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleComponent.h"
#include "jleTransform.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/cTransformNetSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleComponent.h"

Expand Down
2 changes: 1 addition & 1 deletion engine/cUITransformUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion engine/editor/jleConsoleEditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#if JLE_BUILD_EDITOR

Expand Down
2 changes: 1 addition & 1 deletion engine/editor/jleEditorBuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#if JLE_BUILD_EDITOR

Expand Down
2 changes: 1 addition & 1 deletion engine/editor/jleEditorGizmos.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef JLE_EDITORGIZMOS_H
#define JLE_EDITORGIZMOS_H

#include "jleBuildConfig.h"
#include "jleCommon.h"

#if JLE_BUILD_EDITOR

Expand Down
2 changes: 1 addition & 1 deletion engine/editor/jleEditorSaveState.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef JLE_EDITORSAVESTATE
#define JLE_EDITORSAVESTATE

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleSerializedResource.h"
#include "jleTypeReflectionUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/editor/jleEditorTextEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef JLEEDITORTEXTEDIT_H
#define JLEEDITORTEXTEDIT_H

#include "jleBuildConfig.h"
#include "jleCommon.h"

#if JLE_BUILD_EDITOR

Expand Down
2 changes: 1 addition & 1 deletion engine/editor/jleGameEditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#if JLE_BUILD_EDITOR

Expand Down
2 changes: 1 addition & 1 deletion engine/jle3DGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <glm/glm.hpp>

Expand Down
2 changes: 1 addition & 1 deletion engine/jle3DRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jle3DGraph.h"
#include "jle3DSettings.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/jleAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jleAnimation::readBonesFromMesh(const aiAnimation *animation, const aiMesh *mesh
void
jleAnimation::readHierarchyData(jleAnimationNode &dest, aiNode *src)
{
assert(src);
jleAssert(src);

dest.name = src->mName.C_Str();
dest.transformation = glm::transpose(glm::make_mat4(&src->mTransformation.a1));
Expand Down
2 changes: 1 addition & 1 deletion engine/jleAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleAnimationBone.h"
#include "jleSkinnedMesh.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/jleAnimationBone.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <string>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion engine/jleAnimationFinalMatrices.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <glm/glm.hpp>
#include <vector>
Expand Down
55 changes: 55 additions & 0 deletions engine/jleAssert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*********************************************************************************************
* *
* , . , . ,--. *
* | | | | | o *
* | ,-. |- -- | ,-: ,-: ,-: ,-. ,-| |- ;-. ,-: . ;-. ,-. *
* | |-' | | | | | | | | |-' | | | | | | | | | | |-' *
* -' `-' `-' `--' `-` `-| `-| `-' `-' `--' ' ' `-| ' ' ' `-' *
* *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
* Jet-Lagged Engine (jle) is licenced under GNU General Public License v3.0. *
* The licence can be found here: https://github.com/Mormert/jle/blob/master/LICENSE *
* Copyright (c) 2020-2024 Johan Lind. All rights reserved. *
* *
*********************************************************************************************/

#ifndef JLE_ASSERT_H
#define JLE_ASSERT_H

#ifndef NDEBUG

#include <plog/Log.h>

#ifdef _WIN32
#include <intrin.h>
#define JLE_DEBUG_BREAK __debugbreak()
#else
#include <signal.h>
#define JLE_DEBUG_BREAK raise(SIGTRAP)
#endif

// Will only assert once, which can be convenient sometimes to avoid assertion spam
#define jleAssertOnce(condition) \
do { \
static bool triggeredOnce{false}; \
if (!(condition) && !triggeredOnce) { \
triggeredOnce = true; \
LOGE << "Assertion failed: " << #condition << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
JLE_DEBUG_BREAK; \
} \
} while (0)

#define jleAssert(condition) \
do { \
if (!(condition)) { \
LOGE << "Assertion failed: " << #condition << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
JLE_DEBUG_BREAK; \
} \
} while (0)

#else
#define jleAssert(condition) ((void)0)
#define jleAssertOnce(condition) ((void)0)
#endif

#endif // JLE_ASSERT_H
2 changes: 1 addition & 1 deletion engine/jleCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <glm/glm.hpp>

Expand Down
2 changes: 1 addition & 1 deletion engine/jleCommandArguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <string>
#include <vector>
Expand Down
24 changes: 24 additions & 0 deletions engine/jleCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*********************************************************************************************
* *
* , . , . ,--. *
* | | | | | o *
* | ,-. |- -- | ,-: ,-: ,-: ,-. ,-| |- ;-. ,-: . ;-. ,-. *
* | |-' | | | | | | | | |-' | | | | | | | | | | |-' *
* -' `-' `-' `--' `-` `-| `-| `-' `-' `--' ' ' `-| ' ' ' `-' *
* *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
* Jet-Lagged Engine (jle) is licenced under GNU General Public License v3.0. *
* The licence can be found here: https://github.com/Mormert/jle/blob/master/LICENSE *
* Copyright (c) 2020-2024 Johan Lind. All rights reserved. *
* *
*********************************************************************************************/

#ifndef JLE_COMMON_H
#define JLE_COMMON_H

#include "jleBuildConfig.h"
#include "jleAssert.h"

#include <plog/Log.h>

#endif //JLE_COMMON_H
2 changes: 1 addition & 1 deletion engine/jleCompileHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef JLE_COMPILE_HELPER
#define JLE_COMPILE_HELPER

#include "jleBuildConfig.h"
#include "jleCommon.h"

// These macros are used to reduce compile times by having the serialisation function from cereal
// only be compiled once for the archives used in jle, in one .cpp file, and not spread out across multiple.
Expand Down
2 changes: 1 addition & 1 deletion engine/jleComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef JLE_COMPONENT
#define JLE_COMPONENT

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleTypeReflectionUtils.h"

Expand Down
2 changes: 1 addition & 1 deletion engine/jleEngineSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef JLE_ENGINESETTINGS
#define JLE_ENGINESETTINGS

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleSerializedResource.h"
#include "jleTypeReflectionUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/jleFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <glm/glm.hpp>
#include <map>
Expand Down
6 changes: 3 additions & 3 deletions engine/jleFrameBufferInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jleFramebufferInterface::~jleFramebufferInterface()
void
jleFramebufferInterface::blitToOther(jleFramebufferInterface &framebuffer, bool includeDepth)
{
assert(width() == framebuffer.width());
assert(height() == framebuffer.height());
jleAssert(width() == framebuffer.width());
jleAssert(height() == framebuffer.height());

glBindFramebuffer(GL_READ_FRAMEBUFFER, _framebuffer);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer._framebuffer);
Expand Down Expand Up @@ -80,7 +80,7 @@ unsigned int
jleFramebufferInterface::texture() const
{
// Note: the framebuffer doesn't have to keep a texture!
assert(_texture > 0);
jleAssert(_texture > 0);
return _texture;
}

Expand Down
2 changes: 1 addition & 1 deletion engine/jleFrameBufferInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include <glm/glm.hpp>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion engine/jleFramebufferMultisample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jleFramebufferMultisample::setSamples(unsigned int samples)
{
int highestSamples;
glGetIntegerv(GL_SAMPLES, &highestSamples);
assert(samples < highestSamples);
jleAssert(samples < highestSamples);

_msaaSamples = samples;
resize(_width, _height);
Expand Down
2 changes: 1 addition & 1 deletion engine/jleFramebufferPicking.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleFrameBufferInterface.h"

Expand Down
2 changes: 1 addition & 1 deletion engine/jleFramebufferScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "jleBuildConfig.h"
#include "jleCommon.h"

#include "jleFrameBufferInterface.h"

Expand Down
Loading

0 comments on commit aca4634

Please sign in to comment.