|
osgmygui实例中:MYGUIManager.cpp文件中的
- void MYGUIManager::saveImage( int width, int height, MyGUI::PixelFormat format, void* texture, const std::string& filename )
- {
- GLenum pixelFormat = 0;
- unsigned int internalFormat = 0;
- switch ( format.getValue() )
- {
- case MyGUI::PixelFormat::L8: pixelFormat = GL_ALPHA; internalFormat = 1; break;
- case MyGUI::PixelFormat::L8A8: pixelFormat = GL_LUMINANCE_ALPHA; internalFormat = 2; break;
- case MyGUI::PixelFormat::R8G8B8: pixelFormat = GL_BGR; internalFormat = 3; break;
- case MyGUI::PixelFormat::R8G8B8A8: pixelFormat = GL_BGRA; internalFormat = 4; break;
- default: return;
- }
- internalFormat = 1;
- unsigned int size = width * height * internalFormat;
- unsigned char* imageData = new unsigned char[size];
- memcpy( imageData, texture, size );
-
- osg::ref_ptr<osg::Image> image = new osg::Image;
- image->setImage( width, height, 1, internalFormat, pixelFormat, GL_UNSIGNED_BYTE,
- static_cast<unsigned char*>(imageData), osg::Image::USE_NEW_DELETE );
- image->flipVertical();
- osgDB::writeImageFile( *image, filename );
- }
复制代码 1. switch ( format.getValue() )中的getValue()在MyGUI:ixelFormat不存在, 我用的mygui3.2和mygui3.0.
2. 加载cow.osg到场景中,会被mygui所在的相机遮挡住, 去mygui的背景,并把包含mygui元素的geode直接加到group中,不同种hud相机添加到group中,可以像是牛。
|
|