Archived

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

copying from one texture to another..

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

Is there a more straightforward way to copy a smaller texture, w/ alpha (i.e. keyed) onto a larger texture? UpdateTextures won''t handle blending, and using the larger texture as a render destination seems iffy...

Share this post


Link to post
Share on other sites
Well, I have no clue what you''ll be using this for, but I''ll try
First of all; Multitexturing. Use it! Love it! Check the sdk-docs for all you need to know to make singlepass textureblending.

Second: If you don''t want gradual transparency; Alphatesting. Just set it to mask away anything that doesn''t have the desired alpha or above, and blast away =)


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites
im not sure if this is what u want but i copy from one texture to another like this.....



    
D3DLOCKED_RECT sourceRectangle;
D3DLOCKED_RECT destinationRectangle;
D3DSURFACE_DESC surfaceDescription
//pTexture is the copy texture.

//m_texture is the texture to copy to.

pTexture->GetLevelDesc(NULL, &surfaceDescription);
m_d3d->getD3DDevice()->CreateTexture(surfaceDescription.Width, surfaceDescription.Height, 0, 0, surfaceDescription.Format,
D3DPOOL_MANAGED, &m_texture);

pTexture->LockRect(0, &sourceRectangle, NULL, D3DLOCK_READONLY);
m_texture->LockRect(0, &destinationRectngle, NULL, 0);

memcpy(destinationRectangle.pBits, sourceRectangle.pBits, sourceRectangle.Pitch*surfaceDescription.Height);

m_texture->UnlockRect(0);
pTexture->UnlockRect(0);



oh and incase your wondering about why use the pitch instead of width. do a search on lPitch int his forum there was a big discussion on it a few days ago if i remember correctly

in a few words if you use width your not getting the width that the texture is in your program. because d3d sometimes adds data to the width of a texture and pitch gives a width including that data so its more accurate. i think.

hope that helped

later

[edited by - alfmga on June 24, 2002 12:47:03 PM]

Share this post


Link to post
Share on other sites
hmm... no, i''m looking for copying a smaller texture onto a certain location of a larger texture. for example, drawing a sprite on a large background in a 2d game. i also want the remove the key color when copying, so straight memcopying won''t do it.

Share this post


Link to post
Share on other sites
Then just use the above code, but rather than using

pTexture->LockRect(0, &sourceRectangle, NULL, D3DLOCK_READONLY);

replace null with a pointer to a rect that describes the size you want to copy... then copy as normal.

No idea why bitblit() hasnt been implemented for this kind of thing... roll on dx9!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Then just use the above code, but rather than using

pTexture->LockRect(0, &sourceRectangle, NULL, D3DLOCK_READONLY);

replace null with a pointer to a rect that describes the size you want to copy... then copy as normal.

No idea why bitblit() hasnt been implemented for this kind of thing... roll on dx9!

Share this post


Link to post
Share on other sites