Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / What am I doing wrong when drawing primitives?
- By benko Date 2009-11-24 23:34
This is weird. I'm trying to draw a rectangle with an 'outside' border, so I use draw_line with an Y coordinate 1 pixel less than the rectangle's. But the border is drawn with 1-pixel gap!

I don't understand why... If I draw two lines one with an Y of 100 and another one with Y value of 99, they should appear together... Am I right?

Related code: http://gist.github.com/242335
- By jlnr (dev) Date 2009-11-27 19:11
I don't have a gap. Just goes to show that draw_line should not use GL_LINE but instead do it's own magic - GL_LINE is a mess I will never understand :(

For consistency's sake, I am probably going to rip out draw_triangle, draw_quad and draw_line and replace them by independent pieces of code that will create a 1x1 pixel white texture and use that. Window#draw_xx will remain as a shortcut for Gosu::draw_xx. I just wish I had time to get to it faster :)
- By ippa Date 2009-11-27 19:30
as far as I can tell.. it's draw_line()

draw_line(0, 0, color, 100, 0, color)   doesn't give me a visible line. (drawing from X  / Y   0/0  --> 100 / 0)
- By jlnr (dev) Date 2009-11-27 19:40
Oh and as far as contributions go, does anyone have any idea how draw_line *should* work? I think it's fine that draw_quad excludes its bottom-right pixel, but I am not sure what to do about draw_line.
- By benko Date 2009-11-29 23:07

> I don't have a gap. Just goes to show that draw_line should not use GL_LINE but instead do it's own magic - GL_LINE is a mess I will never understand :(


:(

> Oh and as far as contributions go, does anyone have any idea how draw_line *should* work? I think it's fine that draw_quad excludes its bottom-right pixel, but I am not sure what to do about draw_line.


draw_quad excludes pixels? Why? If we tell draw_quad to draw a rectangle in the given coordinates, why does it exclude the last col & row of pixels? It's not intuitive (at least not for me).
- By jlnr (dev) Date 2009-11-30 16:27

> draw_quad excludes pixels? Why?


I have given my view on it in http://www.libgosu.org/cgi-bin/mwf/topic_show.pl?pid=221.

Maybe the actual explanation is that I just hand things to OpenGL which does the same, and that it has never made my code uglier to justify a change :)

It's just a bit complicated to think about the lines now …
- By renton_django Date 2009-12-14 21:16
Hi benko,

What is the resolution of your window and what is the native resolution of your monitor? If you are running in fullscreen, then try setting the window resolution the same as your monitor's native resolution.
- By jlnr (dev) Date 2009-12-14 21:45
Wow, you are raising a VERY valid point. Thanks. It never occured to me that when I do the full-screen stretching via OpenGL, one-pixel lines lose their last bit of sense.

For now only Linux is affected, but other platforms will follow. Changing the resolution is not worth the hassle. The Linux port has become a lot less problematic since I gave up.
Up Topic Gosu / Gosu Exchange / What am I doing wrong when drawing primitives?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill