Camera Not Updating after Reload

Posted By: Dooley

Camera Not Updating after Reload - 03/31/18 21:30

I added a new feature to my game in which a small panel shows a top down view of the level. It works great, and it even works after leaving the level and coming back to it.

However, I just noticed that if I leave the game, then come back and reload a saved game, any levels I try to go to with the top down viewer, will cause an error.

The level seems to load fine, but the screen is no longer updated, somehow the main camera object no longer works. I can move my character, fire his weapon, even call up panels and swap equipment, but none of the 3D cameras are working after reloading these levels.

Obviously, it's a huge complex issue where one would have to understand the code I used to figure it out. Before I burden anyone else with my code, I though maybe someone might have a vague idea of what might be causing this so I could investigate further.

I will be researching to find out exactly where this problem began to manifest itself, but if you have seen anything like it before, especially when using multiple views, I would greatly appreciate any advice or suggestions!
Posted By: Dooley

Re: Camera Not Updating after Reload - 03/31/18 21:39

Okay, I can confirm that this is caused by my extra VIEW that I'm using. I commented out all references to it in my code and now the levels load fine and work normally.

This is strange because I have another additional VIEW object (in my spaceship) which works fine when loading and reloading the game. It is only when landing on a planet when the third VIEW object will come into play, so only two VIEWS will be used at the same time - the main camera and the additional view screen in the spaceship, or top down map on planets.

So there is some combination of views perhaps that prevents the main camera from updating properly. The additional strange bit is that it works fine during the first play session. Only after leaving the game and coming back will the camera view be disrupted upon reloading an existing level, and also when loading a new planet level.

The good news is that I know the approximate cause of the problem - my new VIEW object. The bad news is that I can't use this object in the game until I figure this out ...
Posted By: Dooley

Re: Camera Not Updating after Reload - 04/01/18 05:27

Okay, I have narrowed it down to one line of code that is causing the failure.

Quote:
scan_view.bmap = scan_bmp;


Everything else works if I remove this one line. But this is the line that makes the map work.
Posted By: Dooley

Re: Camera Not Updating after Reload - 04/01/18 06:47

I found out that my other bmap/view entity uses a 16 bit, vs 24 bit image. Maybe that's the issue?
Posted By: Dooley

Re: Camera Not Updating after Reload - 04/01/18 07:15

Woooooo!
I fixed it. I changed the bitmap size from 1024 x 1024 down to 256 x 256. That seemed to resolve the problem, so it must have been somehow memory related. Strange that it worked the first time around, bit only failed after exiting and reloading the game. 256 is actually big enough to capture all the detail I need, so 1024 was kind of a waste of memory anyway.
Posted By: Dooley

Re: Camera Not Updating after Reload - 04/01/18 19:35

Okay, I thought I fixed it, and it does indeed work better than before. However, now if I go to a few different locations the game will crash. It gave me a directx ZTARG error.

On another thread I saw that someone mentioned that it could not create the buffer, and would then try to render to the screen - causing the error.

Is there any way to avoid this? Maybe a wait statement until it creates the buffer?
Posted By: Dooley

Re: Camera Not Updating after Reload - 04/01/18 20:52

Okay, I think I have stabilized it. I have been calling the following line in the while loop:

Quote:
scan_bmp = bmap_for_entity(my,1);


But it looks like it only needs to be called once when the view is created. In any case, it seems to work, and has not crashed after a long play session.
© 2024 lite-C Forums