Skip to content

Commit

Permalink
[#17] : Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
ange-yaghi committed Jun 28, 2020
1 parent c334d6c commit 35b4a16
Show file tree
Hide file tree
Showing 58 changed files with 402 additions and 519 deletions.
2 changes: 1 addition & 1 deletion engines/basic/include/delta_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace dbasic {
dphysics::MassSpringSystem PhysicsSystem;
dphysics::RigidBodySystem RBSystem;

ysError CreateGameWindow(const char *title, void *instance, ysContextObject::DEVICE_API API, const char *shaderDirectory = "../DeltaEngineTullahoma/Shaders/", bool depthBuffer = true);
ysError CreateGameWindow(const char *title, void *instance, ysContextObject::DeviceAPI API, const char *shaderDirectory = "../DeltaEngineTullahoma/Shaders/", bool depthBuffer = true);
ysError StartFrame();
ysError EndFrame();
ysError Destroy();
Expand Down
8 changes: 4 additions & 4 deletions engines/basic/src/delta_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dbasic::DeltaEngine::~DeltaEngine() {
assert(m_lightingControlBuffer == nullptr);
}

ysError dbasic::DeltaEngine::CreateGameWindow(const char *title, void *instance, ysContextObject::DEVICE_API API, const char *shaderDirectory, bool depthBuffer) {
ysError dbasic::DeltaEngine::CreateGameWindow(const char *title, void *instance, ysContextObject::DeviceAPI API, const char *shaderDirectory, bool depthBuffer) {
YDS_ERROR_DECLARE("CreateGameWindow");

// Create the window system
Expand Down Expand Up @@ -297,8 +297,8 @@ ysError dbasic::DeltaEngine::InitializeShaders(const char *shaderDirectory) {

char buffer[256];

if (m_device->GetAPI() == ysContextObject::DIRECTX11 ||
m_device->GetAPI() == ysContextObject::DIRECTX10)
if (m_device->GetAPI() == ysContextObject::DeviceAPI::DirectX11 ||
m_device->GetAPI() == ysContextObject::DeviceAPI::DirectX10)
{
sprintf_s(buffer, "%s%s", shaderDirectory, "delta_engine_shader.fx");
YDS_NESTED_ERROR_CALL(m_device->CreateVertexShader(&m_vertexShader, buffer, "VS_STANDARD"));
Expand All @@ -309,7 +309,7 @@ ysError dbasic::DeltaEngine::InitializeShaders(const char *shaderDirectory) {
YDS_NESTED_ERROR_CALL(m_device->CreateVertexShader(&m_consoleVertexShader, buffer, "VS_CONSOLE"));
YDS_NESTED_ERROR_CALL(m_device->CreatePixelShader(&m_consolePixelShader, buffer, "PS_CONSOLE"));
}
else if (m_device->GetAPI() == ysContextObject::OPENGL4_0) {
else if (m_device->GetAPI() == ysContextObject::DeviceAPI::OpenGL4_0) {
sprintf_s(buffer, "%s%s", shaderDirectory, "delta_engine_shader.glvs");
YDS_NESTED_ERROR_CALL(m_device->CreateVertexShader(&m_vertexShader, buffer, "VS"));
YDS_NESTED_ERROR_CALL(m_device->CreateVertexShader(&m_vertexSkinnedShader, buffer, "VS"));
Expand Down
1 change: 0 additions & 1 deletion include/yds_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define YDS_BASE_H

#include "yds_dynamic_array.h"
#include "yds_syntax.h"

class ysObject : public ysDynamicArrayElement {
public:
Expand Down
29 changes: 10 additions & 19 deletions include/yds_context_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,26 @@

#include "yds_base.h"

class ysContextObject : public ysObject
{

class ysContextObject : public ysObject {
public:

enum DEVICE_API
{

API_UNKNOWN,
DIRECTX10,
DIRECTX11,
OPENGL4_0

enum class DeviceAPI {
Unknown,
DirectX10,
DirectX11,
OpenGL4_0
};

public:

ysContextObject();
ysContextObject(const char *typeID, DEVICE_API API);
ysContextObject(const char *typeID, DeviceAPI API);
virtual ~ysContextObject();

DEVICE_API GetAPI() const { return m_api; }
DeviceAPI GetAPI() const { return m_api; }

bool CheckCompatibility(ysContextObject *object) const { return (object) ? object->m_api == m_api : true; }

private:

DEVICE_API m_api;

DeviceAPI m_api;
};

#endif
#endif /* YDS_CONTEXT_OBJECT_H */
10 changes: 3 additions & 7 deletions include/yds_depth_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@

#include "yds_context_object.h"

class ysDepthBuffer : public ysContextObject
{

class ysDepthBuffer : public ysContextObject {
public:

ysDepthBuffer();
ysDepthBuffer(DEVICE_API API);
ysDepthBuffer(DeviceAPI API);
virtual ~ysDepthBuffer();

};

#endif
#endif /* YDS_DEPTH_BUFFER_H */
4 changes: 2 additions & 2 deletions include/yds_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ struct ysTextureSlot {
class ysDevice : public ysContextObject {
protected:
ysDevice();
ysDevice(ysContextObject::DEVICE_API API);
ysDevice(ysContextObject::DeviceAPI API);
virtual ~ysDevice();

public:
static ysError CreateDevice(ysDevice **device, DEVICE_API API);
static ysError CreateDevice(ysDevice **device, DeviceAPI API);

/* Main Device Interface */

Expand Down
2 changes: 1 addition & 1 deletion include/yds_gpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ysGPUBuffer : public ysContextObject {

public:
ysGPUBuffer();
ysGPUBuffer(DEVICE_API API);
ysGPUBuffer(DeviceAPI API);
virtual ~ysGPUBuffer();

int GetSize() const { return m_size; }
Expand Down
54 changes: 13 additions & 41 deletions include/yds_handle_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,90 +2,62 @@
#define YDS_HANDLE_ARRAY_H

#include "yds_dynamic_array.h"

#include "yds_linked_list.h"

template<typename TYPE, int START_SIZE=0>
class ysHandleArray : public ysDynamicArray<TYPE, START_SIZE>
{

class ysHandleArray : public ysDynamicArray<TYPE, START_SIZE> {
public:
ysHandleArray() { /* void */ }
~ysHandleArray() { /* void */ }

ysHandleArray()
{
}

~ysHandleArray()
{
}

void Preallocate(int nObjects)
{

if (!nObjects) return;
if (m_array) return;
void Preallocate(int nObjects) {
if (nObjects == 0) return;
if (m_array != nullptr) return;

m_array = new TYPE[nObjects];

}

int New()
{

int New() {
if (m_nObjects >= m_maxSize) Extend();

m_array[m_nObjects] = new TYPE;
return m_nObjects++;

}

void Delete(int index)
{

void Delete(int index) {
if (m_nObjects <= m_maxSize / 2) Condense();

delete m_array[index];
m_array[index] = NULL;
m_nObjects--;

}

TYPE *Get(int index)
{

TYPE *Get(int index) {
return m_array[index];

}

protected:

void Extend()
{

void Extend() {
TYPE **newArray = new TYPE *[m_maxSize * 2];
memcpy(newArray, m_array, sizeof(TYPE *) * m_nObjects);

delete [] m_array;

m_array = newArray;

}

void Condense()
{

void Condense() {
TYPE **newArray = new TYPE *[m_maxSize / 2];
memcpy(newArray, m_array, sizeof(TYPE *) * m_nObjects);

delete [] m_array;

m_array = newArray;

}

protected:

ysLinkedList m_slots;

};

#endif
#endif /* YDS_HANDLE_ARRAY_H */
2 changes: 1 addition & 1 deletion include/yds_input_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ysInputLayout : public ysContextObject {

public:
ysInputLayout();
ysInputLayout(DEVICE_API API);
ysInputLayout(DeviceAPI API);
virtual ~ysInputLayout();

protected:
Expand Down
15 changes: 5 additions & 10 deletions include/yds_key_maps.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#ifndef KEY_MAPS_H
#define KEY_MAPS_H
#ifndef YDS_KEY_MAPS_H
#define YDS_KEY_MAPS_H

#include "yds_keyboard.h"

class ysKeyMaps
{

class ysKeyMaps {
public:

ysKeyMaps() { m_windowsKeyMap = 0; }
ysKeyMaps() { m_windowsKeyMap = nullptr; }
~ysKeyMaps() {}

static const ysKeyboard::KEY_CODE *GetWindowsKeyMap();

protected:

static ysKeyboard::KEY_CODE *m_windowsKeyMap;

};

#endif
#endif /* YDS_KEY_MAPS_H */
52 changes: 10 additions & 42 deletions include/yds_linked_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,95 +3,65 @@

#include "yds_memory_base.h"

class ysLinkedList;
class ysLink
{

friend ysLinkedList;

class ysLink {
friend class ysLinkedList;
public:

ysLink();
~ysLink();

union
{

union {
void *Data;
int *IntData;

};

ysLink *GetNext() { return Next; }
ysLink *GetPrevious() { return Previous; }

protected:

ysLink *Next;
ysLink *Previous;

};

class ysLinkedListIterator
{

class ysLinkedListIterator {
public:

ysLinkedListIterator(ysLink *start);
ysLinkedListIterator();
~ysLinkedListIterator();

void SetStart(ysLink *start)
{

void SetStart(ysLink *start) {
m_start = start;

}

void Reset(ysLink *start) { SetStart(start); Reset(); }
void Reset() { m_location = m_start; m_reachedStart = false; }

void Increment()
{

void Increment() {
m_location = m_location->GetNext();
if (m_location == m_start) m_reachedStart = true;
else m_reachedStart = false;

}

void Decrement()
{

void Decrement() {
m_location = m_location->GetNext();
if (m_location == m_start) m_reachedStart = true;
else m_reachedStart = false;

}

bool AtEnd()
{

bool AtEnd() {
return m_reachedStart;

}

ysLink *GetLink() { return m_location; }

protected:

ysLink *m_start;
ysLink *m_location;

bool m_reachedStart;

};

class ysLinkedList
{

class ysLinkedList {
public:

ysLinkedList();
~ysLinkedList();

Expand All @@ -103,9 +73,7 @@ class ysLinkedList
ysLink *GetTail();

protected:

ysLink *m_head;

};

#endif
#endif /* YDS_LINKED_LIST_H */
Loading

0 comments on commit 35b4a16

Please sign in to comment.