设置osg::GraphicsContext::Traits的 sample 属性,经过测试后,可能增加CPU GPU的计算时间,从而导致视景运动的时候出现卡顿,需要有好的显卡支持。
主要是 traits->samples = 8;
采样倍数的设置;
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
//支持窗口扩展,默认是不支持的
traits->windowDecoration = true;
//支持双缓存,默认不支持
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->red = 8;
traits->blue = 8;
traits->green = 8;
//支持alpha,默认不支持为0,这里改为支持,使截出来的图片具有alpha值
traits->alpha = 8;
//采样倍数
traits->samples = 8;
traits->sampleBuffers = 1;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());