1

I'm using how-to 1 source DX9 from http://www.mikoweb.eu/index.php?node=28

Everything works fine on that example, but now I'd like to use PNG (or any format with alpha and better compression) rather than BMP.

Function call is:

 D3DXCreateTextureFromResourceEx(m_pD3DDevice,
                               gl_hThisInstance,
                               MAKEINTRESOURCE(IDB_BITMAP1),
                               256,
                               128,
                               0,
                               NULL,
                               D3DFMT_UNKNOWN,
                               D3DPOOL_MANAGED,
                               D3DX_FILTER_NONE,
                               D3DX_FILTER_NONE,
                               0xFF000000,
                               NULL,
                               NULL,
                               &m_pBackgroundTexture);

Resource file:

IDB_BITMAP1             BITMAP                  "background.bmp"

I change resource to:

IDB_BITMAP1             RC_DATA                  "pic.png"

After my change D3DXCreateTextureFromResourceEx return D3D_OK, however there is nothing displayed on screen. After seeing documentation my quick thought was that I should specify format in D3DXIMAGE_INFO structure (and left rest as 0, still nothing.

My final goal is to load texture from file, so I tried:

D3DXCreateTextureFromFileEx(m_pD3DDevice, "pic.png", 200, 200, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, D3DCOLOR_ARGB(150,100,100,100), NULL, NULL, &m_pBackgroundTexture);

But it didn't worked.

4
  • Turns out that I have to specify exact x and y dimensions of file, or set it to 0. Commented Jun 1, 2014 at 12:45
  • Now I have new problem, can't make my textures as alpha, tried png, dds, ... Commented Jun 1, 2014 at 12:46
  • If you have new problems, please update your post instead of just leave a comment. Commented Jun 2, 2014 at 0:14
  • Thanks, I solved the issue. Now its added as answer. Commented Jun 2, 2014 at 4:09

1 Answer 1

1

Problem was because there were specified Height and Width in D3DXCreateTextureFromFileEx, leaving both parameters as 0 loaded texture correctly on all formats.

But that didn't make my textures appear as alpha on screen.

By googling I found:

m_pBackgroundSprite->Begin(D3DXSPRITE_ALPHABLEND);

which solved the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.