Jump to content
  • Advertisement
Sign in to follow this  
Kwizatz

2D GL_POLYGON and GL_LINE_LOOP don't match

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

I am using an ortho projection for my 2D GUI and I have some rects, I keep an array with the 4 coordinates in each rect to pass to DrawArrays when I need to render the rects, I want to render the rect with a border, so I call DrawArrays with GL_POLYGON (or GL_QUADS, same issue) and then with GL_LINE_LOOP (or in turn changing polygon mode to GL_LINE and drawing again).

No problems there, however, if I don't draw the border I notice that the filled rect is short one pixel to the right and to the bottom, it is properly set at X,Y but its width and height is cut short one line.

I have used the 0.375f magic number and I get pixel perfect accuracy anywhere else but on this issue, I have changed the size of the viewport and played with scale and translation, but I always get the error or variations of it, so I am asking, is there some function I need to call, some state I need to be in so the rendering includes the last line in the X and Y direction? or will I just have to compensate for it by rendering the extra lines in a separate step?

I am surprised I couldn't find much information on this.

Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
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!