But how would you pick an image? I understand, that you would technically pick and check if the pixel is not transparent. But how would you know what image you are picking. Also how would you tint the image with the corrospondent owner color.
1. For each region:
2. Check if mouse is inside region bounding box (= inside the image).
3. If it is, check if the pixel under the mouse is transparent.
4. If it is transparent, you've found the region that is being clicked.
Assuming OpenGL, what's wrong with glColor3f(r, g, b) for team color? Maybe multitexturing, or just a shader that adds the team color to the region color? It should be easy anyway.
I just talked to my father, who programms in graphics and has done alot of picking in them. He said I could make them all meshes (he has the point data) and fill them via opengl. (would look rather fugly though.) and then pick them.
My thought was to make the armys and cities as seperate images ontop of one big worldmap and only make those clickable.
I would make armys and cities as seperate images with a hitzone so I can pick them. Id still have the problem of not being able to tint the provinces.
Drawing lots of stuff just for picking seems like a bad idea. Picking also forces the CPU and GPU to synchronize in a way that they aren't really meant to do for optimal performance.
If you draw each region as its own image, why is team colors a problem?
1 2 3 4 5 6 7 8
| uniform vec3 teamColor; uniform sampler2D image;
varying vec2 texCoord;
void main(){ gl_FragColor = texture2D(image, texCoord) + teamColor; } |
Could be done with multitexturing or something else too, but that is trickier (if you ask me). With a good texture even glColor3f(teamColorR, teamColorC, teamColorB) should work fine.