Sign in to follow this  
horsfield2001

color filling a texture

Recommended Posts

ok i am trying to create a blank texture of a particular color that i can then render to the screen. i am using the August 2007 SDK. so far i have followed one of the examples here to no success. VOID WINAPI ColorFill (D3DXVECTOR4* pOut, const D3DXVECTOR2* pTexCoord, const D3DXVECTOR2* pTexelSize, LPVOID pData) { D3DCOLORVALUE* color = (D3DCOLORVALUE*)pData; *pOut = D3DXVECTOR4(color->r, color->g, color->b, color->a); } ... DX9Texture::DX9Texture(LPDIRECT3DDEVICE9 pDevice, int iWidth, int iHeight, D3DCOLOR clrColor) { // Set the width and height m_iWidth = iWidth; m_iHeight = iHeight; m_NumColor = 1; m_fRotation = 0; m_fScaleX = 1; m_fScaleY = 1; D3DXCreateTexture(pDevice, iWidth, iHeight, 0, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &m_pTexture); // Fill the texture using D3DXFillTexture D3DXFillTexture (m_pTexture, ColorFill, &clrColor); } perhaps i am using the code wrong let me know if i am. void DX9Texture::Draw(LPD3DXSPRITE d3dspt, LONG x, LONG y, int xPart, int yPart, int wPart, int hPart) { if(m_pTexture != NULL) { D3DXMATRIX mat; D3DXVECTOR2 scaling(m_fScaleX, m_fScaleY); D3DXVECTOR2 center((float)wPart/2, (float)hPart/2); // center at the upper-left corner D3DXVECTOR2 position((FLOAT)x, (FLOAT)y); // position at x, y with no depth // out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation D3DXMatrixTransformation2D(&mat,NULL,0.0,&scaling,¢er,m_fRotation,&position); // Tell the sprite about the matrix d3dspt->SetTransform(&mat); RECT rectangle = {xPart, yPart, xPart + wPart, yPart + hPart}; // create the rectangle d3dspt->Draw(m_pTexture, &rectangle, NULL, NULL, D3DCOLOR_XRGB(255, 255, 255)); // draw it! } }

Share this post


Link to post
Share on other sites
I am unfamiliar with the technique you are using. It seems like there may be easier ways to achieve what you are doing. I don't really know what you are doing with this code so I can't say for sure.

It seems like there is a problem when you are creating your texture. I am pretty sure that if you are creating a texture to be used as a render target that it must use D3DPOOL_DEFAULT.

Share this post


Link to post
Share on other sites
well for someone who didnt know whati was doing you sure hit the nail on the head. i changed the paramiter you suggested and it worked ... sort of ... the texture appeared on the screen but only seems to of registered the red chanel and not the green or blue.... anny ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this