Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gosu #draw_line bug?
- - By Andrek Date 2016-01-24 17:08
Hello everybody! i try to draw a line from 0, 0 to 640, 0 and no work, to draw pixels 0, 0 i need use draw_line(0, 1 to 640, 1), i think the coords of screen start in 1, 1 point?

Gosu.draw_line(0, 1, Gosu::Color::RED, 640, 1, Gosu::Color::RED, 0)
Parent - - By jlnr (dev) Date 2016-01-24 17:12
OpenGL lines seem to be pretty unreliable, depending on the graphics driver. I recommend that you use draw_quad or images whenever you can.
Parent - - By Andrek Date 2016-01-24 17:19
Ok ty bro!
Parent - - By Andrek Date 2016-01-24 17:23
I have a problem, the quad is filled and i need just lines! what can i do?
Parent - - By lol_o2 Date 2016-01-24 17:52
draw_line(x1, y1, c1, x2, y2, c2, z)

is the same as

draw_quad(x1, y1, c1, x2, y2, c2, x2, y2+1, c2, x1, y1+1, c1, z)
Parent - By Andrek Date 2016-01-24 18:16
Well... i used draw_line and i fit it what i need, ty :D
Parent - - By RunnerPack Date 2016-01-25 00:38
@jlnr: Have you ever seen this?
https://github.com/tyt2y3/vaserenderer
Or an earlier, basic version:
http://artgrammer.blogspot.com/2011/05/drawing-nearly-perfect-2d-line-segments.html

I suppose they could be implemented in Ruby as an add-on to Gosu, but they'd be faster in the library itself. I wish I had time to do it...
Parent - - By jlnr (dev) Date 2016-01-25 06:47
Thanks for the links, I've filed a ticket: https://github.com/gosu/gosu/issues/315

One downside that I anticipate is that img = record { draw_line(...) }; scale(10) { img.draw(...) } will inevitably look terrible, because the quads used for anti-aliasing would be 10px wide now, instead of 1px.
Parent - - By RunnerPack Date 2016-01-26 00:57
Ah, yes... hadn't thought of that. You could include a non-AA mode option for this use case, right?

I assume not, but is there any (efficient) way to let stuff inside the macro know what size its being drawn at, or somehow record a scale-independent version of the line code?

One work-around would be to record everything but the draw_line()s, and then draw the lines scaled up wherever you draw the recorded "image".

Anyway, thanks for taking a look at it.
Parent - By jlnr (dev) Date 2016-01-26 21:32
I think including a non-AA mode would be the way to go.

This is a common problem in Gosu, actually. If you create a Gosu::Font in a fullscreen window that is being scaled up, it would be nice if Font could automatically use a higher resolution. I wish Gosu could magically handle this behind the scenes, but for now that's all up to the game itself.
Parent - By Andrek Date 2016-01-27 00:11
Well i can do what i need, add a screenshot. Ty!!!

Up Topic Gosu / Gosu Exchange / Gosu #draw_line bug?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill