Jump to content
  • Advertisement
Sign in to follow this  
snooty

pixel center

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

Hi, In 2D, should a whole number coordinate like (0, 0) or (1, 10) be mapped to the pixel center or the corner of the pixel? How does DirectX or OpenGL or other graphics libraries treat it? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
By default, both DirectX and OpenGL map 0,0 to the corner of a pixel. Of course, a translation by 0.5,0.5 changes that behavior.

Share this post


Link to post
Share on other sites
Thanks.

Another question:
Do DirectX and OpenGL map (0, 0) to the lower-left or upper-left of a surface by default?

Share this post


Link to post
Share on other sites
You have to be careful. Some older cards and drivers would use different pixel centers, and you would actually have to translate by (-0.5, -0.5) to get them back to the corner.....

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
By default, both DirectX and OpenGL map 0,0 to the corner of a pixel. Of course, a translation by 0.5,0.5 changes that behavior.

I think that has changed in Direct3D10. (0,0) maps to the center of the top-left pixel now.

Share this post


Link to post
Share on other sites
Thanks for the replies.
Quote:
Original post by Sc4Freak
I think that has changed in Direct3D10. (0,0) maps to the center of the top-left pixel now.

Doesn't this break backward compatibility?

Share this post


Link to post
Share on other sites
Quote:

Doesn't this break backward compatibility?

Yes. But the entire D3D10 API break backwards compatibility. And having a direct mapping now is so much nicer to work with.


Except when you first port you code before you knew the mapping was adjusted, and spend three hours tracking down the "bug."

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
Yes. But the entire D3D10 API break backwards compatibility. And having a direct mapping now is so much nicer to work with.

Direct mapping is better? How come?

Share this post


Link to post
Share on other sites
Because half-pixel offsets are annoying. There was no particular benefit to having to do it; everybody who needed to do accurate per-pixel mapping had to implement it, and it was just useless (albiet trivial) cruft. Since there's no benefit to it, the simpler and more natural solution of not having to do the offsets is more beneficial.

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!