3D line

How to implement Bresenham’s algorithm to plot a 3D line…using only GL_POINTS function?

You don’t do that sort of thing with OpenGL(R) and you don’t do line segment drawing in 3D.

First of all, OpenGL(R) is a standard API for (potentially) hardware accellerated 3D graphics. There already are line drawing functions that
may or may not use Bresenhams algorithm, depending on the implementation.

For the “3D” part of the question: For a line segmentin 3D space, you simply take the endpoints, transform them as you wish, project them onto the screen,
perform some clipping and end up with a 2D line segment that you rasterize.

If you want to draw lines with OpenGL(R), you tell it to draw lines. If you just want to play around with Bresenhams algorithm or other simple rasterization
stuff, you might want to use something much simpler than GL, like drawing to a memory framebuffer and writing it out to an image file or something
similar, i.e. piecing together something like this (playing around with primitive 2D drawing algorithms) or this (another tiny software rasterizer).

For the “3D” part of the question: For a line segmentin 3D space, you simply take the endpoints, transform them as you wish, project them onto the screen

it’s dificullt to show you with some text. You should watch guide in Youtube

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.