- Timestamp:
- 10/07/10 13:53:28 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgtexture3D/osgtexture3D.cpp
r6941 r11829 39 39 typedef std::vector< osg::ref_ptr<osg::Image> > ImageList; 40 40 41 42 class MyGraphicsContext {43 public:44 MyGraphicsContext()45 {46 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;47 traits->x = 0;48 traits->y = 0;49 traits->width = 1;50 traits->height = 1;51 traits->windowDecoration = false;52 traits->doubleBuffer = false;53 traits->sharedContext = 0;54 traits->pbuffer = true;55 56 _gc = osg::GraphicsContext::createGraphicsContext(traits.get());57 58 if (!_gc)59 {60 traits->pbuffer = false;61 _gc = osg::GraphicsContext::createGraphicsContext(traits.get());62 }63 64 if (_gc.valid())65 {66 _gc->realize();67 _gc->makeCurrent();68 }69 }70 71 bool valid() const { return _gc.valid() && _gc->isRealized(); }72 73 private:74 osg::ref_ptr<osg::GraphicsContext> _gc;75 };76 77 78 41 osg::StateSet* createState() 79 42 { 80 MyGraphicsContext gc;81 if (!gc.valid())82 {83 osg::notify(osg::NOTICE)<<"Unable to create the graphics context required to build 3d image."<<std::endl;84 return 0;85 }86 87 43 // read 4 2d images 88 44 osg::ref_ptr<osg::Image> image_0 = osgDB::readImageFile("Images/lz.rgb"); … … 103 59 } 104 60 105 // get max 3D texture size 106 GLint textureSize = osg::Texture3D::getExtensions(0,true)->maxTexture3DSize(); 107 if (textureSize > 256) 108 textureSize = 256; 61 GLint textureSize = 256; 109 62 110 63 // scale them all to the same size.
