Jump to content
  • Advertisement
Sign in to follow this  
hpesoj

Copying one texture onto another

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

I am trying to 'paste' one 16 bit (with alpha channel) direct3d texture onto another one. The pasted texture may be pasted at any position relative to the base texture. So far I have managed to access and change the base texture, but simply setting each pixel individually to 0 is fairly slow, and I can see that when I am reading from boths textures, calculating the result, and writing to one texture, that the whole process is going to be slower that the process I am trying to optimise (combining multiple textures and copying one texture to the screen rather than copying them all each screen refresh). Here is part of my code (Delphi):
  Image := IDirect3DTexture9(GetImagePointer(ImageID));
  Width := GetImageWidth(ImageID);
  Height := GetImageHeight(ImageID);

  New(RectPtr);
  RectPtr^.Left := 0;
  RectPtr^.Top := 0;
  RectPtr^.Right := Width;
  RectPtr^.Bottom := Height;

  Image.LockRect(0,LockedRect,RectPtr,D3DLOCK_DISCARD);

  Depth := LockedRect.Pitch div Width;

  for x := 1 to Height*LockedRect.Pitch do begin
    PByte(LockedRect.pBits)^ := 0;
    Inc(PByte(LockedRect.pBits));
  end;

  Image.UnlockRect(0);
Is there any faster way to blend two textures, or part of two textures, together? Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!