PDA

View Full Version : How to do additive line drawing



MarkusEugen
12-20-2013, 06:10 PM
Hi All,

I am having a hard time converting code to draw a vectorscope which is currently drawn with Qt using QPainter.
I can't figure out now to get the additive line drawing effect: I am drawing a large number of "randomn" dark gray lines on top of each other and the points where they cross they should get brighter. Somehow I am not allowed to post an example image :(

Thanks for you help
Markus

tonyo_au
12-20-2013, 11:45 PM
Are you doing alpha blending?

MarkusEugen
12-21-2013, 09:29 AM
No, currently I am only setting glBegin(GL_LINE_STRIP) and draw using glVertex3f().
I am not sure how to use alpha blending.

Osbios
12-21-2013, 04:04 PM
If you use a black surface as base (glClearColor(0,0,0,0)), you can simply use additive blending. Meaning if you draw the value 20,20,20 two times on a pixel then the pixel will be 40,40,40. Three times will be 60,60,60 and so one...


glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);

//your drawing

glDisable(GL_BLEND);

MarkusEugen
12-26-2013, 11:27 AM
Thanks a lot, that worked!