Is there to anyway speed this up? I came to learn, accessing the Frame Buffer itself can do it quickly. but i dont know how... is there a way to do that in opengl?
-
3The way to speed it up is to use OpenGL's own line drawing of course. – timday Jan 12 '15 at 13:09
2 Answers
If you're implementing Bresenham for the sake of learning Bresenham then I suggest you put the "pixels" you're about to draw into an array (std::vector
in C++). Then when you're done with the Bresenham "rasterization", pass that array as a vertex array to OpenGL and draw it with a single glDrawArrays
call.
Otherwise, if your goal is to draw a line, just use a OpenGL line.

- 159,371
- 13
- 185
- 298
To complement @datenwolf's answer, you're probably issuing a lot of drawcalls. That can and will make impose significant performance drawbacks. You don't even have to access the framebuffer directly, just make sure you don't make unnecessary operations between each point. There are multiple ways of achieving that, and indeed mapping a buffer is one of them. You can also stick to your own memory and simply "blit" the result to OGL.
And similarly, if you just want to draw a line, GL_LINES
will pretty much always be faster and more convenient.

- 38,596
- 7
- 91
- 135