文章分类 - C++
C++学习互换值和指针以及指向函数的指针
摘要:互换数值主要是出现实参和虚参问题,下面是小结下。第一种使用指针方法,来互换内容//使用指针互换指针内容值voidswap(int*a,int*b){inttemp=*b;*b=*a;*a=temp;}第二种可以通过引用来互换数值//使用引用来互换值voidswap1(int&a,int&b){inttemp=b;b=a;a=temp;}下面给出互换指针方法,主要是通过引用来互换。//互换指针值非内容voidptrswap(int*&a,int*&b){int*temp=b;b=a;a=temp;}下面是指向函数的指针实现以及定义//指向函数的指针intmin(i
阅读全文
osg替代节点示例osgSim::Impostor
摘要:#include<osgViewer/Viewer>#include<osg/Node>#include<osg/Geometry>#include<osg/Geode>#include<osg/Group>#include<osg/AutoTransform>#include<osgDB/ReadFile>#include<osgDB/WriteFile>#include<osgText/Text>#include<osgUtil/Optimizer>#include<
阅读全文
osg纹理动画效果
摘要:#include<osg/ImageSequence>#include<osg/Texture2D>#include<osg/Geometry>#include<osg/Geode>#include<osgDB/ReadFile>#include<osgViewer/Viewer>voidcreateTexture2D(osg::StateSet&ss,osg::Image*image){osg::ref_ptr<osg::Texture2D>texture=newosg::Texture2D;text
阅读全文
osg简单渐变动画物体的淡入淡出
摘要:#include<osg/BlendFunc>#include<osg/Geode>#include<osg/ShapeDrawable>#include<osgAnimation/EaseMotion>#include<osgDB/ReadFile>#include<osgViewer/Viewer>classFadeCallback:publicosg::NodeCallback{public:FadeCallback(){_motion=newosgAnimation::InOutCubicMotion;}virtu
阅读全文
C++中string erase函数的使用(转载)
摘要:erase函数的原型如下:(1)string& erase ( size_t pos = 0, size_t n = npos );(2)iterator erase ( iterator position );(3)iterator erase ( iterator first, iterator last );也就是说有三种用法:(1)erase(pos,n); 删除从pos开始的n个字符,比如erase(0,1)就是删除第一个字符(2)erase(position);删除position处的一个字符(position是个string类型的迭代器)(3)erase(first,la
阅读全文