Merge the game to dengine, reduce header coupling
Until engine architecture can clearly be separated from the game, i.e. notion of entity storage belonging to game and concept of entity belonging to engine, worlds/scenes belonging to game or engine- the project will only refer to Dengine.
This commit is contained in:
parent
8a3886a60e
commit
85becdfd6c
@ -154,7 +154,7 @@
|
|||||||
<ClInclude Include="src\include\Dengine\Renderer.h" />
|
<ClInclude Include="src\include\Dengine\Renderer.h" />
|
||||||
<ClInclude Include="src\include\Dengine\Shader.h" />
|
<ClInclude Include="src\include\Dengine\Shader.h" />
|
||||||
<ClInclude Include="src\include\Dengine\Texture.h" />
|
<ClInclude Include="src\include\Dengine\Texture.h" />
|
||||||
<ClInclude Include="src\include\WorldTraveller\WorldTraveller.h" />
|
<ClInclude Include="src\include\Dengine\WorldTraveller.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@ -33,9 +33,6 @@
|
|||||||
<ClCompile Include="src\Platform.c">
|
<ClCompile Include="src\Platform.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\dengine.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\AssetManager.c">
|
<ClCompile Include="src\AssetManager.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -51,6 +48,9 @@
|
|||||||
<ClCompile Include="src\Entity.c">
|
<ClCompile Include="src\Entity.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\dengine.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="data\shaders\default.vert.glsl" />
|
<None Include="data\shaders\default.vert.glsl" />
|
||||||
@ -80,9 +80,6 @@
|
|||||||
<ClInclude Include="src\include\Dengine\Renderer.h">
|
<ClInclude Include="src\include\Dengine\Renderer.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\include\WorldTraveller\WorldTraveller.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\include\Dengine\Entity.h">
|
<ClInclude Include="src\include\Dengine\Entity.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -104,5 +101,8 @@
|
|||||||
<ClInclude Include="src\include\Dengine\Audio.h">
|
<ClInclude Include="src\include\Dengine\Audio.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\include\Dengine\WorldTraveller.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -21,6 +21,8 @@
|
|||||||
#include "Dengine/OpenGL.h"
|
#include "Dengine/OpenGL.h"
|
||||||
#include "Dengine/Platform.h"
|
#include "Dengine/Platform.h"
|
||||||
|
|
||||||
|
// TODO(doyle): Switch to hash based lookup
|
||||||
|
// TODO(doyle): Use pointers, so we can forward declare all assets?
|
||||||
AudioVorbis *asset_getVorbis(AssetManager *assetManager,
|
AudioVorbis *asset_getVorbis(AssetManager *assetManager,
|
||||||
const enum AudioList type)
|
const enum AudioList type)
|
||||||
{
|
{
|
||||||
|
90
src/Debug.c
90
src/Debug.c
@ -1,8 +1,81 @@
|
|||||||
#include "Dengine/Debug.h"
|
#include "Dengine/Debug.h"
|
||||||
#include "Dengine/Platform.h"
|
|
||||||
#include "Dengine/AssetManager.h"
|
#include "Dengine/AssetManager.h"
|
||||||
|
#include "Dengine/Entity.h"
|
||||||
|
#include "Dengine/MemoryArena.h"
|
||||||
|
#include "Dengine/Platform.h"
|
||||||
|
#include "Dengine/Renderer.h"
|
||||||
|
#include "Dengine/WorldTraveller.h"
|
||||||
|
|
||||||
DebugState GLOBAL_debug;
|
typedef struct DebugState
|
||||||
|
{
|
||||||
|
Font font;
|
||||||
|
i32 *callCount;
|
||||||
|
f32 stringLineGap;
|
||||||
|
|
||||||
|
/* Debug strings rendered in top left corner */
|
||||||
|
char debugStrings[64][128];
|
||||||
|
i32 numDebugStrings;
|
||||||
|
f32 stringUpdateTimer;
|
||||||
|
f32 stringUpdateRate;
|
||||||
|
v2 initialStringP;
|
||||||
|
v2 currStringP;
|
||||||
|
|
||||||
|
/* Debug gui console log */
|
||||||
|
char console[20][128];
|
||||||
|
i32 consoleIndex;
|
||||||
|
v2 initialConsoleP;
|
||||||
|
} DebugState;
|
||||||
|
|
||||||
|
GLOBAL_VAR DebugState GLOBAL_debug;
|
||||||
|
|
||||||
|
inline char *debug_entitystate_string(i32 val)
|
||||||
|
{
|
||||||
|
char *string;
|
||||||
|
switch(val)
|
||||||
|
{
|
||||||
|
case entitystate_idle:
|
||||||
|
string = "EntityState_Idle";
|
||||||
|
break;
|
||||||
|
case entitystate_battle:
|
||||||
|
string = "EntityState_Battle";
|
||||||
|
break;
|
||||||
|
case entitystate_attack:
|
||||||
|
string = "EntityState_Attack";
|
||||||
|
break;
|
||||||
|
case entitystate_dead:
|
||||||
|
string = "EntityState_Dead";
|
||||||
|
break;
|
||||||
|
case entitystate_count:
|
||||||
|
string = "EntityState_Count (Error!)";
|
||||||
|
break;
|
||||||
|
case entitystate_invalid:
|
||||||
|
string = "EntityState_Invalid (Error!)";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
string = "EntityState Unknown (NOT DEFINED)";
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char *debug_entityattack_string(i32 val)
|
||||||
|
{
|
||||||
|
char *string;
|
||||||
|
switch(val)
|
||||||
|
{
|
||||||
|
case entityattack_tackle:
|
||||||
|
string = "EntityAttack_Tackle";
|
||||||
|
break;
|
||||||
|
case entityattack_count:
|
||||||
|
string = "EntityAttack_Count (Error!)";
|
||||||
|
break;
|
||||||
|
case entityattack_invalid:
|
||||||
|
string = "EntityAttack_Invalid";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
string = "EntityAttack Unknown (NOT DEFINED)";
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
void debug_init(MemoryArena *arena, v2 windowSize, Font font)
|
void debug_init(MemoryArena *arena, v2 windowSize, Font font)
|
||||||
{
|
{
|
||||||
@ -30,6 +103,19 @@ void debug_init(MemoryArena *arena, v2 windowSize, Font font)
|
|||||||
GLOBAL_debug.initialConsoleP = V2(consoleXPos, consoleYPos);
|
GLOBAL_debug.initialConsoleP = V2(consoleXPos, consoleYPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_callCountIncrement(i32 id)
|
||||||
|
{
|
||||||
|
ASSERT(id < debugcallcount_num);
|
||||||
|
GLOBAL_debug.callCount[id]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void debug_clearCallCounter()
|
||||||
|
{
|
||||||
|
for (i32 i = 0; i < debugcallcount_num; i++)
|
||||||
|
GLOBAL_debug.callCount[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void debug_consoleLog(char *string, char *file, int lineNum)
|
void debug_consoleLog(char *string, char *file, int lineNum)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
96
src/Entity.c
96
src/Entity.c
@ -1,11 +1,7 @@
|
|||||||
#include "Dengine/AssetManager.h"
|
|
||||||
#include "Dengine/MemoryArena.h"
|
|
||||||
#include "Dengine/Platform.h"
|
|
||||||
#include "Dengine/Debug.h"
|
|
||||||
|
|
||||||
#include "Dengine/Entity.h"
|
#include "Dengine/Entity.h"
|
||||||
|
#include "Dengine/Debug.h"
|
||||||
#include "WorldTraveller/WorldTraveller.h"
|
#include "Dengine/Platform.h"
|
||||||
|
#include "Dengine/WorldTraveller.h"
|
||||||
|
|
||||||
void entity_setActiveAnim(Entity *entity, enum AnimList animId)
|
void entity_setActiveAnim(Entity *entity, enum AnimList animId)
|
||||||
{
|
{
|
||||||
@ -25,7 +21,8 @@ void entity_setActiveAnim(Entity *entity, enum AnimList animId)
|
|||||||
|
|
||||||
void entity_updateAnim(Entity *entity, f32 dt)
|
void entity_updateAnim(Entity *entity, f32 dt)
|
||||||
{
|
{
|
||||||
if (!entity->tex) return;
|
if (!entity->tex)
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO(doyle): Recheck why we have this twice
|
// TODO(doyle): Recheck why we have this twice
|
||||||
EntityAnim_ *entityAnim = &entity->anim[entity->currAnimId];
|
EntityAnim_ *entityAnim = &entity->anim[entity->currAnimId];
|
||||||
@ -47,20 +44,20 @@ void entity_updateAnim(Entity *entity, f32 dt)
|
|||||||
// may exceed the hitbox size of the entity
|
// may exceed the hitbox size of the entity
|
||||||
switch (entity->type)
|
switch (entity->type)
|
||||||
{
|
{
|
||||||
case entitytype_hero:
|
case entitytype_hero:
|
||||||
case entitytype_mob:
|
case entitytype_mob:
|
||||||
case entitytype_npc:
|
case entitytype_npc:
|
||||||
entity->renderSize = math_getRectSize(texRect);
|
entity->renderSize = math_getRectSize(texRect);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void entity_addAnim(AssetManager *assetManager, Entity *entity, i32 animId)
|
void entity_addAnim(AssetManager *assetManager, Entity *entity, i32 animId)
|
||||||
{
|
{
|
||||||
Animation *anim = asset_getAnim(assetManager, animId);
|
Animation *anim = asset_getAnim(assetManager, animId);
|
||||||
entity->anim[animId].anim = anim;
|
entity->anim[animId].anim = anim;
|
||||||
entity->anim[animId].currFrame = 0;
|
entity->anim[animId].currFrame = 0;
|
||||||
entity->anim[animId].currDuration = anim->frameDuration;
|
entity->anim[animId].currDuration = anim->frameDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,12 +84,11 @@ void entity_addGenericMob(MemoryArena *arena, AssetManager *assetManager,
|
|||||||
entity_addAnim(assetManager, mob, animlist_hero_battlePose);
|
entity_addAnim(assetManager, mob, animlist_hero_battlePose);
|
||||||
entity_addAnim(assetManager, mob, animlist_hero_tackle);
|
entity_addAnim(assetManager, mob, animlist_hero_tackle);
|
||||||
mob->currAnimId = animlist_hero_idle;
|
mob->currAnimId = animlist_hero_idle;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *entity_add(MemoryArena *arena, World *world, v2 pos, v2 size,
|
Entity *entity_add(MemoryArena *arena, World *world, v2 pos, v2 size,
|
||||||
enum EntityType type, enum Direction direction,
|
enum EntityType type, enum Direction direction, Texture *tex,
|
||||||
Texture *tex, b32 collides)
|
b32 collides)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DENGINE_DEBUG
|
#ifdef DENGINE_DEBUG
|
||||||
@ -111,39 +107,39 @@ Entity *entity_add(MemoryArena *arena, World *world, v2 pos, v2 size,
|
|||||||
entity.tex = tex;
|
entity.tex = tex;
|
||||||
entity.collides = collides;
|
entity.collides = collides;
|
||||||
|
|
||||||
switch(type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case entitytype_hero:
|
case entitytype_hero:
|
||||||
entity.stats = PLATFORM_MEM_ALLOC(arena, 1, EntityStats);
|
entity.stats = PLATFORM_MEM_ALLOC(arena, 1, EntityStats);
|
||||||
entity.stats->maxHealth = 100;
|
entity.stats->maxHealth = 100;
|
||||||
entity.stats->health = entity.stats->maxHealth;
|
entity.stats->health = entity.stats->maxHealth;
|
||||||
entity.stats->actionRate = 100;
|
entity.stats->actionRate = 100;
|
||||||
entity.stats->actionTimer = entity.stats->actionRate;
|
entity.stats->actionTimer = entity.stats->actionRate;
|
||||||
entity.stats->actionSpdMul = 100;
|
entity.stats->actionSpdMul = 100;
|
||||||
entity.stats->entityIdToAttack = -1;
|
entity.stats->entityIdToAttack = -1;
|
||||||
entity.stats->queuedAttack = entityattack_invalid;
|
entity.stats->queuedAttack = entityattack_invalid;
|
||||||
entity.state = entitystate_idle;
|
entity.state = entitystate_idle;
|
||||||
break;
|
break;
|
||||||
case entitytype_mob:
|
case entitytype_mob:
|
||||||
{
|
{
|
||||||
entity.stats = PLATFORM_MEM_ALLOC(arena, 1, EntityStats);
|
entity.stats = PLATFORM_MEM_ALLOC(arena, 1, EntityStats);
|
||||||
entity.stats->maxHealth = 100;
|
entity.stats->maxHealth = 100;
|
||||||
entity.stats->health = entity.stats->maxHealth;
|
entity.stats->health = entity.stats->maxHealth;
|
||||||
entity.stats->actionRate = 100;
|
entity.stats->actionRate = 100;
|
||||||
entity.stats->actionTimer = entity.stats->actionRate;
|
entity.stats->actionTimer = entity.stats->actionRate;
|
||||||
entity.stats->actionSpdMul = 100;
|
entity.stats->actionSpdMul = 100;
|
||||||
entity.stats->entityIdToAttack = -1;
|
entity.stats->entityIdToAttack = -1;
|
||||||
entity.stats->queuedAttack = entityattack_invalid;
|
entity.stats->queuedAttack = entityattack_invalid;
|
||||||
entity.state = entitystate_idle;
|
entity.state = entitystate_idle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
world->entities[world->freeEntityIndex++] = entity;
|
world->entities[world->freeEntityIndex++] = entity;
|
||||||
Entity *result = &world->entities[world->freeEntityIndex-1];
|
Entity *result = &world->entities[world->freeEntityIndex - 1];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -154,8 +150,8 @@ void entity_delete(MemoryArena *arena, World *world, i32 entityIndex)
|
|||||||
PLATFORM_MEM_FREE(arena, entity->stats, sizeof(EntityStats));
|
PLATFORM_MEM_FREE(arena, entity->stats, sizeof(EntityStats));
|
||||||
|
|
||||||
// TODO(doyle): Inefficient shuffle down all elements
|
// TODO(doyle): Inefficient shuffle down all elements
|
||||||
for (i32 i = entityIndex; i < world->freeEntityIndex-1; i++)
|
for (i32 i = entityIndex; i < world->freeEntityIndex - 1; i++)
|
||||||
world->entities[i] = world->entities[i+1];
|
world->entities[i] = world->entities[i + 1];
|
||||||
|
|
||||||
world->freeEntityIndex--;
|
world->freeEntityIndex--;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "Dengine/Platform.h"
|
#include "Dengine/Platform.h"
|
||||||
#include "Dengine/Debug.h"
|
#include "Dengine/MemoryArena.h"
|
||||||
|
|
||||||
void platform_memoryFree(MemoryArena *arena, void *data, i32 numBytes)
|
void platform_memoryFree(MemoryArena *arena, void *data, i32 numBytes)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include "Dengine/Renderer.h"
|
#include "Dengine/Renderer.h"
|
||||||
#include "Dengine/Debug.h"
|
#include "Dengine/Debug.h"
|
||||||
|
#include "Dengine/Entity.h"
|
||||||
#include "Dengine/OpenGL.h"
|
#include "Dengine/OpenGL.h"
|
||||||
#include "Dengine/Platform.h"
|
#include "Dengine/Platform.h"
|
||||||
|
#include "Dengine/Shader.h"
|
||||||
|
#include "Dengine/Texture.h"
|
||||||
|
|
||||||
#define RENDER_BOUNDING_BOX FALSE
|
#define RENDER_BOUNDING_BOX FALSE
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "WorldTraveller/WorldTraveller.h"
|
#include "Dengine/WorldTraveller.h"
|
||||||
|
|
||||||
#include "Dengine/Audio.h"
|
#include "Dengine/Audio.h"
|
||||||
#include "Dengine/Debug.h"
|
#include "Dengine/Debug.h"
|
||||||
#include "Dengine/Entity.h"
|
#include "Dengine/Entity.h"
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
#if 1
|
|
||||||
#include "Dengine/AssetManager.h"
|
#include "Dengine/AssetManager.h"
|
||||||
#include "Dengine/Audio.h"
|
|
||||||
#include "Dengine/Common.h"
|
#include "Dengine/Common.h"
|
||||||
#include "Dengine/Debug.h"
|
#include "Dengine/Debug.h"
|
||||||
#include "Dengine/Math.h"
|
#include "Dengine/Math.h"
|
||||||
#include "Dengine/OpenGL.h"
|
#include "Dengine/OpenGL.h"
|
||||||
#include "Dengine/Platform.h"
|
#include "Dengine/WorldTraveller.h"
|
||||||
|
|
||||||
#include "WorldTraveller/WorldTraveller.h"
|
|
||||||
|
|
||||||
// TODO(doyle): Temporary
|
|
||||||
struct AudioRenderer;
|
|
||||||
|
|
||||||
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mode)
|
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mode)
|
||||||
{
|
{
|
||||||
@ -176,7 +169,3 @@ int main()
|
|||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
#include <Tutorial.cpp>
|
|
||||||
#endif
|
|
||||||
|
@ -8,10 +8,6 @@
|
|||||||
/* Forward declaration */
|
/* Forward declaration */
|
||||||
typedef struct MemoryArena MemoryArena;
|
typedef struct MemoryArena MemoryArena;
|
||||||
|
|
||||||
#define MAX_TEXTURE_SIZE 1024
|
|
||||||
|
|
||||||
// TODO(doyle): Switch to hash based lookup
|
|
||||||
// TODO(doyle): Use pointers, so we can forward declare all assets?
|
|
||||||
typedef struct AssetManager
|
typedef struct AssetManager
|
||||||
{
|
{
|
||||||
Texture textures[32];
|
Texture textures[32];
|
||||||
@ -22,7 +18,7 @@ typedef struct AssetManager
|
|||||||
Font font;
|
Font font;
|
||||||
} AssetManager;
|
} AssetManager;
|
||||||
|
|
||||||
GLOBAL_VAR AssetManager assetManager;
|
#define MAX_TEXTURE_SIZE 1024
|
||||||
|
|
||||||
AudioVorbis *asset_getVorbis(AssetManager *assetManager,
|
AudioVorbis *asset_getVorbis(AssetManager *assetManager,
|
||||||
const enum AudioList type);
|
const enum AudioList type);
|
||||||
@ -48,8 +44,7 @@ const i32 asset_loadTTFont(AssetManager *assetManager, MemoryArena *arena,
|
|||||||
|
|
||||||
inline i32 asset_getVFontSpacing(FontMetrics metrics)
|
inline i32 asset_getVFontSpacing(FontMetrics metrics)
|
||||||
{
|
{
|
||||||
i32 result =
|
i32 result = metrics.ascent - metrics.descent + metrics.lineGap;
|
||||||
metrics.ascent - metrics.descent + metrics.lineGap;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
#define STB_VORBIS_HEADER_ONLY
|
#define STB_VORBIS_HEADER_ONLY
|
||||||
#include <STB/stb_vorbis.c>
|
#include <STB/stb_vorbis.c>
|
||||||
|
|
||||||
|
#include "Dengine/Common.h"
|
||||||
#include "Dengine/Math.h"
|
#include "Dengine/Math.h"
|
||||||
#include "Dengine/Texture.h"
|
|
||||||
|
/* Forward Declaration */
|
||||||
|
typedef struct Texture Texture;
|
||||||
|
|
||||||
enum TexList
|
enum TexList
|
||||||
{
|
{
|
||||||
|
@ -21,9 +21,10 @@ typedef struct AudioManager
|
|||||||
|
|
||||||
} AudioManager;
|
} AudioManager;
|
||||||
|
|
||||||
|
|
||||||
#define AUDIO_REPEAT_INFINITE -10
|
#define AUDIO_REPEAT_INFINITE -10
|
||||||
#define AUDIO_SOURCE_UNASSIGNED -1
|
#define AUDIO_SOURCE_UNASSIGNED -1
|
||||||
struct AudioRenderer
|
typedef struct AudioRenderer
|
||||||
{
|
{
|
||||||
i32 sourceIndex;
|
i32 sourceIndex;
|
||||||
ALuint bufferId[4];
|
ALuint bufferId[4];
|
||||||
@ -31,9 +32,8 @@ struct AudioRenderer
|
|||||||
AudioVorbis *audio;
|
AudioVorbis *audio;
|
||||||
ALuint format;
|
ALuint format;
|
||||||
i32 numPlays;
|
i32 numPlays;
|
||||||
};
|
} AudioRenderer;
|
||||||
|
|
||||||
typedef struct AudioRenderer AudioRenderer;
|
|
||||||
|
|
||||||
const i32 audio_init(AudioManager *audioManager);
|
const i32 audio_init(AudioManager *audioManager);
|
||||||
const i32 audio_streamPlayVorbis(AudioManager *audioManager,
|
const i32 audio_streamPlayVorbis(AudioManager *audioManager,
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#include "Dengine/Assets.h"
|
#include "Dengine/Assets.h"
|
||||||
#include "Dengine/Common.h"
|
#include "Dengine/Common.h"
|
||||||
#include "Dengine/Math.h"
|
#include "Dengine/Math.h"
|
||||||
#include "Dengine/Renderer.h"
|
|
||||||
#include "Dengine/Entity.h"
|
|
||||||
|
|
||||||
#include "WorldTraveller/WorldTraveller.h"
|
/* Forward Declaration */
|
||||||
|
typedef struct GameState GameState;
|
||||||
|
typedef struct MemoryArena MemoryArena;
|
||||||
|
|
||||||
#define INVALID_CODE_PATH 0
|
#define INVALID_CODE_PATH 0
|
||||||
enum DebugCallCount
|
enum DebugCallCount
|
||||||
@ -16,98 +16,16 @@ enum DebugCallCount
|
|||||||
debugcallcount_num,
|
debugcallcount_num,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct DebugState
|
|
||||||
{
|
|
||||||
Font font;
|
|
||||||
i32 *callCount;
|
|
||||||
f32 stringLineGap;
|
|
||||||
|
|
||||||
/* Debug strings rendered in top left corner */
|
|
||||||
char debugStrings[64][128];
|
|
||||||
i32 numDebugStrings;
|
|
||||||
f32 stringUpdateTimer;
|
|
||||||
f32 stringUpdateRate;
|
|
||||||
v2 initialStringP;
|
|
||||||
v2 currStringP;
|
|
||||||
|
|
||||||
/* Debug gui console log */
|
|
||||||
char console[20][128];
|
|
||||||
i32 consoleIndex;
|
|
||||||
v2 initialConsoleP;
|
|
||||||
} DebugState;
|
|
||||||
|
|
||||||
extern DebugState GLOBAL_debug;
|
|
||||||
|
|
||||||
inline void debug_callCountIncrement(i32 id)
|
|
||||||
{
|
|
||||||
ASSERT(id < debugcallcount_num);
|
|
||||||
GLOBAL_debug.callCount[id]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void debug_clearCallCounter()
|
|
||||||
{
|
|
||||||
for (i32 i = 0; i < debugcallcount_num; i++)
|
|
||||||
GLOBAL_debug.callCount[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char *debug_entitystate_string(i32 val)
|
|
||||||
{
|
|
||||||
char *string;
|
|
||||||
switch(val)
|
|
||||||
{
|
|
||||||
case entitystate_idle:
|
|
||||||
string = "EntityState_Idle";
|
|
||||||
break;
|
|
||||||
case entitystate_battle:
|
|
||||||
string = "EntityState_Battle";
|
|
||||||
break;
|
|
||||||
case entitystate_attack:
|
|
||||||
string = "EntityState_Attack";
|
|
||||||
break;
|
|
||||||
case entitystate_dead:
|
|
||||||
string = "EntityState_Dead";
|
|
||||||
break;
|
|
||||||
case entitystate_count:
|
|
||||||
string = "EntityState_Count (Error!)";
|
|
||||||
break;
|
|
||||||
case entitystate_invalid:
|
|
||||||
string = "EntityState_Invalid (Error!)";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
string = "EntityState Unknown (NOT DEFINED)";
|
|
||||||
}
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char *debug_entityattack_string(i32 val)
|
|
||||||
{
|
|
||||||
char *string;
|
|
||||||
switch(val)
|
|
||||||
{
|
|
||||||
case entityattack_tackle:
|
|
||||||
string = "EntityAttack_Tackle";
|
|
||||||
break;
|
|
||||||
case entityattack_count:
|
|
||||||
string = "EntityAttack_Count (Error!)";
|
|
||||||
break;
|
|
||||||
case entityattack_invalid:
|
|
||||||
string = "EntityAttack_Invalid";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
string = "EntityAttack Unknown (NOT DEFINED)";
|
|
||||||
}
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void debug_init(MemoryArena *arena, v2 windowSize, Font font);
|
void debug_init(MemoryArena *arena, v2 windowSize, Font font);
|
||||||
|
|
||||||
|
void debug_callCountIncrement(enum DebugCallCount id);
|
||||||
|
void debug_clearCallCounter();
|
||||||
#define DEBUG_LOG(string) debug_consoleLog(string, __FILE__, __LINE__);
|
#define DEBUG_LOG(string) debug_consoleLog(string, __FILE__, __LINE__);
|
||||||
void debug_consoleLog(char *string, char *file, int lineNum);
|
void debug_consoleLog(char *string, char *file, int lineNum);
|
||||||
|
|
||||||
#define DEBUG_PUSH_STRING(string) debug_pushString(string, NULL, "char")
|
#define DEBUG_PUSH_STRING(string) debug_pushString(string, NULL, "char")
|
||||||
#define DEBUG_PUSH_VAR(formatString, data, type) \
|
#define DEBUG_PUSH_VAR(formatString, data, type) \
|
||||||
debug_pushString(formatString, CAST(void *)&data, type)
|
debug_pushString(formatString, CAST(void *) & data, type)
|
||||||
void debug_pushString(char *formatString, void *data, char *dataType);
|
void debug_pushString(char *formatString, void *data, char *dataType);
|
||||||
|
|
||||||
void debug_drawUi(GameState *state, f32 dt);
|
void debug_drawUi(GameState *state, f32 dt);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
typedef struct AssetManager AssetManager;
|
typedef struct AssetManager AssetManager;
|
||||||
typedef struct AudioRenderer AudioRenderer;
|
typedef struct AudioRenderer AudioRenderer;
|
||||||
|
typedef struct MemoryArena MemoryArena;
|
||||||
typedef struct Texture Texture;
|
typedef struct Texture Texture;
|
||||||
typedef struct Animation Animation;
|
typedef struct Animation Animation;
|
||||||
typedef struct World World;
|
typedef struct World World;
|
||||||
@ -101,10 +102,10 @@ typedef struct Entity
|
|||||||
void entity_setActiveAnim(Entity *entity, enum AnimList animId);
|
void entity_setActiveAnim(Entity *entity, enum AnimList animId);
|
||||||
void entity_updateAnim(Entity *entity, f32 dt);
|
void entity_updateAnim(Entity *entity, f32 dt);
|
||||||
void entity_addAnim(AssetManager *assetManager, Entity *entity, i32 animId);
|
void entity_addAnim(AssetManager *assetManager, Entity *entity, i32 animId);
|
||||||
void entity_addGenericMob(MemoryArena *arena, AssetManager *assetManager, World *world,
|
void entity_addGenericMob(MemoryArena *arena, AssetManager *assetManager,
|
||||||
v2 pos);
|
World *world, v2 pos);
|
||||||
Entity *entity_add(MemoryArena *arena, World *world, v2 pos, v2 size,
|
Entity *entity_add(MemoryArena *arena, World *world, v2 pos, v2 size,
|
||||||
enum EntityType type, enum Direction direction, Texture *tex,
|
enum EntityType type, enum Direction direction, Texture *tex,
|
||||||
b32 collides);
|
b32 collides);
|
||||||
void entity_delete(MemoryArena *arena, World *world, i32 entityIndex);
|
void entity_delete(MemoryArena *arena, World *world, i32 entityIndex);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#ifndef DENGINE_RENDERER_H
|
#ifndef DENGINE_RENDERER_H
|
||||||
#define DENGINE_RENDERER_H
|
#define DENGINE_RENDERER_H
|
||||||
|
|
||||||
#include "Dengine/AssetManager.h"
|
|
||||||
#include "Dengine/Common.h"
|
#include "Dengine/Common.h"
|
||||||
#include "Dengine/Entity.h"
|
|
||||||
#include "Dengine/Math.h"
|
#include "Dengine/Math.h"
|
||||||
#include "Dengine/Shader.h"
|
|
||||||
#include "Dengine/MemoryArena.h"
|
/* Forward Declaration */
|
||||||
|
typedef struct Shader Shader;
|
||||||
|
typedef struct Entity Entity;
|
||||||
|
typedef struct MemoryArena MemoryArena;
|
||||||
|
typedef struct Texture Texture;
|
||||||
|
typedef struct Font Font;
|
||||||
|
|
||||||
typedef struct Renderer
|
typedef struct Renderer
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#define TARGET_TEXTURE_SIZE 1024
|
#define TARGET_TEXTURE_SIZE 1024
|
||||||
#define TARGET_BYTES_PER_PIXEL 4
|
#define TARGET_BYTES_PER_PIXEL 4
|
||||||
|
|
||||||
|
// TODO(doyle): Look into merging into assets.h file ..
|
||||||
typedef struct Texture
|
typedef struct Texture
|
||||||
{
|
{
|
||||||
// Holds the ID of the texture object, used for all texture operations to
|
// Holds the ID of the texture object, used for all texture operations to
|
||||||
|
Loading…
Reference in New Issue
Block a user