I'm currently creating my own 2d fighting game and I've implemented things to mostly match Casey's project as far as the live code reloading and things go (up to about day 26). From there I've added in a third party animation library, spine, to help with my animations. I've gotten everything to work prior to adding in some actual animations as I have this library calling my own allocator and using my game memory block.
The issue I'm having is sometimes an exception is thrown on this line of the spine library upon building and trying to reload my gamecode dll:
1 2 3 4 | 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); } |
The 'VTABLE' macro expands to:
1 2 | /* Gets the vtable for the specified type. Not type safe, use with care. */ #define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable) |
Again, my code reloading does still work about 50% of the time but when it does crash it almost always falters here. Is anyone able to help me work through why this is spotty? My current gamecode looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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........ } |