Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The points drawn are square #61

Open
GuoJiaoyang opened this issue Feb 8, 2025 · 0 comments
Open

The points drawn are square #61

GuoJiaoyang opened this issue Feb 8, 2025 · 0 comments

Comments

@GuoJiaoyang
Copy link

The points drawn using the same code in osgqt are square, while the points drawn using the window created by osg's built - in functions are round.

osg::ref_ptrosg::Node createPoint()
{
osg::ref_ptrosg::Group root = new osg::Group;
osg::ref_ptrosg::Geode geode = new osg::Geode;
root->addChild(geode);
osg::ref_ptrosg::Geometry geometry = new osg::Geometry;
geode->addDrawable(geometry);
osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array;
vertices->push_back(osg::Vec3(30.0f, 30.0f, 30.0f));
geometry->setVertexArray(vertices);
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, vertices->size()));

osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(255.0f, 1.0f, 0.0f, 1.0f));
geometry->setColorArray(colors, osg::Array::BIND_OVERALL);
osg::ref_ptr<osg::StateSet> stateSet = geode->getOrCreateStateSet();


stateSet->setMode(GL_POINT_SMOOTH, osg::StateAttribute::ON);
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc;
blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
stateSet->setAttributeAndModes(blendFunc, osg::StateAttribute::ON);
osg::ref_ptr<osg::Point> point = new osg::Point;
point->setSize(30.0f);
stateSet->setAttributeAndModes(point, osg::StateAttribute::ON);

return root;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant