Hello,
I've been having an issue trying to consistently get my dynamic code reloading working with spine-c animations. Currently, I have a giant memory block that I allocate from my main exe and this memory is passed to my gamecode.dll file. The memory I allocate in my exe (with Windows virtualalloc()) is set to have a base address that I specify so my game code memory will always be in the same addresses. This way, I can have all my game data saved to this memory block, which is controlled by the exe, and just reload the dll file and have everything just work again upon reload. I have setup spine, through the extension.h file, to utilize my game memory and everything has worked fine up until I added some animations.
The issue I'm having is sometimes an exception is thrown on this line of spine upon building and trying to reload my gamecode dll:
void spTimeline_apply (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
VTABLE(spTimeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventsCount, alpha, blend, direction);
}
Again, sometimes my dll reloading works perfectly fine and sometimes is doesn't (about 50/50). I was wondering if anyone could help me work through what is happening to hopefully solve the issue. If you need to checkout my code then I can provide the github link. Here is what my current spine implementation looks like inside my gamecode dll:
extern "C" void
GameUpdate(Game_Memory* GameMemory, Platform_Services PlatformServices, Game_Render_Cmds RenderCmds,
Game_Sound_Output_Buffer* SoundOutput, const Game_Input* GameInput)
{
Game_State* GameState = (Game_State*)GameMemory->PermanentStorage;
GlobalGameState = GameState;
const Game_Controller* Keyboard = &GameInput->Controllers[0];
const Game_Controller* GamePad = &GameInput->Controllers[1];
if(!GameMemory->IsInitialized)
{
GameState->DynamAllocator.MemRegions[SPINEDATA] = CreateRegionFromGameMem(GameMemory, Megabytes(10));
InitDynamAllocator(&GameState->DynamAllocator, SPINEDATA);
GameState->Atlas = spAtlas_createFromFile("data/spineboy.atlas", 0);
GameState->SkelJson = spSkeletonJson_create(GameState->Atlas);
GameState->SkelData = spSkeletonJson_readSkeletonDataFile(GameState->SkelJson, "data/spineboy-ess.json");
GameState->MySkeleton = spSkeleton_create(GameState->SkelData);
GameState->AnimationStateData = spAnimationStateData_create(GameState->SkelData);
GameState->AnimationState = spAnimationState_create(GameState->AnimationStateData);
spAnimationState_setAnimationByName(GameState->AnimationState, 0, "walk", 1);
spAnimationState_addAnimationByName(GameState->AnimationState, 1, "run", 1, 1.0f);
GameMemory->IsInitialized = true;
ViewportWidth = 1280.0f;
ViewportHeight = 720.0f;
}
spAnimationState_update(GameState->AnimationState, .007f);
spAnimationState_apply(GameState->AnimationState, GameState->MySkeleton);
rest of code........
}
Thank you.