Jump to content
  • Advertisement
Sign in to follow this  
Programmer16

Manual data handling or DirectX

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

Okay, I've got some simple 2D effects that I want to use, but currently I need to have access to the data. For example I have border blitting. I run the bitmap vertically and: [/source] if(Pixel - 1H == ColorKey) ThisPixel = BorderColor else if(Pixel + 1H == ColorKey) ThisPixel = BorderColor else if(Pixel - 1V == ColorKey) ThisPixel = BorderColor else if(Pixel + 1V == ColorKey) ThisPixel = BorderColor [/source] Is there any easy way of doing this with DirectX? I could have a separate bitmap and render that, but my technique will work for any shape (and I don't have to waste my time making the highlighting bitmaps.) Also, for sprites that are 24x32, will this be very slow to do on one sprite. Or do you think that this would look hideous and I should just render a circle underneath it (saving me and you a lot of time.) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Do the borders change at all? as in, is the texture/sprite animated? if not, you could just do what you want *once* and store the results for later.

I can't think of any way of doing this on-the-fly using texture blending in the FF pipe, but it should be possible using pixel shaders and dependent reads (provided you can use shaders in your program!).

Other than that, you're gonna have to look into the various pixel-editing routines via LockRect() calls. If you optimize your code heavily, it's not necessarily going to hurt performance too badly [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Tsk tsk, everybody can do things with pixel shaders...

For FFP, you can set the COLOROP to SELECTARG1 and the COLORARG1 to diffuse.
This should tell the card to take the alpha from the texture (you do use alpha testing?) and the color only from the diffuse value. This ought to display a silhouette of your sprite with a solid color.

To get the selection border render the image four times with offsets (-1,0) (1,0) (0,-1) and (0,1) with the diffuse set to your selection color.
You probably can use the material (if you've got lighting) or the texture factor as well (so no need to modify the diffuse value).
After that render the sprite at the actual poosition with the COLOROP set to your usual value.

If i'm completely wrong just ignore this post ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Endurion
Tsk tsk, everybody can do things with pixel shaders...

For FFP, you can set the COLOROP to SELECTARG1 and the COLORARG1 to diffuse.
This should tell the card to take the alpha from the texture (you do use alpha testing?) and the color only from the diffuse value. This ought to display a silhouette of your sprite with a solid color.

To get the selection border render the image four times with offsets (-1,0) (1,0) (0,-1) and (0,1) with the diffuse set to your selection color.
You probably can use the material (if you've got lighting) or the texture factor as well (so no need to modify the diffuse value).
After that render the sprite at the actual poosition with the COLOROP set to your usual value.

If i'm completely wrong just ignore this post ;)


Clever algorithm, I like it [grin]

Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
Clever algorithm, I like it [grin]

Jack


Thanks, though not really that clever, it ups the rendering to four times plus render state switching. Still, it should work on pretty much everything.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!