Jump to content
  • Advertisement

Archived

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

Spoogy

ID3DXSprite interface and rendering the mipmapped textures?

This topic is 5295 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, I'm using multiple levels on textures (mipmapped textures) in my 2D game, which uses ID3DXSprite->draw() method for rendering the texture. Everything works just fine, but I don't know how to render other levels than the topmost (0) of the texture? Is that impossible with ID3DXSprite? Should I begin to use textured quad instead? (should I begin to use that quad "thing" anyway for the performance, even if I could render those mipmapped textures with ID3DXSprite interface?). [edited by - Spoogy on May 20, 2004 10:37:56 PM]

Share this post


Link to post
Share on other sites
Advertisement
Mip maps are generally used for improving texture efficiency based on the distance from the camera. I don''t believe they are applicable to 2D textures, though I could be wrong. I don''t see why that would be implemented by Microsoft anyway.

What are you trying to do exactly? Just have a more simplified interface for rendering different textures in a single sprite on-screen?

Chris

Share this post


Link to post
Share on other sites
Okey I'll explain more.

I'll have 4 pieces 32x32 sized sprites (at pixels) in one .png file (at the row). So, this file is 32 pixel tall and 128 pixels width.

In my game initialization code (I'm programming with Delphi, but I can read C++ very well) I'll read image information by using D3DXGetImageInfoFromFile() function.

With retrieved information I set the size of the surface which I create with D3DDevice->CreateImageSurface() function. Then I load the .png file to that surface with D3DXLoadSurfaceFromFile() funtion.

After that, I'll create new texture by using D3DDevice->CreateTexture() function. The texture is sized by the size of the one sprite in the .png file (in this case it would be 32x32 pixels). I also create so many levels to that texture as it needs to hold all the sprites from that .png file (if there's 4 sprites like my example here, then there should be 4 levels on that texture).

Then I iterate (or how you spell out for loop?) all levels and get their surface with Texture->GetSurfaceLevel() function and I copy each sprite (one at the each loop) from source surface to that texture surface level which is current in the for loop by using the D3DXLoadSurfaceFromSurface() function (I'm very poor to explain in english what my code does). I hope you got the point.

I simplify littlebit what I explained above.

- Create surface and load .png file into it.
- Create texture with needed count of levels in it.
- copy each sprite from source surface to each texture level.

Now I like to animate that sprite by drawing the texture on the screen each level at the time, but ID3DXSprite->Draw() funtion does not have parameter where you can tell which level to draw on the screen.

I tried to draw that texture with that draw function, but it only draws the topmost level of the sprite (level 0). How I can draw other levels too? Do I have to use textured quads (D3DFVF_XYZRHW) to draw requested levels (which is set with D3DDevice->SetRenderState() or some sort of function like that)?


[edited by - Spoogy on May 21, 2004 7:58:29 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Supernat02
Mip maps are generally used for improving texture efficiency based on the distance from the camera. I don''t believe they are applicable to 2D textures, though I could be wrong. I don''t see why that would be implemented by Microsoft anyway.


It doesn''t need to be. The D3DXSprite engine simply spits
out textured quads with the sizes and texture coordinates
that you specify. If you draw them in object space, mip maps
will be rendered as if they were any other polygon.

So if your camera is zooming in and out, yes, I believe mip
maps will automatically be used.

Share this post


Link to post
Share on other sites
I dont see what your using surface levels for. it seems like you are trying to draw an animated sprite.

use D3DXCreateTextureFromFileEx() load up the full texture

store each frame from the texture in a RECT structure

when using ID3DXSprite::Draw you can specify the source rect from the texture

for example:
pSprite->Draw(pTexture, &frames[currentFrame], NULL, NULL, 0xFFFFFF);

Share this post


Link to post
Share on other sites
quote:
Original post by eFoDay
I dont see what your using surface levels for. it seems like you are trying to draw an animated sprite.

use D3DXCreateTextureFromFileEx() load up the full texture

store each frame from the texture in a RECT structure

when using ID3DXSprite::Draw you can specify the source rect from the texture

for example:
pSprite->Draw(pTexture, &frames[currentFrame], NULL, NULL, 0xFFFFFF);


Yes correct. I am trying to create texture which I want to animate by changing the texture levels when drawing the texture. But ID3DXSprite doesn't seems to support texture levels or does it? I don't know.

Your idea for loading all the sprites in one texture is what I like to do, but isn't there some kind of limits for the texture sizes you can load?

I read before from this forum that, you can't load texture sized more than 256x256 pixels on voodoo cards. Is that true? So, if I have animated sprite which has (for example) 16 different frames sized 64x64 pixels each. Then it needs so big texture that some graphics card doesn't support it. Am I right?

That's why I'm trying to use texture levels. Another reason is to get rid of the off-screen surfaces. I don't want to copy frames from off-screen surfaces while i'm rendering (That's how things are done before, but I'm trying to change that behavior).

Seems that I has to began to use vertexbuffers and drawprimitive methods to draw my multilevel textures and get rid of the D3DXSprite interface. Am I correct?



[edited by - Spoogy on May 23, 2004 1:34:30 PM]

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!