#### Archived

This topic is now archived and is closed to further replies.

# DX8/Bitmap & Programming RPGs w/DX

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

## Recommended Posts

Hi all, I hope this isn''t an overly stupid question. I am working with Jim Adam''s _Programming Role Playing Games with Direct X_, but am having a lot of trouble using bitmaps. So, I''m either looking for clarification from someone who has used this book, or else a completely different approach to bitmaps. What I am trying to do is build a Tetris-clone to teach myself. Whenever I try to use his code to load the bitmaps, the images stretch. If I put a call to GetWidth/Height, they go from 20x20, to 32x32 (I''m really hoping all images in DX don''t have to be powers of 2 in size!). So, how can I use bitmaps in DX? If anyone has a link to information, or a class already built, that''d be wonderful. Much appreciated, JT

##### Share on other sites
Textures are loaded in powers of two. You can make D3DX load them, not stretching using this code:

HRESULT WINAPI D3DXCreateTextureFromFileEx(    LPDIRECT3DDEVICE9 pDevice,    LPCTSTR pSrcFile,    UINT Width,    UINT Height,    UINT MipLevels,    DWORD Usage,    D3DFORMAT Format,    D3DPOOL Pool,    DWORD Filter,         //D3DX_FILTER_NONE    DWORD MipFilter,      //D3DX_FILTER_NONE    D3DCOLOR ColorKey,    D3DXIMAGE_INFO *pSrcInfo,    PALETTEENTRY *pPalette,    LPDIRECT3DTEXTURE9 *ppTexture);

BTW, you don't have to learn how to use surfaces at all. Unless it's the only way. (Which is almost never)

--
You're Welcome,
Rick Wong

- sitting in his chair doing the most time-consuming thing..

[edited by - Pipo DeClown on May 9, 2004 7:37:15 AM]

##### Share on other sites
Hi Rick,

Thanks for the code. I haven''t tried it yet - I was specifically looking for something compatible with DirectX 8, not 9, but perhaps there is an easy way to change it. Like I said, I have only just peeked at the message, and then written this.

I found out, after a couple hours of searching, that the texture sizes "have" to be powers of 2 in size (prior to your code), so that''s what I''m doing now - my images were 220x440 and 20x20, so I just bumped them up, but then only blit the actual size. Works well enough for me that I don''t really care.

##### Share on other sites
I''m sorry, the code is THE SAME in Direct3D8. Just set BOTH the filter parameters to D3DX_FILTER_NONE.

Done!

--
You''re Welcome,
Rick Wong

- sitting in his chair doing the most time-consuming thing..

1. 1
2. 2
JoeJ
14
3. 3
4. 4
5. 5
frob
11

• 13
• 16
• 13
• 20
• 12
• ### Forum Statistics

• Total Topics
632178
• Total Posts
3004604

×