Skip to content

Commit

Permalink
Massive changes/fixes - remvoe a lot of "DE" prefixes and macros
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianensis committed May 2, 2021
1 parent 682b6b1 commit 3244c82
Show file tree
Hide file tree
Showing 188 changed files with 2,817 additions and 2,694 deletions.
52 changes: 2 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,10 @@
# README
---
## 🌿🎮 Druid Engine
## New Engine

<img src="./druid.png" width=50%>

> Druid Engine 🌿🎮 is a C++ / OpenGL Game Engine made from scratch with the only purpose of improving my gamedev and programming skills.
---

## Index
* [About the author](#about-the-author)
* [Evolution of Druid Engine](#evolution-of-druid-engine)
* [YouTube Devlogs](#youtube-devlogs)
* [Build instructions](#build)

---

## About the author

Hi! I'm Adrian, UE4/C++ games programmer. You can find me on Twitter and YouTube :D

* <img src="https://www.iconpacks.net/icons/2/free-twitter-logo-icon-2429-thumb.png" width=3%> **Twitter**: [Link to my Twitter profile](https://twitter.com/AdrianensisDev)
* <img src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c545.png" width=3.1%> **YouTube**: [Link to my YouTube channel](https://www.youtube.com/c/Adrianensis)
* <img src="https://hotemoji.com/images/dl/b/books-emoji-by-twitter.png" width=2.8%> **Portfolio**: [Link to my Portfolio](https://adrianensis.github.io/portfolio)

---

## Evolution of Druid Engine

[Link to Druid Engine Showcase repository](https://github.com/adrianensis/DruidEngineShowcase)

In this repository you'll find a lot of GIFs showing the evoultion of Druid Engine! I love GIFs :'D

## YouTube Devlogs

I created a short Devlog series in YouTube to explain, in general aspects, the most important modules I implemented in Druid Engine.

|Links to my YouTube channel and the Devlog playlist|
|---|
|[<img src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c545.png" width=3.1%> Link to my YouTube channel](https://www.youtube.com/c/Adrianensis)|
|[<img src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c545.png" width=3.1%> Link to Druid Engine - Devlog Playlist](https://www.youtube.com/watch?v=ViNNHauNDpw&list=PLfQ-ZA-2VtX2gE5ZX4U3I63zGHeWsxyxk)|

#### Druid Engine - Devlog Playlist

Here all the single videos in the playlist in case you want to take a quick look.
**Click any image** to go to the video!

| | | |
|---|---|---|
|[<img src="https://img.youtube.com/vi/ViNNHauNDpw/0.jpg">](https://www.youtube.com/watch?v=ViNNHauNDpw)|[<img src="https://img.youtube.com/vi/O7SM94nIfVg/0.jpg">](https://www.youtube.com/watch?v=O7SM94nIfVg)|[<img src="https://img.youtube.com/vi/XduOT0DWK-c/0.jpg">](https://www.youtube.com/watch?v=XduOT0DWK-c)|
|[<img src="https://img.youtube.com/vi/JsFuFA9nLpE/0.jpg">](https://www.youtube.com/watch?v=JsFuFA9nLpE)|[<img src="https://img.youtube.com/vi/JxJW0vuo_kw/0.jpg">](https://www.youtube.com/watch?v=JxJW0vuo_kw)|[<img src="https://img.youtube.com/vi/BqxLhTcZmtg/0.jpg">](https://www.youtube.com/watch?v=BqxLhTcZmtg)|

---

> New Engine is a C++ / OpenGL Game Engine made from scratch with the only purpose of improving my gamedev and programming skills.
## Build

Expand Down
2 changes: 1 addition & 1 deletion code/Config/ConfigMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace DE {
String ConfigMap::trueString = "true";
String ConfigMap::falseString = "false";

ConfigMap::ConfigMap() : DE_Class() {
ConfigMap::ConfigMap() : ObjectBase() {
}

ConfigMap::~ConfigMap() {
Expand Down
11 changes: 6 additions & 5 deletions code/Config/ConfigMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@

namespace DE {

class ConfigMap: public DE_Class {
class ConfigMap : public ObjectBase {

private:
using StringStringMap = HashMap<String, String>;
DE_M(Map, StringStringMap)
HashMap<String, String> mMap;

static String trueString;
static String falseString;

public:

DE_CLASS_BODY(ConfigMap)
GENERATE_METADATA(ConfigMap);

ConfigMap();
virtual ~ConfigMap() override;

void init();
void clear();
Expand All @@ -35,5 +37,4 @@ class ConfigMap: public DE_Class {
/*template<class T>
const List<T>* getList(const String &key);*/
};

}
2 changes: 1 addition & 1 deletion code/Config/EngineConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace DE {

EngineConfig::EngineConfig() : DE_Class(), Singleton() {
EngineConfig::EngineConfig() : ObjectBase(), Singleton() {
}

EngineConfig::~EngineConfig() {
Expand Down
9 changes: 6 additions & 3 deletions code/Config/EngineConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

namespace DE {

class EngineConfig: public DE_Class, public Singleton<EngineConfig> {
class EngineConfig: public ObjectBase, public Singleton<EngineConfig> {

private:
DE_M(ConfigMap, ConfigMap)
ConfigMap mConfigMap;

public:

DE_CLASS_BODY(EngineConfig)
GENERATE_METADATA(EngineConfig);

EngineConfig();
virtual ~EngineConfig() override;

void init();
void readConfigFile(const String &path);
Expand Down
20 changes: 10 additions & 10 deletions code/Containers/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ class Array: public SequentialContainer<T> {

private:

DE_M(TStart, T*);
DE_M(Start, byte*);
T* mTStart;
byte* mStart;

T& randomAccessOperator(u32 index) const {
DE_ASSERT(index >= 0 && index < this->getLength(), "Index out of bounds.");
ASSERT(index >= 0 && index < this->getLength(), "Index out of bounds.");
return mTStart[index];
}

void checkPut(const SequentialContainer<T> &other, u32 destinyIndex, u32 sourceIndex, u32 length) override {
DE_ASSERT(sourceIndex >= 0 && sourceIndex < other.getLength(), "sourceIndex is out of bounds.");
DE_ASSERT(destinyIndex >= 0, "destinyIndex must be greater than 0.");
DE_ASSERT(length <= other.getLength() - sourceIndex, "Not enough space to copy.");
DE_ASSERT(length <= this->getLength() - destinyIndex, "Not enough space to put array.");
ASSERT(sourceIndex >= 0 && sourceIndex < other.getLength(), "sourceIndex is out of bounds.");
ASSERT(destinyIndex >= 0, "destinyIndex must be greater than 0.");
ASSERT(length <= other.getLength() - sourceIndex, "Not enough space to copy.");
ASSERT(length <= this->getLength() - destinyIndex, "Not enough space to put array.");
}

void raw_copy(const Array &other) {
Expand Down Expand Up @@ -76,7 +76,7 @@ class Array: public SequentialContainer<T> {

using SequentialContainer<T>::put; // because "put" method is ambiguous.

DE_CLASS_BODY_TEMPLATE(Array<T>, T);
GENERATE_METADATA(Array<T>);

/*!
\brief Default Constructor.
Expand Down Expand Up @@ -142,12 +142,12 @@ class Array: public SequentialContainer<T> {
}

T get(u32 index) const override {
DE_ASSERT(index >= 0 && index < SequentialContainer<T>::getLength(), "Index out of bounds.");
ASSERT(index >= 0 && index < SequentialContainer<T>::getLength(), "Index out of bounds.");
return mTStart[index];
}

void set(u32 index, const T element) override {
DE_ASSERT(index >= 0 && index < SequentialContainer<T>::getLength(), "Index out of bounds.");
ASSERT(index >= 0 && index < SequentialContainer<T>::getLength(), "Index out of bounds.");
mTStart[index] = element;
}

Expand Down
2 changes: 1 addition & 1 deletion code/Containers/BaseContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace DE {

BaseContainer::BaseContainer() : DE_Class() {
BaseContainer::BaseContainer() : ObjectBase() {
mLength = 0;
mElementSize = 0;
mAlignment = 0;
Expand Down
20 changes: 14 additions & 6 deletions code/Containers/BaseContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ namespace DE {
/*!
\brief Generic container.
*/
class BaseContainer: public DE_Class {
class BaseContainer : public ObjectBase {

protected:

DE_M_GET(Length, u32)
DE_M_GET(ElementSize, u32)
DE_M_GET(Alignment, u32)
DE_M_GET_SET(Allocator, Allocator*)
u32 mLength;
u32 mElementSize;
u32 mAlignment;
Allocator* mAllocator;

void init(u32 length, u32 elementSize, u32 alignment);

public:

DE_CLASS_BODY(BaseContainer)
GENERATE_METADATA(BaseContainer);

BaseContainer();
virtual ~BaseContainer() override;

GET(Length);
GET(ElementSize);
GET(Alignment);
GET_SET(Allocator);

/*!
\brief Clear the container.
Expand Down
28 changes: 14 additions & 14 deletions code/Containers/DynamicArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template<class T>
class DynamicArray: public SequentialContainer<T> {

template<class K, class V>
friend class HashMap; // Friend Class
friend class HashMap; // Friend ObjectBase

private:

Expand All @@ -33,7 +33,7 @@ class DynamicArray: public SequentialContainer<T> {
}

T& randomAccessOperator(u32 index) const {
DE_ASSERT(index >= 0, "Index out of bounds.");
ASSERT(index >= 0, "Index out of bounds.");

u32 realIndex = index % smMinSize;
u32 arrayIndex = ceil(index / smMinSize);
Expand All @@ -43,15 +43,15 @@ class DynamicArray: public SequentialContainer<T> {
}

void checkPut(const SequentialContainer<T> &other, u32 destinyIndex, u32 sourceIndex, u32 length) override {
DE_ASSERT(sourceIndex >= 0 && sourceIndex < other.getLength(), "sourceIndex is out of bounds.");
DE_ASSERT(destinyIndex >= 0, "destinyIndex must be greater than 0.");
DE_ASSERT(length <= other.getLength() - sourceIndex, "Not enough space to copy.");
ASSERT(sourceIndex >= 0 && sourceIndex < other.getLength(), "sourceIndex is out of bounds.");
ASSERT(destinyIndex >= 0, "destinyIndex must be greater than 0.");
ASSERT(length <= other.getLength() - sourceIndex, "Not enough space to copy.");
}


public:

DE_CLASS_BODY_TEMPLATE(DynamicArray<T>, T);
GENERATE_METADATA(DynamicArray<T>);

/*!
\brief Default Constructor.
Expand All @@ -68,10 +68,10 @@ class DynamicArray: public SequentialContainer<T> {
if (mArrays != nullptr) {

FOR_LIST (it, mArrays) {
DE_FREE(it.get());
Memory::free(it.get());
}

DE_FREE(mArrays);
Memory::free(mArrays);
}
}

Expand All @@ -81,13 +81,13 @@ class DynamicArray: public SequentialContainer<T> {
*/
void init(const DynamicArray<T> &other) {
BaseContainer::init(other.BaseContainer::mLength, other.mElementSize, other.BaseContainer::mAlignment);
mArrays = DE_NEW<List<Array<T>*> >();
mArrays = Memory::allocate<List<Array<T>*> >();
mArrays->init();

FOR_LIST (it, other.mArrays)
{
Array<T>* otherArray = it.get();
Array<T>* array = DE_NEW<Array<T>>();
Array<T>* array = Memory::allocate<Array<T>>();
array->init(*otherArray);
mArrays->pushBack(array);
}
Expand Down Expand Up @@ -133,7 +133,7 @@ class DynamicArray: public SequentialContainer<T> {
*/
void init(const T rawArray[], u32 length, u32 alignment) override {
BaseContainer::setAllocator(&Memory::getGlobal());
Array<T>* array = DE_NEW<Array<T>>(alignment);
Array<T>* array = Memory::allocate<Array<T>>(alignment);
array->init(rawArray, length);
DynamicArray::init(*array);
}
Expand Down Expand Up @@ -162,15 +162,15 @@ class DynamicArray: public SequentialContainer<T> {
BaseContainer::init(length, sizeof(T), alignment);

// list of arrays
mArrays = DE_NEW<List<Array<T>*> >();
mArrays = Memory::allocate<List<Array<T>*> >();
mArrays->init();

// how many arrays are needed.
u32 arrayCount = ceil(length / smMinSize) + 1;

FOR_RANGE(i, 0, arrayCount)
{
Array<T>* newArray = DE_NEW<Array<T>>(SequentialContainer<T>::mAlignment);
Array<T>* newArray = Memory::allocate<Array<T>>(SequentialContainer<T>::mAlignment);
newArray->init(smMinSize);

mArrays->pushBack(newArray);
Expand Down Expand Up @@ -206,7 +206,7 @@ class DynamicArray: public SequentialContainer<T> {
void set(u32 index, const T element) {
// resize
if (index >= mArrays->getLength() * smMinSize) {
Array<T>* newArray = DE_NEW<Array<T>>(SequentialContainer<T>::mAlignment);
Array<T>* newArray = Memory::allocate<Array<T>>(SequentialContainer<T>::mAlignment);
newArray->init(smMinSize);

mArrays->pushBack(newArray);
Expand Down
Loading

0 comments on commit 3244c82

Please sign in to comment.