Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Create sprites from tilesets


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 SamiHuutoniemi   Members   -  Reputation: 259

Like
0Likes
Like

Posted 13 November 2012 - 06:52 AM

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!

Sponsor:

#2 Tordin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 13 November 2012 - 08:05 AM

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"

#3 SamiHuutoniemi   Members   -  Reputation: 259

Like
0Likes
Like

Posted 14 November 2012 - 02:30 AM

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?

#4 Tordin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 14 November 2012 - 03:01 AM

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

Edited by Tordin, 14 November 2012 - 03:54 AM.

"There will be major features. none to be thought of yet"




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS