Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Background Issues

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 17th Apr 2011 21:57 Edited at: 17th Apr 2011 22:20
I have a small batch of code that will load a background, resize it then paste it to fullscreen using copy bitmap and some other things. It works a treat until i add sync to it (which i will need to as there are 3d elements to what i am trying to do).
Now as soon as i do this the background is black UNTIL i move the window then the image comes up ok. What causes this and how is it worked around.

I have searched and can only find posts when i put the word "Background" in which is a bit broad and comes up with lots of posts. Only a handful appear from the outset to be the same problem then when i actually look at them they arent at all. Or they are issues solved with texture backdrop which is no longer a command in DBpro as far as i know (i only believe this as i have the latest DBpro and typing that command comes up with nothing).

Thanks in advance.

Edit: It seems to work when the sync is in a do loop, which to be honest if it at least syncs once before the wait key that for me should be enough to display it but it doesnt. When you do a
Do
Sync
Loop
The image displayes, i would like to know why this is.

Also more importantly i would like to know how i can then display 3d objects on top of that image because so far my attempts at even getting a cube to show up at the same time as the background is proving impossible for my skill right now.
Make Cube then putting position object in the do loop is not curing the problem. I cant get 3d objects to display over a background bmp. Is this even possible or am i trying to do something that dbpro shouldnt be doing. Then only other way i can think to do this is very stupid and i dont like it, and thats to make a plane the size of the screen and texture it with the image but i think that is a long way round to doing it surely there must be an easier way.
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 17th Apr 2011 23:19 Edited at: 17th Apr 2011 23:33
Hi Somarl,

Because this question is obviously related to the challenge I've set you, I'm not going to give you a full and complete answer so that you will still have something to investigate. However, I will give you a signpost or two:

First of all, your question in relation to SYNC isn't part of the challenge, so will explain that one in full. It's not a concept that I expect a learner to fully understand, so don't worry if you're not following. The system is based on what's known as a double buffer refresh, which means you have to sync the screen twice before the user will see what you've drawn. Whenever you draw to the screen (with PRINT, or PASTE IMAGE, or any other command that makes something appear on screen) you are not really drawing to the screen you are drawing to what's called the backbuffer, which isn't visible to the user. Each time you call a SYNC, the contents of the backbuffer are copied to the viewable screen and the user can see it. Even after you've done this, all future draw operations will continue to work on the backbuffer.

Now, the catch is that the backbuffer has to be SYNC'd too: There's nothing in the backbuffer, even if you've drawn things, until you use SYNC for the first time, because until that point the backbuffer hasn't been rendered. This means that the very first time you call a SYNC, an empty, blackscreen backbuffer is being dumped to the viewable screen and then all the stuff you've drawn is placed in the backbuffer (which the user can't see yet). From that point on, every time you call SYNC you will dump visible stuff to the screen (assuming you've been drawing stuff). In practical terms, the very first SYNC of the day doesn't do anything visible, and every SYNC you call after that is actually displaying a frame behind your program.

This is why your first SYNC doesn't seem to be working on its own, and why it does seem to be working when it's in a loop: you're firing many SYNCs per second and the backbuffer is being worked at full speed.

Being just one single frame behind in display isn't really a problem when you're running at 60 frames per second, as it isn't noticable. However as you've seen, it can result in confusion if you don't realise what's going on.

Now, onto the challenge related stuff. You should take a look at two commands called DRAW TO FRONT and DRAW TO BACK. One of these commands (I'll let you investigate and experiment to discover which) is going to help you stop images from preventing your 3D elements from showing up.

I see that you've encountered the demon beast known as the "backdrop" before. It may not have got in your way yet, but it's going to soon. If your background image disappears and gets replaced by a big blue background of evilness, you'll know it has you in its grasp. Since you'd rather be making your own background with your resized image, you may not require the big ugly blue "backdrop" at all. Perhaps you can find some way to turn it off...

You'll know you've got it right because your cube will show up in the middle of your screen in front of the background image without positioning either the cube or the camera in any specific way. Just make the cube; it'll be in the centre of your screen. If you can see it, you'll know you've beaten both the backdrop and the draw order problems you're experiencing.

These questions show you've been doing your homework for the challenge - Carry on, padawan!

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 18th Apr 2011 02:03
Excellent, i think i have a good idea of whats going on. Only problem is i have to sleep now, then get up in 6 hours, then work for nearly 9. Thats 15 hours away from being able to do any more code. AHHHHHH.
Dont post that source code till i get something up, even if i cant get it all working
im looking forward to getting stuck into this, i already have bees drawn up.

Login to post a reply

Server time is: 2024-11-22 23:29:33
Your offset time is: 2024-11-22 23:29:33