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 :-)
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
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...
BACKGROUND% = GENSPRITE() ; LOADSPRITE "backgrounds/bkg1_960x640.png", BACKGROUND%
USESCREEN -1
DRAWSPRITE BACKGROUND%,0,0
SHOWSCREEN
MOUSEWAIT
great works as I'd expect. However...
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....
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.
Have you tried USEASBMP ?
Lee
Sent from my HTC Wildfire using Tapatalk 2
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.
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
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.
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
If i remeber right, you have 3 ways to do this:
Use offscreens:
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:
[create your background image here]
GRABSPRITE backgroundid%
REPEAT
DRAWIMAGE backgroundid%
[draw all other stuff here]
SHOWSCREEN
UNTIL TRUE
Or do everything manual in memory:
LOCAL barray%[]
barray%[]=[create your background image here]
MEM2SPRITE barray%[], backgroundid%
REPEAT
DRAWIMAGE backgroundid%
[draw all other stuff here]
SHOWSCREEN
UNTIL TRUE
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:
Is USEASBMP really faster than drawing it on your own? (I never tested it)
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.
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.
If you draw your own background image you can disable clearing the backbuffer with black by using CLEARSCREEN -1. Should save some time.
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.
Quote from: kanonet on 2013-May-06
If you draw your own background image you can disable clearing the backbuffer with black by using CLEARSCREEN -1. Should save some time.
This is really useful, If I use CLEARSCREEN -1 and PV's to blit my background I get an increase from 376fps to 428fps on my PC compared to when I used LOADBMP with a pre-scaled and saved file. Guess this makes LOADBMP obsolete for me, although a good topic for other to read and determine what to use for themselves.