Can I copy a sprite to the background buffer instead of using LOADBMP

Previous topic - Next topic

spicypixel

I want to be able to generate my own LOADBMP equivalent background which is generated before my main loop, so that when I use SHOWSCREEN it continually shows my generated image for the background instead of having to use LOADBMP. I've been trying with USESCREEN -1 and then DRAWSPRITE but all I generate is a nice black background :-)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

spacefractal

I'm have never use LOADBMP, due it's limits (scaling to one of them). I'm always use LOADSPRITE and LOADANIM to load them, and then draw them to backbuffer, even backgrounds.

I'm think this command is your friend:
http://www.glbasic.com/xmlhelp.php?lang=en&id=230&action=view

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spicypixel

I can use CREATESCREEN to make my Virtual Screen and then resize my sprite to fit within it, SAVE the created screen out and use LOADBMP to load a background image now at my device resolution but if I can do this in memory it would be lots easier. Like I said in my first post I'm already using USESCREEN -1 and then DRAWSPRITE but I'm getting a blackscreen.

Example...

Code (glbasic) Select

BACKGROUND% = GENSPRITE() ; LOADSPRITE "backgrounds/bkg1_960x640.png", BACKGROUND%
USESCREEN -1
DRAWSPRITE BACKGROUND%,0,0
SHOWSCREEN
MOUSEWAIT


great works as I'd expect. However...

Code (glbasic) Select

USESCREEN -1
DRAWSPRITE BACKGROUND%,0,0

REPEAT
    SHOWSCREEN
FOREVER


shows a black screen, which I kinda expect as nothing is being blit in the loop, which is why I want to know how to do the equivalent of LOADBMP because....

Code (glbasic) Select

LOADBMP "backgroun.png"

REPEAT
    SHOWSCREEN
FOREVER


would show a background.

I can use a DRAWSPRITE, but blitting a huuuuuge sprite every frame is not how I want to roll :-) So if someone could explain how I could get my image into the same buffer that LOADBMP is using that would be uber cool. Thanks for pointing me at the online manual, and I appreciate English is not your native tongue, but I am using the same commands you suggested in my first post.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

fuzzy70

Have you tried USEASBMP ?

Lee

Sent from my HTC Wildfire using Tapatalk 2

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

spicypixel

Quote from: fuzzy70 on 2013-May-06
Have you tried USEASBMP ?

Lee

Sent from my HTC Wildfire using Tapatalk 2

Perfect albeit only working in portrait mode on the iPhone :-(
Really wish there was a way to do this without having to save a copy of the image out to LOADBMP back in again.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

fuzzy70

Odd, does LOADBMP work in landscape on iPhone?. Strange if one does but the other doesn't as they both must put an image into the same buffer.

I don't have any Apple gear so can't really help anymore in that arena :(

Lee

Sent from my HTC Wildfire using Tapatalk 2

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

spicypixel

Quote from: fuzzy70 on 2013-May-06
Odd, does LOADBMP work in landscape on iPhone?. Strange if one does but the other doesn't as they both must put an image into the same buffer.

I don't have any Apple gear so can't really help anymore in that arena :(

Lee

Sent from my HTC Wildfire using Tapatalk 2

It's stated in the manual that USEASBMP only works in portrait on the iPhone. Does your help not state this also??? I haven't tested it but as you say it only replaces the same buffer anyway so shouldn't make a difference. LOADBMP works fine on the iPhone anyway.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

fuzzy70

I'm not at home lol. Mentioned USEASBMP as had a similar situation a few months back & it just sprung to mind :)

Lee

Sent from my HTC Wildfire using Tapatalk 2

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

kanonet

If i remeber right, you have 3 ways to do this:

Use offscreens:
Code (glbasic) Select
CREATESCREEN 0, backgroundid%

USESCREEN 0
[create your background image here]
USESCREEN -1

REPEAT
    DRAWIMAGE backgroundid%
    [draw all other stuff here]
    SHOWSCREEN
UNTIL TRUE


Use grabsprite:
Code (glbasic) Select
[create your background image here]
GRABSPRITE backgroundid%

REPEAT
    DRAWIMAGE backgroundid%
    [draw all other stuff here]
    SHOWSCREEN
UNTIL TRUE


Or do everything manual in memory:
Code (glbasic) Select
LOCAL barray%[]
barray%[]=[create your background image here]
MEM2SPRITE barray%[], backgroundid%

REPEAT
    DRAWIMAGE backgroundid%
    [draw all other stuff here]
    SHOWSCREEN
UNTIL TRUE
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

spicypixel

The downside with all of these methods is the blitting of a full screen sprite in all cases. You could argue that the LOADBMP has to also draw the full image each frame, however by not using LOADBMP we have a screen which is cleared each frame which will take time, and then blit a full-screen sprite ontop.

It's a shame we can't load a sprite and then have the id% be used in the LOADBMP, that would be awesome :-)

I have decided to LOADBMP, CREATESCREEN, STRETCHSPRITE, SAVEBMP and then LOADBMP. It's not a nice method but it does mean I don't have to worry about screen sizes. I am using the VIEWPORT positions and sizes when using STRETCHSPRITE to maintain correct AR and game alignment when AR isn't 1:1.

Or... maybe Gernot could just fix USEASBMP  :help:
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

kanonet

Is USEASBMP really faster than drawing it on your own? (I never tested it)
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

spacefractal

Loadbmp also need draw everytime in each frame... So not sure its actuelly faster than draw the sprite in each frame...

Im never used those my self.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spicypixel

Quote from: spacefractal on 2013-May-06
Loadbmp also need draw everytime in each frame... So not sure its actuelly faster than draw the sprite in each frame...

Im never used those my self.

True but that would depend how its done under the hood I guess, but if you don't use LOADBMP then the frame is being CLEARED to black anyway which will take cpu processing and then drawing a background on top as well. Using LOADBMP you have no need to clear the screen. Just assuming here really, but why have the LOADBMP if it serves no advantage than STRETCHSPRITE or PV's.

Looking through the manual I see reference to BACKBUFFER and BACKGROUND IMAGE BUFFER, with BIB referring to the LOADBMP.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

kanonet

If you draw your own background image you can disable clearing the backbuffer with black by using CLEARSCREEN -1. Should save some time.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

spacefractal

LOADBMP mightbeen faster, but with those devices you have, im thinks there is not very much advance anyway. The main issue is LOADBMP is practical unusable for use in Android, due you never know which resoulution they use, and sometimes sidebar is not counted at all.

So sometimes you need to do some tradeoffs.

Howover yes, you should not need to clear the buffer, if you make sure the background fill the whole resoulution.

Howover in some situtions, you might need to clear the buffer before drawing,  but not allways. in my next game, that CLEARSCREEN is not required, but was needed in Greedy Mouse.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/