[Solved] Max2D + OpenB3D Image Blending Help

BlitzMax Forums/MiniB3D Module/[Solved] Max2D + OpenB3D Image Blending Help

RustyKristi(Posted 2016) [#1]
Hi,

I'm trying to load an splash image with a solid blend in between level completion, apparently this works but the image is blending in the 3d background.

While 'MainLoop

loading:TImage = LoadImage("splash.png")
...
...

If complete then
		RenderWorld
			BeginMax2D()
				'Rem
				SetColor 255,255,255
				DrawImage loading , 0 , 0
				SetBlend SOLIDBLEND
			EndMax2D()		
		Flip
                Delay 2000
End If

RenderWorld

Max2DGuiEvents()

Flip

Wend


Any help appreciated


Kryzon(Posted 2016) [#2]
If you want the image to be solid-blended, the SetBlend call needs to come before the DrawImage call.


RustyKristi(Posted 2016) [#3]
thanks Kryzon, I already did but with the same result. It is working after the last RenderWorld when it is currently playing but I need it to stop and load something up before it goes again in the main loop.

Am I doing this wrong?

Edit: Relocated my code near last renderworld. Thanks again Kryzon for that info.


Kryzon(Posted 2016) [#4]
I'm not authoritative enough to say if it's wrong. From what I know, if you want to do that kind of behaviour (show a "Loading..." screen while resources load), you need to use a child thread.
The hard-disk operations are synchronous, meaning the thread that uses the hard-disk functions will pause until the functions finish. Delegating these operations to a child thread will turn things asynchronous (that is, the thing that's paused is an invisible part of the program that's unrelated to playing the game).

The main thread of your program can draw an animation or even continue the game fully interactive while the resources load in the child thread. The program doesn't need to stop. The main thread keeps checking if the child thread has finished the job, and when it does the main thread can use the resources for something and ignore the child thread (release it).

There's a good discussion here:
http://www.blitzbasic.com/Community/posts.php?topic=105795


RustyKristi(Posted 2016) [#5]
Thank you for clearing this up. I think I had this discussion before if I should do multithreading or not and if I remember I was advised not to.

This time I can see the problem right in front of me when the game tries to load assets or do a heavy loop at the same time, making the game screech to a halt for some seconds. For an ordinary user who does not know what is going on, he/she might think the game looks like it would crash anytime.

I will check out the multithread link you posted and since I'm really new with bmx and multithreading, this is gonna be a bit of a challenge to do it correctly.


Kryzon(Posted 2016) [#6]
I was the same before trying threading, but BlitzMax makes it very easy. Best of luck.