Original Post
for textures i use IDirect3DTexture9. How can i lock the texture and then update its pixels?
LPDIRECT3DTEXTURE8 Txr;D3DLOCKED_RECT Rc;unsigned int* Pntr;D3DXCreateTexture(D3DDevice,256,256,0,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&Txr)Txr->LockRect(0,&Rc,NULL,D3DLOCK_NOSYSLOCK);Pntr=(unsigned int *)Rc.pBits;Pntr[(10*256)+80]=0xFF00FF00; //plots a full green pixel at 80,10//do more drawingTxr->UnlockRect(0);Quote:
Textures placed in the D3DPOOL_DEFAULT pool cannot be locked unless they are dynamic textures or they are private, four-character code (FOURCC), driver formats. To access unlockable textures, you must use functions such as IDirect3DDevice9::UpdateSurface, IDirect3DDevice9::UpdateTexture, IDirect3DDevice9::GetFrontBufferData, and IDirect3DDevice9::GetRenderTargetData. D3DPOOL_MANAGED is probably a better choice than D3DPOOL_DEFAULT for most applications.
float fTime; // your time in the range 0..1Pntr=(unsigned int *)Rc.pBits;// Calculate the colour to useDWORD dwIntensity = ((DWORD)fTime*255.0f);DWORD dwColour = dwIntensity << 16;// Fill the texturefor(int y=0; y<texture_height; ++y){ pRow = Pntr[y*Rc.Pitch]; // Get a pointer to the start of this row of texels for(int x=0; x<texture_width; ++x) *pRow++ = dwColour;}Quote:
Original post by ryt
thx, theats what i meant.
DWORD dwColour = dwIntensity << 16;
what does this mean << 16; ??
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more