Skip to main content
gamedev.net
🔒 Locked

About loading textures

Started by jackywu 0 replies 300+ views
Original Post
jackywu
jackywu
hello~ I am a beginner of DirectX 8.1 SDK. I read Programming Role Playing Games with DirectX and then encounter a problem about loading textures. This book said if we want to split a bitmap into several tiles, we can only load a bitmap whose width and height are power of 2. (ex. 512x512, 1024x1024...) Is there any way can load a bitmap whose width and height are "not" power of 2 ??? P.S: We use D3DXCrateTextureFromFileEx() to load a bitmap, and ID3DXSprite::Draw() to get tiles. [edited by - jackywu on July 31, 2003 5:19:27 AM]
miodragsm
miodragsm
Create surface of power of 2 width and height that is greater or equal to dim. of image and then :
-You can load image into temporary data structure, resize it to fit surface and then load onto empty created surface (look at dxsdk7 framework source - d3dtexture.cpp if I remember correctly) or
-you can skip resizing in first solution, just create surface and copy image onto surface. You will have to change uv coordinates for this (there will be empty portion of texture...) - coordinates will be:
tu : (width of image / width of pow2 surface)* original tu
tv : (height of image / height of pow2 surface) * original tv
(remember to use floats for dims. when calculating )

Topic Locked

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

Sign in to reply to this topic.