VisioDevKit  v2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
VgEngine::VgITextureManager Interface Referenceabstract

The VgITextureManager class is used to create VgITexture given a VgBinaryBuffer. More...

Public Member Functions

virtual ~VgITextureManager ()
 Destructor. More...
 
virtual VgEngine::VgRefPtr
< VgEngine::VgITexture
createTexture (VgEngine::VgConstRefPtr< VgEngine::VgBinaryBuffer >const &pBuffer, bool pGenerateMipmaps=true)=0
 Creates a Texture from a VgBinaryBuffer. More...
 
virtual VgEngine::VgRefPtr
< VgEngine::VgITexture
getTexture (const std::string &pTextureName)=0
 Returns a named texture from the registered textures. More...
 

Static Public Member Functions

static VgEngine::VgRefPtr
< VgBinaryBuffer
prepareTextureBuffer (VgEngine::UInt pWidth, VgEngine::UInt pHeight, VgEngine::VgPixelFormat pPixelFormat, VgEngine::Byte *&pOutData)
 Creates a buffer that can receive an image with the specific pixel format. More...
 

Protected Member Functions

 VgITextureManager ()
 Constructor. More...
 

Detailed Description

The VgITextureManager class is used to create VgITexture given a VgBinaryBuffer.

The VgITextureManager class is in charge of passing the VgBinaryBuffer data to the graphics engine and creates internal objects that allows usage of the returned texture.

The below code snippet demonstrates how a VgITexture can be created.

...
VgApplication::VgIApplication* mVgApplication;
...
// Create VgITexture from an image file and assign it to a member variable
VgEngine::VgRefPtr< VgEngine::VgBinaryBuffer > lBuffer = mVgApplication->editEngine()->editResourceManager()->readFromFileOrURL("/path/to/file.png");
VgEngine::VgITextureManager* lTextureManager = lEngine->editTextureManager();
VgEngine::VgRefPtr< VgEngine::VgITexture > lTexture = lTextureManager->createTexture(*lBuffer);
mTexture = lTexture.get();
...
Date
25/02/2010

Constructor & Destructor Documentation

VgEngine::VgITextureManager::VgITextureManager ( )
inlineprotected

Constructor.

virtual VgEngine::VgITextureManager::~VgITextureManager ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual VgEngine::VgRefPtr< VgEngine::VgITexture > VgEngine::VgITextureManager::createTexture ( VgEngine::VgConstRefPtr< VgEngine::VgBinaryBuffer >const &  pBuffer,
bool  pGenerateMipmaps = true 
)
pure virtual

Creates a Texture from a VgBinaryBuffer.

Remarks
Once the VgBinaryBuffer is used to create a VgITexture, it should not be modified afterwards. The graphic's context should be active when this call is made.
Parameters
pBufferThe buffer from where the texture will be loaded.
pGenerateMipmapsIndicates whether mipmaps should be auto-generated.
Remarks
Under iOS, if the VgBinaryBuffer contains a png file. It must not be compressed (Uncheck "Compress PNG Files" under XCode), and the internal png reader does not handle Apple proprietary png extensions.
Textures should be square and the width and height should be a power of two to avoid having problems on certain devices.
Version
2.0.8955
virtual VgEngine::VgRefPtr< VgEngine::VgITexture > VgEngine::VgITextureManager::getTexture ( const std::string &  pTextureName)
pure virtual

Returns a named texture from the registered textures.

This method is mainly used to get back textures from the ones declared in vg_config.xml in the <resources> section.

Parameters
pTextureNameThe name of the texture. In vg_config this is the 'id' attribute of the 'texture' tag.
Returns
A referenced pointer on the texture if any, null if none. Check the isValid method before use.
Version
2.0.9263
static VgEngine::VgRefPtr< VgBinaryBuffer > VgEngine::VgITextureManager::prepareTextureBuffer ( VgEngine::UInt  pWidth,
VgEngine::UInt  pHeight,
VgEngine::VgPixelFormat  pPixelFormat,
VgEngine::Byte *&  pOutData 
)
static

Creates a buffer that can receive an image with the specific pixel format.

Parameters
pWidthwidth of the image
pHeightheight of the image
pPixelFormatthe pixel format to use.
[out]pOutDatapointer that will be updated and that will later receive the image width*height*4*sizeof(char). This is done to minimize copies.
Remarks
The image will be distorted if pWidth and pHeight are not equal.
Before creating a texture using the returned VgBinaryBuffer, pOutData should first be populate in the format of the specified pixel format.
The result of doing getData() on the resulting buffer will not be the same thing as pOutData. pOutData is where the image data will live, whereas getData() returns what will be delete[]d and includes additional information such as the PVR texture header.
Remarks
Textures should be square and the width and height should be a power of two to avoid having problems on certain devices.
Version
2.0

The documentation for this interface was generated from the following file:
VisioDevKit 2.0, Visioglobe® 2013