Jump to content
  • Advertisement
Sign in to follow this  
prthealien

Displaying a texture greater than 2048x2048

This topic is 4130 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'm learning DirectX9 by making a photo screensaver/slideshow and using IDirect3DTexture9 and ID3DXSprite to load and display photos. To display an image, I just load it from disk straight to a texture, set the sprite's transform to scale and position it, then display it with the sprite. But if I try to display a photo greater than 2048x2048, all the pixels beyond that are not displayed, so the picture is clipped. I am aware that graphics cards have a limit to their texture size, but is there a way around it? Perhaps by breaking up large images into several smaller textures? Or may be by resizing it when it loads? How would I go about doing something like that?

Share this post


Link to post
Share on other sites
Advertisement
Like you said, you could indeed have reached the limits of your graphics card. However when I encountered it the texture just failed to load. Maybe your card handles this differently, or it could be you reached the max size for sprites (I don't know this for sure, I never use them).
Splitting the photo into smaller pieces is an option. I had the same problem a while ago and solved it by manually splitting the texture (in my case it was 4096x4096) into four 2048x2048 bitmaps. I then managed to texture a single quad by passing all 4 textures to a pixel shader, which then stitched them together.
However if you want your screensaver to load photos (at random) from a directory, you want to split the textures automatically.
I doubt if ID3DXSprite is the best way to do this, I would prefer manually creating a quad (although I must admit I never really used sprites).
Also, why do you want to use textures bigger than 2048x2048? Are you directly using images you shot with a digital camera perhaps?
If you just want to show a photo you're best off scaling the photo itself down. This has to be done before you load the photo as a texture i think.
Hope this helps

-Paul

Share this post


Link to post
Share on other sites
Digital cameras create images with huge resolutions. I don't want to change the original photo. I need to resize the photo in memory or split them up in memory.

Share this post


Link to post
Share on other sites
If you load into D3DPOOL_SCRATCH you should be free from card capabilities and limits... though I've never actually tried it. It will then be up to you to move the data to several other textures in D3DPOOL_MANAGED that meet your card's requirements. Also remember to pass the D3DX_DEFAULT_NONPOW flag as width and height to the load function so it won't scale your original image data. Another option is to specify a filter of D3DX_FILTER_NONE which may make a larger texture, but only fill in the first part of it with unscaled data.

Share this post


Link to post
Share on other sites
Quote:
Original post by Namethatnobodyelsetook
If you load into D3DPOOL_SCRATCH you should be free from card capabilities and limits... though I've never actually tried it. It will then be up to you to move the data to several other textures in D3DPOOL_MANAGED that meet your card's requirements.
This, with a greedy algorithm approach, works just fine. I had this approach working in an older engine I wrote that had to handle hardware (Voodoo 3) capable of a mere 256x256 texture [lol]

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by prthealien
Sounds good. But how can I move data from one texture to another (using DX9)?
You need to lock both textures (IDirect3DTexture9::LockRect()), then copy the pixels from one texture to another. If you're using mipmaps, you'll have to copy each mipmap in turn.

Share this post


Link to post
Share on other sites
When you lock the texture you are given a pointer to the pixels.

Also rather than stitching together the separate textures in a pixel shader, it's generally easier to just render multiple quads. You don't have to worry about limits on number of textures that way.

Share this post


Link to post
Share on other sites
Excellent. Final question: how do I calculate the size of the array of pixels? If I'm using 8 bits for a, r, g, and b then it would be 4 bytes per pixel? So (rectWidth * rectHeight * 4) bytes? Or is there something extra to take into consideration?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!