67 #ifndef _graphicsproceduraltexturebuffer_cpp
68 #define _graphicsproceduraltexturebuffer_cpp
70 #include "Graphics/Procedural/Texture/texturebuffer.h"
71 #include "Graphics/Procedural/proceduralenumerations.h"
73 #include "Graphics/texturemanager.h"
74 #include "Graphics/texture.h"
75 #include "Graphics/image.h"
77 #include "MathTools/mathtools.h"
79 #include <OgrePixelFormat.h>
95 Width(
std::max(SquareSize,
Whole(8)) ),
96 Height(
std::max(SquareSize,
Whole(8)) )
104 this->
SetAlphaByte( X, Y, std::numeric_limits<ColourChannelType>::max() );
110 Width(
std::max(TexWidth,
Whole(8)) ),
111 Height(
std::max(TexHeight,
Whole(8)) )
119 this->
SetAlphaByte( X, Y, std::numeric_limits<ColourChannelType>::max() );
156 if( Other.
Pixels != NULL ) {
161 if( this->
Pixels != NULL ) {
167 memcpy(this->
Pixels, Other.
Pixels, this->GetByteSize());
172 {
return this->
Width; }
189 Ogre::PixelUtil::bulkPixelConversion(this->
Pixels,static_cast<Ogre::PixelFormat>(Graphics::PF_R8G8B8A8),NewBuff,static_cast<Ogre::PixelFormat>(Format),this->
GetPixelCount());
229 { this->
GetPixel(X,Y,Procedural::CCI_Red) = Red; }
233 if( Red > 1.0 || Red < 0.0 )
239 {
return this->
GetPixel(X,Y,Procedural::CCI_Red); }
242 {
return ( static_cast<Real>( this->
GetPixel(X,Y,Procedural::CCI_Red) ) / 255.0 ); }
245 { this->
GetPixel(X,Y,Procedural::CCI_Green) = Green; }
249 if( Green > 1.0 || Green < 0.0 )
255 {
return this->
GetPixel(X,Y,Procedural::CCI_Green); }
258 {
return ( static_cast<Real>( this->
GetPixel(X,Y,Procedural::CCI_Green) ) / 255.0 ); }
261 { this->
GetPixel(X,Y,Procedural::CCI_Blue) = Blue; }
265 if( Blue > 1.0 || Blue < 0.0 )
271 {
return this->
GetPixel(X,Y,Procedural::CCI_Blue); }
274 {
return ( static_cast<Real>( this->
GetPixel(X,Y,Procedural::CCI_Blue) ) / 255.0 ); }
277 { this->
GetPixel(X,Y,Procedural::CCI_Alpha) = Alpha; }
281 if( Alpha > 1.0 || Alpha < 0.0 )
287 {
return this->
GetPixel(X,Y,Procedural::CCI_Alpha); }
290 {
return ( static_cast<Real>( this->
GetPixel(X,Y,Procedural::CCI_Alpha) ) / 255.0 ); }
ColourChannelType & GetPixel(const Whole X, const Whole Y, const UInt16 Component)
Gets access to the pixel at the specified position in this buffer. the X or Y location go beyond the ...
TextureBuffer(const Whole SquareSize)
Square size constructor.
void SetRedByte(const Whole X, const Whole Y, const ColourChannelType Red)
Sets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...
Whole Height
The size of the texture to be generated on the Y axis.
void SetPixelByte(const Whole X, const Whole Y, const ColourChannelType Red, const ColourChannelType Green, const ColourChannelType Blue, const ColourChannelType Alpha=255)
Set colour of a specified pixel using a 0-255 range. the X or Y location go beyond the set size of th...
Real GetBlueReal(const Whole X, const Whole Y) const
Gets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
Whole GetWidth() const
Get the pixel width of this texture.
Real GetAlphaReal(const Whole X, const Whole Y) const
Gets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
ColourChannelType GetBlueByte(const Whole X, const Whole Y) const
Gets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
Real GetGreenReal(const Whole X, const Whole Y) const
Gets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
Whole Width
The size of the texture to be generated on the X axis.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Whole GetByteSize() const
Gets the size of the internal buffer in bytes.
ColourChannelType * Pixels
A pointer to the buffer storing all the pixels of this texture buffer.
ColourChannelType GetAlphaByte(const Whole X, const Whole Y) const
Gets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
float Real
A Datatype used to represent a real floating point number.
Texture * GenerateTexture(const String &TexName, const String &TexGroup, const Graphics::PixelFormat Format=Graphics::PF_R8G8B8A8) const
Creates a Texture from this buffer.
void SetGreenByte(const Whole X, const Whole Y, const ColourChannelType Green)
Sets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
uint16_t UInt16
An 16-bit unsigned integer.
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
void SetGreenReal(const Whole X, const Whole Y, const Real Green)
Sets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
static TextureManager * GetSingletonPtr()
Fetches a pointer to the singleton.
This class represents a texture loaded into video memory.
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
This class represents an image loaded into system memory.
PixelFormat
This is used to describe how bits are arraged for each pixel in an image.
Thrown when a passed parameter is checked at runtime and not in the expected range.
void SetPixelReal(const Whole X, const Whole Y, const Real Red, const Real Green, const Real Blue, const Real Alpha=1.0)
Set colour of a specified pixel using a 0.0-1.0 range. the X or Y location go beyond the set size of ...
void SetAlphaReal(const Whole X, const Whole Y, const Real Alpha)
Sets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
void SetBlueReal(const Whole X, const Whole Y, const Real Blue)
Sets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
Real GetRedReal(const Whole X, const Whole Y) const
Gets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...
~TextureBuffer()
Class destructor.
A convenience buffer that stores pixel colour values of a texture to be generated.
A normal 2 dimensional texture.
void SetRedReal(const Whole X, const Whole Y, const Real Red)
Sets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...
The bulk of the engine components go in this namspace.
void _WriteToBuffer(UInt8 *SrcBuffer, const Whole BufferSize, const Graphics::PixelFormat SrcFormat)
Writes to the textures internal buffer. the size of this texture is smaller than the buffer being wri...
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Whole GetHeight() const
Get the pixel height of this texture.
Real BlueChannel
Value from 0.0 to 1.0 representing the amount of blue present in the colour. 1.0 if very blue...
void SetPixel(const Whole X, const Whole Y, const ColourValue &Colour)
Set colour of a specified pixel using a ColourValue. the X or Y location go beyond the set size of th...
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
ColourChannelType GetGreenByte(const Whole X, const Whole Y) const
Gets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
Thrown when attempted to access something that really should note be accessed.
void SetAlphaByte(const Whole X, const Whole Y, const ColourChannelType Alpha)
Sets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
void SetBlueByte(const Whole X, const Whole Y, const ColourChannelType Blue)
Sets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
std::string String
A datatype used to a series of characters.
Image * GenerateImage(const Graphics::PixelFormat Format=Graphics::PF_R8G8B8A8) const
Creates an Image from this buffer.
void SetData(const TextureBuffer &Other)
Copies image data from another buffer into this buffer.
Whole GetSubChannelCount() const
Gets the number of colour channels among all the pixels in this texture.
ColourChannelType GetRedByte(const Whole X, const Whole Y) const
Gets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...
UInt8 ColourChannelType
Convenience typedef for the datatype containing the value for each colour channel.
Whole GetPixelCount() const
Gets the number of pixels in this texture.