• Advertisement
Sign in to follow this  

LockRect

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

If i create my texture at 100 by 100 then wouldnt i fill in my pixel data in a for loop from 0 to 10000? but for some reason when my texture is applied to an object(say a simple polygon) it only shows up partly(about 85% is blue and the 15% is black) what could i possible be doing wrong....probably a simple answer but i havent slept in a while...lol...any help would be great! p_device->CreateTexture(100,100,1,D3DUSAGE_DYNAMIC,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&p_texture,NULL); D3DLOCKED_RECT rect; p_texture->LockRect(0,&rect,NULL,D3DLOCK_DISCARD); DWORD* pData=(DWORD*)(rect.pBits); for(long i = 0;i < 10000;i++){ //repeat the same pixel color for the whole texture pData = (DWORD)t.rgba[0]; } p_texture->UnlockRect(0);

Share this post


Link to post
Share on other sites
Advertisement
You should keep an eye on the pitch, which is the width of the texture in memory. If you create a 100 by 100 texture, the actual dimensions might be 128 by 128. So.. Google!

Share this post


Link to post
Share on other sites
ok i fianlly get it...woohoo time for some sleep...if 12pm...lol

for(long i = 0;i < width;i++){
for(long j = 0;j < height;j++){
pData[i+j*rect.Pitch] = (DWORD)0x00ff00ff;
}
}

Share this post


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

  • Advertisement