diff --git a/include/eepp/ee.hpp b/include/eepp/ee.hpp index bafd9085d..03343bdee 100755 --- a/include/eepp/ee.hpp +++ b/include/eepp/ee.hpp @@ -26,13 +26,13 @@ Short-term plans: @TODO Stabilize the API - STATE: It's looking good. + STATE: It's looking good. But i'm changing things. @TODO Improve documentation. STATE: EE ( Base ) documented what is needed. EE::Window documented. EE::System documented. - EE::Graphics 50 % commented. + EE::Graphics 85 % commented. EE::Audio 50 % commented. EE::Math 30 to 40 % commented. EE::UI Not commented at all. @@ -54,6 +54,10 @@ STATE: Not started. @TODO Add a cLock class in EE::System. + STATE: Not implemented. + + @TODO Add a NonCopyable class and inherit from it the classes that are non copyable. + STATE: Not implemented. Middle-term plans: diff --git a/include/eepp/graphics/cfontmanager.hpp b/include/eepp/graphics/cfontmanager.hpp index 181c72456..97f11fee2 100644 --- a/include/eepp/graphics/cfontmanager.hpp +++ b/include/eepp/graphics/cfontmanager.hpp @@ -13,12 +13,12 @@ class EE_API cFontManager : public tResourceManager { SINGLETON_DECLARE_HEADERS(cFontManager) public: - cFontManager(); - virtual ~cFontManager(); /** @brief Adds a new font to the manager */ cFont * Add( cFont * Font ); + protected: + cFontManager(); }; }} diff --git a/include/eepp/graphics/cglobalbatchrenderer.hpp b/include/eepp/graphics/cglobalbatchrenderer.hpp index b7ec22212..41d51b1aa 100755 --- a/include/eepp/graphics/cglobalbatchrenderer.hpp +++ b/include/eepp/graphics/cglobalbatchrenderer.hpp @@ -11,9 +11,9 @@ class EE_API cGlobalBatchRenderer : public cBatchRenderer { SINGLETON_DECLARE_HEADERS(cGlobalBatchRenderer) public: - cGlobalBatchRenderer(); - - ~cGlobalBatchRenderer(); + ~cGlobalBatchRenderer(); + protected: + cGlobalBatchRenderer(); }; }} diff --git a/include/eepp/graphics/cglobaltextureatlas.hpp b/include/eepp/graphics/cglobaltextureatlas.hpp index dfd0eeb35..2e72032d1 100644 --- a/include/eepp/graphics/cglobaltextureatlas.hpp +++ b/include/eepp/graphics/cglobaltextureatlas.hpp @@ -13,9 +13,9 @@ class EE_API cGlobalTextureAtlas : public cTextureAtlas { SINGLETON_DECLARE_HEADERS(cGlobalTextureAtlas) public: - cGlobalTextureAtlas(); - ~cGlobalTextureAtlas(); + protected: + cGlobalTextureAtlas(); }; }} diff --git a/include/eepp/graphics/cshaderprogrammanager.hpp b/include/eepp/graphics/cshaderprogrammanager.hpp index a3f1d4378..98fc8887c 100644 --- a/include/eepp/graphics/cshaderprogrammanager.hpp +++ b/include/eepp/graphics/cshaderprogrammanager.hpp @@ -6,18 +6,17 @@ namespace EE { namespace Graphics { -/** @brief The Shader Program Manager is a singleton class that manages all the instance of Shader Programs instanciated. +/** @brief The Shader Program Manager is a singleton class that manages all the instances of Shader Programs instanciated. Releases the Shader Program instances automatically. So the user doesn't need to release any Shader Program instance. */ class EE_API cShaderProgramManager : public tResourceManager { SINGLETON_DECLARE_HEADERS(cShaderProgramManager) public: - cShaderProgramManager(); - virtual ~cShaderProgramManager(); void Reload(); protected: + cShaderProgramManager(); }; }} diff --git a/include/eepp/graphics/csprite.hpp b/include/eepp/graphics/csprite.hpp index f67f915da..0efa1f3ae 100755 --- a/include/eepp/graphics/csprite.hpp +++ b/include/eepp/graphics/csprite.hpp @@ -13,19 +13,37 @@ class EE_API cSprite { public: typedef cb::Callback2< void, Uint32, cSprite * > SpriteCallback; + /** @enum The events that can be reported by the Sprite */ enum SpriteEvents { SPRITE_EVENT_LAST_FRAME, SPRITE_EVENT_FIRST_FRAME, SPRITE_EVENT_END_ANIM_TO }; + /** Instanciate an empty sprite */ cSprite(); + /** Creates an animated Sprite from a animation name. It will search for a pattern name. + * @param name First part of the sub texture name + * @param extension Extension of the sub texture name ( if have one, otherwise is empty ) + * @param SearchInTextureAtlas If you want only to search in a especific atlas ( NULL if you want to search in all atlases ) + * @example Search for name "car" with extensions "png", i will try to find car00.png car01.png car02.png, and so on, it will continue if find something, otherwise it will stop ( it will always search at least for car00.png and car01.png ). + * @note Texture atlases saves the SubTextures names without extension by default. + * @see cTextureAtlasManager::GetSubTexturesByPattern +*/ cSprite( const std::string& name, const std::string& extension = "", cTextureAtlas * SearchInTextureAtlas = NULL ); + /** Creates a Sprite from a SubTexture + ** @param SubTexture The subtexture to use */ cSprite( cSubTexture * SubTexture ); - cSprite( const Uint32& TexId, const eeFloat& DestWidth = 0, const eeFloat& DestHeight = 0, const eeFloat& offSetX = 0, const eeFloat& offSetY = 0, const eeRecti& TexSector = eeRecti(0,0,0,0) ); + /** Creates a Sprite instance that holds a new SubTexture from a texture already loaded. + * @param TexId The texture Id used to create the SubTexture + * @param DestSize The destination size of the SubTexture created + * @param Offset The offset added to the position of the frame ( the SubTexture ) + * @param TexSector The sector of the texture used by the SubTexture to be rendered + */ + cSprite( const Uint32& TexId, const eeSizef &DestSize = eeSizef(0,0), const eeVector2i &Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) ); virtual ~cSprite(); @@ -34,61 +52,50 @@ class EE_API cSprite { /** Set the x axis position */ void X( const eeFloat& X ); - /** Get the x axis position */ + /** @return The x axis position */ eeFloat X() const; /** Set the y axis position */ void Y( const eeFloat& Y ); - /** Get the y axis position */ + /** @return The y axis position */ eeFloat Y() const; /** Set the Angle for the rendered sprite */ void Angle( const eeFloat& Angle ); - /** Get the Angle for the rendered sprite */ + /** @return The Angle for the rendered sprite */ eeFloat Angle() const; /** Set the Scale for the rendered sprite */ void Scale( const eeFloat& Scale ); - /** Get the Scale for the rendered sprite */ + /** @return The Scale for the rendered sprite */ eeFloat Scale() const; - /** Set the Frame Number Sprite Width - * @param FrameNum If the Frame Number is 0 use the Current Frame Number - * @param SubFrame If the Sub Frame Number is 0 use the Current Sub Frame Number + /** Set the Frame Number Sprite Size + * @param Size The new size + * @param FrameNum If the Frame Number is 0 it will use the Current Frame Number + * @param SubFrame If the Sub Frame Number is 0 it will use the Current Sub Frame Number */ - void Width( const eeFloat& Width, const eeUint& FrameNum, const eeUint& SubFrame); + void Size( const eeSizef& Size, const eeUint& FrameNum, const eeUint& SubFrame ); - /** Set the current SubTexture Width */ - void Width( const eeFloat& Width ); + /** Set the current SubTexture Size ( destination size ) */ + void Size( const eeSizef& Size ); - /** Get the Frame Number Sprite Width */ - eeFloat Width( const eeUint& FrameNum, const eeUint& SubFrame ); - - /** Get the current Frame Width */ - eeFloat Width(); - - /** Set the Frame Number Sprite Height - * @param FrameNum If the Frame Number is 0 use the Current Frame Number - * @param SubFrame If the Sub Frame Number is 0 use the Current Sub Frame Number + /** @return the Frame Number Sprite Size + * @param FrameNum If the Frame Number is 0 it will use the Current Frame Number + * @param SubFrame If the Sub Frame Number is 0 it will use the Current Sub Frame Number */ - void Height( const eeFloat& Height, const eeUint& FrameNum, const eeUint& SubFrame ); + eeSizef Size( const eeUint& FrameNum, const eeUint& SubFrame ); - /** Set the current Frame Width */ - void Height( const eeFloat& Height ); - - /** Get the Frame Number Sprite Height */ - eeFloat Height( const eeUint& FrameNum, const eeUint& SubFrame ); - - /** Get the current Frame Width */ - eeFloat Height(); + /** @return The current Frame Size */ + eeSizef Size(); /** Set the sprite animation speed ( AnimSpeed equals to Animation Frames per Second ) */ void AnimSpeed( const eeFloat& AnimSpeed ); - /** Get the sprite animation speed ( AnimSpeed equals to Animation Frames per Second ) */ + /** @return The sprite animation speed ( AnimSpeed equals to Animation Frames per Second ) */ eeFloat AnimSpeed() const; /** @return If the animation is paused */ @@ -100,16 +107,16 @@ class EE_API cSprite { /** Set the sprite color */ void Color( const eeColorA& Color); - /** Get the sprite color */ + /** @return The sprite color */ const eeColorA& Color() const; /** Set the sprite Color Alpha */ void Alpha( const Uint8& Alpha ); - /** Get the sprite Color Alpha */ + /** @return The sprite Color Alpha */ const Uint8& Alpha() const; - /** Get if the sprite it's scaled from the center */ + /** @return If the sprite it's scaled from the center */ bool ScaleCentered() const; /** Set if the sprite it's scaled centered or scaled from the Left - Top position of the sprite ( default True ) */ @@ -118,10 +125,10 @@ class EE_API cSprite { /** Set the Current Frame */ void CurrentFrame( eeUint CurFrame ); - /** Get the Current Frame */ + /** @return The Current Frame */ const eeUint& CurrentFrame() const; - /** Get the Exact Current FrameData + /** @return The Exact Current FrameData * @return The eeFloat fpoint of the current frame, the exact position of the interpolation. */ const eeFloat& ExactCurrentFrame() const; @@ -132,19 +139,19 @@ class EE_API cSprite { /** Set the Current Sub Frame */ void CurrentSubFrame( const eeUint &CurSubFrame ); - /** Get the Current Sub Frame */ + /** @return The Current Sub Frame */ const eeUint& CurrentSubFrame() const; /** Set the Render Type */ void RenderMode( const EE_RENDER_MODE& Effect ); - /** Get the Render Type */ + /** @return The Render Type */ const EE_RENDER_MODE& RenderMode() const; /** Set the Blend Mode */ void BlendMode( const EE_BLEND_MODE& Blend ); - /** Get the Blend Mode */ + /** @return The Blend Mode */ const EE_BLEND_MODE& BlendMode() const; /** Reset the sprite as a new one. */ @@ -179,16 +186,14 @@ class EE_API cSprite { */ bool CreateStatic( cSubTexture * SubTexture ); - /** Creates an static sprite (no animation) + /** Creates an static sprite (no animation). It creates a new SubTexture. * @param TexId The internal Texture Id - * @param DestWidth The default destination width of the sprite - * @param DestHeight The default destination height of the sprite - * @param offSetX The default offset on axis x added to the x position - * @param offSetY The default offset on axis y added to the y position + * @param DestSize The destination size of the SubTexture created + * @param Offset The offset added to the position of the frame ( the SubTexture ) * @param TexSector The texture sector to be rendered ( default all the texture ) * @return True if success */ - bool CreateStatic( const Uint32& TexId, const eeFloat& DestWidth = 0, const eeFloat& DestHeight = 0, const eeFloat& offSetX = 0, const eeFloat& offSetY = 0, const eeRecti& TexSector = eeRecti(0,0,0,0) ); + bool CreateStatic(const Uint32& TexId, const eeSizef &DestSize = eeSizef(0,0), const eeVector2i &Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) ); /** Creates an animated sprite * @param SubFramesNum The number of subframes of the sprite @@ -197,14 +202,12 @@ class EE_API cSprite { /** Add a frame to the sprite (on the current sub frame) * @param TexId The internal Texture Id - * @param DestWidth The destination width of the frame - * @param DestHeight The destination height of the frame - * @param offSetX The offset on axis x added to the x position of the frame - * @param offSetY The offset on axis y added to the y position of the frame + * @param DestSize The destination size of the frame + * @param Offset The offset added to the position of the frame * @param TexSector The texture sector to be rendered ( default all the texture ) * @return The frame position or 0 if fails */ - eeUint AddFrame( const Uint32& TexId, const eeFloat& DestWidth = 0, const eeFloat& DestHeight = 0, const eeFloat& offSetX = 0, const eeFloat& offSetY = 0, const eeRecti& TexSector = eeRecti(0,0,0,0) ); + eeUint AddFrame( const Uint32& TexId, const eeSizef& DestSize = eeSizef(0,0), const eeVector2i& Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) ); /** Add a frame to the sprite (on the current sub frame) * @param SubTexture The SubTexture used in the frame @@ -226,14 +229,12 @@ class EE_API cSprite { * @param TexId The internal Texture Id * @param NumFrame The Frame Number * @param NumSubFrame The Sub Frame Number - * @param DestWidth The destination width of the frame - * @param DestHeight The destination height of the frame - * @param offSetX The offset on axis x added to the x position of the frame - * @param offSetY The offset on axis y added to the y position of the frame + * @param DestSize The destination size of the frame + * @param Offset The offset added to the x position of the frame * @param TexSector The texture sector to be rendered ( default all the texture ) * @return True if success */ - bool AddSubFrame( const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeFloat& DestWidth = 0, const eeFloat& DestHeight = 0, const Int32& offSetX = 0, const Int32& offSetY = 0, const eeRecti& TexSector = eeRecti(0,0,0,0) ); + bool AddSubFrame( const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeSizef& DestSize = eeSizef(0,0), const eeVector2i& Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) ); /** Add a frame on an specific subframe to the sprite * @param SubTexture The SubTexture used in the frame @@ -268,23 +269,14 @@ class EE_API cSprite { /** Set if the class auto-animate the sprite ( default it's active ) */ void AutoAnimate( const bool& Autoanim ); - /** Get if the class is auto-animated */ + /** @return If the class is auto-animated */ bool AutoAnimate() const; /** @return The four vertex position of the Sprite */ eeQuad2f GetQuad(); - /** @return The OffsetX of the current frame */ - Int32 OffsetX(); - - /** Set the OffsetX of the current frame */ - void OffsetX( const Int32& offsetx ); - - /** @return The OffsetY of the current frame */ - Int32 OffsetY(); - - /** Set the OffsetY of the current frame */ - void OffsetY( const Int32& offsety ); + /** @return The Offset of the current frame */ + eeVector2i Offset(); /** Set the Offset of the current frame */ void Offset( const eeVector2i& offset ); diff --git a/include/eepp/graphics/csubtexture.hpp b/include/eepp/graphics/csubtexture.hpp index b2077dd9b..466b3e6cb 100644 --- a/include/eepp/graphics/csubtexture.hpp +++ b/include/eepp/graphics/csubtexture.hpp @@ -9,47 +9,75 @@ namespace EE { namespace Graphics { /** @brief A cSubTexture is a part of a texture that represent an sprite.*/ class EE_API cSubTexture { public: + /** Creates an empty SubTexture */ cSubTexture(); + /** Creates a SubTexture from a Texture. It will use the full Texture as a SubTexture. + * @param TexId The texture id + * @param Name The texture name ( if any ) + */ cSubTexture( const Uint32& TexId, const std::string& Name = "" ); + /** Creates a SubTexture of the indicated part of the texture. + * @param TexId The texture id + * @param SrcRect The texture part that will be used as the SubTexture. + * @param Name The texture name ( if any ) + */ cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const std::string& Name = "" ); - cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name = "" ); + /** Creates a SubTexture of the indicated part of the texture. + * @param TexId The texture id + * @param SrcRect The texture part that will be used as the SubTexture. + * @param DestSize The destination size that the SubTexture will have when rendered. + * @param Name The texture name ( if any ) + */ + cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const std::string& Name = "" ); - cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const Int32& OffsetX, const Int32& OffsetY, const std::string& Name = "" ); + /** Creates a SubTexture of the indicated part of the texture. + * @param TexId The texture id + * @param SrcRect The texture part that will be used as the SubTexture. + * @param DestSize The destination size that the SubTexture will have when rendered. + * @param Offset The offset that will be added to the position passed when any Draw call is used. + * @param Name The texture name ( if any ) + */ + cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const eeVector2i& Offset, const std::string& Name = "" ); virtual ~cSubTexture(); + /** @return The SubTexture Id. The Id is the String::Hash of the SubTexture name. */ const Uint32& Id() const; + /** @return The SubTexture Name. */ const std::string Name() const; + /** Sets the SubTexture Name, it will also change the Id. */ void Name( const std::string& name ); + /** @return The Texture Id that holds the SubTexture. */ const Uint32& Texture(); + /** Set the Texture Id that holds the SubTexture. */ void Texture( const Uint32& TexId ); + /** @return The Texture sector that represents the SubTexture */ const eeRecti& SrcRect() const; + /** Sets the Texture sector that represents the SubTexture */ void SrcRect( const eeRecti& Rect ); - const eeFloat& DestWidth() const; + /** @return The Destination Size of the SubTexture. */ + const eeSizef& DestSize() const; - void DestWidth( const eeFloat& width ); + /** Sets the Destination Size of the SubTexture. + * The size can be different from the original size of the SubTexture. + * For example if the SubTexture width is 32 pixels, by default the destination width is 32 pixels, but it can be changed to anything wanted. */ + void DestSize( const eeSizef& destSize ); - const eeFloat& DestHeight() const; + /** @return The SubTexture default offset. The offset is added to the position passed when is drawed. */ + const eeVector2i& Offset() const; - void DestHeight( const eeFloat& height ); - - const Int32& OffsetX() const; - - void OffsetX( const Int32& offsetx ); - - const Int32& OffsetY() const; - - void OffsetY( const Int32& offsety ); + /** Set the SubTexture offset. */ + void Offset( const eeVector2i& offset ); void Draw( const eeFloat& X, const eeFloat& Y, const eeColorA& Color = eeColorA(), const eeFloat& Angle = 0.f, const eeFloat& Scale = 1.f, const EE_BLEND_MODE& Blend = ALPHA_NORMAL, const EE_RENDER_MODE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); @@ -57,39 +85,63 @@ class EE_API cSubTexture { void Draw( const eeQuad2f Q, const eeFloat& X, const eeFloat& Y, const eeFloat& Angle = 0.f, const eeFloat& Scale = 1.f, const eeColorA& Color0 = eeColorA(), const eeColorA& Color1 = eeColorA(), const eeColorA& Color2 = eeColorA(), const eeColorA& Color3 = eeColorA(), const EE_BLEND_MODE& Blend = ALPHA_NORMAL ); + /** @return The texture instance used by the SubTexture. */ cTexture * GetTexture(); + /** Replaces a color in the SubTexture ( needs Lock() ) */ void ReplaceColor( eeColorA ColorKey, eeColorA NewColor ); + /** Creates a mask from a color. */ void CreateMaskFromColor( eeColorA ColorKey, Uint8 Alpha ); + /** Creates a mask from a color. */ void CreateMaskFromColor( eeColor ColorKey, Uint8 Alpha ); + /** Creates a copy of the alpha mask to memory from the texture loaded in VRAM. */ void CacheAlphaMask(); + /** Creates a copy in memory from the texture loaded in VRAM. */ void CacheColors(); + /** @return The alpha value that corresponds to the position indicated in the SubTexture. + * If the SubTexture wasn't locked before this call, it will be locked automatically. */ Uint8 GetAlphaAt( const Int32& X, const Int32& Y ); + /** @return The color that corresponds to the position indicated in the SubTexture. + * If the SubTexture wasn't locked before this call, it will be locked automatically. */ eeColorA GetColorAt( const Int32& X, const Int32& Y ); + /** @brief Set a color to the position indicated in the SubTexture. + * If the SubTexture wasn't locked before this call, it will be locked automatically. + */ void SetColorAt( const Int32& X, const Int32& Y, const eeColorA& Color ); + /** Deletes the texture buffer from memory ( not from VRAM ) if it was cached before ( using Lock() ). */ void ClearCache(); + /** @brief Locks the texture to be able to perform read/write operations. + * @see cTexture::Lock */ Uint8 * Lock(); + /** @brief Unlocks the current texture locked. + * @see cTexture::Unlock */ bool Unlock( const bool& KeepData = false, const bool& Modified = false ); + /** @return The SubTexture size in the texture. This is the source rect size. */ eeSize RealSize(); + /** @return This is the same as Destination Size but with the values rounded as integers. */ eeSize Size(); + /** @return A pixel pointer to the texture loaded in memory ( downloaded from VRAM doing Lock()/Unlock() ). */ const Uint8* GetPixelsPtr(); - bool SaveToFile(const std::string& filepath, const EE_SAVE_TYPE& Format); + /** Saves the SubTexture to a file in the file format specified. + * This will get the Texture from VRAM ( it will not work with OpenGL ES ) */ + bool SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format ); - void ResetDestWidthAndHeight(); + /** Sets the Destination Size as the Source Rect Size ( the real size of the SubTexture ). */ + void ResetDestSize(); protected: Uint8 * mPixels; Uint8 * mAlpha; @@ -98,10 +150,8 @@ class EE_API cSubTexture { Uint32 mTexId; cTexture * mTexture; eeRecti mSrcRect; - eeFloat mDestWidth; - eeFloat mDestHeight; - Int32 mOffsetX; - Int32 mOffsetY; + eeSizef mDestSize; + eeVector2i mOffset; void CreateUnnamed(); }; diff --git a/include/eepp/graphics/ctexture.hpp b/include/eepp/graphics/ctexture.hpp index 6d8be8b7b..6e0ea01c4 100755 --- a/include/eepp/graphics/ctexture.hpp +++ b/include/eepp/graphics/ctexture.hpp @@ -8,12 +8,6 @@ namespace EE { namespace Graphics { -#define TEX_FLAG_MIPMAP ( 1 << 0 ) -#define TEX_FLAG_MODIFIED ( 1 << 1 ) -#define TEX_FLAG_COMPRESSED ( 1 << 2 ) -#define TEX_FLAG_LOCKED ( 1 << 3 ) -#define TEX_FLAG_GRABED ( 1 << 4 ) - class EE_API cTexture : public cImage { public: /** Set the OpenGL Texture Id (texture handle) */ @@ -49,10 +43,15 @@ class EE_API cTexture : public cImage { /** @return The Texture Clamp Mode */ EE_CLAMP_MODE ClampMode() const { return mClampMode; } - /** Lock the Texture for direct access */ + /** Lock the Texture for direct access. + ** It is needed to have any read/write access to the texture. This feature is not supported in OpenGL ES. */ Uint8 * Lock( const bool& ForceRGBA = false ); - /** Unlock the previously locked Texture */ + /** @brief Unlock the previously locked Texture. + * Unlocking the texture will upload the local copy of the texture ( that could have been modified ) to the GPU. + * @param KeepData If true keeps the local copy of the texture un memory, otherwise it will be released. + * @param Modified The flag indicates of the texture was modified between the Lock and Unlock calls. This is to force reloading the texture from memory to VRAM. In the case that the texture in ram was modified using the cTexture methods to do this, it will already know that this is true, so it will upload the changes to the GPU. + */ bool Unlock(const bool& KeepData = false, const bool& Modified = false); /** @return A pointer to the first pixel of the texture ( keeped with a local copy ). \n You must have a copy of the texture on local memory. For that you need to Lock the texture first. */ @@ -61,6 +60,7 @@ class EE_API cTexture : public cImage { /** Set the Texture Filter Mode */ void TextureFilter( const EE_TEX_FILTER& filter ); + /** @return The texture filter used by the texture */ const EE_TEX_FILTER& TextureFilter() const; /** Save the Texture to a new File */ @@ -191,6 +191,15 @@ class EE_API cTexture : public cImage { virtual ~cTexture(); protected: + enum TEXTURE_FLAGS + { + TEX_FLAG_MIPMAP = ( 1 << 0 ), + TEX_FLAG_MODIFIED = ( 1 << 1 ), + TEX_FLAG_COMPRESSED = ( 1 << 2 ), + TEX_FLAG_LOCKED = ( 1 << 3 ), + TEX_FLAG_GRABED = ( 1 << 4 ) + }; + friend class cTextureFactory; cTexture(); diff --git a/include/eepp/graphics/ctextureatlas.hpp b/include/eepp/graphics/ctextureatlas.hpp index 18c034043..ebf9efe79 100644 --- a/include/eepp/graphics/ctextureatlas.hpp +++ b/include/eepp/graphics/ctextureatlas.hpp @@ -6,36 +6,76 @@ namespace EE { namespace Graphics { +/** @brief The texture atlas class represents a large image containing a collection of sub-images, or "atlas" which contains many smaller sub-images. +* The texture atlas in eepp can represent more than one texture or image, but the common use should be a image with sub-images. +* More information about Texture Atlases: http://en.wikipedia.org/wiki/Texture_atlas */ class EE_API cTextureAtlas : public tResourceManager { public: + /** Creates a new texture atlas with the given name. */ cTextureAtlas( const std::string& name = "" ); ~cTextureAtlas(); + /** Adds a SubTexture to the Texture Atlas */ cSubTexture * Add( cSubTexture * subTexture ); + /** Creates and add to the texture atlas a SubTexture from a Texture. It will use the full Texture as a SubTexture. + * @param TexId The texture id + * @param Name The texture name ( if any ) + */ cSubTexture * Add( const Uint32& TexId, const std::string& Name = "" ); + /** Creates and add to the texture atlas a SubTexture of the indicated part of the texture. + * @param TexId The texture id + * @param SrcRect The texture part that will be used as the SubTexture. + * @param Name The texture name ( if any ) + */ cSubTexture * Add( const Uint32& TexId, const eeRecti& SrcRect, const std::string& Name = "" ); - cSubTexture * Add( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name = "" ); + /** Creates and add to the texture atlas a SubTexture of the indicated part of the texture. + * @param TexId The texture id + * @param SrcRect The texture part that will be used as the SubTexture. + * @param DestSize The destination size that the SubTexture will have when rendered. + * @param Name The texture name ( if any ) + */ + cSubTexture * Add( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const std::string& Name = "" ); - cSubTexture * Add( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& OffsetX, const eeFloat& OffsetY, const std::string& Name = "" ); + /** Creates and add to the texture atlas a SubTexture of the indicated part of the texture. + * @param TexId The texture id + * @param SrcRect The texture part that will be used as the SubTexture. + * @param DestSize The destination size that the SubTexture will have when rendered. + * @param Offset The offset that will be added to the position passed when any Draw call is used. + * @param Name The texture name ( if any ) + */ + cSubTexture * Add( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const eeVector2i& Offset, const std::string& Name = "" ); + /** @return The texture atlas name. */ const std::string& Name() const; + /** Sets the texture atlas name. */ void Name( const std::string& name ); + /** @return The texture atlas path. */ const std::string& Path() const; + /** Sets the texture atlas path. */ void Path( const std::string& path ); + /** @return The texture atlas Id. The Id is the String::Hash of the texture atlas name. */ const Uint32& Id() const; + /** @return The number of SubTextures inside the texture atlas. */ Uint32 Count(); + /** @return The texture that corresponds to the texture atlas. + * @param texnum The texture index. A texture atlas can use more than one texture, so it can be 0 to GetTexturesLoadedCount(). Usually a texture atlas corresponds to only one texture, so the texture index is 0. + * @note Some texture atlases could not have any texture, since you can use it as a container of SubTextures from any texture. \n + * The texture atlases loaded from a file always will be linked to a texture. \n + * The Global Texture Atlas for example doesn't have any texture linked to it. + */ cTexture * GetTexture( const Uint32& texnum = 0 ) const; + /** @return The number of textures linked to the texture atlas. */ Uint32 GetTexturesCount(); protected: friend class cTextureAtlasLoader; diff --git a/include/eepp/graphics/ctextureatlasloader.hpp b/include/eepp/graphics/ctextureatlasloader.hpp index f2edfeda3..db6074f95 100644 --- a/include/eepp/graphics/ctextureatlasloader.hpp +++ b/include/eepp/graphics/ctextureatlasloader.hpp @@ -14,51 +14,113 @@ using namespace Private; class cTextureAtlas; +/** @brief The Texture Atlas Loader loads any previously created Texture Atlas. */ class EE_API cTextureAtlasLoader { public: typedef cb::Callback1 GLLoadCallback; + /** Creates an empty loader. The texture atlas can be loaded callin any Load* function. */ cTextureAtlasLoader(); + /** Loads a texture atlas from its path ( the texture atlas binary is expected, not the texture, the ".eta" file ). + * If the loader is not threaded, it will load the atlas immediately. + * @param TextureAtlasPath The texture atlas path. + * @param Threaded Indicates if the loading is done in another thread. + * @param LoadCallback The load notification callback. + */ cTextureAtlasLoader( const std::string& TextureAtlasPath, const bool& Threaded = false, GLLoadCallback LoadCallback = GLLoadCallback() ); + /** Loads a texture atlas from memory. + * If the loader is not threaded, it will load the atlas immediately. + * @param Data The texture atlas buffer pointer + * @param DataSize The texture atlas buffer pointer size + * @param TextureAtlasName Since the texture atlas is loaded from memory, the name can't be obtained from the file name. So it needs to be indicated manually. + * @param Threaded Indicates if the loading is done in another thread. + * @param LoadCallback The load notification callback. + */ cTextureAtlasLoader( const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName, const bool& Threaded = false, GLLoadCallback LoadCallback = GLLoadCallback() ); + /** Loads a texture atlas from a pack file. + * If the loader is not threaded, it will load the atlas immediately. + * @param Pack The pointer of the pack instance to be used to load the file. + * @param FilePathPath The path of the file inside the pack. + * @param Threaded Indicates if the loading is done in another thread. + * @param LoadCallback The load notification callback. + */ cTextureAtlasLoader( cPack * Pack, const std::string& FilePackPath, const bool& Threaded = false, GLLoadCallback LoadCallback = GLLoadCallback() ); + /** Loads a texture atlas from a io stream. + * If the loader is not threaded, it will load the atlas immediately. + * @param IOS The io stream to use for the loading. + * @param Threaded Indicates if the loading is done in another thread. + * @param LoadCallback The load notification callback. + */ cTextureAtlasLoader( cIOStream& IOS, const bool& Threaded = false, GLLoadCallback LoadCallback = GLLoadCallback() ); ~cTextureAtlasLoader(); + /** In the case that the loader is threaded, to know if the texture atlas was loaded, the main thread must call Update to update the state of the load. And finish the job. */ void Update(); + /** Loads a texture atlas from its path ( the texture atlas binary is expected, not the texture, the ".eta" file ). + * If the loader is not threaded, it will load the atlas immediately. + * @param TextureAtlasPath The texture atlas path. + */ void Load( const std::string& TextureAtlasPath = "" ); + /** Loads a texture atlas from a io stream. + * If the loader is not threaded, it will load the atlas immediately. + * @param IOS The io stream to use for the loading. + */ void LoadFromStream( cIOStream& IOS ); + /** Loads a texture atlas from memory. + * If the loader is not threaded, it will load the atlas immediately. + * @param Data The texture atlas buffer pointer + * @param DataSize The texture atlas buffer pointer size + * @param TextureAtlasName Since the texture atlas is loaded from memory, the name can't be obtained from the file name. So it needs to be indicated manually. + */ void LoadFromMemory( const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName ); + /** Loads a texture atlas from a pack file. + * If the loader is not threaded, it will load the atlas immediately. + * @param Pack The pointer of the pack instance to be used to load the file. + * @param FilePathPath The path of the file inside the pack. + */ void LoadFromPack( cPack * Pack, const std::string& FilePackPath ); + /** @return If the loader is threaded ( asynchronous ). */ bool Threaded() const; + /** If threaded is true sets the loader as asynchronous. This must be called before the loading is done. */ void Threaded( const bool& threaded ); + /** @return True if the texture atlas is loaded. */ const bool& IsLoaded() const; + /** @return True if the texture atlas is loading. */ const bool& IsLoading() const; - /** Will check if the texture atlas is updated ( all the image of the path are inside the texture atlas, and are the same version, otherwise it will recreate or update the texture atlas. */ + /** @brief The function will check if the texture atlas is updated. + Checks if all the images inside the images path are inside the texture atlas, and if they have the same date and size, otherwise it will recreate or update the texture atlas. + */ bool UpdateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ); + /** Rewrites the texture atlas file. Usefull if the SubTextures where modified and need to be updated inside the texture atlas. */ bool UpdateTextureAtlas(); + /** @return The texture that corresponds to the texture atlas. + * @param texnum The texture index. A texture atlas can use more than one texture, so it can be 0 to GetTexturesLoadedCount(). Usually a texture atlas corresponds to only one texture, so the texture index is 0. + */ cTexture * GetTexture( const Uint32& texnum = 0 ) const; + /** @return The number of textures linked to the texture atlas. */ Uint32 GetTexturesLoadedCount(); + /** @return The texture atlas instance pointer ( NULL if the atlas isn't loaded yet ). */ cTextureAtlas * GetTextureAtlas() const; + /** Sets a load notification callback. */ void SetLoadCallback( GLLoadCallback LoadCallback ); protected: cResourceLoader mRL; diff --git a/include/eepp/graphics/ctextureatlasmanager.hpp b/include/eepp/graphics/ctextureatlasmanager.hpp index 70e3bfe42..5090cfe9b 100644 --- a/include/eepp/graphics/ctextureatlasmanager.hpp +++ b/include/eepp/graphics/ctextureatlasmanager.hpp @@ -7,43 +7,61 @@ namespace EE { namespace Graphics { +/** @brief The Texture Atlas Manager is a singleton class that manages all the instances of Texture Atlases instanciated. + Releases the Texture Atlases instances automatically. So the user doesn't need to release any Texture Atlas instance. */ class EE_API cTextureAtlasManager : public tResourceManager { SINGLETON_DECLARE_HEADERS(cTextureAtlasManager) public: - cTextureAtlasManager(); - virtual ~cTextureAtlasManager(); + /** Loads a texture atlas from its path ( the texture atlas binary is expected, not the texture, the ".eta" file ). */ cTextureAtlas * Load( const std::string& TextureAtlasPath ); + /** Loads a texture atlas from a io stream. */ cTextureAtlas * LoadFromStream( cIOStream& IOS ); + /** Loads a texture atlas from memory. */ cTextureAtlas * LoadFromMemory( const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName ); + /** Loads a texture atlas from a pack file. */ cTextureAtlas * LoadFromPack( cPack * Pack, const std::string& FilePackPath ); + /** It will search for a SubTexture Name in the texture atlases loaded. + * @return The first SubTexture found with the given name in any atlas. */ cSubTexture * GetSubTextureByName( const std::string& Name ); + /** It will search for a SubTexture Id in the texture atlases loaded. + * @return The first SubTexture found with the given id in any atlas. */ cSubTexture * GetSubTextureById( const Uint32& Id ); /** Search for a pattern name * @param name First part of the sub texture name - * @param extension Extension of the sub texture name ( if have one, otherwise "" ) + * @param extension Extension of the sub texture name ( if have one, otherwise is empty ) * @param SearchInTextureAtlas If you want only to search in a especific atlas ( NULL if you want to search in all atlases ) * @example Search for name "car" with extensions "png", i will try to find car00.png car01.png car02.png, and so on, it will continue if find something, otherwise it will stop ( it will always search at least for car00.png and car01.png ) + * @note Texture atlases saves the SubTextures names without extension by default. */ std::vector GetSubTexturesByPattern( const std::string& name, const std::string& extension = "", cTextureAtlas * SearchInTextureAtlas = NULL ); + /** Search for a pattern id. + * This will look for the SubTexture with the id passed, and it will try to find any pattern by the SubTexture name. + * @see GetSubTexturesByPattern + */ std::vector GetSubTexturesByPatternId( const Uint32& SubTextureId, const std::string& extension = "", cTextureAtlas * SearchInTextureAtlas = NULL ); + /** Prints all the resources name to the screen. */ void PrintResources(); + /** Sets if the warnings for not finding a resource must be printed in screen. */ void PrintWarnings( const bool& warn ); + /** @return If warnings are being printed. */ const bool& PrintWarnings() const; protected: bool mWarnings; + + cTextureAtlasManager(); }; }} diff --git a/include/eepp/graphics/ctexturefactory.hpp b/include/eepp/graphics/ctexturefactory.hpp index 9839aaa9f..88a0bfd6f 100755 --- a/include/eepp/graphics/ctexturefactory.hpp +++ b/include/eepp/graphics/ctexturefactory.hpp @@ -13,7 +13,7 @@ class EE_API cTextureFactory : protected cMutex { SINGLETON_DECLARE_HEADERS(cTextureFactory) public: - /** Create an empty texture + /** Creates an empty texture * @param Width Texture Width * @param Height Texture Height * @param Channels Texture Number of Channels (in bytes) @@ -62,7 +62,7 @@ class EE_API cTextureFactory : protected cMutex { */ Uint32 LoadFromMemory( const unsigned char* ImagePtr, const eeUint& Size, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); - /** Load a Texture from a file path + /** Load a Texture from stream * @param Stream The cIOStream instance * @param mipmap Use mipmaps? * @param ClampMode Defines the CLAMP MODE diff --git a/include/eepp/graphics/ctexturefontloader.hpp b/include/eepp/graphics/ctexturefontloader.hpp index 94d060b65..c469761b3 100644 --- a/include/eepp/graphics/ctexturefontloader.hpp +++ b/include/eepp/graphics/ctexturefontloader.hpp @@ -9,11 +9,6 @@ namespace EE { namespace Graphics { -#define TEF_LT_PATH (1) -#define TEF_LT_MEM (2) -#define TEF_LT_PACK (3) -#define TEF_LT_TEX (4) - class EE_API cTextureFontLoader : public cObjectLoader { public: cTextureFontLoader( const std::string FontName, cTextureLoader * TexLoader, const eeUint& StartChar = 0, const eeUint& Spacing = 0, const bool& VerticalDraw = false, const eeUint& TexColumns = 16, const eeUint& TexRows = 16, const Uint16& NumChars = 256 ); @@ -34,6 +29,14 @@ class EE_API cTextureFontLoader : public cObjectLoader { cFont * Font() const; protected: + enum TEXTURE_FONT_LOAD_TYPE + { + TEF_LT_PATH = 1, + TEF_LT_MEM = 2, + TEF_LT_PACK = 3, + TEF_LT_TEX = 4 + }; + Uint32 mLoadType; // From memory, from path, from pack cTextureFont * mFont; diff --git a/include/eepp/graphics/ctextureloader.hpp b/include/eepp/graphics/ctextureloader.hpp index 19fd9ad1d..e72c572ea 100644 --- a/include/eepp/graphics/ctextureloader.hpp +++ b/include/eepp/graphics/ctextureloader.hpp @@ -20,7 +20,7 @@ class EE_API cTextureLoader : public cObjectLoader { cTextureLoader( const unsigned char * Pixels, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = EE_CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ); - ~cTextureLoader(); + virtual ~cTextureLoader(); void SetColorKey( eeColor Color ); diff --git a/include/eepp/graphics/ctexturepacker.hpp b/include/eepp/graphics/ctexturepacker.hpp index 10b62bc5f..d1105ff1e 100644 --- a/include/eepp/graphics/ctexturepacker.hpp +++ b/include/eepp/graphics/ctexturepacker.hpp @@ -41,33 +41,65 @@ namespace Private { class cTexturePackerNode; class cTexturePackerTex; } using namespace Private; +/** @brief The Texture Packer class is used to create new Texture Atlases. +* Atlases can be created indicating the texture atlas size and adding textures to the atlases. +*/ class EE_API cTexturePacker { public: + /** Creates a new texture packer ( you will need to call SetOptions before adding any texture or image ). */ cTexturePacker(); + /** Creates a new texture packer indicating the size of the texture atlas. + * @param MaxWidth The maximum width that the texture atlas will use. + * @param MaxHeight The maximum height that the texture atlas will use. + * @param ForcePowOfTwo Indicates that if the max with and height must be adjusted to fit a power of two texture. + * @param PixelBorder Indicates how many pixels will be added to separate one image to another in the texture atlas. Usefull to avoid artifacts when rendered scaled SubTextures. Use at least 1 pixel to separate images if you will scale any SubTexture. + * @param AllowFlipping Indicates if the images can be flipped inside the texture atlas. This is not compatible with eepp ( since it can't flip the textures back to the original orientation ). So avoid it for eepp. + */ cTexturePacker( const Uint32& MaxWidth, const Uint32& MaxHeight, const bool& ForcePowOfTwo = true, const Uint32& PixelBorder = 0, const bool& AllowFlipping = false ); ~cTexturePacker(); + /** Adds a image/texture from its path to the texture atlas. + * @param TexturePath The image path. */ bool AddTexture( const std::string& TexturePath ); + /** Adds a image to the texture atlas. The image instance must remain in memory until the texture atlas is saved. */ bool AddImage( cImage * Img, const std::string& Name ); + /** Adds a directory with images. It will try to add all the images inside that directory to the texture atlas. */ bool AddTexturesPath( std::string TexturesPath ); + /** After adding all the images that will be used to create the texture atlas. Packing the textures will generate the texture atlas information ( it will fit the images inside the texture atlas, etc ). */ Int32 PackTextures(); - void Save( const std::string& Filepath, const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_DDS, const bool& SaveExtensions = false ); + /** @brief Save the texture atlas to a file, in the indicated format. + * If PackTexture() has not been called, it will be called automatically by the function ( so you don't need to call it ). + * @param Filepath The path were it will be saved the new texture atlas. + * @param Format The image format of the new texture atlas. + * @param SaveExtensions Indicates if the extensions of the image files must be saved. Usually you wan't to find the SubTextures by its name without extension, but this can be changed here. + */ + void Save( const std::string& Filepath, const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_PNG, const bool& SaveExtensions = false ); void Close(); - /** First of all you need to set at least the max dimensions of the texture atlas. */ + /** First of all you need to set at least the max dimensions of the texture atlas. + * If the instance of the texture packer was created without indicating this data, this must be called before adding any texture or image. + * @param MaxWidth The maximum width that the texture atlas will use. + * @param MaxHeight The maximum height that the texture atlas will use. + * @param ForcePowOfTwo Indicates that if the max with and height must be adjusted to fit a power of two texture. + * @param PixelBorder Indicates how many pixels will be added to separate one image to another in the texture atlas. Usefull to avoid artifacts when rendered scaled SubTextures. Use at least 1 pixel to separate images if you will scale any SubTexture. + * @param AllowFlipping Indicates if the images can be flipped inside the texture atlas. This is not compatible with eepp ( since it can't flip the textures back to the original orientation ). So avoid it for eepp. + */ void SetOptions( const Uint32& MaxWidth, const Uint32& MaxHeight, const bool& ForcePowOfTwo = true, const Uint32& PixelBorder = 0, const bool& AllowFlipping = false ); + /** @return The texture atlas to generate width. */ const Int32& Width() const; + /** @return The texture atlas to generate height */ const Int32& Height() const; + /** @return If the texture atlas has already been saved, returns the file path to the texture atlas. */ const std::string& GetFilepath() const; protected: enum PackStrategy { diff --git a/include/eepp/graphics/cttffontloader.hpp b/include/eepp/graphics/cttffontloader.hpp index 9c4c19051..19bdf2025 100644 --- a/include/eepp/graphics/cttffontloader.hpp +++ b/include/eepp/graphics/cttffontloader.hpp @@ -8,10 +8,6 @@ namespace EE { namespace Graphics { -#define TTF_LT_PATH (1) -#define TTF_LT_MEM (2) -#define TTF_LT_PACK (3) - class EE_API cTTFFontLoader : public cObjectLoader { public: cTTFFontLoader( const std::string& FontName, const std::string& Filepath, const eeUint& Size, EE_TTF_FONT_STYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); @@ -20,7 +16,7 @@ class EE_API cTTFFontLoader : public cObjectLoader { cTTFFontLoader( const std::string& FontName, Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONT_STYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); - ~cTTFFontLoader(); + virtual ~cTTFFontLoader(); void Update(); @@ -30,6 +26,13 @@ class EE_API cTTFFontLoader : public cObjectLoader { cFont * Font() const; protected: + enum TTF_LOAD_TYPE + { + TTF_LT_PATH = 1, + TTF_LT_MEM = 2, + TTF_LT_PACK = 3 + }; + Uint32 mLoadType; // From memory, from path, from pack cTTFFont * mFont; diff --git a/include/eepp/graphics/cvertexbufferogl.hpp b/include/eepp/graphics/cvertexbufferogl.hpp index 8435cc9ef..7540060cd 100644 --- a/include/eepp/graphics/cvertexbufferogl.hpp +++ b/include/eepp/graphics/cvertexbufferogl.hpp @@ -5,6 +5,9 @@ namespace EE { namespace Graphics { +/** The Vertex Buffer OGL is the implementation of a Vertex Buffer without using the specific VBOs extensions from OpenGL. +* @see cVertexBuffer +*/ class EE_API cVertexBufferOGL : public cVertexBuffer { public: cVertexBufferOGL( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_MODE DrawType = DM_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); @@ -30,4 +33,3 @@ class EE_API cVertexBufferOGL : public cVertexBuffer { }} #endif - diff --git a/include/eepp/graphics/cvertexbuffervbo.hpp b/include/eepp/graphics/cvertexbuffervbo.hpp index 0e4ad649b..c38654a2d 100644 --- a/include/eepp/graphics/cvertexbuffervbo.hpp +++ b/include/eepp/graphics/cvertexbuffervbo.hpp @@ -5,6 +5,9 @@ namespace EE { namespace Graphics { +/** @brief The Vertex Buffer VBO class is the implementation of a Vertex Buffer using the GPU's VBO. + @see cVertexBuffer +*/ class EE_API cVertexBufferVBO : public cVertexBuffer { public: cVertexBufferVBO( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_MODE DrawType = DM_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); @@ -23,19 +26,14 @@ class EE_API cVertexBufferVBO : public cVertexBuffer { void Unbind(); protected: - void SetVertexStates(); - bool mCompiled; - bool mBuffersSet; - bool mTextured; - Uint32 mVAO; - Uint32 mElementHandle; - Uint32 mArrayHandle[ VERTEX_FLAGS_COUNT ]; + + void SetVertexStates(); }; }} diff --git a/include/eepp/graphics/pixelperfect.hpp b/include/eepp/graphics/pixelperfect.hpp index 03273d861..627903de7 100644 --- a/include/eepp/graphics/pixelperfect.hpp +++ b/include/eepp/graphics/pixelperfect.hpp @@ -17,7 +17,7 @@ namespace EE { namespace Graphics { * @warning Stress the CPU easily. \n Creates a copy of the texture on the app contex. \n It will not work with scaled or rotated textures. * @return True if collided */ -bool EE_API PixelPerfectCollide( cTexture * Tex1, const Uint16& x1, const Uint16& y1, cTexture * Tex2, const Uint16& x2, const Uint16& y2, const eeRectu& Tex1_SrcRECT = eeRectu(0,0,0,0), const eeRectu& Tex2_SrcRECT = eeRectu(0,0,0,0) ); +bool EE_API PixelPerfectCollide( cTexture * Tex1, const eeUint& x1, const eeUint& y1, cTexture * Tex2, const eeUint& x2, const eeUint& y2, const eeRectu& Tex1_SrcRECT = eeRectu(0,0,0,0), const eeRectu& Tex2_SrcRECT = eeRectu(0,0,0,0) ); /** Pixel Perfect Collition implementation between texture and a point * @param TexId_1 First Texture Id @@ -28,7 +28,7 @@ bool EE_API PixelPerfectCollide( cTexture * Tex1, const Uint16& x1, const Uint16 * @param Tex1_SrcRECT The sector of the texture from TexId_1 that you are rendering, the sector you want to collide ( on cSprite the SprSrcRECT ) * @return True if collided */ -bool EE_API PixelPerfectCollide( cTexture * Tex, const Uint16& x1, const Uint16& y1, const Uint16& x2, const Uint16& y2, const eeRectu& Tex1_SrcRECT = eeRectu(0,0,0,0) ); +bool EE_API PixelPerfectCollide( cTexture * Tex, const eeUint& x1, const eeUint& y1, const eeUint& x2, const eeUint& y2, const eeRectu& Tex1_SrcRECT = eeRectu(0,0,0,0) ); }} diff --git a/include/eepp/physics/cphysicsmanager.hpp b/include/eepp/physics/cphysicsmanager.hpp index df2d0876d..c9cf74a9f 100644 --- a/include/eepp/physics/cphysicsmanager.hpp +++ b/include/eepp/physics/cphysicsmanager.hpp @@ -37,8 +37,6 @@ class CP_API cPhysicsManager { cpFloat LineThickness; }; - cPhysicsManager(); - ~cPhysicsManager(); /** The Memory Manager will keep track of all the allocations from cSpace, cBody, cShape and cConstraint and will release any non-released pointer. @@ -64,6 +62,8 @@ class CP_API cPhysicsManager { std::list mConstraintFree; std::list mSpaces; + cPhysicsManager(); + void AddBodyFree( cBody * body ); void RemoveBodyFree( cBody * body ); diff --git a/include/eepp/system/cpackmanager.hpp b/include/eepp/system/cpackmanager.hpp index e9172dc9e..b5660fe9a 100644 --- a/include/eepp/system/cpackmanager.hpp +++ b/include/eepp/system/cpackmanager.hpp @@ -14,8 +14,6 @@ class EE_API cPackManager : public tContainer { SINGLETON_DECLARE_HEADERS(cPackManager) public: - cPackManager(); - virtual ~cPackManager(); /** @brief Searchs for the filepath in the packs, if the file is found it will return the pack that belongs to. @@ -39,6 +37,8 @@ class EE_API cPackManager : public tContainer { void FallbackToPacks( const bool& fallback ); protected: bool mFallback; + + cPackManager(); }; }} diff --git a/include/eepp/ui/cuimanager.hpp b/include/eepp/ui/cuimanager.hpp index 94b71285c..4e677403c 100644 --- a/include/eepp/ui/cuimanager.hpp +++ b/include/eepp/ui/cuimanager.hpp @@ -12,8 +12,6 @@ class EE_API cUIManager { SINGLETON_DECLARE_HEADERS(cUIManager) public: - cUIManager(); - ~cUIManager(); cUIWindow * MainControl() const; @@ -103,6 +101,8 @@ class EE_API cUIManager { bool mFirstPress; bool mShootingDown; + cUIManager(); + void InputCallback( InputEvent * Event ); void CheckTabPress( const Uint32& KeyCode ); diff --git a/include/eepp/ui/cuithememanager.hpp b/include/eepp/ui/cuithememanager.hpp index fd13b660e..2008aac1b 100644 --- a/include/eepp/ui/cuithememanager.hpp +++ b/include/eepp/ui/cuithememanager.hpp @@ -12,8 +12,6 @@ class EE_API cUIThemeManager : public tResourceManager { SINGLETON_DECLARE_HEADERS(cUIThemeManager) public: - cUIThemeManager(); - virtual ~cUIThemeManager(); void DefaultFont( cFont * Font ); @@ -72,6 +70,8 @@ class EE_API cUIThemeManager : public tResourceManager { bool mTooltipFollowMouse; eeSize mCursorSize; + + cUIThemeManager(); }; }} diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 2b234e857..18d50c20d 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/src/eepp/gaming/cgameobjectsubtexture.cpp b/src/eepp/gaming/cgameobjectsubtexture.cpp index 50964c5df..0de548285 100644 --- a/src/eepp/gaming/cgameobjectsubtexture.cpp +++ b/src/eepp/gaming/cgameobjectsubtexture.cpp @@ -57,9 +57,9 @@ void cGameObjectSubTexture::Draw() { GetAngle(), 1.f, LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y ) ), - LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y + mSubTexture->DestHeight() ) ), - LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestWidth(), mPos.y + mSubTexture->DestHeight() ) ), - LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestWidth(), mPos.y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y + mSubTexture->DestSize().y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestSize().x, mPos.y + mSubTexture->DestSize().y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestSize().y, mPos.y ) ), ALPHA_NORMAL, RenderModeFromFlags() ); diff --git a/src/eepp/gaming/cgameobjectsubtextureex.cpp b/src/eepp/gaming/cgameobjectsubtextureex.cpp index 0cfb58b71..d0633094b 100644 --- a/src/eepp/gaming/cgameobjectsubtextureex.cpp +++ b/src/eepp/gaming/cgameobjectsubtextureex.cpp @@ -63,9 +63,9 @@ void cGameObjectSubTextureEx::Draw() { mAngle, mScale, LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y ) ), - LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y + mSubTexture->DestHeight() ) ), - LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestWidth(), mPos.y + mSubTexture->DestHeight() ) ), - LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestWidth(), mPos.y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y + mSubTexture->DestSize().y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestSize().x, mPos.y + mSubTexture->DestSize().y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestSize().x, mPos.y ) ), mBlend, mRender ); diff --git a/src/eepp/gaming/cgameobjectvirtual.cpp b/src/eepp/gaming/cgameobjectvirtual.cpp index 8bcec901a..33e3f158a 100644 --- a/src/eepp/gaming/cgameobjectvirtual.cpp +++ b/src/eepp/gaming/cgameobjectvirtual.cpp @@ -87,9 +87,9 @@ void cGameObjectVirtual::Draw() { GetAngle(), 1.f, LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y ) ), - LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y + mSubTexture->DestHeight() ) ), - LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestWidth(), mPos.y + mSubTexture->DestHeight() ) ), - LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestWidth(), mPos.y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x, mPos.y + mSubTexture->DestSize().y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestSize().x, mPos.y + mSubTexture->DestSize().y ) ), + LM->GetColorFromPos( eeVector2f( mPos.x + mSubTexture->DestSize().x, mPos.y ) ), ALPHA_NORMAL, RenderModeFromFlags() ); diff --git a/src/eepp/gaming/cisomap.cpp b/src/eepp/gaming/cisomap.cpp index d75e1d6a1..ca4a56b7a 100755 --- a/src/eepp/gaming/cisomap.cpp +++ b/src/eepp/gaming/cisomap.cpp @@ -155,17 +155,17 @@ void cIsoMap::Draw() { if ( T != NULL ) { eeVector2f TileCenter( T->Q.V[1].x + (T->Q.V[3].x - T->Q.V[1].x) * 0.5f, T->Q.V[0].y + (T->Q.V[2].y - T->Q.V[0].y) * 0.5f ); - eeVector2f ObjPos( TileCenter.x - SubTexture->DestWidth() * 0.5f, TileCenter.y - SubTexture->DestHeight() * 0.80f ); + eeVector2f ObjPos( TileCenter.x - SubTexture->DestSize().x * 0.5f, TileCenter.y - SubTexture->DestSize().y * 0.80f ); - eeAABB LayerAABB( TileCenter.x - SubTexture->DestWidth() * 0.5f, TileCenter.y - SubTexture->DestHeight(), TileCenter.x + SubTexture->DestWidth() * 0.5f, TileCenter.y ); - eeAABB ShadowAABB( ObjPos.x, TileCenter.y - SubTexture->DestHeight(), TileCenter.x + SubTexture->DestWidth(), TileCenter.y ); + eeAABB LayerAABB( TileCenter.x - SubTexture->DestSize().x * 0.5f, TileCenter.y - SubTexture->DestSize().y, TileCenter.x + SubTexture->DestSize().x * 0.5f, TileCenter.y ); + eeAABB ShadowAABB( ObjPos.x, TileCenter.y - SubTexture->DestSize().y, TileCenter.x + SubTexture->DestSize().x, TileCenter.y ); if ( mScreenAABB.Intersect( ShadowAABB ) ) { SubTexture->Draw( mOffsetX + ObjPos.x, mOffsetY + ObjPos.y, 0, 1, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC ); } if ( mScreenAABB.Intersect( LayerAABB ) ) { - SubTexture->Draw( mOffsetX + TileCenter.x - (eeFloat)SubTexture->DestWidth() * 0.5f, mOffsetY + TileCenter.y - (eeFloat)SubTexture->DestHeight(), 0, 1, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) ); + SubTexture->Draw( mOffsetX + TileCenter.x - (eeFloat)SubTexture->DestSize().x * 0.5f, mOffsetY + TileCenter.y - (eeFloat)SubTexture->DestSize().y, 0, 1, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) ); } } } diff --git a/src/eepp/gaming/mapeditor/cmapeditor.cpp b/src/eepp/gaming/mapeditor/cmapeditor.cpp index 10ee8311b..13676c5b9 100644 --- a/src/eepp/gaming/mapeditor/cmapeditor.cpp +++ b/src/eepp/gaming/mapeditor/cmapeditor.cpp @@ -469,6 +469,10 @@ void cMapEditor::OnAddObject( Uint32 Type, eePolygon2f poly ) { return; } + if ( poly.Size() < 3 ) { + return; + } + cObjectLayer * OL = static_cast ( mCurLayer ); if ( GAMEOBJECT_TYPE_OBJECT == Type ) { @@ -965,7 +969,7 @@ void cMapEditor::MapMenuClick( const cUIEvent * Event ) { const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); if ( "New Texture Atlas..." == txt ) { - cUIWindow * tWin = mTheme->CreateWindow( NULL, eeSize( 1024, 768 ), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON, eeSize( 1024, 768 ) ); + cUIWindow * tWin = mTheme->CreateWindow( NULL, eeSize( 1024, 768 ), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_DRAGABLE_CONTAINER, eeSize( 1024, 768 ) ); eeNew ( Tools::cTextureAtlasEditor, ( tWin ) ); tWin->Center(); tWin->Show(); diff --git a/src/eepp/graphics/cframebuffermanager.hpp b/src/eepp/graphics/cframebuffermanager.hpp index 3d9cdebc4..e8869a789 100644 --- a/src/eepp/graphics/cframebuffermanager.hpp +++ b/src/eepp/graphics/cframebuffermanager.hpp @@ -10,12 +10,11 @@ class EE_API cFrameBufferManager : public tContainer { SINGLETON_DECLARE_HEADERS(cFrameBufferManager) public: - cFrameBufferManager(); - virtual ~cFrameBufferManager(); void Reload(); protected: + cFrameBufferManager(); }; }}} diff --git a/src/eepp/graphics/cscrollparallax.cpp b/src/eepp/graphics/cscrollparallax.cpp index 32d614048..25eae623a 100755 --- a/src/eepp/graphics/cscrollparallax.cpp +++ b/src/eepp/graphics/cscrollparallax.cpp @@ -126,7 +126,7 @@ void cScrollParallax::Draw() { } mSubTexture->SrcRect( Rect ); - mSubTexture->ResetDestWidthAndHeight(); + mSubTexture->ResetDestSize(); if ( !( Rect.Right == 0 || Rect.Bottom == 0 ) ) mSubTexture->Draw( AABB.Left, AABB.Top, mColor, 0.f, 1.f, mBlend ); @@ -144,7 +144,7 @@ void cScrollParallax::Draw() { } mSubTexture->SrcRect( mRect ); - mSubTexture->ResetDestWidthAndHeight(); + mSubTexture->ResetDestSize(); } } diff --git a/src/eepp/graphics/csprite.cpp b/src/eepp/graphics/csprite.cpp index 6c786c1c6..ebb85aa8a 100755 --- a/src/eepp/graphics/csprite.cpp +++ b/src/eepp/graphics/csprite.cpp @@ -71,7 +71,7 @@ cSprite::cSprite( cSubTexture * SubTexture ) : CreateStatic( SubTexture ); } -cSprite::cSprite( const Uint32& TexId, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& offSetX, const eeFloat& offSetY, const eeRecti& TexSector ) : +cSprite::cSprite( const Uint32& TexId, const eeSizef &DestSize, const eeVector2i &Offset, const eeRecti& TexSector ) : mFlags( SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_SCALE_CENTERED | SPRITE_FLAG_EVENTS_ENABLED ), mPos(), mAngle( 0.f ), @@ -89,7 +89,7 @@ cSprite::cSprite( const Uint32& TexId, const eeFloat& DestWidth, const eeFloat& mAnimTo( 0 ) { mCb.Reset(); - CreateStatic( TexId, DestWidth, DestHeight, offSetX, offSetY, TexSector ); + CreateStatic( TexId, DestSize, Offset, TexSector ); } @@ -243,14 +243,14 @@ eeAABB cSprite::GetAABB() { if ( S != NULL ) { if ( SPR_FGET( SPRITE_FLAG_SCALE_CENTERED ) ) { if ( mScale == 1.f ) { - TmpR = eeRectf( mPos.x, mPos.y, mPos.x + S->DestWidth(), mPos.y + S->DestHeight() ); + TmpR = eeRectf( mPos.x, mPos.y, mPos.x + S->DestSize().x, mPos.y + S->DestSize().y ); } else { - eeFloat halfW = S->DestWidth() * 0.5f; - eeFloat halfH = S->DestHeight() * 0.5f; + eeFloat halfW = S->DestSize().x * 0.5f; + eeFloat halfH = S->DestSize().y * 0.5f; TmpR = eeRectf( mPos.x + halfW - halfW * mScale, mPos.y + halfH - halfH * mScale, mPos.x + halfW + halfW * mScale, mPos.y + halfH + halfH * mScale ); } } else { - TmpR = eeRectf(mPos.x, mPos.y, mPos.x + S->DestWidth() * mScale, mPos.y + + S->DestHeight() * mScale); + TmpR = eeRectf(mPos.x, mPos.y, mPos.x + S->DestSize().x * mScale, mPos.y + + S->DestSize().y * mScale); } } } @@ -299,11 +299,11 @@ bool cSprite::CreateStatic( cSubTexture * SubTexture ) { return true; } -bool cSprite::CreateStatic( const Uint32& TexId, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& offSetX, const eeFloat& offSetY, const eeRecti& TexSector ) { +bool cSprite::CreateStatic( const Uint32& TexId, const eeSizef& DestSize, const eeVector2i& Offset, const eeRecti& TexSector ) { if ( cTextureFactory::instance()->TextureIdExists( TexId ) ) { Reset(); - AddFrame( TexId, DestWidth, DestHeight, offSetX, offSetY, TexSector ); + AddFrame( TexId, DestSize, Offset, TexSector ); return true; } @@ -387,16 +387,16 @@ eeUint cSprite::AddFrame( cSubTexture * SubTexture ) { return id; } -eeUint cSprite::AddFrame(const Uint32& TexId, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& offSetX, const eeFloat& offSetY, const eeRecti& TexSector) { +eeUint cSprite::AddFrame( const Uint32& TexId, const eeSizef& DestSize, const eeVector2i& Offset, const eeRecti& TexSector ) { eeUint id = FramePos(); - if ( AddSubFrame( TexId, id, mCurrentSubFrame, DestWidth, DestHeight, offSetX, offSetY, TexSector ) ) + if ( AddSubFrame( TexId, id, mCurrentSubFrame, DestSize, Offset, TexSector ) ) return id; return 0; } -bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeFloat& DestWidth, const eeFloat& DestHeight, const Int32& offSetX, const Int32& offSetY, const eeRecti& TexSector) { +bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeSizef& DestSize, const eeVector2i& Offset, const eeRecti& TexSector) { if ( !cTextureFactory::instance()->TextureIdExists( TexId ) ) return false; @@ -410,18 +410,18 @@ bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeU else S->SrcRect( eeRecti( 0, 0, (Int32)Tex->Width(), (Int32)Tex->Height() ) ); - if ( DestWidth > 0 ) - S->DestWidth( DestWidth ); - else - S->DestWidth( static_cast ( S->SrcRect().Right - S->SrcRect().Left ) ); + eeSizef destSize( DestSize ); - if ( DestHeight > 0 ) - S->DestHeight( DestHeight ); - else - S->DestHeight( static_cast ( S->SrcRect().Bottom - S->SrcRect().Top ) ); + if ( destSize.x <= 0 ) { + destSize.x = static_cast ( S->SrcRect().Right - S->SrcRect().Left ); + } - S->OffsetX( offSetX ); - S->OffsetY( offSetY ); + if ( destSize.y <= 0 ) { + destSize.y = static_cast ( S->SrcRect().Bottom - S->SrcRect().Top ); + } + + S->DestSize( destSize ); + S->Offset( Offset ); AddSubFrame( S, NumFrame, NumSubFrame ); @@ -575,77 +575,37 @@ eeUint cSprite::GetSubFrame( const eeUint& SubFrame ) { return SFN; } -Int32 cSprite::OffsetX() { +eeVector2i cSprite::Offset() { cSubTexture* S = GetCurrentSubTexture(); if ( S != NULL ) - return S->OffsetX(); + return S->Offset(); - return 0; -} - -void cSprite::OffsetX( const Int32& offsetx ) { - cSubTexture* S = GetCurrentSubTexture(); - - if ( S != NULL ) - S->OffsetX( offsetx ); -} - -Int32 cSprite::OffsetY() { - cSubTexture* S = GetCurrentSubTexture(); - - if ( S != NULL ) - return S->OffsetY(); - - return 0; -} - -void cSprite::OffsetY( const Int32& offsety ) { - cSubTexture* S = GetCurrentSubTexture(); - - if ( S != NULL ) - S->OffsetY( offsety ); + return eeVector2i(); } void cSprite::Offset( const eeVector2i& offset ) { cSubTexture* S = GetCurrentSubTexture(); if ( S != NULL ) { - S->OffsetX( offset.x ); - S->OffsetY( offset.y ); + S->Offset( offset ); } } -void cSprite::Width( const eeFloat& Width, const eeUint& FrameNum, const eeUint& SubFrame ) { - mFrames[ GetFrame(FrameNum) ].Spr[ GetSubFrame(SubFrame) ]->DestWidth( Width ); +void cSprite::Size( const eeSizef& Size, const eeUint& FrameNum, const eeUint& SubFrame ) { + mFrames[ GetFrame(FrameNum) ].Spr[ GetSubFrame(SubFrame) ]->DestSize( Size ); } -void cSprite::Width( const eeFloat& Width ) { - mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]->DestWidth( Width ); +void cSprite::Size( const eeSizef& Size ) { + mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]->DestSize( Size ); } -eeFloat cSprite::Width( const eeUint& FrameNum, const eeUint& SubFrame ) { - return mFrames[ GetFrame(FrameNum) ].Spr[ GetSubFrame(SubFrame) ]->DestWidth(); +eeSizef cSprite::Size( const eeUint& FrameNum, const eeUint& SubFrame ) { + return mFrames[ GetFrame(FrameNum) ].Spr[ GetSubFrame(SubFrame) ]->DestSize(); } -eeFloat cSprite::Width() { - return mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]->DestWidth(); -} - -void cSprite::Height( const eeFloat& Height, const eeUint& FrameNum, const eeUint& SubFrame ) { - mFrames[ GetFrame(FrameNum) ].Spr[ GetSubFrame(SubFrame) ]->DestHeight( Height ); -} - -void cSprite::Height( const eeFloat& Height ) { - mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]->DestHeight( Height ); -} - -eeFloat cSprite::Height( const eeUint& FrameNum, const eeUint& SubFrame ) { - return mFrames[ GetFrame(FrameNum) ].Spr[ GetSubFrame(SubFrame) ]->DestHeight(); -} - -eeFloat cSprite::Height() { - return mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]->DestHeight(); +eeSizef cSprite::Size() { + return mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]->DestSize(); } void cSprite::SetRepeations( const int& Repeations ) { @@ -674,14 +634,14 @@ eeQuad2f cSprite::GetQuad() { if ( SPR_FGET( SPRITE_FLAG_SCALE_CENTERED ) ) { if ( mScale == 1.0f ) - TmpR = eeRectf( mPos.x, mPos.y, mPos.x + S->DestWidth(), mPos.y + S->DestHeight() ); + TmpR = eeRectf( mPos.x, mPos.y, mPos.x + S->DestSize().x, mPos.y + S->DestSize().y ); else { - eeFloat halfW = S->DestWidth() * 0.5f; - eeFloat halfH = S->DestHeight() * 0.5f; + eeFloat halfW = S->DestSize().x * 0.5f; + eeFloat halfH = S->DestSize().y * 0.5f; TmpR = eeRectf( mPos.x + halfW - halfW * mScale, mPos.y + halfH - halfH * mScale, mPos.x + halfW + halfW * mScale, mPos.y + halfH + halfH * mScale ); } } else { - TmpR = eeRectf( mPos.x, mPos.y, mPos.x + S->DestWidth() * mScale, mPos.y + S->DestHeight() * mScale ); + TmpR = eeRectf( mPos.x, mPos.y, mPos.x + S->DestSize().x * mScale, mPos.y + S->DestSize().y * mScale ); } eeQuad2f Q = eeQuad2f( eeVector2f( TmpR.Left, TmpR.Top ), eeVector2f( TmpR.Left, TmpR.Bottom ), eeVector2f( TmpR.Right, TmpR.Bottom ), eeVector2f( TmpR.Right, TmpR.Top ) ); diff --git a/src/eepp/graphics/csubtexture.cpp b/src/eepp/graphics/csubtexture.cpp index a9fbc00c1..0439ec4ef 100644 --- a/src/eepp/graphics/csubtexture.cpp +++ b/src/eepp/graphics/csubtexture.cpp @@ -13,10 +13,8 @@ cSubTexture::cSubTexture() : mTexId(0), mTexture(NULL), mSrcRect( eeRecti(0,0,0,0) ), - mDestWidth(0), - mDestHeight(0), - mOffsetX(0), - mOffsetY(0) + mDestSize(0,0), + mOffset(0,0) { CreateUnnamed(); } @@ -29,10 +27,8 @@ cSubTexture::cSubTexture( const Uint32& TexId, const std::string& Name ) : mTexId( TexId ), mTexture( cTextureFactory::instance()->GetTexture( TexId ) ), mSrcRect( eeRecti( 0, 0, NULL != mTexture ? mTexture->Width() : 0, NULL != mTexture ? mTexture->Height() : 0 ) ), - mDestWidth( (eeFloat)mSrcRect.Size().Width() ), - mDestHeight( (eeFloat)mSrcRect.Size().Height() ), - mOffsetX(0), - mOffsetY(0) + mDestSize( (eeFloat)mSrcRect.Size().Width(), (eeFloat)mSrcRect.Size().Height() ), + mOffset(0,0) { if ( !GLi->IsExtension( EEGL_ARB_texture_non_power_of_two ) ) { mSrcRect = eeRecti( 0, 0, mTexture->ImgWidth(), mTexture->ImgHeight() ); @@ -48,16 +44,14 @@ cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const std mId( String::Hash( mName ) ), mTexId( TexId ), mTexture( cTextureFactory::instance()->GetTexture( TexId ) ), - mSrcRect(SrcRect), - mDestWidth( (eeFloat)( mSrcRect.Right - mSrcRect.Left ) ), - mDestHeight( (eeFloat)( mSrcRect.Bottom - mSrcRect.Top ) ), - mOffsetX(0), - mOffsetY(0) + mSrcRect( SrcRect ), + mDestSize( (eeFloat)( mSrcRect.Right - mSrcRect.Left ), (eeFloat)( mSrcRect.Bottom - mSrcRect.Top ) ), + mOffset(0,0) { CreateUnnamed(); } -cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name ) : +cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const std::string& Name ) : mPixels(NULL), mAlpha(NULL), mName( Name ), @@ -65,15 +59,13 @@ cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeF mTexId( TexId ), mTexture( cTextureFactory::instance()->GetTexture( TexId ) ), mSrcRect(SrcRect), - mDestWidth(DestWidth), - mDestHeight(DestHeight), - mOffsetX(0), - mOffsetY(0) + mDestSize(DestSize), + mOffset(0,0) { CreateUnnamed(); } -cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const Int32& OffsetX, const Int32& OffsetY, const std::string& Name ) : +cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const eeVector2i &Offset, const std::string& Name ) : mPixels(NULL), mAlpha(NULL), mName( Name ), @@ -81,10 +73,8 @@ cSubTexture::cSubTexture( const Uint32& TexId, const eeRecti& SrcRect, const eeF mTexId( TexId ), mTexture( cTextureFactory::instance()->GetTexture( TexId ) ), mSrcRect(SrcRect), - mDestWidth(DestWidth), - mDestHeight(DestHeight), - mOffsetX(OffsetX), - mOffsetY(OffsetY) + mDestSize(DestSize), + mOffset(Offset) { CreateUnnamed(); } @@ -134,46 +124,30 @@ void cSubTexture::SrcRect( const eeRecti& Rect ) { CacheAlphaMask(); } -const eeFloat& cSubTexture::DestWidth() const { - return mDestWidth; +const eeSizef& cSubTexture::DestSize() const { + return mDestSize; } -void cSubTexture::DestWidth( const eeFloat& width ) { - mDestWidth = width; +void cSubTexture::DestSize( const eeSizef& destSize ) { + mDestSize = destSize; } -const eeFloat& cSubTexture::DestHeight() const { - return mDestHeight; +const eeVector2i& cSubTexture::Offset() const { + return mOffset; } -void cSubTexture::DestHeight( const eeFloat& height ) { - mDestHeight = height; -} - -const Int32& cSubTexture::OffsetX() const { - return mOffsetX; -} - -void cSubTexture::OffsetX( const Int32& offsetx ) { - mOffsetX = offsetx; -} - -const Int32& cSubTexture::OffsetY() const { - return mOffsetY; -} - -void cSubTexture::OffsetY( const Int32& offsety ) { - mOffsetY = offsety; +void cSubTexture::Offset( const eeVector2i& offset ) { + mOffset = offset; } void cSubTexture::Draw( const eeFloat& X, const eeFloat& Y, const eeColorA& Color, const eeFloat& Angle, const eeFloat& Scale, const EE_BLEND_MODE& Blend, const EE_RENDER_MODE& Effect, const bool& ScaleRendered ) { if ( NULL != mTexture ) - mTexture->DrawEx( X + mOffsetX, Y + mOffsetY, mDestWidth, mDestHeight, Angle, Scale, Color, Color, Color, Color, Blend, Effect, ScaleRendered, mSrcRect ); + mTexture->DrawEx( X + mOffset.x, Y + mOffset.y, mDestSize.x, mDestSize.y, Angle, Scale, Color, Color, Color, Color, Blend, Effect, ScaleRendered, mSrcRect ); } void cSubTexture::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Angle, const eeFloat& Scale, const eeColorA& Color0, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_BLEND_MODE& Blend, const EE_RENDER_MODE& Effect, const bool& ScaleRendered ) { if ( NULL != mTexture ) - mTexture->DrawEx( X + mOffsetX, Y + mOffsetY, mDestWidth, mDestHeight, Angle, Scale, Color0, Color1, Color2, Color3, Blend, Effect, ScaleRendered, mSrcRect ); + mTexture->DrawEx( X + mOffset.x, Y + mOffset.y, mDestSize.x, mDestSize.y, Angle, Scale, Color0, Color1, Color2, Color3, Blend, Effect, ScaleRendered, mSrcRect ); } void cSubTexture::Draw( const eeQuad2f Q, const eeFloat& X, const eeFloat& Y, const eeFloat& Angle, const eeFloat& Scale, const eeColorA& Color0, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_BLEND_MODE& Blend ) { @@ -371,7 +345,7 @@ eeSize cSubTexture::RealSize() { } eeSize cSubTexture::Size() { - return eeSize( (Int32)mDestWidth, (Int32)mDestHeight ); + return eeSize( (Int32)mDestSize.x, (Int32)mDestSize.y ); } const Uint8* cSubTexture::GetPixelsPtr() { @@ -403,10 +377,10 @@ bool cSubTexture::SaveToFile(const std::string& filepath, const EE_SAVE_TYPE& Fo return Res; } -void cSubTexture::ResetDestWidthAndHeight() { +void cSubTexture::ResetDestSize() { eeSize Size = mSrcRect.Size(); - mDestWidth = (eeFloat)Size.Width(); - mDestHeight = (eeFloat)Size.Height(); + mDestSize.x = (eeFloat)Size.Width(); + mDestSize.y = (eeFloat)Size.Height(); } }} diff --git a/src/eepp/graphics/ctexture.cpp b/src/eepp/graphics/ctexture.cpp index 72538e0df..84ea2aac3 100755 --- a/src/eepp/graphics/ctexture.cpp +++ b/src/eepp/graphics/ctexture.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace EE { namespace Graphics { diff --git a/src/eepp/graphics/ctextureatlas.cpp b/src/eepp/graphics/ctextureatlas.cpp index e0d8ea4da..5e1ff64f3 100644 --- a/src/eepp/graphics/ctextureatlas.cpp +++ b/src/eepp/graphics/ctextureatlas.cpp @@ -44,12 +44,12 @@ cSubTexture * cTextureAtlas::Add( const Uint32& TexId, const eeRecti& SrcRect, c return Add( eeNew( cSubTexture, ( TexId, SrcRect, Name ) ) ); } -cSubTexture * cTextureAtlas::Add( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name ) { - return Add( eeNew ( cSubTexture, ( TexId, SrcRect, DestWidth, DestHeight, Name ) ) ); +cSubTexture * cTextureAtlas::Add( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const std::string& Name ) { + return Add( eeNew ( cSubTexture, ( TexId, SrcRect, DestSize, Name ) ) ); } -cSubTexture * cTextureAtlas::Add( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& OffsetX, const eeFloat& OffsetY, const std::string& Name ) { - return Add( eeNew ( cSubTexture, ( TexId, SrcRect, DestWidth, DestHeight, OffsetX, OffsetY, Name ) ) ); +cSubTexture * cTextureAtlas::Add( const Uint32& TexId, const eeRecti& SrcRect, const eeSizef& DestSize, const eeVector2i& Offset, const std::string& Name ) { + return Add( eeNew ( cSubTexture, ( TexId, SrcRect, DestSize, Offset, Name ) ) ); } Uint32 cTextureAtlas::Count() { diff --git a/src/eepp/graphics/ctextureatlasloader.cpp b/src/eepp/graphics/ctextureatlasloader.cpp index 09eea8727..f9ebc3f0f 100644 --- a/src/eepp/graphics/ctextureatlasloader.cpp +++ b/src/eepp/graphics/ctextureatlasloader.cpp @@ -230,7 +230,7 @@ void cTextureAtlasLoader::CreateSubTextures() { eeRecti tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height ); - cSubTexture * tSubTexture = eeNew( cSubTexture, ( tTex->Id(), tRect, (eeFloat)tSh->DestWidth, (eeFloat)tSh->DestHeight, tSh->OffsetX, tSh->OffsetY, SubTextureName ) ); + cSubTexture * tSubTexture = eeNew( cSubTexture, ( tTex->Id(), tRect, eeSizef( (eeFloat)tSh->DestWidth, (eeFloat)tSh->DestHeight ), eeVector2i( tSh->OffsetX, tSh->OffsetY ), SubTextureName ) ); //if ( tSh->Flags & HDR_SUBTEXTURE_FLAG_FLIPED ) // Should rotate the sub texture, but.. sub texture rotation is not stored. @@ -297,10 +297,10 @@ bool cTextureAtlasLoader::UpdateTextureAtlas() { cSubTexture * tSubTexture = mTextureAtlas->GetById( tSh->ResourceID ); if ( NULL != tSubTexture ) { - tSh->OffsetX = tSubTexture->OffsetX(); - tSh->OffsetY = tSubTexture->OffsetY(); - tSh->DestWidth = (Int32)tSubTexture->DestWidth(); - tSh->DestHeight = (Int32)tSubTexture->DestHeight(); + tSh->OffsetX = tSubTexture->Offset().x; + tSh->OffsetY = tSubTexture->Offset().x; + tSh->DestWidth = (Int32)tSubTexture->DestSize().x; + tSh->DestHeight = (Int32)tSubTexture->DestSize().x; } } } diff --git a/src/eepp/graphics/cvertexbuffermanager.hpp b/src/eepp/graphics/cvertexbuffermanager.hpp index a20c89692..eb6efe04d 100644 --- a/src/eepp/graphics/cvertexbuffermanager.hpp +++ b/src/eepp/graphics/cvertexbuffermanager.hpp @@ -10,12 +10,11 @@ class EE_API cVertexBufferManager : public tContainer { SINGLETON_DECLARE_HEADERS(cVertexBufferManager) public: - cVertexBufferManager(); - virtual ~cVertexBufferManager(); void Reload(); protected: + cVertexBufferManager(); }; }}} diff --git a/src/eepp/graphics/pixelperfect.cpp b/src/eepp/graphics/pixelperfect.cpp index ab0805bae..d284c4dc5 100644 --- a/src/eepp/graphics/pixelperfect.cpp +++ b/src/eepp/graphics/pixelperfect.cpp @@ -2,34 +2,34 @@ namespace EE { namespace Graphics { -bool PixelPerfectCollide( cTexture * Tex1, const Uint16& x1, const Uint16& y1, cTexture * Tex2, const Uint16& x2, const Uint16& y2, const eeRectu& Tex1_SrcRECT, const eeRectu& Tex2_SrcRECT ) { +bool PixelPerfectCollide( cTexture * Tex1, const eeUint& x1, const eeUint& y1, cTexture * Tex2, const eeUint& x2, const eeUint& y2, const eeRectu& Tex1_SrcRECT, const eeRectu& Tex2_SrcRECT ) { eeASSERT( NULL != Tex1 && NULL != Tex2 ); - Uint16 ax1, ay1, ax2, ay2, bx1, by1, bx2, by2; + eeUint ax1, ay1, ax2, ay2, bx1, by1, bx2, by2; bool Collide = false; ax1 = x1; ay1 = y1; if (Tex1_SrcRECT.Right != 0 && Tex1_SrcRECT.Bottom != 0) { - ax2 = ax1 + (Uint16)Tex1_SrcRECT.Right - (Uint16)Tex1_SrcRECT.Left - 1; - ay2 = ay1 + (Uint16)Tex1_SrcRECT.Bottom - (Uint16)Tex1_SrcRECT.Top - 1; + ax2 = ax1 + Tex1_SrcRECT.Right - Tex1_SrcRECT.Left - 1; + ay2 = ay1 + Tex1_SrcRECT.Bottom - Tex1_SrcRECT.Top - 1; } else { - ax2 = ax1 + (Uint16)Tex1->Width() - 1; - ay2 = ay1 + (Uint16)Tex1->Height() - 1; + ax2 = ax1 + Tex1->Width() - 1; + ay2 = ay1 + Tex1->Height() - 1; } bx1 = x2; by1 = y2; if (Tex2_SrcRECT.Right != 0 && Tex2_SrcRECT.Bottom != 0) { - bx2 = bx1 + (Uint16)Tex2_SrcRECT.Right - (Uint16)Tex2_SrcRECT.Left - 1; - by2 = by1 + (Uint16)Tex2_SrcRECT.Bottom - (Uint16)Tex2_SrcRECT.Top - 1; + bx2 = bx1 + Tex2_SrcRECT.Right - Tex2_SrcRECT.Left - 1; + by2 = by1 + Tex2_SrcRECT.Bottom - Tex2_SrcRECT.Top - 1; } else { - bx2 = bx1 + (Uint16)Tex2->Width() - 1; - by2 = by1 + (Uint16)Tex2->Height() - 1; + bx2 = bx1 + Tex2->Width() - 1; + by2 = by1 + Tex2->Height() - 1; } if ( !(ax1 > bx2 || ax2 < bx1 || ay1 > by2 || ay2 < by1) ) { - Uint16 inter_x0, inter_x1, inter_y0, inter_y1; + eeUint inter_x0, inter_x1, inter_y0, inter_y1; Tex1->Lock(); Tex2->Lock(); @@ -40,8 +40,8 @@ bool PixelPerfectCollide( cTexture * Tex1, const Uint16& x1, const Uint16& y1, c inter_y1 = eemin(ay2,by2); eeColorA C1, C2; - for(Uint16 y = inter_y0 ; y <= inter_y1 ; y++) { - for(Uint16 x = inter_x0 ; x <= inter_x1 ; x++) { + for(eeUint y = inter_y0 ; y <= inter_y1 ; y++) { + for(eeUint x = inter_x0 ; x <= inter_x1 ; x++) { if (Tex1_SrcRECT.Right != 0 && Tex1_SrcRECT.Bottom != 0) C1 = Tex1->GetPixel( x - x1 + Tex1_SrcRECT.Left, y - y1 + Tex1_SrcRECT.Top ); else @@ -65,20 +65,20 @@ bool PixelPerfectCollide( cTexture * Tex1, const Uint16& x1, const Uint16& y1, c return Collide; } -bool PixelPerfectCollide( cTexture * Tex, const Uint16& x1, const Uint16& y1, const Uint16& x2, const Uint16& y2, const eeRectu& Tex1_SrcRECT) { +bool PixelPerfectCollide( cTexture * Tex, const eeUint& x1, const eeUint& y1, const eeUint& x2, const eeUint& y2, const eeRectu& Tex1_SrcRECT) { eeASSERT( NULL != Tex ); - Uint16 ax1, ay1, ax2, ay2; + eeUint ax1, ay1, ax2, ay2; bool Collide = false; ax1 = x1; ay1 = y1; if (Tex1_SrcRECT.Right != 0 && Tex1_SrcRECT.Bottom != 0) { - ax2 = ax1 + (Uint16)Tex1_SrcRECT.Right - (Uint16)Tex1_SrcRECT.Left - 1; - ay2 = ay1 + (Uint16)Tex1_SrcRECT.Bottom - (Uint16)Tex1_SrcRECT.Top - 1; + ax2 = ax1 + Tex1_SrcRECT.Right - Tex1_SrcRECT.Left - 1; + ay2 = ay1 + Tex1_SrcRECT.Bottom - Tex1_SrcRECT.Top - 1; } else { - ax2 = ax1 + (Uint16)Tex->Width() - 1; - ay2 = ay1 + (Uint16)Tex->Height() - 1; + ax2 = ax1 + Tex->Width() - 1; + ay2 = ay1 + Tex->Height() - 1; } if ( !( ax1 >= x2 && ax2 <= x2 && ay1 >= y2 && ay2 <= y2 ) ) { diff --git a/src/eepp/physics/cshapecirclesprite.cpp b/src/eepp/physics/cshapecirclesprite.cpp index 59f777f0a..4154ea472 100644 --- a/src/eepp/physics/cshapecirclesprite.cpp +++ b/src/eepp/physics/cshapecirclesprite.cpp @@ -32,10 +32,8 @@ void cShapeCircleSprite::Draw( cSpace * space ) { } void cShapeCircleSprite::OffsetSet() { - mSprite->Width( cShapeCircle::Radius() * 2 ); - mSprite->Height( cShapeCircle::Radius() * 2 ); - mSprite->OffsetX( -cShapeCircle::Radius() + cShapeCircle::Offset().x ); - mSprite->OffsetY( -cShapeCircle::Radius() + cShapeCircle::Offset().y ); + mSprite->Size( eeSizef( cShapeCircle::Radius() * 2, cShapeCircle::Radius() * 2 ) ); + mSprite->Offset( eeVector2i( -cShapeCircle::Radius() + cShapeCircle::Offset().x, -cShapeCircle::Radius() + cShapeCircle::Offset().y ) ); } cSprite * cShapeCircleSprite::GetSprite() const { diff --git a/src/eepp/physics/cshapepolysprite.cpp b/src/eepp/physics/cshapepolysprite.cpp index f68334bc4..4346b4707 100644 --- a/src/eepp/physics/cshapepolysprite.cpp +++ b/src/eepp/physics/cshapepolysprite.cpp @@ -27,8 +27,7 @@ cShapePolySprite::cShapePolySprite( cBody * body, cpFloat width, cpFloat height, mSprite( Sprite ), mSpriteAutoDelete( AutoDeleteSprite ) { - mSprite->Width( width ); - mSprite->Height( height ); + mSprite->Size( eeSizef( width, height ) ); OffsetSet( cVectNew( width / 2, height / 2 ) ); } @@ -47,7 +46,7 @@ void cShapePolySprite::Draw( cSpace * space ) { } void cShapePolySprite::OffsetSet( cVect center ) { - cVect myCenter = cVectNew( ( mSprite->Width() / 2 ), ( mSprite->Height() / 2 ) ); + cVect myCenter = cVectNew( ( mSprite->Size().x / 2 ), ( mSprite->Size().y / 2 ) ); mOffset = eeVector2i( (Int32)( -myCenter.x + ( center.x - myCenter.x ) ) , (Int32)( -myCenter.y + ( center.y - myCenter.y ) ) ); } diff --git a/src/eepp/ui/cuigfx.cpp b/src/eepp/ui/cuigfx.cpp index ec03404cc..0182b39e3 100644 --- a/src/eepp/ui/cuigfx.cpp +++ b/src/eepp/ui/cuigfx.cpp @@ -50,53 +50,41 @@ void cUIGfx::Draw() { if ( mVisible ) { if ( NULL != mSubTexture && 0.f != mAlpha ) { - eeFloat oDestWidth = mSubTexture->DestWidth(); - eeFloat oDestHeight = mSubTexture->DestHeight(); - Int32 oOffX = mSubTexture->OffsetX(); - Int32 oOffY = mSubTexture->OffsetY(); + eeSizef oDestSize = mSubTexture->DestSize(); + eeVector2i oOff = mSubTexture->Offset(); if ( mFlags & UI_FIT_TO_CONTROL ) { - mSubTexture->OffsetX( 0 ); - mSubTexture->OffsetY( 0 ); - - mSubTexture->DestWidth( (eeFloat)mSize.x ); - mSubTexture->DestHeight( (eeFloat)mSize.y ); + mSubTexture->Offset( eeVector2i( 0, 0 ) ); + mSubTexture->DestSize( eeVector2f( mSize.x, mSize.y ) ); DrawSubTexture(); - mSubTexture->DestWidth( oDestWidth ); - mSubTexture->DestHeight( oDestHeight ); - - mSubTexture->OffsetX( oOffX ); - mSubTexture->OffsetY( oOffY ); + mSubTexture->DestSize( oDestSize ); + mSubTexture->Offset( oOff ); } else if ( mFlags & UI_AUTO_FIT ) { - mSubTexture->OffsetX( 0 ); - mSubTexture->OffsetY( 0 ); + mSubTexture->Offset( eeVector2i( 0, 0 ) ); - eeFloat Scale1 = mSize.x / oDestWidth; - eeFloat Scale2 = mSize.y / oDestHeight; + eeFloat Scale1 = mSize.x / oDestSize.x; + eeFloat Scale2 = mSize.y / oDestSize.y; if ( Scale1 < 1 || Scale2 < 1 ) { if ( Scale2 < Scale1 ) Scale1 = Scale2; - mSubTexture->DestWidth( oDestWidth * Scale1 ); - mSubTexture->DestHeight( oDestHeight * Scale1 ); + mSubTexture->DestSize( eeSizef( oDestSize.x * Scale1, oDestSize.y * Scale1 ) ); AutoAlign(); DrawSubTexture(); - mSubTexture->DestWidth( oDestWidth ); - mSubTexture->DestHeight( oDestHeight ); + mSubTexture->DestSize( oDestSize ); AutoAlign(); } else { DrawSubTexture(); } - mSubTexture->OffsetX( oOffX ); - mSubTexture->OffsetY( oOffY ); + mSubTexture->Offset( oOff ); } else { DrawSubTexture(); } @@ -139,17 +127,17 @@ void cUIGfx::AutoAlign() { return; if ( HAlignGet( mFlags ) == UI_HALIGN_CENTER ) { - mAlignOffset.x = mSize.Width() / 2 - mSubTexture->DestWidth() / 2; + mAlignOffset.x = mSize.Width() / 2 - mSubTexture->DestSize().x / 2; } else if ( FontHAlignGet( mFlags ) == UI_HALIGN_RIGHT ) { - mAlignOffset.x = mSize.Width() - mSubTexture->DestWidth(); + mAlignOffset.x = mSize.Width() - mSubTexture->DestSize().x; } else { mAlignOffset.x = 0; } if ( VAlignGet( mFlags ) == UI_VALIGN_CENTER ) { - mAlignOffset.y = mSize.Height() / 2 - mSubTexture->DestHeight() / 2; + mAlignOffset.y = mSize.Height() / 2 - mSubTexture->DestSize().y / 2; } else if ( FontVAlignGet( mFlags ) == UI_VALIGN_BOTTOM ) { - mAlignOffset.y = mSize.Height() - mSubTexture->DestHeight(); + mAlignOffset.y = mSize.Height() - mSubTexture->DestSize().y; } else { mAlignOffset.y = 0; } diff --git a/src/eepp/ui/cuiskincomplex.cpp b/src/eepp/ui/cuiskincomplex.cpp index 5bf18347a..131a89287 100644 --- a/src/eepp/ui/cuiskincomplex.cpp +++ b/src/eepp/ui/cuiskincomplex.cpp @@ -79,11 +79,11 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi tSubTexture = mSubTexture[ State ][ Left ]; if ( NULL != tSubTexture ) { - tSubTexture->DestHeight( Height - uls.Height() - dls.Height() ); + tSubTexture->DestSize( eeSizef( tSubTexture->DestSize().x, Height - uls.Height() - dls.Height() ) ); tSubTexture->Draw( X, Y + uls.Height(), mTempColor ); - tSubTexture->ResetDestWidthAndHeight(); + tSubTexture->ResetDestSize(); if ( uls.Width() == 0 ) uls.x = tSubTexture->RealSize().Width(); @@ -92,11 +92,11 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi tSubTexture = mSubTexture[ State ][ Up ]; if ( NULL != tSubTexture ) { - tSubTexture->DestWidth( Width - uls.Width() - urs.Width() ); + tSubTexture->DestSize( eeSizef( Width - uls.Width() - urs.Width(), tSubTexture->DestSize().y ) ); tSubTexture->Draw( X + uls.Width(), Y, mTempColor ); - tSubTexture->ResetDestWidthAndHeight(); + tSubTexture->ResetDestSize(); if ( urs.Height() == 0 ) urs.y = tSubTexture->RealSize().Height(); @@ -111,21 +111,21 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( urs.Width() == 0 ) urs.x = tSubTexture->RealSize().Width(); - tSubTexture->DestHeight( Height - urs.Height() - drs.Height() ); + tSubTexture->DestSize( eeSizef( tSubTexture->DestSize().x, Height - urs.Height() - drs.Height() ) ); tSubTexture->Draw( X + Width - tSubTexture->RealSize().Width(), Y + urs.Height(), mTempColor ); - tSubTexture->ResetDestWidthAndHeight(); + tSubTexture->ResetDestSize(); } tSubTexture = mSubTexture[ State ][ Down ]; if ( NULL != tSubTexture ) { - tSubTexture->DestWidth( Width - dls.Width() - drs.Width() ); + tSubTexture->DestSize( eeSizef( Width - dls.Width() - drs.Width(), tSubTexture->DestSize().y ) ); tSubTexture->Draw( X + dls.Width(), Y + Height - tSubTexture->RealSize().Height(), mTempColor ); - tSubTexture->ResetDestWidthAndHeight(); + tSubTexture->ResetDestSize(); if ( dls.Height() == 0 && drs.Height() == 0 ) dls.Height( tSubTexture->RealSize().Height() ); @@ -134,12 +134,11 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi tSubTexture = mSubTexture[ State ][ Center ]; if ( NULL != tSubTexture ) { - tSubTexture->DestWidth( Width - uls.Width() - urs.Width() ); - tSubTexture->DestHeight( Height - uls.Height() - dls.Height() ); + tSubTexture->DestSize( eeSizef( Width - uls.Width() - urs.Width(), Height - uls.Height() - dls.Height() ) ); tSubTexture->Draw( X + uls.Width(), Y + uls.Height(), mTempColor ); - tSubTexture->ResetDestWidthAndHeight(); + tSubTexture->ResetDestSize(); } } diff --git a/src/eepp/ui/cuiskinsimple.cpp b/src/eepp/ui/cuiskinsimple.cpp index d6d707d70..ec8d5e7e2 100644 --- a/src/eepp/ui/cuiskinsimple.cpp +++ b/src/eepp/ui/cuiskinsimple.cpp @@ -23,8 +23,7 @@ void cUISkinSimple::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wid mTempColor = mColor[ State ]; if ( NULL != tSubTexture ) { - tSubTexture->DestWidth( Width ); - tSubTexture->DestHeight( Height ); + tSubTexture->DestSize( eeSizef( Width, Height ) ); if ( mTempColor.Alpha != Alpha ) { mTempColor.Alpha = (Uint8)( (eeFloat)mTempColor.Alpha * ( (eeFloat)Alpha / 255.f ) ); @@ -32,7 +31,7 @@ void cUISkinSimple::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wid tSubTexture->Draw( X, Y, mTempColor ); - tSubTexture->ResetDestWidthAndHeight(); + tSubTexture->ResetDestSize(); } } diff --git a/src/eepp/ui/tools/ctextureatlaseditor.cpp b/src/eepp/ui/tools/ctextureatlaseditor.cpp index 23ff0e98d..47e000232 100644 --- a/src/eepp/ui/tools/ctextureatlaseditor.cpp +++ b/src/eepp/ui/tools/ctextureatlaseditor.cpp @@ -136,8 +136,8 @@ void cTextureAtlasEditor::OnResetDestSize( const cUIEvent * Event ) { if ( NULL != mCurSubTexture && MouseEvent->Flags() & EE_BUTTON_LMASK ) { eeSize RealSize = mCurSubTexture->RealSize(); - mCurSubTexture->DestWidth( RealSize.Width() ); - mCurSubTexture->DestHeight( RealSize.Height() ); + mCurSubTexture->ResetDestSize(); + mSpinDestW->Value( RealSize.Width() ); mSpinDestH->Value( RealSize.Height() ); } @@ -156,7 +156,7 @@ void cTextureAtlasEditor::OnCenterOffset( const cUIEvent * Event ) { const cUIEventMouse * MouseEvent = reinterpret_cast ( Event ); if ( NULL != mCurSubTexture && MouseEvent->Flags() & EE_BUTTON_LMASK ) { - eeSize NSize( -( (Int32)mCurSubTexture->DestWidth() / 2 ), -( (Int32)mCurSubTexture->DestHeight() / 2 ) ); + eeSize NSize( -( (Int32)mCurSubTexture->DestSize().x / 2 ), -( (Int32)mCurSubTexture->DestSize().y / 2 ) ); mSpinOffX->Value( NSize.x ); mSpinOffY->Value( NSize.y ); @@ -167,7 +167,7 @@ void cTextureAtlasEditor::OnHBOffset( const cUIEvent * Event ) { const cUIEventMouse * MouseEvent = reinterpret_cast ( Event ); if ( NULL != mCurSubTexture && MouseEvent->Flags() & EE_BUTTON_LMASK ) { - eeSize NSize( -( (Int32)mCurSubTexture->DestWidth() / 2 ), -(Int32)mCurSubTexture->DestHeight() ); + eeSize NSize( -( (Int32)mCurSubTexture->DestSize().x / 2 ), -(Int32)mCurSubTexture->DestSize().y ); mSpinOffX->Value( NSize.x ); mSpinOffY->Value( NSize.y ); @@ -176,25 +176,25 @@ void cTextureAtlasEditor::OnHBOffset( const cUIEvent * Event ) { void cTextureAtlasEditor::OnOffXChange( const cUIEvent * Event ) { if ( NULL != mCurSubTexture ) { - mCurSubTexture->OffsetX( (Int32)mSpinOffX->Value() ); + mCurSubTexture->Offset( eeVector2i( (Int32)mSpinOffX->Value(), mCurSubTexture->Offset().y ) ); } } void cTextureAtlasEditor::OnOffYChange( const cUIEvent * Event ) { if ( NULL != mCurSubTexture ) { - mCurSubTexture->OffsetY( (Int32)mSpinOffY->Value() ); + mCurSubTexture->Offset( eeVector2i( mCurSubTexture->Offset().x, (Int32)mSpinOffY->Value() ) ); } } void cTextureAtlasEditor::OnDestWChange( const cUIEvent * Event ) { if ( NULL != mCurSubTexture ) { - mCurSubTexture->DestWidth( (Int32)mSpinDestW->Value() ); + mCurSubTexture->DestSize( eeSizef( (Int32)mSpinDestW->Value(), mCurSubTexture->DestSize().y ) ); } } void cTextureAtlasEditor::OnDestHChange( const cUIEvent * Event ) { if ( NULL != mCurSubTexture ) { - mCurSubTexture->DestHeight( (Int32)mSpinDestH->Value() ); + mCurSubTexture->DestSize( eeSizef( mCurSubTexture->DestSize().x, (Int32)mSpinDestH->Value() ) ); } } @@ -315,10 +315,10 @@ void cTextureAtlasEditor::OnSubTextureChange( const cUIEvent * Event ) { if ( NULL != mCurSubTexture ) { mSubTextureEditor->SubTexture( mCurSubTexture ); - mSpinOffX->Value( mCurSubTexture->OffsetX() ); - mSpinOffY->Value( mCurSubTexture->OffsetY() ); - mSpinDestW->Value( mCurSubTexture->DestWidth() ); - mSpinDestH->Value( mCurSubTexture->DestHeight() ); + mSpinOffX->Value( mCurSubTexture->Offset().x ); + mSpinOffY->Value( mCurSubTexture->Offset().y ); + mSpinDestW->Value( mCurSubTexture->DestSize().x ); + mSpinDestH->Value( mCurSubTexture->DestSize().y ); } } } diff --git a/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp b/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp index 0be3019c4..21930a112 100644 --- a/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp +++ b/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp @@ -49,11 +49,10 @@ void cTextureAtlasSubTextureEditor::Update() { if ( NULL != mGfx->SubTexture() && mDrag->DragEnable() && mDrag->Dragging() && Pos != mDrag->Pos() ) { eeVector2i Diff = -( Pos - mDrag->Pos() ); - mGfx->SubTexture()->OffsetX( mGfx->SubTexture()->OffsetX() + Diff.x ); - mGfx->SubTexture()->OffsetY( mGfx->SubTexture()->OffsetY() + Diff.y ); + mGfx->SubTexture()->Offset( eeVector2i( mGfx->SubTexture()->Offset().x + Diff.x, mGfx->SubTexture()->Offset().y + Diff.y ) ); - mEditor->SpinOffX()->Value( mGfx->SubTexture()->OffsetX() ); - mEditor->SpinOffY()->Value( mGfx->SubTexture()->OffsetY() ); + mEditor->SpinOffX()->Value( mGfx->SubTexture()->Offset().x ); + mEditor->SpinOffY()->Value( mGfx->SubTexture()->Offset().y ); } mGfx->Pos( mUICenter ); diff --git a/src/eepp/window/inputhelper.cpp b/src/eepp/window/inputhelper.cpp index fe2f33c1a..884033201 100644 --- a/src/eepp/window/inputhelper.cpp +++ b/src/eepp/window/inputhelper.cpp @@ -64,6 +64,8 @@ Uint32 eeConvertKeyCharacter( const Uint32& KeyCode, const Uint16& Unicode, cons default: break; } +/** @TODO: Report SDL2 bug not reporting Key Modifiers correctly. */ +#ifndef EE_SDL_VERSION_2 if ( !( Modifiers & KEYMOD_NUM ) ) { switch ( KeyCode ) { case KEY_KP0: value = KEY_INSERT; break; @@ -79,6 +81,7 @@ Uint32 eeConvertKeyCharacter( const Uint32& KeyCode, const Uint16& Unicode, cons default: break; } } +#endif return value; } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index c646d1c93..173eb985c 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -858,7 +858,7 @@ void cEETest::LoadTextures() { for ( Int32 my = 0; my < 4; my++ ) for( Int32 mx = 0; mx < 8; mx++ ) - SP.AddFrame( TN[4], 0, 0, 0, 0, eeRecti( mx * 64, my * 64, mx * 64 + 64, my * 64 + 64 ) ); + SP.AddFrame( TN[4], eeSizef( 0, 0 ), eeVector2i( 0, 0 ), eeRecti( mx * 64, my * 64, mx * 64 + 64, my * 64 + 64 ) ); PS[0].SetCallbackReset( cb::Make2( this, &cEETest::ParticlesCallback ) ); PS[0].Create( PSE_Callback, 500, TN[5], eeVector2f( 0, 0 ), 16, true ); @@ -904,13 +904,10 @@ void cEETest::LoadTextures() { CL1.Position( 500, 400 ); CL1.Scale( 0.5f ); - CL2.AddFrame(TN[0], 96, 96); + CL2.AddFrame(TN[0], eeSizef(96, 96) ); CL2.Color( eeColorA( 255, 255, 255, 255 ) ); - int x, y, c; - - if ( cImage::GetInfo( MyPath + "extra/bnb.png", &x, &y, &c ) ) - { + if ( cImage::IsImage( MyPath + "extra/bnb.png" ) ) { mTGL = eeNew( cTextureAtlasLoader, ( MyPath + "extra/bnb" + EE_TEXTURE_ATLAS_EXTENSION ) ); }