Skip to main content
gamedev.net
🔒 Locked

Texture Problem

Started by Greg K 1 reply 650+ views
Original Post
Greg K
Greg K
I have a massive texture on disk that I want to load into my program and use in pieces. It is a texture that covers my whole landscape (4096*4096) so I can''t have it in one piece. Does anyone have any suggestions on how I can load it and break it up? The resulting textures should be 256*256. I tried tackling this problem by saving the file as a .raw file in photoshop and then using basic binary input into a WORD array (16 bit bitmap) and then creating all the D3DTextures, locking their rectangles, and dumping all the image data in but all that came out was garbage. I then tried using windows bitmaps but that was clunky and I still couldn''t get it to work (just turned one shade of brown). The last thing I tried was to use the D3DXLoadTextureFromFile() function, but as I expected it tried to put it all in video memory and just... died. So if anyone has any ideas that could help me out I would be very thankfull. -Greg
Spacecat
Spacecat
All right, here''s a tip. I managed to take fullscreen images and split them properly in 256x256 textures thanks to this little tutorial: http://www.mvps.org/directx/articles/splash_screen.htm

Just experiment with that code, there''s a miniature error in it, make sure that any D3DFORMAT you use matches your backbuffer D3DFORMAT to avoid hassles.

The idea is as follows: D3DTextures are limited by your video card, but D3DSurfaces can be put wholly in memory and NOT be limited by your hardware! That''s the key, build yourself a huge surface loaded from your big file, leave it in sysmemory, build the bunch of textures you need by copying data properly from the big surfaces to the smaller surfaces underlying your textures.

D3DTextures each contains a D3DSurface, you knew that right? Just lock''em and fill''em up.

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.
=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Topic Locked

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

Sign in to reply to this topic.