• ### Announcements

#### Archived

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

# getting pixel from texture x,y

## Recommended Posts

Glak    315
I am making a game with a map similar to RISK or Europa Universalis. This means that I have a bunch of 2d shapes that cannot be modeled with any sort of math equation. You need to be able to select them though. My solution is to make a second map where every country is a unique color. Then when you click the mouse it will take the x,y coordinates and check on the secret map to see what color it is. Each color is an id number for that territory. However it doesn''t work, it always gives 0xCDCDCDCD, which means that my values aren''t writing to the memory. Ok here is what I have:
if(FAILED( D3DXCreateTextureFromFileEx( renderer,"texture2.bmp", 0, 0, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_DEFAULT,
/*colorkey*/0, 0 , NULL, &texture2) ) )
}

image_data = (unsigned int (*)[1024][768])malloc(1024*768*sizeof(unsigned int));

D3DXIMAGE_INFO info;

if(FAILED(D3DXGetImageInfoFromFileInMemory
(
image_data,
1024*768*sizeof(unsigned int),
&info
)))
{
Write("Graphics::Startup get image failed");
}

and it prints that last error message, the get image part. Am I even using the right function? Also I normally use new for memory allocation, but I am not sure how to do it with my 2d array. My books are back home. Thanks for any help