渲染抗锯齿时碰到问题将切片数据渲染到图片上呈现抗锯齿实现如下
void Slice::RenderAnti()
{
unsigned int l;
unsigned int s;
//for each loop
//for each filled loop
//面合成用源色和目标色相加,无抗锯齿
glBlendFunc(GL_ONE,GL_ONE);
for(l=0;l<loopList.size();l++)
{
if(loopList[l].isfill)
{
glColor3f(0.01,0,0);//filled
}
else
{
glColor3f(0,0.01,0);//void
}
loopList[l].RenderTriangles();
}
//轮廓线源色通过alpha通道处理后与目标色相加,实现抗锯齿
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
for(l=0;l<loopList.size();l++)
{
for(s = 0; s < loopList[l].segListp.size();s++)
{
//(outlines)
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINES);
glVertex2d( loopList[l].segListp[s]->p1.x(), loopList[l].segListp[s]->p1.y());
glVertex2d( loopList[l].segListp[s]->p2.x(), loopList[l].segListp[s]->p2.y());
glEnd();
}
}
}
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
在抗锯齿处理时,如果轮廓线处理用上面方法,出现面区域填充不满的现象。或者说白色具体不需要再做抗锯齿处理,只需要黑色部分处理既可。