Jump to content
  • Advertisement


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


Loading raw pixel data on a d3d8 texture

This topic is 6129 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 have been loading pixel data from my own propietary graphical file format in DD7 using Lock and Unlock without any problems, supporting any bit depth and really fast texture loading times. Now we''re using DX8 and the DX8 SDK help says I can''t lock textures in video memory, so, how am U supposed to load textures from my own files in DX8? With further investigation I came to conclusion that I need to create a DX8 surface, lock it, load the image, unlock it and then CopyRect it to the DX8 texture. Isn''t there a way to load my textures right into the DX8 texture without doing any copy stuff?

Share this post

Link to post
Share on other sites
You can create a texture, get the surface, lock it, load your data, unlock it, and then use it throughout your app without locking it again (unless you really want to)

if (FAILED(m_pD3DDevice->CreateTexture(2, 2, 0, 0,
return FALSE;

//Set the checker pattern. First get the surface and lock the
//whole rectangle.
m_pCheckerTexture->GetSurfaceLevel(0, &pWorkSurface);
pWorkSurface->LockRect(&WorkRect, NULL, 0);

//set the first 4 bytes to 0xff (white) and
//the second 4 bytes to 0x00 (black), then increment by the pitch
//and so the reverse for the second row. In most cases, the pitch
//will probably be 8, but that''s not guaranteed.
memset((BYTE *)WorkRect.pBits, 0xff, 4);
memset((BYTE *)WorkRect.pBits + 4, 0x00, 4);
memset((BYTE *)WorkRect.pBits + WorkRect.Pitch, 0x00, 4);
memset((BYTE *)WorkRect.pBits + WorkRect.Pitch + 4, 0xff, 4);

//Now unlock the rect and release the surface.

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!