IIRC render target usage is incompatible with managed pool allocation. Other than that, the code should generate a square texture with linear gradients for all channels, including alpha.
Note that texture scanline width (or Pitch) is not guaranteed to be same as width*bytesPerPixel; this code assumes that it is but this is often an incorrect assumption. The locked rect structure contains the Pitch field for this.
The [color=#000000]m_pRGBAData array is not needed; D3D will allocate (or give) the scratch space from system memory for you when you lock resources. The pointer to the scratch space is in the locked rect structure's pBits field.
The x loop counter is incremented in a funny way; usually, the incrementation is done in the "for" statement:
[font=courier new,courier,monospace]for (int x = 0; x < something; ++x) {}[/font]
-The y coordinate range is 0...height-1. You are now writing past the allocated area, and if you're lucky, you get an access violation + crash your program.
-The pBits field is a void pointer; the compiler cannot determine the width of the elements automatically if you treat it as an array. Cast it to a unsigned char* before performing pointer arithmetic.
-The x coordinate should still span just the width of the texture; pitch can be the same or greater than width*bytes per pixel (you can't really assume anything else).
-Assuming x and y span the width and height of the texture respectively, the unsigned char (or byte) pointer for a 32-bit texel at x,y can be found as follows:
y * pitch + x * 4
...since each pixel is 4 bytes wide, assuming the format is a8r8g8b8, and each scanline is pitch bytes wide in memory. The byte pointer can be cast to UINT* so you can easily dereference a whole UINT. Alternatively, you can also write the argb data directly to the pointer by treating it as a byte array.
well...looks like that i didn't understand anything....but no, something i understand, but not enough to write correct code...is there maybe a working sample about texture alpha? Or some lessons? I just need working code, cause trying to understand code, that don't work its hard...
Alpha data is just an another byte in the texels (assuming a8r8g8b8), just like red, green and blue.
Do you understand the difference between "void*" and "unsigned char *" (or pointer to any data type), and how the pointer type affects the way the array element addresses are calculated? It is best to start from the language basics before doing more advanced stuff with D3D.