amirrimal.official

01-30-2016, 02:39 AM

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

View Full Version : 3D line

amirrimal.official

01-30-2016, 02:39 AM

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

Agent D

02-05-2016, 02:12 AM

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 (https://www.opengl.org/discussion_boards/showthread.php/198157-Algorithm-implemented-for-drawing-line-in-OpenGL?p=1281382#post1281382), 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 (https://github.com/AgentD/lib2D) (playing around with primitive 2D drawing algorithms) or this (https://github.com/AgentD/swrast) (another tiny software rasterizer).

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 (https://www.opengl.org/discussion_boards/showthread.php/198157-Algorithm-implemented-for-drawing-line-in-OpenGL?p=1281382#post1281382), 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 (https://github.com/AgentD/lib2D) (playing around with primitive 2D drawing algorithms) or this (https://github.com/AgentD/swrast) (another tiny software rasterizer).

vytieubao

02-24-2016, 04:59 AM

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

concuca

02-24-2016, 08:12 PM

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

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.