PDA

View Full Version : GL_LINE Vs. DDA algorithm

mahsa_shk
02-12-2012, 02:50 PM
I do not understand what is the difference between the line that is drawn by glBegin(GL_LINE) and the line which is drawn by DDA algorithm.

and I do not know whether DDA is better than glBegin(GL_LINE) or not.

Alfonse Reinheart
02-12-2012, 05:28 PM
What is "DDA algorithm"?

mhagain
02-12-2012, 05:35 PM
OpenGL itself doesn't specify how a line is drawn, it just specifies that a line is drawn. So it could be using any algorithm, or different algorithms on different implementations, or even different algorithms on the same implementation, depending on combinations of states and/or parameters.

Also - and this is critical - OpenGL will most likely be using your graphics hardware for drawing lines (note that some hardware can't draw some lines which are required to be supported, in which case the driver will do it in software). It's (mostly) incorrect to think of anything OpenGL does in terms of comparison to any software algorithm.

(It's also the case that what's efficient or better quality in a software approach is not necessarily so with hardware, so many such comparisons are completely invalid to begin with.)

Dark Photon
02-12-2012, 05:45 PM
What is "DDA algorithm"?
Digital Differential Analyzer.

Blast from the past -- remember reading about this back in the 80's back before modern 3D graphics APIs. Simple fixed-point technique for deciding which pixels get set when drawing a line (or curve) between 2 points on a raster display. Wikipedia entry: Digital differential analyzer (graphics algorithm) (https://en.wikipedia.org/wiki/Digital_differential_analyzer_%28graphics_algorith m%29) Related wikipedia entry: Bresenham's line algorithm (https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm)
"The Bresenham algorithm can be interpreted as slightly modified DDA (using 0.5 as error threshold instead of 0, which is required for non-overlapping polygon rasterizing)."

mahsa_shk
02-13-2012, 02:39 AM