-
Book Overview & Buying
-
Table Of Contents
OpenSceneGraph 3.0: Beginner's Guide
To perform basic texture mapping in your applications, you have to follow these steps:
Set the texture coordinates of specified geometries
Create a texture attribute object for a 1D, 2D, 3D or cube map texture mapping operation
Specify one or more images for the texture attribute
Attach the appropriate texture attribute and modes to a state set, which will be applied to related nodes and drawables
OSG defines the osg::Texture class to encapsulate all kinds of textures. It has subclasses osg::Texture1D, osg::Texture2D, osg::Texture3D, and osg::TextureCubeMap, which can represent different OpenGL texture mapping techniques.
The most common method of the osg::Texture class is setImage(). This simply sets an allocated image to the texture object. For instance:
osg::ref_ptr<osg::Image> image =
osgDB::readImageFile( "picture.bmp" );
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setImage( image.get() );Otherwise, you may pass the image...
Change the font size
Change margin width
Change background colour