A texture rectangle, texture type is RGBA.
the alpha channel like this: (0=0,x=255)
[0][0][0][0][0][0][0]
[0][0][x][x][0][0][0]
[0][x][x][x][0][0][0]
[0][x][x][x][x][x][0]
[0][0][0][x][x][x][0]
[0][0][0][x][x][0][0]
[0][0][0][0][0][0][0]
I want a function to picking. now I have a very clumsy solutions:
//system Init.............
//..........
//pixel buffer to texture....... (texture is handle, a number.cannot get pixel matrix.)
//..........
BYTE pixel_alpha[7][7];//save alpha channel matrix
//..........
texture.draw(30,30);//draw the picture in the window x=30 , y=30
//..........
if(picking(GetMouseX,GetMouseY))MessageBox("click!"); // picking functio
//..........
/*picking function*/
bool picking(int x,int y)
{
int mouse_to_image_x, mouse_to_image_y;//get mouse position in the image
mouse_to_image_x = 30 - x;
mouse_to_image_y = 30 - y;
if((mouse_to_image_x < 0 && mouse_to_image_x > 7) && (mouse_to_image_y < 0 && mouse_to_image_y > 7))return false;//mouse is not in the image
for(int i = 0; i < 7 * 7; i++)
{
if(pixel_alpha[mouse_to_image_x][mouse_to_image_y] == 255)return true;//in the image and alpha channel is 255
}
return false;
}
//=============================================================================================
but......
1.an excessive amount of memory in alpha channel matrix.
2.i think efficiency is not high.
so, how to do?
not is ray picking, What is this technology called?