Sign in to follow this  

Background Scrolling with DX9

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use a resolution of 1024 by 768 and my map will be 40x40 screens. There I can't use normal surfaces ...i have heard about a method to declare the surface which contains the 40x40 screens with D3DPOOL_SCRATCH. Or as long DX9 is always in 3D terminology, i could declare many rectangles with textures (one texture is a part of a screen e.g. half the screen size 512x384) and do the scrolling that i only let the rectangles move in the 3d space. But i don't know if one of these possibilities are fast enough for my purpose or work(40x40 screens) I am sure you can help me! :)

Share this post


Link to post
Share on other sites
Most scrolling backgrounds used for games are tile based... Lets assume for a second you don't plan to use tiles. You haven't said, so I'm just demonstrating why you NEED to use tiles.

If you want 40x40 screens (1600 screens) at 1024x768 (768K pixels). Lets say you're doing 16 bit.

768K * 16 bit = 1536K
1536K * 1600 screens = 2400M.

You'll need 2.4GB of storage. Up that to 4.8GB for 32 bit.

Are you still sure that "all I want to do is scroll a large background image"?

Share this post


Link to post
Share on other sites
It can be done as long as you specify some restraints:

1) Fast CPU
2) Large Memory Video Card
3) Slow Scrolling
4) Use a fast hard drive for accessing the images
5) Make use of Multi-Threading
6) Load the images up in chunks (i.e. 4 images make a full screen)

If you abide by these rules you can do it. Just load up an array of 25 full-screen textures initially (which would range from 0 to 4 in the x and y directions of your grid, and would result in 25x4 textures). Now, create a single thread that just renders the current full-screen image (which may be comprised of any number of the textures around. For instance, you might have moved 1/3rd into the y=1 screen so you need to render the 4 textures from y=0 and the two top textures from y=1).

Here's where the multi-threading is important. In a second thread, once you pass 1 full texture in any direction, begin loading the next one out in that direction and unload the 1 furthest in the opposite direction. For instance, if you moved to the right 1 textures worth, remove the texture to the furthest left of the grid and load the one to the furthest right of the grid. Remember though that special care has to be taken when you are near the borders. You can't just remove the furthest left texture if it's still on the screen because you're near a border. Some consideration into the algorithm must be taken. As long as you are scrolling slowly, have fast access to the hard drive, and a fast CPU, you will be fine. Of course, you could increase the scrolling rate the better any of these three parameters are.

Good luck,
Chris

Share this post


Link to post
Share on other sites
If your video card supports textures that large (I doubt it, but I don't know what they are up to now days, I'm thinking 1280x1024 is probably the max out there on a typical card), then you would just apply the texture to that quad and slide the quad across the screen.

Share this post


Link to post
Share on other sites
Quote:
Original post by Supernat02
If your video card supports textures that large (I doubt it, but I don't know what they are up to now days, I'm thinking 1280x1024 is probably the max out there on a typical card), then you would just apply the texture to that quad and slide the quad across the screen.
My GeForce 4 can do up to 4096x4096. Although that takes up 64Mb (32-bit texture), so I doubt there'll be much room for anything else on the card...

Share this post


Link to post
Share on other sites

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this