Jump to content
  • Advertisement

Archived

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

Naku

Creating a D3D texture without D3DXCreateTextureFromFile()

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

How could I create a texure without using D3DXCreateTextureFromFile() just using the raw colour data? The texture data I want is inside another format that I can read into memory easy enough but how do I turn that into a texture. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Did you try this one : D3DXCreateTexture ?

Then, you can fill/read/clear the surface like any other DirectDraw Surface...

__________________________



Bruno Wieckowski
Lead Programmer
Exood4 Studios

Share this post


Link to post
Share on other sites
This is a simple way, not necessarily the best way


  

LPDIRECT3DTEXTURE8 myTexture;
HRESULT returnvalue;
D3DLOCKED_RECT lr;

returnvalue = g_pd3dDevice->CreateTexture(width,
height, 1, 0 ,
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &myTexture);

if (FAILED(returnvalue))
{
return E_FAIL;
}

returnvalue = myTexture->LockRect(0, &lr, NULL, 0);
if (FAILED(returnvalue)){
return E_FAIL;
}


UCHAR* pRect = (UCHAR*) lr.pBits;

long o=0;

// just memcpy your image to pRect here

// Remember to have your image in the same format as the texture


returnvalue = myTexture->UnlockRect(0);
if (FAILED(returnvalue)){
return E_FAIL;
}

Share this post


Link to post
Share on other sites
Thanks, that was a big help.

Still not quite working (it won''t let me use D3DFMT_R8G8B8 for some reason) but its getting closer.

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!