Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Raloth

setting bytes in a locked texture

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

I've gone over this code twenty times, searched all over, and I can't find what is wrong.
	D3DLOCKED_RECT texture;
	alphamap->LockRect(0,&texture,NULL,D3DLOCK_DISCARD);
	BYTE* pBits = (BYTE*)(texture.pBits);
	for(int i=0;i<256;i++) {
		for(int j=0;j<256;j++) {
			pBits[j*texture.Pitch + i*4 + 2] = alphavalues[0][ i ][j];
			pBits[j*texture.Pitch + i*4 + 1] = alphavalues[1][ i ][j];
			pBits[j*texture.Pitch + i*4 + 0] = alphavalues[2][ i ][j];
			pBits[j*texture.Pitch + i*4 + 3] = alphavalues[3][ i ][j];
		}
	}
	alphamap->UnlockRect(0);  
The alphavalues array is made of BYTEs. Nothing crashes and it ends up filling all the data, but it isn't in the right place. It ends up scattered around the texture at equal intervals. What am I missing? [edited by - Raloth on January 24, 2004 6:49:06 PM]

Share this post


Link to post
Share on other sites
Advertisement
for(int i=0;i<256;i++)
{
for(int j=0;j<256;j++)
{
pBits[(j * texture.Pitch + i) * 4 + 2] = alphavalues[0][ i ][j];
pBits[(j * texture.Pitch + i) * 4 + 1] = alphavalues[1][ i ][j];
pBits[(j * texture.Pitch + i) * 4 + 0] = alphavalues[2][ i ][j];
pBits[(j * texture.Pitch + i) * 4 + 3] = alphavalues[3][ i ][j];
}
}


Should work better, I think..

-Morten-

Share this post


Link to post
Share on other sites
When the texture gets uploaded to video memory it usually gets swizzled, so it better fits the texel-cache hardware. I was just wondering if the driver got it wrong doing that operation. If there''s a problem with that, though, I''d be very surprised (needs a bug doing some fancy page fault thing to mark the area of the texture you''ve just scribbled to).

-Morten-

Share this post


Link to post
Share on other sites
Here''s a screenshot of the problem:

http://www20.brinkster.com/raloth/texturelock.jpg

It''s supposed to be all red with a 32x32 bit of yellow in the top left, but it comes out like that. Making the 32x32 bit bigger makes the dots get bigger.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!