Jump to content
  • Advertisement


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


Creating a texture from the screen shot

This topic is 5880 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'm trying to make a texture based on my screenshot, this is my code
//creating texture and surface

m_p2DApp->m_pd3dDevice->CreateImageSurface(800, 600, D3DFMT_A8R8G8B8, &frontbuf);

//get the front buffer
hr = m_p2DApp->m_pd3dDevice->GetFrontBuffer(frontbuf);

//lock the texture and surface
D3DLOCKED_RECT lockedrect1;
D3DLOCKED_RECT lockedrect2;
RECT rect;
hr= m_pTextureBG->LockRect(0,&lockedrect1,&rect,0);
hr= frontbuf->LockRect(&lockedrect2,&rect,D3DLOCK_READONLY);

//copy rectangle from surface to texture
unsigned char *pSurfBits1=static_cast(lockedrect1.pBits);
unsigned char *pSurfBits2=static_cast(lockedrect2.pBits);

this doesn't work !! my texture is nothing but a blank texture, I've tried to save the surface using D3DXSaveSurfaceToFile and the result is fine so nothing wrong with the surface Can somebody help me ?? [edited by - yanuart on August 17, 2002 12:30:25 AM]

Share this post

Link to post
Share on other sites
A much more efficient way to do this is to render to a texture. There are plenty of good tutorials on that, so I won''t go into it here.

Oh, and your memcpy will fail if your bpp is greater than 8. Which it probably is.

Don''t listen to me. I''ve had too much coffee.

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!