   Manually filled textures problem Direct3D 10
  What this function does is draws a box to the new texture, then returns that texture once it is done.  If I use the D3DX10SaveTextureToFile function, it works, and I get the box in a file, so I know the texture is good. ID3D10Texture2D* CreateBox()    {    ID3D10Texture2D* pTextPointer=0;    D3D10_MAPPED_TEXTURE2D pMappedTex;    D3D10_TEXTURE2D_DESC pBoxDesc;ZeroMemory(&pBoxDesc,sizeof(D3D10_TEXTURE2D_DESC));pBoxDesc.MipLevels=1;pBoxDesc.ArraySize=1;pBoxDesc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;pBoxDesc.SampleDesc.Count=1;pBoxDesc.Usage=D3D10_USAGE_DYNAMIC;pBoxDesc.CPUAccessFlags=D3D10_CPU_ACCESS_WRITE;pBoxDesc.BindFlags=D3D10_BIND_SHADER_RESOURCE;pBoxDesc.Width=600;pBoxDesc.Height=100;    pD3DDevice->CreateTexture2D(&pBoxDesc,0,&pTextPointer);    pTextPointer->Map(D3D10CalcSubresource(0,0,1),D3D10_MAP_WRITE_DISCARD,0,&pMappedTex);    UCHAR* pTexels=(UCHAR*)pMappedTex.pData;    for(unsigned short iRow=0;iRow<pBoxDesc.Height;iRow++) {//for(unsigned short iRow=0;iRow<pBoxDesc.Height;iRow++)unsigned int rowStart = iRow * pMappedTex.RowPitch;for( unsigned short iCol=0;iCol<pBoxDesc.Width;iCol++){unsigned int colStart = iCol * 4;if(((!iRow)||(iRow==(pBoxDesc.Height-1)))&&(!iCol||(iCol==(pBoxDesc.Width-1)))){pTexels[rowStart+colStart+3]=255;// Alpha}else{pTexels[rowStart+colStart+3]=0;// Alpha}//map black pixels firstif(  !iRow//first row||!iCol//first column||(iRow==(pBoxDesc.Height-1))//last row||(iCol==(pBoxDesc.Width-1))//last column||((iRow==1)&&(iCol==1))//first pixel from each corner||((iRow==(pBoxDesc.Height-2))&&((iCol==1)||(iCol==(pBoxDesc.Width-2))))||((iCol==(pBoxDesc.Width-2))&&(iRow==1))||((iRow==3)&&(iCol==3))//third pixel from each corner||((iRow==(pBoxDesc.Height-4))&&((iCol==3)||(iCol==(pBoxDesc.Width-4))))||((iCol==(pBoxDesc.Width-4))&&(iRow==3))  ){pTexels[rowStart + colStart + 0] = 0; // RedpTexels[rowStart + colStart + 1] = 0; // GreenpTexels[rowStart + colStart + 2] = 0; // Bluecontinue;}//second (brown) layer of pixelsif(  (((iRow==1)||(iRow==(pBoxDesc.Height-2)))&&((iCol>1)&&(iCol<(pBoxDesc.Width-2))))||(((iCol==1)||(iCol==(pBoxDesc.Width-2)))&&((iRow>1)&&(iRow<(pBoxDesc.Height-2))))||(((iRow==2)||(iRow==(pBoxDesc.Height-3)))&&((iCol==2)||(iCol==(pBoxDesc.Width-3))))||((iRow==3)&&((iCol==4)||(iCol==(pBoxDesc.Width-5))))||((iRow==4)&&((iCol==3)||(iCol==(pBoxDesc.Width-4))))||((iRow==(pBoxDesc.Height-4))&&((iCol==4)||(iCol==(pBoxDesc.Width-5))))||((iRow==(pBoxDesc.Height-5))&&((iCol==3)||(iCol==(pBoxDesc.Width-4))))//fourth layer of pixels, same color as second||(((iRow==4)||(iRow==(pBoxDesc.Height-5)))&&((iCol>5)&&(iCol<(pBoxDesc.Width-6))))||(((iCol==4)||(iCol==(pBoxDesc.Width-5)))&&((iRow>5)&&(iRow<(pBoxDesc.Height-6))))||((iRow==5)&&((iCol==5)||(iCol==(pBoxDesc.Width-6))))||((iRow==(pBoxDesc.Height-6))&&((iCol==5)||(iCol==(pBoxDesc.Width-6))))  ){pTexels[rowStart+colStart+0]=104;// RedpTexels[rowStart+colStart+1]=68;// GreenpTexels[rowStart+colStart+2]=8;// Bluecontinue;}//third (gold) layer of pixelsif(  (((iRow==2)||(iRow==(pBoxDesc.Height-3)))&&((iCol>2)&&(iCol<(pBoxDesc.Width-3))))||(((iCol==2)||(iCol==(pBoxDesc.Width-3)))&&((iRow>2)&&(iRow<(pBoxDesc.Height-3))))||(((iRow==3)||(iRow==(pBoxDesc.Height-4)))&&((iCol==5)||(iCol==(pBoxDesc.Width-6))))||(((iRow==4)||(iRow==(pBoxDesc.Height-5)))&&((iCol==4)||(iCol==(pBoxDesc.Width-5))))||(((iRow==5)||(iRow==(pBoxDesc.Height-6)))&&((iCol==3)||(iCol==(pBoxDesc.Width-4))))  ){pTexels[rowStart+colStart+0]=240;// RedpTexels[rowStart+colStart+1]=176;// GreenpTexels[rowStart+colStart+2]=88;// Bluecontinue;}if(  (((iRow==3)||(iRow==(pBoxDesc.Height-4)))&&((iCol>4)&&(iCol<(pBoxDesc.Width-5))))||(((iCol==3)||(iCol==(pBoxDesc.Width-4)))&&((iRow>4)&&(iRow<(pBoxDesc.Height-5))))||(((iRow==4)||(iRow==(pBoxDesc.Height-5)))&&((iCol==5)||(iCol==(pBoxDesc.Width-6))))||(((iRow==5)||(iRow==(pBoxDesc.Height-6)))&&((iCol==4)||(iCol==(pBoxDesc.Width-5))))  ){pTexels[rowStart+colStart+0]=255;// RedpTexels[rowStart+colStart+1]=255;// GreenpTexels[rowStart+colStart+2]=255;// Bluecontinue;}//define box fill color (default blue)if(  (((iRow>5)&&(iRow<(pBoxDesc.Height-6)))&&((iCol>4)&&(iCol<(pBoxDesc.Width-5))))||(((iRow==5)||(iRow==(pBoxDesc.Height-6)))&&((iCol>5)&&(iCol<(pBoxDesc.Width-6))))  )  {pTexels[rowStart+colStart+0]=0;// RedpTexels[rowStart+colStart+1]=32;// GreenpTexels[rowStart+colStart+2]=120;// Bluecontinue;}}}//for(unsigned short iRow=0;iRow<pBoxDesc.Height;iRow++)pTextPointer->Unmap(D3D10CalcSubresource(0,0,1));return pTextPointer;}What I am trying to do is use this function to generate box textures to use in D3DX10_SPRITE structures.ID3D10Texture2D* pBoxPoint=CreateBox();ID3D10ShaderResourceView* pShaderRV=0;D3D10_TEXTURE2D_DESC pBoxDesc;pBoxPoint->GetDesc(&pBoxDesc);D3D10_SHADER_RESOURCE_VIEW_DESC pBoxDescSRV;ZeroMemory(&pBoxDescSRV,sizeof(D3D10_SHADER_RESOURCE_VIEW_DESC));pBoxDescSRV.Format=pBoxDesc.Format;pBoxDescSRV.ViewDimension=D3D10_SRV_DIMENSION_TEXTURE2D;pBoxDescSRV.Texture2D.MipLevels=pBoxDesc.MipLevels;hResult=pD3DDevice->CreateShaderResourceView(pBoxPoint,&pBoxDescSRV,&pShaderRV);D3DX10_SPRITE testSprite;testSprite.ColorModulate=D3DXCOLOR(1,1,1,1);testSprite.pTexture=pShaderRV;testSprite.TexCoord.x=0;testSprite.TexCoord.y=0;testSprite.TexSize.x=1;testSprite.TexSize.y=1;testSprite.TextureIndex=0;D3DXMATRIX mScaleMat;D3DXMatrixScaling(&mScaleMat,600,100,1);D3DXMATRIX mTransMat;D3DXMatrixTranslation(&mTransMat,200,200,0.1);testSprite.matWorld=(mScaleMat*mTransMat);The problem is that while the call to CreateShaderResourceView() returns S_OK, I get zero output.  The ONLY way I have been able to get an output is to load the texture from a file, and create the shader resource view from there.  Since these boxes are going to be needed sporadically and dynamically, it is not going to be possible to keep files for each and every type.  I have tried every combination of flags in the D3D10_TEXTURE2D_DESC structure that I can think of but only this one will get the example to even run.  Can somebody see what I am doing wrong?   
  When using D3D10_CREATE_DEVICE_DEBUG during device creation, is anything written to the output regarding that CreateShaderResourceView?   ;  Not by the looks of it.  This is the only thing I am seeing regarding ShaderResourceView, and that is only on terminating the program.D3D10: INFO: ID3D10Device::PSSetShaderResources: A currently bound PixelShader ShaderResourceView is being deleted; so naturally, will no longer be bound. [ STATE_SETTING INFO #43: PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT ].I understand what is happening now.  The problem is that the Alpha values I set in the call to Map() should be reversed.  I was reading from an example and had the impression that Alpha represents degree of TRANSPARENCY but instead it represents degree of OPACITY.  I switch the 255 alpha values with 0 alpha values and it works as expected.  The reason I never suspected this before was because I was able to see the entire texture when I saved it to file and opened the file, or even when I reloaded the file.  I am such a nub >_<.[Edited by - DarkMasterBosel on January 24, 2009 11:04:34 AM]