Jump to content

  • Log In with Google      Sign In   
  • Create Account

a question about d3d display ,for help


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 BugShan   Members   -  Reputation: 115

Like
0Likes
Like

Posted 08 November 2011 - 03:19 AM

Now ,I have a problem with d3d programming.I want to use d3d to display a image on the screeen.Although I have set the colorkey as 0xffff00ff, but the image is always in black box.
My code is as the following:
        //set the render state

        m_pD3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
	m_pD3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
	m_pD3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

        //create a surface and load the image

        HRESULT hResult=D3DXGetImageInfoFromFile(imageFile,&imageInfo);
	if(S_OK!=hResult)
		return NULL;
	hResult=m_pD3dDevice->CreateOffscreenPlainSurface(imageInfo.Width,
		imageInfo.Height,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,
		&surface/*m_pSurface[m_nSurfaceUsed]*/,NULL);
	
	if(S_OK!=hResult)
		return NULL;
	hResult=D3DXLoadSurfaceFromFile(surface/*m_pSurface[m_nSurfaceUsed]*/,NULL,NULL,
		imageFile,NULL,D3DX_DEFAULT,colorKey,NULL);                                                                         //i have sat the colorkey as 0xffff00ff
        hResult=m_pD3dDevice->StretchRect(surface,res,m_pBackBuffer,dest,D3DTEXF_NONE);


i know that i can use another metohd to display this image ,such as IDXSprite,but i always want to know why my code doesnt work .
where is woring or the StretchRect function doesnt support the transprarency color ? anybody can help me?Thanks!

Sponsor:

#2 Adam_42   Crossbones+   -  Reputation: 2618

Like
0Likes
Like

Posted 08 November 2011 - 06:41 AM

StretchRect() does a simple texture copy and ignores the alpha channel. You probably want to use ID3DXSprite to draw your image.

#3 BugShan   Members   -  Reputation: 115

Like
0Likes
Like

Posted 08 November 2011 - 08:10 AM

StretchRect() does a simple texture copy and ignores the alpha channel. You probably want to use ID3DXSprite to draw your image.


Thank you very much!I have considered it but not for sure.I just want to use a simple method and i think DirectDraw was in my mind.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS