123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|283|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> [BUG] Loading Images after (multiple) Graphics change

Mon, 04 Nov 2019, 05:28
Dan

[BUG] Loading Images after (multiple) Graphics change


Needed image:


Hi,
In my current project, i have implemented the loading of images from the source code.

Everything worked seemingly fine, before.

But now, occasionally, the game crashes (after the menue), when it has been started for the first time.

I'm atm bugtesting it, and found either the same or similar annoyance.

I'v implemented an in-game screen resolution change.

So every now and then the font, which is loaded as anim image, causes a Memmory access Violation.

I have no idea why is this happening, as there are (now) few checks to ensure that the image is loaded (see the code below)

And still, the mav happens.




To reproduce the Mav, start the program and press 1 to 4 to change graphic resolution.

After 1-10 changes, the mav happens - without the graphic change, it does not happen.


Does anyone have an idea how to make this code work without mav's ?
Mon, 04 Nov 2019, 06:24
Jayenkai
Yes, this is a known issue with Blitz's. I think it still happened on BMax, too, but can't be sure. Been a while!!
Make sure you reload all images after a graphics switch.
Be sure to make a loader function that flicks through all the loaded images, and .. maybe sound, too.. I can't remember!!
Then you can simply retrigger the load function if the resolution changes.

-=-=-
''Load, Next List!''
Mon, 04 Nov 2019, 15:49
Dan
Hmmh, the trouble is, that the image is loaded, and the image handle does show that it is loaded.


The resolution change, in this game, happens in the options menue, where this image font is used to display the options text,
and yes i'm reloading every image at the resolution change.
The game does preload all images, and the same code is used at start and at every res-change.


So far, if this bug is up to the blitz-sourcecode (edit: or up to DirectX 7) , then i see only two or maybe 3 options.

1. That the resolution change takes effect at the next start.
2. To try to resize the window without resolution change.
3. maybe write another graphic change program, without any images loaded. (because resolution change is saved in a .ini file)
Mon, 04 Nov 2019, 15:56
Jayenkai
The image handle is lying.
Reload everything.
This is a known issue, and I'm repeating myself.

Iirc, it was a bug in DirectX, back in the day. The system "thinks" everything is ok, but it isn't.
It isn't ok, and you need to reload everything.

And since B3d's stuck in the dark ages of DirectX, you need to reload.

-=-=-
''Load, Next List!''
Mon, 04 Nov 2019, 17:08
Dan
I said, i did reload everything.

After Graphics change and reloading, the image variable, (which was freed by the FreeImage command and even set to 0 manually), shows that the handle has a number, a new number. (displaying this in the debuglog window)

But the Mav Happens, still. Sometime on the "MaskImage img_font,$ff,$ff,$ff" command, sometime a bit later, while trying to draw the single letters.

What i haven't tried, is to use the FreeImage on each variable, before setting the new graphics. Ill try it next time (as now it is 1am ... ).
Mon, 04 Nov 2019, 17:43
Pakz
I think there are still a number of games that require you to restart the game for the new settings to take effect. That is probably becourse of a reason of windows not being able to change things on the fly.

Maybe just do that?
Wed, 06 Nov 2019, 02:51
Dan
Yeah. I it's done.

Basically, the game does not need a resolution change, because only the window size is changed for every option (borderless, desktop, and size: 1*,2*,3*,4*")

But to get back to the resizeable window from the Faked fullscreen (borderless fullscreen window) a resolution change (graphic call) is needed, and i do not know how to get the borders and the titlebar back otherwise.

The borderless mode is set with api command, which is:


But now, the game restarts only if it was in the Borderless mode and the user wants to change to any other.
Wed, 06 Nov 2019, 04:53
Dan
Ok i'v been playing around with the code in my 1st post.

Here are the, and i have to say, strange results. At least for the last two examples:

If the images are unloaded before the graphic call, like this:



The crash does not happen. That would be Logical.

If, on the other hand, the images are unloaded only after the Graphics change, like this:



The Crash does not happen (and i'v tried up to 50~60 graphics changes.

The strange thing, is, when the images are unloaded, like i'v done, right before loading the new images:



The mav's happen, after 1~15th graphic change.

I hope that this information will be helpful for others, who are coding in BB3D.