• Advertisement


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

modifying a texture

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

Im trying to write to a texture who format is D3DFMT_R5G6B5 im getting a value from 0 and 255 out of an array this value represents a grayscale color and i want to write this color onto a texture heres the code im using
	//this function will convert the raw blend map into a texture

	unsigned int *bits;
	unsigned int pitch;
	int i,j;
	char col;
	terrBlendMap[mapnumber]->GetLevelDesc(0, &desc);
	terrBlendMap[mapnumber]->LockRect( 0, &lr, 0, 0 );
	bits=(unsigned int*)lr.pBits;

	//Copy the data onto the texture


i know im messing something up but i cant figure it out [edited by - kapru on January 6, 2004 1:13:31 AM]

Share this post

Link to post
Share on other sites
I see two problems.

1: Int is 32-bit wide variable, but you would need to use 16 bits per pixel (cast the locked data pointer to WORD* instead of int*).
2: D3DCOLOR_XRGB produces a 32-bit (8888) color value; you must convert this to 16-bit (565) representation.


EDIT: Look up the D3DCOLOR_XRGB macro definition. With trivial modification, you can make a 16-bit version of it (as it simply consists of a few bit shifts and bitmasks).

[edited by - Nik02 on January 6, 2004 8:10:20 AM]

Share this post

Link to post
Share on other sites

  • Advertisement