Skip to main content
gamedev.net
🔒 Locked

Rendering background image

Started by WildWest 0 replies 900+ views
Original Post
WildWest
WildWest
Hi! I am using DX9 and ID3DXSPRITE for all 2D stuff, which all works perfect. What I want to know is: It is good to render the background (1024x768) as one texture? (My graphics card can only handle textures with powers of 2, so i have one texture with size 1024x1024) Or is it better (and faster) to use smaller textures (like 128x128) and reassemble the whole background image? Thanks in advance!
The Wild Wild West - Desperado!
jollyjeffers
jollyjeffers
You'll only find the "best" way by profiling your options. A single draw call is probably quickest... but for ID3DXSprite you'd have to (as you mention) use 2^n textures, probably wasting a bit of memory and making the sprite bigger than the screen (afaik you have to use the whole texture for a sprite?)..

Our graphics engine uses a greedy algoirthm to sub-divide and render a background bitmap so there is no memory loss. It's also speedy (~2000fps with just a background), so it does me fine.

If you load the bitmap into a SYSTEMMEM surface (D3DXLoadSurfaceFromFile) and then create a chain of 2^n textures you can fit all the data in exactly. e.g. an 800x600 screen will have (for width) a 512, 256 and 32 pixel width columns if you use a greedy algorithm.

I'd love to show you the code (I have a 'GHNDLE CreateBackground( std::string& file, const int& width, const int& height )' function that does all the work) but it's not strictly owned by me - so I cant publicly post it [sad]. I can give you more details if you're interested tho...

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.