Archived

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

Terrain/Unit Selection

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

OK now, i understand to select units in isometric games you will need to color-code things to tell what you are selecting. What I need to know is how to read in a color from a surface. IE what I want to do is print out an extra surface in memory only that consists of say blue green and red, and depending on what color it is i will know what has been selected. I need to know how to interpret what color a pixel is on that surface by giving a function 2 coords (x,y). Thanks if anyone knows, i''m using 32 bit color in directx. Mike

Share this post


Link to post
Share on other sites
Look up the directX documentation for lock(). This will give you a surface pointer and pitch value. Together with the pixel format (which you should already know from setting the graphics mode, or also get through the lock call), that''s all you need.
Be careful though:
1) pitch is not generally the same as the surface width
2) locking videomemory surfaces may be expensive performance wise and might not even work at all on some driver/card combinations (or some surfaces, IIRC you cannot lock a D3D z-buffer for example)

BuschnicK


Life would be much easier if I had the source code.
blackfish.sourceforge.net

Share this post


Link to post
Share on other sites