-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace draw_line/triangle with draw_quad - Resolves #315 ... #433
base: master
Are you sure you want to change the base?
Conversation
src/DrawOp.hpp
Outdated
@@ -30,13 +30,12 @@ namespace Gosu | |||
|
|||
// Number of vertices used, or: complement index of code block | |||
int vertices_or_block_index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about removing this attribute completely but couldn't figure out how this would work then:
DrawOpQueue.hpp:142
manager.set_render_state(op.render_state);
if (op.vertices_or_block_index >= 0) {
op.perform(0);
}
else {
// GL code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be just int block_index
and a value of -1 indicates that it is not a block, but a quad.
Gosu/Graphics.hpp
Outdated
static void draw_line(double x1, double y1, Color c1, | ||
double x2, double y2, Color c2, | ||
ZPos z, AlphaMode mode = AM_DEFAULT); | ||
ZPos z, AlphaMode mode = AM_DEFAULT, | ||
double thickness=1.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+space around =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of adding a parameter at the end :/ But I also don't see any sane way to avoid this without subtly breaking code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer it right before z as well but no idea how to not break code too. I mean in Ruby we could use a named parameter but a list of 8(!) normal and 1 named param would look a bit akward I think. But thickness seems like a good Addition to use draw line especially once someone codes even fancier lines 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the 8 parameter thing is another good theme for post-1.0! :/
src/Graphics.cpp
Outdated
op.vertices[1] = DrawOp::Vertex(x2, y2, c2); | ||
op.vertices_or_block_index = 4; | ||
|
||
double angle = Gosu::angle(x1, y1, x2, y2)-90.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+space around -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you don't need to use Gosu::
inside a Gosu method (I've started to clean this up recently, I used to be undecided about this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you can ignore the call if x1 == x2 && y1 == y2
, in which case Gosu::angle
cannot return anything useful.
rdoc/gosu.rb
Outdated
@@ -1160,12 +1172,13 @@ def offset_x(theta, r); end | |||
def offset_y(theta, r); end | |||
|
|||
## | |||
# @return [Float] the angular distance from (x1, y1) to (x1, y2) in degrees, where 0.0 is up. Returns 0 if both points are equal. | |||
# @return [Float] the angular distance from (x1, y1) to (x1, y2) in degrees, where 0.0 is up. Returns default(=0.0) if both points are equal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is not needed for the line-drawing code, let's leave it out of this PR
OK, so I think the best course of action is:
|
Sounds good to me 👍 |
afcd791
to
10e8da3
Compare
Ok rebased and everthing is green - thanks to the Also changed the I'm ready for review @jlnr |
(Haven't look at the code yet, on my way to work) - I think we should be careful with I also found an open browser tab where I hadn't finished typing my comment on the last PR, so here it goes :) I think the (I wonder if Gosu shouldn't generally respect a GOSU_DEBUG or GOSU_VERBOSE env variable even during runtime, to log texture allocations etc...) |
👍
I think thats what happens at the moment and would be at least what I expect - First and last pixel should be part of the line. And if you use them for "Debugging" I guess you could live with a minor color inconsitency but I get the point. As there is at the moment no way to draw an unfilled triangle/rect this might be a thing to consider. So there three options I guess:
|
f8b504c
to
5e41001
Compare
I've opened #440 for the GOSU_DEBUG/GOSU_VERBOSE thingie. As for the line drawing, I have also thought about these questions and I think I'm opposed to even the single additional If anyone really needs to draw pretty lines/shapes, they should implement it on top of |
On the other hand – if |
I use them as well e.g. as Cursor ....
Thats definetly a valid argumentation.
Not sure how I can handle this, because (at least in my tests) if draw a quad with only 2 points I get no output at all. Thats why the angle/offset_x/y stuff made it in the code in the first place. And since I needed to calculate new coordinates is was no big step to make the variable publicly available. For now I would only went back to the apply the equivavalent of 1px to (x,y) to the "right" of the line. |
Oh triangles are great, but they can also be implemented using Yeah...making |
Oh and don't let GitHub get in the way of your real work I can wait 😄 |
Wow. Time flies. Has it really been over a month since last post.... I guess the good weather doesn't help - its hard to get motivated to stay inside coding when you finally can do something outdoors again 😄
Did you have a chance to look/think over at the "remaining" point of this PR? |
Oh sorry, I didn't realize that you were waiting for me here. Thanks for nudging me! I tend to ignore everything else when my own PRs get stuck 😅 I really need to play around with If we merge this before #443, then I think we should not introduce keyword arguments yet, and we should also not introduce a non-keyword |
Add thickness option to draw_lines
5e41001
to
c17ea31
Compare
Here's a Several problems with the existing implementation:
OK. Never mind compatibility with the previous implementation... 😅 Another problem that I've encountered is that quads are always aligned on the physical pixel grid right now, which is barely okay for images, but ruins thin lines. -> I've gone ahead and removed the thickness parameter, because I really think a good I've rebased this branch, will update the test images and then hopefully merge it. |
Umm, great. :D The tests don't run on my HiDPI machine because the screenshots can't possibly match. It seems that the Good thing that I've planned to play around with |
c17ea31
to
3c26e96
Compare
👍 Nice seeing some progress. I'm working for a new company since March 1st so I'm currently a bit overwhelmed by all the new stuff the learn and to remember so it might take some more time until I can "come" back to work at my open PR's. Sorry for that. |
No problem, my text PR is also stuck because I'm working on several client projects at the same time right now :) Good luck with the new project. |
05ac06d
to
46cd8fd
Compare
... & Add a thickness option to draw_lines
It finally resolves at least the visual bugs in the macros and removes a bit of code-complexity. No fancy lines unfortunately so far but a thickness as first step might be a good direction.
Sort of unmergeable at the moment because the screenshot commits are bundled.