Jump to content
  • Advertisement
Sign in to follow this  
thuong

how to Draw on IDirect3DTexture9?

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

Anybody how to draw an image or buffer on IDirect3DTexture9 or use HDC to draw on 3D Screen?

Share this post


Link to post
Share on other sites
Advertisement
You cannot draw directly on a Texture because it's actually a composite of one or more surfaces and other misc data.

For something like this you'd likely only want to create a texture with a single level (no mipmaps). You can get the associated surface by calling GetSurfaceLevel on the texture.

Surfaces support a GetDC call which should get you what you need.

Share this post


Link to post
Share on other sites
You can use D3DXLoadSurfaceFromSurface to copy a surface/texture to another surface/texture.
eg

LPDIRECT3DSURFACE9 pSrcSurface=NULL;
LPDIRECT3DSURFACE9 pDestSurface=NULL;

srcTexture->GetSurfaceLevel(0,&pSrcSurface);
dstTexture->GetSurfaceLevel(0,&pDestSurface);


D3DXLoadSurfaceFromSurface(pDestSurface,NULL,NULL,pSrcSurface,NULL,NULL,D3DX_FILTER_NONE,0);

pSrcSurface->Release();
pDestSurface->Release();

Share this post


Link to post
Share on other sites
i have tried to load surface from buffer before copy to target surface, but it failed:

if(FAILED(hr=D3DXLoadSurfaceFromFileInMemory(sourceSurf,NULL,NULL,mybitmap,size,

NULL,D3DX_DEFAULT,0,NULL)))

if i load mybitmap buffer with D3DXCreateTextureFromFileInMemoryEx, it is OK:
D3DXCreateTextureFromFileInMemoryEx( m_pD3DDevice,
mybimap,
size,
Width,
Height,
D3DX_DEFAULT,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
D3DX_FILTER_LINEAR,
D3DX_FILTER_LINEAR,
0xFFFFFFFF,// Color key
//0xFF000000,
NULL,
NULL,
&m_pTexture
)

so, can anybody explain what wrong with my function to load surface from buffer.

Share this post


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

  • 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!