Help Please
BlitzPlus Forums/BlitzPlus Programming/Help Please
| ||
SetBuffer DesktopBuffer() Global imagebackground=CreateImage( 773,600 ) GrabImage imagebackground,GraphicsWidth()/2-386,GraphicsHeight()/2-300 windowx = (GraphicsWidth()/2-(773/2)) windowy = (GraphicsHeight()/2-(600/2)) window = CreateWindow ("Game",windowx,windowy,773,600,Desktop(),0) canvas = CreateCanvas (0, 0, ClientWidth (window), ClientHeight (window), window) SetGadgetLayout canvas, 1, 1, 1, 1 SetBuffer CanvasBuffer (canvas) While Not KeyHit(1) DrawBlock imagebackground,0,0 FlipCanvas (canvas) Cls Wend ;----------------------------------- ;----------------------------------- ;----------------------------------- ;----------------------------------- ;----------------------------------- ;----------------------------------- ;----------------------------------- ;----------------------------------- The above code is a simplified version on code that creates a "transparent" background for my app. I was wondering if anyone had an idea of a way to make it update. Currently if you leave the window and change anything behind the app, nothing lines up in the screenshot anymore. So if anyone has ideas of how to make it update they would be gladly appreciated. |
| ||
Maybe you should try changeing the CreateImage() flags? |
| ||
How So? |
| ||
Well, to get it to update, you need to grab the desktop image repeatedly in your code, instead of just loading once. So like:While Not KeyDown(1) SetBuffer DesktopBuffer() Global imagebackground=CreateImage( 773,600 ) GrabImage imagebackground,GraphicsWidth()/2-386,GraphicsHeight()/2-300 windowx = (GraphicsWidth()/2-(773/2)) windowy = (GraphicsHeight()/2-(600/2)) window = CreateWindow ("Game",windowx,windowy,773,600,Desktop(),0) canvas = CreateCanvas (0, 0, ClientWidth (window), ClientHeight (window), window) SetGadgetLayout canvas, 1, 1, 1, 1 SetBuffer CanvasBuffer (canvas) DrawBlock imagebackground,0,0 FlipCanvas (canvas) WendThe only thing is that this will cause moderate to major slowdown on most PCs. To combat this problem, try creating some code that only updates the background if the window is moved. |
| ||
I can't seem to get it to work correctly. That was is just creates lots of windows. When I change the code to this: windowx = (GraphicsWidth()/2-(773/2)) windowy = (GraphicsHeight()/2-(600/2)) window = CreateWindow ("Game",windowx,windowy,773,600,Desktop(),0) canvas = CreateCanvas (0, 0, ClientWidth (window), ClientHeight (window), window) SetGadgetLayout canvas, 1, 1, 1, 1 imagebackground=CreateImage( 773,600 ) While Not KeyDown(1) SetBuffer DesktopBuffer() GrabImage imagebackground,GraphicsWidth()/2-386,GraphicsHeight()/2-300 SetBuffer CanvasBuffer (canvas) DrawBlock imagebackground,0,0 FlipCanvas (canvas) Wend The window stays black and nothing happens, what should I do? |
| ||
That's because you're not actually copying anything off of the desktop buffer; GrabImage doesn't do that. My suggestion: investigate the CopyImageRect() command. |
| ||
That command doesn't exist. |
| ||
Oh. It exists in Blitz3D's 2D command set, so I thought B+ would have it. |
| ||
Well then any other suggestions |