File ManualTextureManager.h

namespace Gsage
class ManualTextureManager : public Listener
#include <ManualTextureManager.h>

This class is used to handle manual texture management and update

Public Functions

ManualTextureManager(OgreRenderSystem *renderSystem)
virtual ~ManualTextureManager()
void reset()

Destroy all texture objects

TexturePtr createTexture(RenderSystem::TextureHandle handle, DataProxy params)

Create manual texture

List of possible texture parameters:

  • group resource group to use (optional). Defaults to DEFAULT_RESOURCE_GROUP_NAME.

  • textureType texture type (optional). Defaults to TEX_TYPE_2D.

  • width initial texture width (required).

  • height initial texture height (required).

  • depth depth The depth of the texture (optional). Defaults to 0.

  • numMipmaps The number of pre-filtered mipmaps to generate. If left to MIP_DEFAULT then the TextureManager’s default number of mipmaps will be used (see setDefaultNumMipmaps()) If set to MIP_UNLIMITED mipmaps will be generated until the lowest possible level, 1x1x1.

  • pixelFormat texture pixel format (optional). Defaults to PF_R8G8B8A8.

  • usage usage type (optional). Defaults to TU_DEFAULT.

  • hwGammaCorrection use gamma correction (optional). Defaults to false.

  • fsaa antialiasing (optional). Defaults to 0.

  • fsaaHint The level of multisampling to use if this is a render target.

    Ignored if usage does not include TU_RENDERTARGET or if the device does not support it. (optional).

  • explicitResolve Whether FSAA resolves are done implicitly when used as texture, or must be done explicitly. (optional).

  • shareableDepthBuffer Only valid for depth texture formats. When true, the depth buffer is a “view” of an existing depth texture (e.g. useful for reading the depth buffer contents of a GBuffer pass in deferred rendering). When false, the texture gets its own depth buffer created for itself (e.g. useful for shadow mapping, which is a depth-only pass).

Parameters
  • handle: texture handle

  • params: Texture params, see above

TexturePtr getTexture(RenderSystem::TextureHandle handle)

Gets existing texture

Parameters
  • handle: texture handle

bool deleteTexture(RenderSystem::TextureHandle handle)

Delete texture by handle

Return

true if succeed

Parameters
  • handle: texture id

void setDefaultPixelFormat(Ogre::PixelFormat format)

Set default pixelFormat

Parameters
  • format: Ogre::PixelFormat

void updateDirtyTexures()

Update dirty textures

Private Types

typedef std::unordered_map<Ogre::String, int> RenderSystemCapabilities

Private Members

std::map<RenderSystem::TextureHandle, TexturePtr> mTextures
Ogre::PixelFormat mPixelFormat
OgreRenderSystem *mRenderSystem
RenderSystemCapabilities mRenderSystemCapabilities
class OgreTexture : public Texture, public Listener
#include <ManualTextureManager.h>

Implements abstract texture class Texture

Public Types

enum Flags

Values:

BlitDirty = 1

Public Functions

OgreTexture(const std::string &name, const DataProxy &params, Ogre::PixelFormat pixelFormat, int flags = 0)
virtual ~OgreTexture()
void update(const void *buffer, size_t size, int width, int height)

Update texture data

Parameters
  • buffer: buffer to use

  • size: provided buffer size

  • width: buffer width

  • height: buffer height

virtual void update(const void *buffer, size_t size, int width, int height, const Rect<int> &area)

Update texture data using changed rectangle

Parameters
  • buffer: buffer to use

  • size: provided buffer size

  • width: buffer width

  • height: buffer height

  • area: changed rect

bool hasData() const

Check if the texture has actual data

void setSize(int width, int height)

Set texture size

Parameters
  • width: texture width

  • height: texture height

void unloadingComplete(Ogre::Resource *res)

Ogre::Texture::Listener implementation

void create(int width = -1, int height = -1)

Create the underlying texture

Parameters
  • width: override width

  • height: override height

bool isDirty() const

Texture buffer was changed

void render()

Update texture using supplied buffer

Ogre::TexturePtr getOgreTexture()

Get underlying OgreTexture object

void destroy()

Destroy underlying Ogre::TexturePtr

Private Functions

std::unique_ptr<OgreTexture::ScalingPolicy> createScalingPolicy(const DataProxy &params)
bool blitDirty()
bool blitAll()

Private Members

Ogre::TexturePtr mTexture
std::string mName
std::unique_ptr<OgreTexture::ScalingPolicy> mScalingPolicy
bool mHasData
bool mDirty
bool mCreate
int mFlags
std::vector<Rect<int>> mDirtyRegions

Friends

friend Gsage::ScalingPolicy
class AllocateScalingPolicy : public Gsage::OgreTexture::ScalingPolicy

Public Functions

AllocateScalingPolicy(OgreTexture &texture, float scalingFactor)

Protected Functions

bool resize()

Actual resize

Private Members

float mScalingFactor
class DefaultScalingPolicy : public Gsage::OgreTexture::ScalingPolicy

Public Functions

DefaultScalingPolicy(OgreTexture &texture)

Protected Functions

bool resize()

Actual resize

class ScalingPolicy

Subclassed by Gsage::OgreTexture::AllocateScalingPolicy, Gsage::OgreTexture::DefaultScalingPolicy

Public Functions

ScalingPolicy(OgreTexture &texture)
virtual ~ScalingPolicy()
void invalidate()

Forces rescaling without width/height change

void update(int width, int height)

Update scaling policy

bool render()

Should be called in the render loop

Return

true if the texture was recreated

Protected Functions

virtual bool resize() = 0

Actual resize

Protected Attributes

OgreTexture &mTexture
int mWidth
int mHeight
bool mDirty