Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: bresenham's line algorithm

  1. #1
    Guest

    bresenham's line algorithm

    How to do the coding for bresenham's line algorithm using the openGL?? i'm new to programming

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,946

    Re: bresenham's line algorithm

    Bresenham's algorithm is lower level than OpenGL. OpenGL draws lines for you using internal hidden algorithms, these algorithms are not mandated by the OpenGL spec, only the results so the algorithms vary from one implementation to another and from one graphics card to another.

    If you wanted to implement Bresenham's line drawing algorithm, you'd draw a line in memory and use a glDrawPixels call to display the resulting memory image in the framebuffer of OpenGL.

    It's just not appropriate or fast way to do things with OpenGL, but it could be useful for learning.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,755

    Re: bresenham's line algorithm

    You can also use Bresenham's algorithm to draw to data to be used for a texture, and then draw a textured quad with your lines.

    I started a small library for my own use that loads TGAs/BMPs, etc. I have also started to implement various 2D algorithms into it like drawing lines, Perlin noise, etc. Things that could be useful for creating procedural textures.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •