#8428 closed patch
Adding drawLine() to Surface
Reported by: | eriktorbjorn | Owned by: | fingolfin |
---|---|---|---|
Priority: | normal | Component: | Graphics |
Version: | Keywords: | ||
Cc: | Game: |
Description
This adds drawLine() to the Surface class like sev suggested. I'm not committing it myself - not right away at least - because:
I'm not sure about this "const" stuff. I finally got the thing to compile by using const_cast, but I don't know why I had to, and I don't know if it's right.
I'm not completely happy with the naming. It seems wrong to have hLine(), vLine() and drawLine() because in the first two the word "draw" is only implied. But I don't want to call it just "line" either.
Ticket imported from: #1193795. Ticket imported from: patches/533.
Attachments (2)
Change History (8)
by , 20 years ago
Attachment: | drawLine.diff added |
---|
comment:1 by , 20 years ago
Owner: | set to |
---|
comment:2 by , 20 years ago
Well, you have to do the const cast because putting a "const" qualifier on a method which modifies the state of an object is simply wrong -- and in fact, the existing hLine etc. primitives in Graphics::Surface are all wrong (my mistake -- the compiler didn't catch it because getPixels performs casts :-/
I'll fix that.
As for the naming: well, hLine and vLine are just there because they were trivial to implement and useful; not much thought was put into their naming. We could renamed them to "drawHorizontalLine", or to be less verbose, "drawHLine".
And then of course one argue whether it should be "draw" or "plot" ... :)
comment:3 by , 20 years ago
Oh and for efficency, I'd recommend to use two plotPoint methods, one for each bitdepth. It's still slow because we function pointer is used to render pixels, but it's slightly better -- as it is, we wouldn't want to use drawLine for time intensive work anyway :-)
comment:4 by , 20 years ago
I've updated the patch to define two plotPoint methods, and removed the const cast.
comment:5 by , 20 years ago
Status: | new → closed |
---|
comment:6 by , 6 years ago
Component: | → Graphics |
---|
Patch against a May 2 CVS snapshot