Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MattS423

LINES!!

This topic is 5799 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
Bookah! As if by magic...

http://www.gamedev.net/reference/articles/article767.asp

Share this post


Link to post
Share on other sites
thats a great article...but it''s in pascal..

thats fine, (i think i can manage to translate), but what is the C++ equivelent of the := operator?

I have a fealing it''s += but i''m not sure.

thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
equivelent of := is =
not +=

Share this post


Link to post
Share on other sites
Found this great thing on the Internet called Google. Took 2 tenths of a second to use and gave over 5000 results back. Here is the first page.
quote:
Google search results
Searched the web for Bresenham algorithm. Results 1 - 10 of about 5,070. Search took 0.19 seconds.


Category: Computers > Programming > ... > Collision Detection > Software


Bresenham''s algorithm
Definition of Bresenham''s algorithm, possibly with links to more information
and implementations. NIST. Bresenham''s algorithm. (algorithm). ...
www.nist.gov/dads/HTML/bresenham.html - 4k - Cached - Similar pages

The Bresenham Line-Drawing Algorithm
... Algorithm. The basic Bresenham algorithm. ... Here is a C++ implementation of
the Bresenham algorithm for line segments in the first octant. void ...
www.cs.helsinki.fi/group/goa/ mallinnus/lines/bresenh.html - 9k - Cached - Similar pages

[PDF]The Ubiquitous Bresenham Algorithm as a Basis for Graphics ...
File Format: PDF/Adobe Acrobat - View as HTML
The Ubiquitous Bresenham Algorithm as a Basis for Graphics Interpolation Processes
Steve Cunningham California State University Stanislaus rsc@csustan.edu ...
www.cs.csustan.edu/~rsc/SDSU/Interpolation.pdf - Similar pages

A simple derivation of Bresenham''s algorithm
A simple derivation of Bresenham''s algorithm. Kenneth H. Carpenter,
EECE KSU. November 4, 1999 / April 4, 2001. Suppose one wishes ...
www.eece.ksu.edu/~khc/classes/636/bresder.html - 6k - Cached - Similar pages

Speeding Up Bresenham''s Algorithm
November/December 1991 (Vol. 11, No. 6). pp.
16-17 Speeding Up Bresenham''s Algorithm. PDF. ...
www.computer.org/cga/cg1991/g6016abs.htm - 9k - 4 Dec 2002 - Cached - Similar pages

681 Development of Bresenham''s Algorithm
681: Development of Bresenham''s Line Drawing Algorithm. Notes: These
code fragments show how optimizing simple line drawing code ...
www.cis.ohio-state.edu/~parent/ classes/681/OLD/Bresenham.html - 6k - Cached - Similar pages

Bresenham''s Algorithm from Both Ends
Performance of Bresenham''s Algorithm drawing simultaneously from
BOTH ends and utilizing the efficiency of a linear framebuffer. ...
www.cs.unc.edu/~hoff/projects/comp235/ bresline/perform2.html - 4k - Cached - Similar pages

Bresenham algorithm
First Previous Index Text. Slide 12 of 12.
mrl.nyu.edu/~dzorin/ug-graphics/ lectures/lecture5/sld012.htm - 3k - Cached - Similar pages

Bresenham modified algorithm - ALL the points
Bresenham modified algorithm which allows to print ALL the points, not only
1 point per axis. ... I suppose you already know the Bresenham''s algorithm. ...
www.ese-metz.fr/~dedu/projects/bresenham/ - 10k - Cached - Similar pages

AcadWiki - Bresenham Algorithm
AcadWiki: HomePage. Bresenham Algorithm. See Digital Line Drawing.
Last edited on 03/14/01. Edit | Info, Valid XHTML 1.0! Valid CSS! ...
xarch.tu-graz.ac.at/autocad/wiki/BresenhamAlgorithm - 9k - Cached - Similar pages





Make it work, then
make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
ok, this line thing just isn''t working...

It compiles & runs, but it:

1) This is only drawing every other pixel.

2) I can''t be entirely sure it''s drawing the line EXACTALLY where it''s sopposed to be.

here''s the code:


  

int DrawLine(int StartX, int StartY,
int EndX, int EndY,
UINT* Buffer, int Pitch,
UINT Color)
{
int DeltaX = abs(EndX - StartX);
int DeltaY = abs(EndY - StartY);

int x = StartX;
int y = StartY;

int IncX1;
int IncX2;
int IncY1;
int IncY2;

int Numerator;
int Denominator;

int NumAdd;
int NumPixels;

if(EndX >= StartX) // X is increasing.

{
IncX1 = 1;
IncX2 = 2;
}
else //X is decreasing

{
IncX1 = -1;
IncX2 = -1;
}

if(EndY >= StartY) //Y is increasing

{
IncY1 = 1;
IncY2 = 1;
}
else //Y is decreasing

{
IncY1 = -1;
IncY2 = -1;
}

if(DeltaX > DeltaY) //there are more x-values then y-values

{
IncX1 = 0;
IncY2 = 0;
Denominator = DeltaX;
Numerator = DeltaX /2;
NumAdd = DeltaY;
NumPixels = DeltaX;
}
else //there are more y-values then x-values

{
IncX2 = 0;
IncY1 = 0;
Denominator = DeltaY;
Numerator = DeltaY/2;
NumAdd = DeltaX;
NumPixels = DeltaY;
}

int CurrentPixel;

for(CurrentPixel = 0; CurrentPixel <= NumPixels; CurrentPixel++)
{
PlotPixel32(x,y,Buffer,Color,Pitch);
Numerator += NumAdd;

if(Numerator >= Denominator)
{
Numerator -= Denominator;
x += IncX1;
y += IncY1;

}

x += IncX2;
y += IncY2;

}

return 1;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!