Create sprites from tilesets

Started by
2 comments, last by Tordin 11 years, 5 months ago
Hello!

So if I in DirectX 11 want to create a sprite from an image file, comprising of a number of sprites - is this the way to go?

1) Create a temporary texture from the file. (i.e. D3DX11CreateTextureFromFile)
2) Somehow create a blank texture
3) Copy a region of the temporary texture to the blank one (i.e. CopySubresourceRegion)
4) Create a shader resource view from the no longer blank texture (i.e. CreateShaderResourceView)

Or how would you do it? (If like this - how do I in the simplest way create a blank texture?)

Thanks!
Advertisement
2 : You can create a file without binding any subdata to it. Think it´s D3D11CreateTexture (or something similar)


And if you want sprite, you can just copy the subregion directly to the framebuffer. so you can skip som steps.
"There will be major features. none to be thought of yet"

2 : You can create a file without binding any subdata to it. Think it´s D3D11CreateTexture (or something similar)


And if you want sprite, you can just copy the subregion directly to the framebuffer. so you can skip som steps.


I'm not exactly sure what you mean with the first part. I dont want to create a file. I want to create a blank texture onto which i can copy a subregion of a bigger texture. Can this be done? =)

And yes. I would think that the it's very possible to use the second method. However, I'd prefer to save only the relevant texture data in any one sprite object, and thus not the whole original tileset and rectangle data. But if I must do this, how do I render part of a shader resource view? Right now I pretty much just plug it into the pixelshader and then draw. Any hints?
when you load a image from the hard drive, you get out an ID3D11Texture pointer (or if it was, shaderresource or shaderview) and the thing that happens is that dxgi helps you load your texture and then put that data into that texture pointer you get out. you can do this by your self and by pointing to a texture in memory.

as you see with this function (in the webpage) it takes a D3D11_SUBRESOURCE_DATA which points to some texture memory.
http://msdn.microsoft.com/en-us/library/windows/desktop/ff476521(v=vs.85).aspx

i think that webpage got what you are looking for aswell!


you can call the CopySubresourceRegion when you got the atlas, to "Scissor" out specific parts of the atlas to the framebuffer.
http://msdn.microsoft.com/en-us/library/windows/desktop/ff476394(v=vs.85).aspx
"There will be major features. none to be thought of yet"

This topic is closed to new replies.

Advertisement