Jump to content
  • Advertisement

Archived

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

Void

Mipmaps with D3DX??

This topic is 6626 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

Hi, Does any know how to generate mipmaps using the D3DX library. I use the D3DXCreateTextureFromFile function. The docs says it will auto generate the mipmaps if the h/w supports it. I checked the Dx Caps Viewer and it seems to support it.. but the mipmap count from the function returns ZERO.. Do I have to explicitly create a chain of texture using D3DXCreateTexture first and then loading the bitmap data in?? Thanks.. ..

Share this post


Link to post
Share on other sites
Advertisement
That''s the problem.. I did look at that sample..

I''m trying to avoid traversing the surface chain and bltting every (progressively smaller) bitmap to each mipmap surface..

I was thinking in terms of auto mipmap generation like OpenGL using the aux library ..Juz wondering how the d3dx library would help me there..

..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The mipmap thing works for me.

I assume you already have the d3d set up for texturemapping. Then you have to set the render state to use mipmapping with

d3ddevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);

then to create the texture I use

D3DX_SURFACEFORMAT texture_format = D3DX_SF_UNKNOWN;
DWORD num_mipmap = 4; // or however many mipmaps you want
HRESULT hr = D3DXCreateTextureFromFile(d3ddevice, NULL, 0, 0,
&texture_format, NULL, &texture1, &num_mipmap, "filename",
D3DX_FT_LINEAR);
if (FAILED(hr)) error;
// &texture1 is LPDIRECTDRAWSURFACE7

I''m not sure what you mean when the function returns zero. I didn''t know the function returned the number of mipmaps. All I know is that the above code works for me, and you don''t have to do anything directly with the surfaces. D3DX just takes the file, opens it, converts it to the right colour, then creates the mipmaps you need, makes the chain, and everything. Quite useful. If you still have trouble then email me or post here again.

Share this post


Link to post
Share on other sites
Verminaard:

Do you check the "&num_mipmap" parameter you passed in?? (That is the actual number of mipmaps generated from the D3DXCreateTextureFromFile function call)

The call sets that parameter to 0 on my machine. The hresult succeeds and the "flags" paramater DOES NOT return D3DX_TEXTURE_NOMIPMAP..( the mipmap creation is not supported flag)

That is the queer part..

..

Share this post


Link to post
Share on other sites
So you mean after the call num_mipmap contains the actual number created by 3d3x? I''m not sure what the return value is, but I can visibly see the mipmap working. Are you sure d3dx isn''t creating mipmaps (just from looking at the picture)?

Share this post


Link to post
Share on other sites
quote:
Original post by Verminaard

I can visibly see the mipmap working. Are you sure d3dx isn''t creating mipmaps (just from looking at the picture)?




You can visibly see the mipmaps working?? How is that possible unless you use a different image for each smaller mipmap like the Dx7 sample..

As for the num_mipmap parameter, this is from the d3dx Create Texture doc

    
IDirectDrawSurface7 *m_ptex;
m_pd3dDevice = m_pd3dx->GetD3DDevice();

hr = D3DXCreateTextureFromFile(
m_pd3dDevice,
NULL, // dwFlags

NULL, // auto-width

NULL, // auto-height

NULL, // auto-surface type

NULL, // pointer to Palette

&m_ptex, // returned pointer to texture

NULL, // returned number of mipmaps

"texture.bmp", // file name for texture

D3DX_FT_DEFAULT); // default scaling



From the comments there, I assume it would return the number of mipmaps generated.. or else why would it take a pointer..

Could you please check the return value and get back to me??..

..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don''t have my programming computer with me right now (dad has it), but I guess you are right about the return (though it does seem like microsoft loves taking references just for the hell of it).

You can visibly see mipmaps working because the image seems to blur out as you get further away (where as it just seems to get messed up and ''static'') without mipmaps.

Just let your program run even if the return value is 0 and try to see whether the mipmaps are working or not. You are probably better at 3d than me, so I''m not sure I can really help.

Share this post


Link to post
Share on other sites

  • 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!