PDA

View Full Version : GL_BLEND problem



TheSpider
06-20-2010, 06:37 AM
Hello,

I am trying to draw a cloud of points, however I am having some problems when I enable blending.

Here is the relevant code:



glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);

glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);


gluPerspective(fovAngle/2.0,aspect,nearPlane,farPlane);
glMatrixMode(GL_MODELVIEW);

gluLookAt(origin[0],origin[1],origin[2],
target[0],target[1],target[2],
upDirection[0],upDirection[1],upDirection[2]);



const Point3D *p;
glPointSize(size);
glBegin(GL_POINTS);
glColor4f(r,g,b,a);
for(unsigned int ui=0; ui<pts.size(); ui++)
{
p=&amp;(pts[ui]);
glVertex3f((*p)[0],(*p)[1],(*p)[2]);
}
glEnd();
}


This results in the following images.
Left:
http://img97.imageshack.us/img97/9348/leftqf.jpg
Centre:
http://img175.imageshack.us/img175/1702/centre.jpg
Right:
http://img441.imageshack.us/img441/1200/rightc.jpg

Note there is a sphere drawn in using gluSphere to show that lighting is actually disabled (see how it appears up as a circle).

If I remove glEnable(GL_BLEND), then the points have the correct apparent intensity (ie, all have the same intensity, independant of viewing angle). This is good, but the points are blocky, which is what I was trying to solve in the first place.

What is going on? I cannot see where any lighting calculations can come into play if I have disabled lighting completely. I don't know what effect can be causing this view angle dependency!

Any help is greatly appreciated

TheSpider
06-20-2010, 06:50 AM
OH. never mind. I worked it out a few minutes later. This had been bothering me for days :o

I had the points ordered along the cylinder axis, which meant that the blend result was different for a back-to-front versus a front-to-back ordering