Opened 19 years ago

Closed 19 years ago

Last modified 5 years ago

#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)

drawLine.diff (1.6 KB ) - added by eriktorbjorn 19 years ago.
Patch against a May 2 CVS snapshot
drawLine2.diff (1.8 KB ) - added by eriktorbjorn 19 years ago.
Patch against a May 3 CVS snapshot

Download all attachments as: .zip

Change History (8)

by eriktorbjorn, 19 years ago

Attachment: drawLine.diff added

Patch against a May 2 CVS snapshot

comment:1 by fingolfin, 19 years ago

Owner: set to fingolfin

comment:2 by fingolfin, 19 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 fingolfin, 19 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 :-)

by eriktorbjorn, 19 years ago

Attachment: drawLine2.diff added

Patch against a May 3 CVS snapshot

comment:4 by eriktorbjorn, 19 years ago

I've updated the patch to define two plotPoint methods, and removed the const cast.

comment:5 by fingolfin, 19 years ago

Status: newclosed

comment:6 by digitall, 5 years ago

Component: Graphics
Note: See TracTickets for help on using tickets.