From 40086e3bc3b701aa16ed0a586a1e7a7e72d8a79a Mon Sep 17 00:00:00 2001 From: "spartanj@gmail.com" Date: Sat, 1 Dec 2012 20:06:11 -0300 Subject: [PATCH] Added BlendMode class to set the blend mode, since it doesn't make sense to control the blend mode in the texture factory. Added Clear() method to cWindow, to allow the user to control WHEN clear the buffers. Added some operators to eeColorA. Fixed BlendMode for FBO's. Hided cTexture constructors, the only class that it's allowed to create textures is cTextureFactory. --- include/eepp/ee.hpp | 1 + .../eepp/gaming/cgameobjectsubtextureex.hpp | 4 +- include/eepp/graphics.hpp | 1 + include/eepp/graphics/base.hpp | 8 +- include/eepp/graphics/blendmode.hpp | 30 +++++ include/eepp/graphics/cbatchrenderer.hpp | 6 +- include/eepp/graphics/cfont.hpp | 8 +- include/eepp/graphics/cparticlesystem.hpp | 6 +- include/eepp/graphics/cprimitives.hpp | 41 ++++--- include/eepp/graphics/cscrollparallax.hpp | 13 +- include/eepp/graphics/cshaderprogram.hpp | 1 - include/eepp/graphics/csprite.hpp | 10 +- include/eepp/graphics/csubtexture.hpp | 6 +- include/eepp/graphics/ctextcache.hpp | 2 +- include/eepp/graphics/ctexture.hpp | 66 +++++----- include/eepp/graphics/ctextureatlas.hpp | 2 - include/eepp/graphics/ctexturefactory.hpp | 27 +--- include/eepp/graphics/ctexturefont.hpp | 23 +++- include/eepp/graphics/renderer/cgl.hpp | 3 +- include/eepp/graphics/renders.hpp | 6 +- include/eepp/system/colors.hpp | 115 ++++++++++++++---- include/eepp/ui/cuibackground.hpp | 10 +- include/eepp/ui/cuicomplexcontrol.hpp | 2 +- include/eepp/ui/cuicontrol.hpp | 8 +- include/eepp/window/cengine.hpp | 4 +- include/eepp/window/cwindow.hpp | 13 +- projects/linux/ee.creator.user | 12 +- projects/linux/ee.files | 2 + src/eepp/gaming/cgameobjectsubtextureex.cpp | 2 +- src/eepp/gaming/cobjectlayer.cpp | 1 + src/eepp/gaming/ctilelayer.cpp | 1 + src/eepp/graphics/blendmode.cpp | 67 ++++++++++ src/eepp/graphics/cbatchrenderer.cpp | 5 +- src/eepp/graphics/cfont.cpp | 13 +- src/eepp/graphics/cimage.cpp | 2 +- src/eepp/graphics/cparticlesystem.cpp | 10 +- src/eepp/graphics/cprimitives.cpp | 50 ++++---- src/eepp/graphics/cscrollparallax.cpp | 4 +- src/eepp/graphics/csprite.cpp | 8 +- src/eepp/graphics/csubtexture.cpp | 13 +- src/eepp/graphics/ctextcache.cpp | 3 +- src/eepp/graphics/ctexture.cpp | 24 ++-- src/eepp/graphics/ctexturefactory.cpp | 59 +-------- src/eepp/graphics/ctexturefont.cpp | 1 + src/eepp/graphics/ctextureloader.cpp | 1 + src/eepp/graphics/cttffont.cpp | 1 + src/eepp/graphics/renderer/cgl.cpp | 2 + src/eepp/physics/cspace.cpp | 2 +- src/eepp/ui/cuibackground.cpp | 8 +- src/eepp/ui/cuicontrol.cpp | 6 +- src/eepp/window/cengine.cpp | 2 +- src/eepp/window/cwindow.cpp | 12 +- src/examples/empty_window/empty_window.cpp | 27 ++-- .../external_shader/external_shader.cpp | 4 +- src/test/eetest.cpp | 2 +- 55 files changed, 447 insertions(+), 313 deletions(-) create mode 100644 include/eepp/graphics/blendmode.hpp create mode 100644 src/eepp/graphics/blendmode.cpp diff --git a/include/eepp/ee.hpp b/include/eepp/ee.hpp index 0fe9941da..cda6d7d51 100755 --- a/include/eepp/ee.hpp +++ b/include/eepp/ee.hpp @@ -22,6 +22,7 @@ **/ /** + @TODO Add PVRTC and ETC support. @TODO Check for endianness problems, and make EEPP endianness agnostic. @TODO Support for Android ( work in progress, it's working ) and iOS. @TODO Add Scripting support ( squirrel or angel script ). diff --git a/include/eepp/gaming/cgameobjectsubtextureex.hpp b/include/eepp/gaming/cgameobjectsubtextureex.hpp index 5b4fa7d8d..d339acfa4 100644 --- a/include/eepp/gaming/cgameobjectsubtextureex.hpp +++ b/include/eepp/gaming/cgameobjectsubtextureex.hpp @@ -8,7 +8,7 @@ namespace EE { namespace Gaming { class EE_API cGameObjectSubTextureEx : public cGameObjectSubTexture { public: - cGameObjectSubTextureEx( const Uint32& Flags, cLayer * Layer, cSubTexture * SubTexture = NULL, const eeVector2f& Pos = eeVector2f(), EE_PRE_BLEND_FUNC Blend = ALPHA_NORMAL, EE_RENDERTYPE Render = RN_NORMAL, eeFloat Angle = 0.f, eeFloat Scale = 1.f, eeColorA Color = eeColorA() ); + cGameObjectSubTextureEx( const Uint32& Flags, cLayer * Layer, cSubTexture * SubTexture = NULL, const eeVector2f& Pos = eeVector2f(), EE_BLEND_MODE Blend = ALPHA_NORMAL, EE_RENDERTYPE Render = RN_NORMAL, eeFloat Angle = 0.f, eeFloat Scale = 1.f, eeColorA Color = eeColorA() ); virtual ~cGameObjectSubTextureEx(); @@ -20,7 +20,7 @@ class EE_API cGameObjectSubTextureEx : public cGameObjectSubTexture { virtual void FlagSet( const Uint32& Flag ); protected: - EE_PRE_BLEND_FUNC mBlend; + EE_BLEND_MODE mBlend; EE_RENDERTYPE mRender; eeFloat mAngle; eeFloat mScale; diff --git a/include/eepp/graphics.hpp b/include/eepp/graphics.hpp index fbfb8bf21..1ef9a3ae5 100644 --- a/include/eepp/graphics.hpp +++ b/include/eepp/graphics.hpp @@ -1,6 +1,7 @@ #ifndef EEPP_GRAPHICS_HPP #define EEPP_GRAPHICS_HPP +#include #include #include #include diff --git a/include/eepp/graphics/base.hpp b/include/eepp/graphics/base.hpp index e454ec850..e8ddbaa07 100644 --- a/include/eepp/graphics/base.hpp +++ b/include/eepp/graphics/base.hpp @@ -104,7 +104,6 @@ #define glBindRenderbufferEXT glBindRenderbuffer #define glFramebufferRenderbufferEXT glFramebufferRenderbuffer #define glFramebufferTexture2DEXT glFramebufferTexture2D - #define glVertexAttribPointerARB glVertexAttribPointer #endif @@ -137,6 +136,8 @@ #define GL_POINT_SPRITE 0x8861 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define glBlendFuncSeparateEXT glBlendFuncSeparate + #endif #if defined( EE_GLES1 ) && !defined( EE_GLES2 ) || defined( EE_GLES_BOTH ) @@ -164,6 +165,7 @@ #define glBindRenderbufferEXT glBindRenderbufferOES #define glFramebufferRenderbufferEXT glFramebufferRenderbufferOES #define glFramebufferTexture2DEXT glFramebufferTexture2DOES +#define glBlendFuncSeparateEXT glBlendFuncSeparateOES #define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES @@ -237,7 +239,8 @@ #define EE_QUAD_VERTEX 4 #endif - +#include +#include #include #include #include @@ -257,5 +260,6 @@ using namespace EE::Math; using namespace EE::System; #include +#include #endif diff --git a/include/eepp/graphics/blendmode.hpp b/include/eepp/graphics/blendmode.hpp new file mode 100644 index 000000000..0a4730eb8 --- /dev/null +++ b/include/eepp/graphics/blendmode.hpp @@ -0,0 +1,30 @@ +#ifndef EE_GRAPHICS_BLENDMODE_HPP +#define EE_GRAPHICS_BLENDMODE_HPP + +#include + +namespace EE { namespace Graphics { + +class BlendMode { + public: + /** Set a blend function. + * @param SrcFactor Source Factor + * @param DestFactor Destination Factor + */ + static void SetBlendFunc( const EE_BLEND_FUNC& SrcFactor, const EE_BLEND_FUNC& DestFactor ); + + /** Set a Predefined Blend Function + * @param blend The Blend Mode + * @param force If force to apply the blend ( no matters if the last blend was the same blend ) + */ + static void SetMode( const EE_BLEND_MODE& blend, bool force = false ); + + /** @return The last used predefined blend func */ + static const EE_BLEND_MODE& GetPreBlendFunc(); + protected: + static EE_BLEND_MODE sLastBlend; +}; + +}} + +#endif diff --git a/include/eepp/graphics/cbatchrenderer.hpp b/include/eepp/graphics/cbatchrenderer.hpp index feb802487..1c8b478a0 100755 --- a/include/eepp/graphics/cbatchrenderer.hpp +++ b/include/eepp/graphics/cbatchrenderer.hpp @@ -2,7 +2,6 @@ #define EE_GRAPHICSCBATCHRENDERER_H #include -#include #include namespace EE { namespace Graphics { @@ -19,6 +18,7 @@ struct eeVertex { }; class cTextureFactory; +class cTexture; /** @brief A batch rendering class. */ class EE_API cBatchRenderer { @@ -37,7 +37,7 @@ class EE_API cBatchRenderer { void SetTexture( const cTexture * Tex ); /** Set the predefined blending function to use on the batch */ - void SetPreBlendFunc( const EE_PRE_BLEND_FUNC& Blend ); + void SetBlendMode( const EE_BLEND_MODE& Blend ); /** Set if every batch call have to be immediately rendered */ void BatchForceRendering( const bool& force ) { mForceRendering = force; } @@ -208,7 +208,7 @@ class EE_API cBatchRenderer { const cTexture * mTexture; cTextureFactory * mTF; - EE_PRE_BLEND_FUNC mBlend; + EE_BLEND_MODE mBlend; eeTexCoord mTexCoord[4]; eeColorA mVerColor[4]; diff --git a/include/eepp/graphics/cfont.hpp b/include/eepp/graphics/cfont.hpp index 63476caab..bfd166e31 100755 --- a/include/eepp/graphics/cfont.hpp +++ b/include/eepp/graphics/cfont.hpp @@ -82,7 +82,7 @@ class EE_API cFont { * @param Angle The angle of the string rendered * @param Effect Set the Blend Mode ( default ALPHA_NORMAL ) */ - void Draw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); + void Draw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_BLEND_MODE& Effect = ALPHA_NORMAL ); /** Draw the string seted on the screen * @param X The start x position @@ -92,7 +92,7 @@ class EE_API cFont { * @param Angle The angle of the string rendered * @param Effect Set the Blend Mode ( default ALPHA_NORMAL ) */ - void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); + void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_BLEND_MODE& Effect = ALPHA_NORMAL ); /** Draw a string on the screen from a cached text * @param TextCache The cached text @@ -103,7 +103,7 @@ class EE_API cFont { * @param Angle The angle of the string rendered * @param Effect Set the Blend Mode ( default ALPHA_NORMAL ) */ - void Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); + void Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_BLEND_MODE& Effect = ALPHA_NORMAL ); /** Shrink the String to a max width * @param Str The string to shrink @@ -164,7 +164,7 @@ class EE_API cFont { void CacheWidth(); void CacheNumLines(); - void SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const bool& Cached, const EE_PRE_BLEND_FUNC& Effect ); + void SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const bool& Cached, const EE_BLEND_MODE& Effect ); }; }} diff --git a/include/eepp/graphics/cparticlesystem.hpp b/include/eepp/graphics/cparticlesystem.hpp index 940211ab1..279d9ddce 100755 --- a/include/eepp/graphics/cparticlesystem.hpp +++ b/include/eepp/graphics/cparticlesystem.hpp @@ -122,10 +122,10 @@ class EE_API cParticleSystem { void SetCallbackReset( const ParticleCallback& pc ); /** @return The effect blend mode */ - const EE_PRE_BLEND_FUNC& BlendMode() const; + const EE_BLEND_MODE& BlendMode() const; /** Set the effect blend mode */ - void BlendMode( const EE_PRE_BLEND_FUNC& mode ); + void BlendMode( const EE_BLEND_MODE& mode ); /** @return The color of the effect */ const eeColorAf& Color() const; @@ -158,7 +158,7 @@ class EE_API cParticleSystem { Uint32 mLoops; EE_PARTICLE_EFFECT mEffect; - EE_PRE_BLEND_FUNC mBlend; + EE_BLEND_MODE mBlend; eeColorAf mColor; diff --git a/include/eepp/graphics/cprimitives.hpp b/include/eepp/graphics/cprimitives.hpp index 0c6c7ebb1..e1254a269 100755 --- a/include/eepp/graphics/cprimitives.hpp +++ b/include/eepp/graphics/cprimitives.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace EE { namespace Graphics { @@ -76,7 +77,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param x1 First Point x axis @@ -89,7 +90,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param p1 First Point axis @@ -102,7 +103,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param p1 First Point axis @@ -112,7 +113,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param t The Triangle (eeTriangle2f) @@ -120,7 +121,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param t The Triangle (eeTriangle2f) @@ -131,7 +132,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a rectangle on the screen * @param x Screen x axis @@ -144,9 +145,9 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); + void DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); - void DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); + void DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a rectangle on the screen * @param x Screen x axis @@ -163,9 +164,9 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); + void DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); - void DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); + void DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a rectangle on the screen * @param R The Rectangle eeRectf @@ -175,9 +176,9 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); + void DrawRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); - void DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); + void DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a rectangle on the screen * @param R The Rectangle eeRectf @@ -191,9 +192,9 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); + void DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); - void DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); + void DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a four edges polygon on screen * @param x1 First Point x axis @@ -212,7 +213,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); /** Draw a four edges polygon on screen * @param x1 First Point x axis @@ -227,7 +228,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); /** Draw a four edges polygon on screen * @param p1 First Point @@ -242,7 +243,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); /** Draw a four edges polygon on screen * @param p1 First Point @@ -253,7 +254,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); /** Draw a four edges polygon on screen * @param q The Quad @@ -261,7 +262,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); /** Draw a polygon on screen * @param p The Polygon @@ -269,7 +270,7 @@ class EE_API cPrimitives { * @param blend The Blend Mode * @param lineWidth The line width ( default 1.0f ) */ - void DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Set the current color for drawing primitives */ void SetColor( const eeColorA& Color ); diff --git a/include/eepp/graphics/cscrollparallax.hpp b/include/eepp/graphics/cscrollparallax.hpp index 22fd3da7e..34c961663 100755 --- a/include/eepp/graphics/cscrollparallax.hpp +++ b/include/eepp/graphics/cscrollparallax.hpp @@ -10,10 +10,11 @@ namespace EE { namespace Graphics { class EE_API cScrollParallax { public: cScrollParallax(); + ~cScrollParallax(); /** Constructor that create's the Scroll Parallax */ - cScrollParallax( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color = eeColorA(), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); + cScrollParallax( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color = eeColorA(), const EE_BLEND_MODE& Blend = ALPHA_NORMAL ); /** Create's the Scroll Parallax * @param SubTexture The SubTexture to Draw @@ -26,7 +27,7 @@ class EE_API cScrollParallax { * @param Effect The Blend Mode ( default ALPHA_NORMAL ) * @return True if success */ - bool Create( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color = eeColorA(), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); + bool Create( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color = eeColorA(), const EE_BLEND_MODE& Blend = ALPHA_NORMAL ); /** Set the Color */ void Color( const eeColorA& Color ) { mColor = Color; } @@ -35,10 +36,10 @@ class EE_API cScrollParallax { eeColorA Color() const { return mColor; } /** Set the Blend Mode */ - void BlendMode( const EE_PRE_BLEND_FUNC& Blend ) { mBlend = Blend; } + void BlendMode( const EE_BLEND_MODE& Blend ) { mBlend = Blend; } /** @return The Blend Mode */ - const EE_PRE_BLEND_FUNC& BlendMode() const { return mBlend; } + const EE_BLEND_MODE& BlendMode() const { return mBlend; } /** Draw the Scroll Parallax * @param XDirVel X Direction Speed to move the parallax. @@ -75,8 +76,8 @@ class EE_API cScrollParallax { /** @return The parallax speed */ const eeVector2f& Speed() const; private: - cSubTexture * mSubTexture; - EE_PRE_BLEND_FUNC mBlend; + cSubTexture * mSubTexture; + EE_BLEND_MODE mBlend; eeColorA mColor; eeVector2f mInitPos; eeVector2f mPos; diff --git a/include/eepp/graphics/cshaderprogram.hpp b/include/eepp/graphics/cshaderprogram.hpp index 47c442233..d80a6a9a3 100644 --- a/include/eepp/graphics/cshaderprogram.hpp +++ b/include/eepp/graphics/cshaderprogram.hpp @@ -3,7 +3,6 @@ #include #include -#include namespace EE { namespace Graphics { diff --git a/include/eepp/graphics/csprite.hpp b/include/eepp/graphics/csprite.hpp index 974dd82c7..29cabbe6f 100755 --- a/include/eepp/graphics/csprite.hpp +++ b/include/eepp/graphics/csprite.hpp @@ -142,10 +142,10 @@ class EE_API cSprite { const EE_RENDERTYPE& RenderType() const; /** Set the Blend Mode */ - void BlendMode( const EE_PRE_BLEND_FUNC& Blend ); + void BlendMode( const EE_BLEND_MODE& Blend ); /** Get the Blend Mode */ - const EE_PRE_BLEND_FUNC& BlendMode() const; + const EE_BLEND_MODE& BlendMode() const; /** Reset the sprite as a new one. */ void Reset(); @@ -250,12 +250,12 @@ class EE_API cSprite { * @param Blend The Blend Mode * @param Effect The Render Type */ - void Draw( const EE_PRE_BLEND_FUNC& Blend, const EE_RENDERTYPE& Effect ); + void Draw( const EE_BLEND_MODE& Blend, const EE_RENDERTYPE& Effect ); /** Draw the sprite to the screen forcing the Blend Mode * @param Blend The Blend Mode */ - void Draw( const EE_PRE_BLEND_FUNC& Blend ); + void Draw( const EE_BLEND_MODE& Blend ); /** Draw the sprite to the screen forcing the Render Type * @param Effect The Render Type @@ -361,7 +361,7 @@ class EE_API cSprite { eeInt mRepeations; //!< Number of repetions of the animation, default -1 that equals to loop. - EE_PRE_BLEND_FUNC mBlend; + EE_BLEND_MODE mBlend; EE_RENDERTYPE mEffect; eeUint mCurrentFrame; diff --git a/include/eepp/graphics/csubtexture.hpp b/include/eepp/graphics/csubtexture.hpp index c6503c264..0582503cd 100644 --- a/include/eepp/graphics/csubtexture.hpp +++ b/include/eepp/graphics/csubtexture.hpp @@ -51,11 +51,11 @@ class EE_API cSubTexture { void OffsetY( const Int32& offsety ); - void Draw( const eeFloat& X, const eeFloat& Y, const eeColorA& Color = eeColorA(), const eeFloat& Angle = 0.f, const eeFloat& Scale = 1.f, const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL, const EE_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); + 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_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); - void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Angle, const eeFloat& Scale, const eeColorA& Color0 = eeColorA(), const eeColorA& Color1 = eeColorA(), const eeColorA& Color2 = eeColorA(), const eeColorA& Color3 = eeColorA(), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL, const EE_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); + void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Angle, const eeFloat& Scale, const eeColorA& Color0 = eeColorA(), const eeColorA& Color1 = eeColorA(), const eeColorA& Color2 = eeColorA(), const eeColorA& Color3 = eeColorA(), const EE_BLEND_MODE& Blend = ALPHA_NORMAL, const EE_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); - 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_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL ); + 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 ); cTexture * GetTexture(); diff --git a/include/eepp/graphics/ctextcache.hpp b/include/eepp/graphics/ctextcache.hpp index fda9390e6..a39def911 100644 --- a/include/eepp/graphics/ctextcache.hpp +++ b/include/eepp/graphics/ctextcache.hpp @@ -38,7 +38,7 @@ class EE_API cTextCache { std::vector& Colors(); - void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = 0, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, EE_PRE_BLEND_FUNC Effect = ALPHA_NORMAL ); + void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = 0, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, EE_BLEND_MODE Effect = ALPHA_NORMAL ); void Cache(); diff --git a/include/eepp/graphics/ctexture.hpp b/include/eepp/graphics/ctexture.hpp index a5fe5f40b..56c3ba407 100755 --- a/include/eepp/graphics/ctexture.hpp +++ b/include/eepp/graphics/ctexture.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace EE { namespace Graphics { @@ -14,30 +15,6 @@ namespace EE { namespace Graphics { class EE_API cTexture : public cImage { public: - cTexture(); - - cTexture( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); - - cTexture( const cTexture& Copy ); - - virtual ~cTexture(); - - /** Create the Texture - * @param texture The OpenGL Texture Id (texture handler) - * @param width The Texture Width - * @param height The Texture Height - * @param imgwidth The Image Width - * @param imgheight The Image Height - * @param UseMipmap Set if Texture has Mipmaps - * @param Channels The Texture number of channels. - * @param filepath The Texture File path - * @param ColorKey The Texture Color Key - * @param ClampMode The Texture Clamp Mode - * @param CompressedTexture The Texture was compressed on loading - * @param data The Texture (raw texture) - */ - void Create( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); - /** Set the OpenGL Texture Id (texture handle) */ void Handle( const Uint32& texture ) { mTexture = texture; } @@ -134,7 +111,7 @@ class EE_API cTexture : public cImage { * @param width The width of the texture rendered * @param height The height of the texture rendered */ - void DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angle = 0.0f, const eeFloat& Scale = 1.0f, const eeColorA& Color = eeColorA(), const EE_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const eeFloat &width = 0, const eeFloat &height = 0 ); + void DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angle = 0.0f, const eeFloat& Scale = 1.0f, const eeColorA& Color = eeColorA(), const EE_BLEND_MODE &blend = ALPHA_NORMAL, const eeFloat &width = 0, const eeFloat &height = 0 ); /** Render the texture on screen * @param x The x position on screen @@ -149,7 +126,7 @@ class EE_API cTexture : public cImage { * @param ScaleCentered If true the texture will be scaled centered, otherwise will be scale from the Top - Left Corner * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void Draw( const eeFloat &x, const eeFloat &y, const eeFloat &Angle = 0, const eeFloat &Scale = 1.0f, const eeColorA& Color = eeColorA(255,255,255,255), const EE_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const EE_RENDERTYPE &Effect = RN_NORMAL, const bool &ScaleCentered = true, const eeRecti& texSector = eeRecti(0,0,0,0) ); + void Draw( const eeFloat &x, const eeFloat &y, const eeFloat &Angle = 0, const eeFloat &Scale = 1.0f, const eeColorA& Color = eeColorA(255,255,255,255), const EE_BLEND_MODE &blend = ALPHA_NORMAL, const EE_RENDERTYPE &Effect = RN_NORMAL, const bool &ScaleCentered = true, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Render the texture on screen. Extended because can set the vertex colors individually * @param x The x position on screen @@ -167,7 +144,7 @@ class EE_API cTexture : public cImage { * @param ScaleCentered If true the texture will be scaled centered, otherwise will be scale from the Top - Left Corner * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width = 0.0f, const eeFloat &height = 0.0f, const eeFloat &Angle = 0, const eeFloat &Scale = 1.0f, const eeColorA& Color0 = eeColorA(255,255,255,255), const eeColorA& Color1 = eeColorA(255,255,255,255), const eeColorA& Color2 = eeColorA(255,255,255,255), const eeColorA& Color3 = eeColorA(255,255,255,255), const EE_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const EE_RENDERTYPE &Effect = RN_NORMAL, const bool &ScaleCentered = true, const eeRecti& texSector = eeRecti(0,0,0,0) ); + void DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width = 0.0f, const eeFloat &height = 0.0f, const eeFloat &Angle = 0, const eeFloat &Scale = 1.0f, const eeColorA& Color0 = eeColorA(255,255,255,255), const eeColorA& Color1 = eeColorA(255,255,255,255), const eeColorA& Color2 = eeColorA(255,255,255,255), const eeColorA& Color3 = eeColorA(255,255,255,255), const EE_BLEND_MODE &blend = ALPHA_NORMAL, const EE_RENDERTYPE &Effect = RN_NORMAL, const bool &ScaleCentered = true, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Render the texture on screen * @param x The x position on screen @@ -182,7 +159,7 @@ class EE_API cTexture : public cImage { * @param ScaleCentered If true the texture will be scaled centered, otherwise will be scale from the Top - Left Corner * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void DrawEx2( const eeFloat &x, const eeFloat &y, const eeFloat &width = 0.0f, const eeFloat &height = 0.0f, const eeFloat &Angle = 0, const eeFloat &Scale = 1.0f, const eeColorA& Color = eeColorA(255,255,255,255), const EE_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const EE_RENDERTYPE &Effect = RN_NORMAL, const bool &ScaleCentered = true, const eeRecti& texSector = eeRecti(0,0,0,0) ); + void DrawEx2( const eeFloat &x, const eeFloat &y, const eeFloat &width = 0.0f, const eeFloat &height = 0.0f, const eeFloat &Angle = 0, const eeFloat &Scale = 1.0f, const eeColorA& Color = eeColorA(255,255,255,255), const EE_BLEND_MODE &blend = ALPHA_NORMAL, const EE_RENDERTYPE &Effect = RN_NORMAL, const bool &ScaleCentered = true, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Render a GL_QUAD on Screen * @param Q The eeQuad2f @@ -194,7 +171,7 @@ class EE_API cTexture : public cImage { * @param blend Set the Blend Mode ( default ALPHA_NORMAL ) * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void DrawQuad( const eeQuad2f& Q, const eeFloat &offsetx = 0.0f, const eeFloat &offsety = 0.0f, const eeFloat &Angle = 0.0f, const eeFloat &Scale = 1.0f, const eeColorA& Color = eeColorA(255,255,255,255), const EE_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const eeRecti& texSector = eeRecti(0,0,0,0) ); + void DrawQuad( const eeQuad2f& Q, const eeFloat &offsetx = 0.0f, const eeFloat &offsety = 0.0f, const eeFloat &Angle = 0.0f, const eeFloat &Scale = 1.0f, const eeColorA& Color = eeColorA(255,255,255,255), const EE_BLEND_MODE &blend = ALPHA_NORMAL, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Render a GL_QUAD on Screen * @param Q The eeQuad2f @@ -209,7 +186,7 @@ class EE_API cTexture : public cImage { * @param blend Set the Blend Mode ( default ALPHA_NORMAL ) * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx = 0.0f, const eeFloat &offsety = 0.0f, const eeFloat &Angle = 0.0f, const eeFloat &Scale = 1.0f, const eeColorA& Color0 = eeColorA(255,255,255,255), const eeColorA& Color1 = eeColorA(255,255,255,255), const eeColorA& Color2 = eeColorA(255,255,255,255), const eeColorA& Color3 = eeColorA(255,255,255,255), const EE_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const eeRecti& texSector = eeRecti(0,0,0,0) ); + void DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx = 0.0f, const eeFloat &offsety = 0.0f, const eeFloat &Angle = 0.0f, const eeFloat &Scale = 1.0f, const eeColorA& Color0 = eeColorA(255,255,255,255), const eeColorA& Color1 = eeColorA(255,255,255,255), const eeColorA& Color2 = eeColorA(255,255,255,255), const eeColorA& Color3 = eeColorA(255,255,255,255), const EE_BLEND_MODE &blend = ALPHA_NORMAL, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Set the texture factory internal id of the texture */ void Id( const Uint32& id ); @@ -222,7 +199,36 @@ class EE_API cTexture : public cImage { /** Set a pixel to the locked texture. */ void SetPixel( const eeUint& x, const eeUint& y, const eeColorA& Color ); + + /** Bind the texture. Activate the texture for rendering. */ + void Bind(); + + virtual ~cTexture(); protected: + friend class cTextureFactory; + + cTexture(); + + cTexture( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); + + cTexture( const cTexture& Copy ); + + /** Create the Texture + * @param texture The OpenGL Texture Id (texture handler) + * @param width The Texture Width + * @param height The Texture Height + * @param imgwidth The Image Width + * @param imgheight The Image Height + * @param UseMipmap Set if Texture has Mipmaps + * @param Channels The Texture number of channels. + * @param filepath The Texture File path + * @param ColorKey The Texture Color Key + * @param ClampMode The Texture Clamp Mode + * @param CompressedTexture The Texture was compressed on loading + * @param data The Texture (raw texture) + */ + void Create( const Uint32& texture, const eeUint& width, const eeUint& height, const eeUint& imgwidth, const eeUint& imgheight, const bool& UseMipmap, const eeUint& Channels, const std::string& filepath, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); + std::string mFilepath; Uint32 mId; diff --git a/include/eepp/graphics/ctextureatlas.hpp b/include/eepp/graphics/ctextureatlas.hpp index eccaa7506..545cea07a 100644 --- a/include/eepp/graphics/ctextureatlas.hpp +++ b/include/eepp/graphics/ctextureatlas.hpp @@ -4,8 +4,6 @@ #include #include -#define SUBTEXTURE_NONE 0xFFFFFFFF - namespace EE { namespace Graphics { class EE_API cTextureAtlas : public tResourceManager { diff --git a/include/eepp/graphics/ctexturefactory.hpp b/include/eepp/graphics/ctexturefactory.hpp index 24ab0a3d0..c6224f2b8 100755 --- a/include/eepp/graphics/ctexturefactory.hpp +++ b/include/eepp/graphics/ctexturefactory.hpp @@ -2,18 +2,14 @@ #define EECTEXTUREFACTORY_H #include -#include -#include #include namespace EE { namespace Graphics { -#define TEXTURE_NONE 0xFFFFFFFF - -class cGlobalBatchRenderer; +class cTexture; /** @brief The Texture Manager Class. Here we do all the textures stuff. (Singleton Class) */ -class EE_API cTextureFactory: protected cMutex { +class EE_API cTextureFactory : protected cMutex { SINGLETON_DECLARE_HEADERS(cTextureFactory) public: @@ -118,21 +114,6 @@ class EE_API cTextureFactory: protected cMutex { /** Returns the number of textures loaded */ Uint32 GetNumTextures() const { return (Uint32)mTextures.size(); } - /** Set a blend function. - * @param SrcFactor Source Factor - * @param DestFactor Destination Factor - */ - void SetBlendFunc( const EE_BLEND_FUNC& SrcFactor, const EE_BLEND_FUNC& DestFactor ); - - /** Set a Predefined Blend Function - * @param blend The Blend Mode - * @param force If force to apply the blend ( no matters if the last blend was the same blend ) - */ - void SetPreBlendFunc( const EE_PRE_BLEND_FUNC& blend, bool force = false ); - - /** @return The last used predefined blend func */ - const EE_PRE_BLEND_FUNC& GetPreBlendFunc() const; - /** Set the texture enviroment * @param Param The texture param * @param Val The EE_TEXTURE_OP or EE_TEXTURE_FUNC or EE_TEXTURE_SOURCE @@ -211,14 +192,12 @@ class EE_API cTextureFactory: protected cMutex { GLint mCurrentTexture[ EE_MAX_TEXTURE_UNITS ]; - EE_PRE_BLEND_FUNC mLastBlend; + EE_BLEND_MODE mLastBlend; std::vector mTextures; eeUint mMemSize; - std::string mAppPath; - std::list mVectorFreeSlots; void UnloadTextures(); diff --git a/include/eepp/graphics/ctexturefont.hpp b/include/eepp/graphics/ctexturefont.hpp index 692b30fb0..c844d9cca 100755 --- a/include/eepp/graphics/ctexturefont.hpp +++ b/include/eepp/graphics/ctexturefont.hpp @@ -27,7 +27,7 @@ class EE_API cTextureFont : public cFont { */ bool Load( const Uint32& TexId, const eeUint& StartChar = 0, const eeUint& Spacing = 0, const bool& VerticalDraw = false, const eeUint& TexColumns = 16, const eeUint& TexRows = 16, const Uint16& NumChars = 256 ); - /** Load's a texture font and then load's the character coordinates file ( could be generated by the cTTFFont class ) + /** Load's a texture font and then load's the character coordinates file ( generated by the cTTFFont class ) * @param TexId The texture id returned by cTextureFactory * @param CoordinatesDatPath The character coordinates file * @param VerticalDraw If true render the string verticaly @@ -44,7 +44,7 @@ class EE_API cTextureFont : public cFont { */ bool LoadFromPack( const Uint32& TexId, cPack * Pack, const std::string& FilePackPath, const bool& VerticalDraw = false ); - /** Load's a texture font and then load's the character coordinates file previously loaded on memory ( could be generated by the cTTFFont class ) + /** Load's a texture font and then load's the character coordinates file previously loaded on memory ( generated by the cTTFFont class ) * @param TexId The texture id returned by cTextureFactory * @param CoordinatesDatPath The character coordinates file * @param CoordDataSize The size of CoordData @@ -53,10 +53,25 @@ class EE_API cTextureFont : public cFont { */ bool LoadFromMemory( const Uint32& TexId, const char* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw = false ); + /** Load's a texture font and then load's the character coordinates from a IO stream file ( generated by the cTTFFont class ) + * @param TexId The texture id returned by cTextureFactory + * @param IOS IO stream file for the coordinates + * @param VerticalDraw If true render the string verticaly + * @return True if success + */ bool LoadFromStream( const Uint32& TexId, cIOStream& IOS, const bool& VerticalDraw ); private: - eeUint mStartChar, mTexColumns, mTexRows, mSpacing, mNumChars; - eeFloat mtX, mtY, mFWidth, mFHeight; + eeUint mStartChar; + eeUint mTexColumns; + eeUint mTexRows; + eeUint mSpacing; + eeUint mNumChars; + + eeFloat mtX; + eeFloat mtY; + eeFloat mFWidth; + eeFloat mFHeight; + bool mLoadedCoords; void BuildFont(); diff --git a/include/eepp/graphics/renderer/cgl.hpp b/include/eepp/graphics/renderer/cgl.hpp index 125ba8e51..895523438 100644 --- a/include/eepp/graphics/renderer/cgl.hpp +++ b/include/eepp/graphics/renderer/cgl.hpp @@ -31,7 +31,8 @@ enum EEGL_extensions { EEGL_ARB_multitexture, EEGL_EXT_texture_compression_s3tc, EEGL_ARB_vertex_buffer_object, - EEGL_ARB_vertex_array_object + EEGL_ARB_vertex_array_object, + EEGL_EXT_blend_func_separate }; enum EEGL_version { diff --git a/include/eepp/graphics/renders.hpp b/include/eepp/graphics/renders.hpp index b380104cb..5a23c83b4 100755 --- a/include/eepp/graphics/renders.hpp +++ b/include/eepp/graphics/renders.hpp @@ -17,8 +17,8 @@ enum EE_TEX_FILTER { TEX_FILTER_NEAREST //!< No filtering (Pixeled Zoom) }; -/** @enum EE_PRE_BLEND_FUNC Predefined blend functions */ -enum EE_PRE_BLEND_FUNC { +/** @enum EE_BLEND_MODE Predefined blend modes */ +enum EE_BLEND_MODE { ALPHA_NONE, //!< Disable the blend ALPHA_NORMAL, //!< src SRC_ALPHA dst ONE_MINUS_SRC_ALPHA ALPHA_BLENDONE, //!< src SRC_ALPHA dst ONE @@ -27,7 +27,7 @@ enum EE_PRE_BLEND_FUNC { ALPHA_ALPHACHANNELS, //!< src SRC_ALPHA dst SRC_ALPHA ALPHA_DESTALPHA, //!< src SRC_ALPHA dst DST_ALPHA ALPHA_MULTIPLY, //!< src DST_COLOR dst ZERO - ALPHA_CUSTOM //!< Disable the Predefined blend function for the use of custom blend funcs. + ALPHA_CUSTOM //!< Disable the Predefined blend mode for the use of custom blend funcs. }; /** @enum EE_RENDERTYPE Defines the method to use to render a texture. */ diff --git a/include/eepp/system/colors.hpp b/include/eepp/system/colors.hpp index 9556ed5f2..136572d96 100755 --- a/include/eepp/system/colors.hpp +++ b/include/eepp/system/colors.hpp @@ -8,16 +8,20 @@ namespace EE { namespace System { template class tColor { public: - T Red; - T Green; - T Blue; + T Red; //! Red color component + T Green; //! Green color component + T Blue; //! Blue color component tColor(); + tColor(T r, T g, T b); - T R() const; - T G() const; - T B() const; + /** ARGB ( Alpha ignored ) */ + tColor( const Uint32& Col ); + + T R() const; //! @return the Red component + T G() const; //! @return the Green component + T B() const; //! @return the Blue component bool operator==(tColor& Col); bool operator!=(tColor& Col); @@ -26,11 +30,29 @@ class tColor { }; template -tColor::tColor() : Red(255), Green(255), Blue(255) {} +tColor::tColor() : + Red(255), + Green(255), + Blue(255) +{} template -tColor::tColor(T r, T g, T b) { - Red = r; Green = g; Blue = b; +tColor::tColor( const Uint32& Col ) : + Red(0), + Green(0), + Blue(0) +{ + Red |= Col >> 16; + Green |= Col >> 8; + Blue |= Col; +} + +template +tColor::tColor(T r, T g, T b) : + Red( r ), + Green( g ), + Blue( b ) +{ } template @@ -64,36 +86,78 @@ bool tColor::operator!= (tColor& Col) { template class tColorA : public tColor { public: - using tColor::Red; + static const tColorA Transparent; ///< Transparent predefined color + static const tColorA Black; ///< Black predefined color + + using tColor::Red; //! Uses Red Green and Blue component from the RGB color using tColor::Green; using tColor::Blue; - T Alpha; + + T Alpha; //! Alpha color component ( transparency ) tColorA(); + tColorA(T r, T g, T b, T a); + tColorA( const tColor& Col ); /** ARGB format */ tColorA( const Uint32& Col ); - T A() const; + T A() const; //! @return the Alpha component - bool operator==( const tColorA& Col ) const; - bool operator!=( const tColorA& Col ) const; - - static const tColorA Black; ///< Black predefined color - - Uint32 GetUint32(); + Uint32 GetUint32(); //! The color represented as an Uint32 void Assign( T r, T g, T b, T a ); void Assign( const tColorA& Col ); + + bool operator==( const tColorA& Col ) const; + + bool operator!=( const tColorA& Col ) const; + + tColorA operator+( const tColorA& Col ) const; + + tColorA operator-( const tColorA& Col ) const; + + tColorA operator*( const tColorA& Col ) const; }; template -tColorA::tColorA( const Uint32& Col ) +tColorA tColorA::operator+( const tColorA& Col ) const +{ + return tColorA( eemin( this->Red + Col.Red , 255 ), + eemin( this->Green + Col.Green , 255 ), + eemin( this->Blue + Col.Blue , 255 ), + eemin( this->Alpha + Col.Alpha , 255 ) + ); +} + +template +tColorA tColorA::operator-( const tColorA& Col ) const +{ + return tColorA( eemax( this->Red - Col.Red , 0 ), + eemax( this->Green - Col.Green , 0 ), + eemax( this->Blue - Col.Blue , 0 ), + eemax( this->Alpha - Col.Alpha , 0 ) + ); +} + +template +tColorA tColorA::operator*( const tColorA& Col ) const +{ + return tColorA( ( this->Red * Col.Red / 255 ), + ( this->Green * Col.Green / 255 ), + ( this->Blue * Col.Blue / 255 ), + ( this->Alpha * Col.Alpha / 255 ) + ); +} + +template +tColorA::tColorA( const Uint32& Col ) : + tColor( 0, 0, 0 ), + Alpha(0) { - Alpha = Red = Green = Blue = 0; Alpha |= Col >> 24; Red |= Col >> 16; Green |= Col >> 8; @@ -132,15 +196,20 @@ template tColorA::tColorA() : tColor(), Alpha(255) {} template -tColorA::tColorA(T r, T g, T b, T a) : tColor(r, g, b) { - Alpha = a; +tColorA::tColorA(T r, T g, T b, T a) : + tColor(r, g, b), + Alpha( a ) +{ } template tColorA::tColorA( const tColor& Col ) : tColor( Col.R(), Col.G(), Col.B() ), Alpha(255) {} template -const tColorA tColorA::Black = tColorA(0,0,0,0); +const tColorA tColorA::Transparent = tColorA(0,0,0,0); + +template +const tColorA tColorA::Black = tColorA(0,0,0,255); template T tColorA::A() const { diff --git a/include/eepp/ui/cuibackground.hpp b/include/eepp/ui/cuibackground.hpp index bd9bc6d0c..75a1ed146 100644 --- a/include/eepp/ui/cuibackground.hpp +++ b/include/eepp/ui/cuibackground.hpp @@ -8,9 +8,9 @@ namespace EE { namespace UI { class EE_API cUIBackground { public: cUIBackground(); - cUIBackground( const eeColorA& Color, const eeUint& Corners = 0, const EE_PRE_BLEND_FUNC& BlendMode = ALPHA_NORMAL ); + cUIBackground( const eeColorA& Color, const eeUint& Corners = 0, const EE_BLEND_MODE& BlendMode = ALPHA_NORMAL ); cUIBackground( const cUIBackground& Back ); - cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_PRE_BLEND_FUNC& BlendMode ); + cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_BLEND_MODE& BlendMode ); eeColorA& Color( const eeUint& index = 0 ); @@ -22,15 +22,15 @@ class EE_API cUIBackground { void ColorsTo( const eeColorA& Color ); - const EE_PRE_BLEND_FUNC& Blend() const; - void Blend( const EE_PRE_BLEND_FUNC& blend ); + const EE_BLEND_MODE& Blend() const; + void Blend( const EE_BLEND_MODE& blend ); const eeUint& Corners() const; void Corners( const eeUint& corners ); protected: std::vector mColor; - EE_PRE_BLEND_FUNC mBlendMode; + EE_BLEND_MODE mBlendMode; eeUint mCorners; }; diff --git a/include/eepp/ui/cuicomplexcontrol.hpp b/include/eepp/ui/cuicomplexcontrol.hpp index 9e518c23a..d52385c05 100644 --- a/include/eepp/ui/cuicomplexcontrol.hpp +++ b/include/eepp/ui/cuicomplexcontrol.hpp @@ -21,7 +21,7 @@ class EE_API cUIComplexControl : public cUIControlAnim { const eeVector2i& pos = eeVector2i( 0, 0 ), const eeSize& size = eeSize( -1, -1 ), const Uint32& flags = UI_CONTROL_DEFAULT_FLAGS, - const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, + const EE_BLEND_MODE& blend = ALPHA_NORMAL, const cUIBackground& Back = cUIBackground(), const cUIBorder& Bord = cUIBorder(), const eeSize& MinCtrlSize = eeSize(0,0) diff --git a/include/eepp/ui/cuicontrol.hpp b/include/eepp/ui/cuicontrol.hpp index 47e46cf0d..fda540d78 100644 --- a/include/eepp/ui/cuicontrol.hpp +++ b/include/eepp/ui/cuicontrol.hpp @@ -31,7 +31,7 @@ class EE_API cUIControl { const eeVector2i& pos = eeVector2i( 0, 0 ), const eeSize& size = eeSize( -1, -1 ), const Uint32& flags = UI_CONTROL_DEFAULT_FLAGS, - const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, + const EE_BLEND_MODE& blend = ALPHA_NORMAL, const cUIBackground& Back = cUIBackground(), const cUIBorder& Bord = cUIBorder() ) : @@ -67,7 +67,7 @@ class EE_API cUIControl { Uint32 Flags; cUIBackground Background; cUIBorder Border; - EE_PRE_BLEND_FUNC Blend; + EE_BLEND_MODE Blend; }; cUIControl( const CreateParams& Params ); @@ -156,9 +156,9 @@ class EE_API cUIControl { void Flags( const Uint32& flags ); - void Blend( const EE_PRE_BLEND_FUNC& blend ); + void Blend( const EE_BLEND_MODE& blend ); - EE_PRE_BLEND_FUNC Blend(); + EE_BLEND_MODE Blend(); void ToFront(); diff --git a/include/eepp/window/cengine.hpp b/include/eepp/window/cengine.hpp index 706f0dc0a..625478cef 100755 --- a/include/eepp/window/cengine.hpp +++ b/include/eepp/window/cengine.hpp @@ -17,9 +17,9 @@ class EE_API cEngine { ~cEngine(); /** Creates a new window. - * Allegro 5 and SDL2 backends support more than one window creation, SDL 1.2 backend only 1 window. + * Allegro 5, SDL2, SFML backends support more than one window creation, SDL 1.2 backend only 1 window. */ - Window::cWindow * CreateWindow( WindowSettings Settings, ContextSettings Context ); + Window::cWindow * CreateWindow( WindowSettings Settings, ContextSettings Context = ContextSettings() ); /** Destroy the window instance, and set as current other window running ( if any ). * This function is only usefull for multi-window environment. Avoid using it with one window context. diff --git a/include/eepp/window/cwindow.hpp b/include/eepp/window/cwindow.hpp index 42e951d0c..1418f1729 100644 --- a/include/eepp/window/cwindow.hpp +++ b/include/eepp/window/cwindow.hpp @@ -41,7 +41,7 @@ namespace WindowBackend { class WindowSettings { public: - inline WindowSettings( Uint32 width, Uint32 height, Uint32 bpp = 32, Uint32 style = WindowStyle::Default, const std::string& icon = std::string(), const std::string& caption = std::string(), Uint32 backend = WindowBackend::Default ) : + inline WindowSettings( Uint32 width, Uint32 height, const std::string& caption = std::string(), Uint32 style = WindowStyle::Default, Uint32 backend = WindowBackend::Default, Uint32 bpp = 32, const std::string& icon = std::string() ) : Style( style ), Width( width ), Height( height ), @@ -193,8 +193,15 @@ class EE_API cWindow { /** @return The window handler */ virtual eeWindowHandler GetWindowHandler() = 0; - /** Render the Scene to Screen */ - virtual void Display(); + /** Clear the current window + This function is usually called once every frame, to clear the previous frame content. + */ + virtual void Clear(); + + /** Render the Scene to Screen + @param clear Clear after swapping buffers? + */ + virtual void Display( bool clear = true ); /** @return The elapsed time for the last frame rendered */ virtual eeFloat Elapsed() const; diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 84d72528a..ddf3b6936 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -48,9 +48,9 @@ Desktop Desktop {388e5431-b31b-42b3-b9ad-9002d279d75d} - 0 + 8 0 - 0 + 2 /home/programming/eepp @@ -177,7 +177,7 @@ false - -j4 -e DEBUGBUILD=yes es + -j4 -e DEBUGBUILD=yes SHARED_BACKEND=yes BACKENDS_ALL=yes es true Make @@ -497,7 +497,7 @@ false - -j4 -e DEBUGBUILD=yes ew + -j4 -e DEBUGBUILD=yes SHARED_BACKEND=yes BACKENDS_ALL=yes ew true Make @@ -512,7 +512,7 @@ true - -e DEBUGBUILD=yes clean + -e DEBUGBUILD=yes SHARED_BACKEND=yes BACKENDS_ALL=yes clean /usr/bin/make %{buildDir} Custom Process Step diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 85d8f59e7..9040ac613 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -123,6 +123,8 @@ ../../src/eepp/gaming/mapeditor/cmapproperties.cpp ../../src/eepp/gaming/mapeditor/cmapeditor.cpp ../../src/eepp/gaming/mapeditor/clayerproperties.cpp +../../include/eepp/graphics/blendmode.hpp +../../src/eepp/graphics/blendmode.cpp ../../include/eepp/graphics/vbohelper.hpp ../../include/eepp/graphics/renders.hpp ../../include/eepp/graphics/pixelperfect.hpp diff --git a/src/eepp/gaming/cgameobjectsubtextureex.cpp b/src/eepp/gaming/cgameobjectsubtextureex.cpp index b0e6f1c66..3772dacd2 100644 --- a/src/eepp/gaming/cgameobjectsubtextureex.cpp +++ b/src/eepp/gaming/cgameobjectsubtextureex.cpp @@ -4,7 +4,7 @@ namespace EE { namespace Gaming { -cGameObjectSubTextureEx::cGameObjectSubTextureEx( const Uint32& Flags, cLayer * Layer, cSubTexture * SubTexture, const eeVector2f& Pos, EE_PRE_BLEND_FUNC Blend, EE_RENDERTYPE Render, eeFloat Angle, eeFloat Scale, eeColorA Color ) : +cGameObjectSubTextureEx::cGameObjectSubTextureEx( const Uint32& Flags, cLayer * Layer, cSubTexture * SubTexture, const eeVector2f& Pos, EE_BLEND_MODE Blend, EE_RENDERTYPE Render, eeFloat Angle, eeFloat Scale, eeColorA Color ) : cGameObjectSubTexture( Flags, Layer, SubTexture, Pos ), mBlend( Blend ), mRender( Render ), diff --git a/src/eepp/gaming/cobjectlayer.cpp b/src/eepp/gaming/cobjectlayer.cpp index e64aca417..d64b1e5e8 100644 --- a/src/eepp/gaming/cobjectlayer.cpp +++ b/src/eepp/gaming/cobjectlayer.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include using namespace EE::Graphics; diff --git a/src/eepp/gaming/ctilelayer.cpp b/src/eepp/gaming/ctilelayer.cpp index 012c575ca..1f0840f5a 100644 --- a/src/eepp/gaming/ctilelayer.cpp +++ b/src/eepp/gaming/ctilelayer.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include using namespace EE::Graphics; diff --git a/src/eepp/graphics/blendmode.cpp b/src/eepp/graphics/blendmode.cpp new file mode 100644 index 000000000..12efa92a6 --- /dev/null +++ b/src/eepp/graphics/blendmode.cpp @@ -0,0 +1,67 @@ +#include +#include + +namespace EE { namespace Graphics { + +EE_BLEND_MODE BlendMode::sLastBlend = ALPHA_NORMAL; + +void BlendMode::SetMode( const EE_BLEND_MODE& blend, bool force ) { + if ( sLastBlend != blend || force ) { + if (blend == ALPHA_NONE) { + GLi->Disable( GL_BLEND ); + } else { + GLi->Enable( GL_BLEND ); + + switch (blend) { + case ALPHA_NORMAL: + if ( GLi->IsExtension( EEGL_EXT_blend_func_separate ) ) + glBlendFuncSeparateEXT( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); + else + GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); + break; + case ALPHA_BLENDONE: + GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE); + break; + case ALPHA_BLENDTWO: + GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); + GLi->BlendFunc(GL_DST_ALPHA , GL_ONE); + break; + case ALPHA_BLENDTHREE: + GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE); + GLi->BlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA); + break; + case ALPHA_ALPHACHANNELS: + GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); + break; + case ALPHA_DESTALPHA: + GLi->BlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA); + break; + case ALPHA_MULTIPLY: + GLi->BlendFunc(GL_DST_COLOR,GL_ZERO); + break; + case ALPHA_NONE: + // Avoid compiler warning + break; + case ALPHA_CUSTOM: + break; + } + + } + + sLastBlend= blend; + } +} + +void BlendMode::SetBlendFunc( const EE_BLEND_FUNC& SrcFactor, const EE_BLEND_FUNC& DestFactor ) { + GLi->Enable( GL_BLEND ); + + GLi->BlendFunc( (GLenum)SrcFactor, (GLenum)DestFactor ); + + sLastBlend = ALPHA_CUSTOM; +} + +const EE_BLEND_MODE& BlendMode::GetPreBlendFunc() { + return sLastBlend; +} + +}} diff --git a/src/eepp/graphics/cbatchrenderer.cpp b/src/eepp/graphics/cbatchrenderer.cpp index 12b1c8a9f..3619329c1 100755 --- a/src/eepp/graphics/cbatchrenderer.cpp +++ b/src/eepp/graphics/cbatchrenderer.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -70,7 +71,7 @@ void cBatchRenderer::SetTexture( const cTexture * Tex ) { mTexture = Tex; } -void cBatchRenderer::SetPreBlendFunc( const EE_PRE_BLEND_FUNC& Blend ) { +void cBatchRenderer::SetBlendMode( const EE_BLEND_MODE& Blend ) { if ( Blend != mBlend ) Flush(); @@ -103,7 +104,7 @@ void cBatchRenderer::Flush() { bool CreateMatrix = ( mRotation || mScale != 1.0f || mPosition.x || mPosition.y ); - mTF->SetPreBlendFunc( mBlend ); + BlendMode::SetMode( mBlend ); if ( mCurrentMode == DM_POINTS && NULL != mTexture ) { GLi->Enable( GL_POINT_SPRITE ); diff --git a/src/eepp/graphics/cfont.cpp b/src/eepp/graphics/cfont.cpp index 0333ab583..0385f149c 100644 --- a/src/eepp/graphics/cfont.cpp +++ b/src/eepp/graphics/cfont.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace EE { namespace Graphics { @@ -128,21 +129,21 @@ const std::vector& cFont::GetLinesWidth() const { return mLinesWidth; } -void cFont::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect) { +void cFont::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_BLEND_MODE& Effect) { SubDraw( mText, X, Y, Flags, Scale, Angle, true, Effect ); } -void cFont::Draw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect ) { +void cFont::Draw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_BLEND_MODE& Effect ) { SubDraw( Text, X, Y, Flags, Scale, Angle, false, Effect ); } -void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect ) { +void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_BLEND_MODE& Effect ) { if ( !TextCache.Text().size() ) return; cGlobalBatchRenderer::instance()->Draw(); cTextureFactory::instance()->Bind( mTexId ); - cTextureFactory::instance()->SetPreBlendFunc( Effect ); + BlendMode::SetMode( Effect ); if ( Flags & FONT_DRAW_SHADOW ) { Uint32 f = Flags; @@ -334,13 +335,13 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con } } -void cFont::SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const bool& Cached, const EE_PRE_BLEND_FUNC& Effect ) { +void cFont::SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const bool& Cached, const EE_BLEND_MODE& Effect ) { if ( !Text.size() ) return; cGlobalBatchRenderer::instance()->Draw(); cTextureFactory::instance()->Bind( mTexId ); - cTextureFactory::instance()->SetPreBlendFunc( Effect ); + BlendMode::SetMode( Effect ); if ( !Cached && ( Text.size() != mRenderCoords.size() / EE_QUAD_VERTEX || Angle != 0.f || Scale != 1.f || FontHAlignGet( Flags ) == FONT_DRAW_CENTER || FontHAlignGet( Flags ) == FONT_DRAW_RIGHT ) ) { SetText( Text ); diff --git a/src/eepp/graphics/cimage.cpp b/src/eepp/graphics/cimage.cpp index d5e0d9c66..599e7fe33 100644 --- a/src/eepp/graphics/cimage.cpp +++ b/src/eepp/graphics/cimage.cpp @@ -173,7 +173,7 @@ const Uint8* cImage::GetPixelsPtr() { eeColorA cImage::GetPixel( const eeUint& x, const eeUint& y ) { if ( mPixels == NULL || x > mWidth || y > mHeight ) { - return eeColorA::Black; + return eeColorA::Transparent; } eeUint Pos = ( x + y * mWidth ) * mChannels; diff --git a/src/eepp/graphics/cparticlesystem.cpp b/src/eepp/graphics/cparticlesystem.cpp index 9ffdaeae4..8732faeb2 100755 --- a/src/eepp/graphics/cparticlesystem.cpp +++ b/src/eepp/graphics/cparticlesystem.cpp @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include using namespace EE::Window; @@ -319,7 +321,7 @@ void cParticleSystem::Draw() { cTextureFactory * TF = cTextureFactory::instance(); TF->Bind( mTexId ); - TF->SetPreBlendFunc( mBlend ); + BlendMode::SetMode( mBlend ); if ( mPointsSup ) { GLi->Enable( GL_POINT_SPRITE ); @@ -343,7 +345,7 @@ void cParticleSystem::Draw() { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); BR->SetTexture( Tex ); - BR->SetPreBlendFunc( mBlend ); + BR->SetBlendMode( mBlend ); BR->QuadsBegin(); for ( Uint32 i = 0; i < mPCount; i++ ) { @@ -459,11 +461,11 @@ bool cParticleSystem::Using() const { return mUsed; } -const EE_PRE_BLEND_FUNC& cParticleSystem::BlendMode() const { +const EE_BLEND_MODE& cParticleSystem::BlendMode() const { return mBlend; } -void cParticleSystem::BlendMode( const EE_PRE_BLEND_FUNC& mode ) { +void cParticleSystem::BlendMode( const EE_BLEND_MODE& mode ) { mBlend = mode; } diff --git a/src/eepp/graphics/cprimitives.cpp b/src/eepp/graphics/cprimitives.cpp index 89aab00c6..dac11c9be 100755 --- a/src/eepp/graphics/cprimitives.cpp +++ b/src/eepp/graphics/cprimitives.cpp @@ -12,9 +12,9 @@ cPrimitives::cPrimitives() : cPrimitives::~cPrimitives() { } -void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners ) { +void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) { mBR->SetTexture( NULL ); - mBR->SetPreBlendFunc( blend ); + mBR->SetBlendMode( blend ); eeUint i; eeFloat xscalediff = width * Scale - width; @@ -86,14 +86,14 @@ void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const DrawBatch(); } -void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners) { +void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { if ( 0 != Corners ) { DrawRoundedRectangle( x, y, width, height, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners ); return; } mBR->SetTexture( NULL ); - mBR->SetPreBlendFunc( blend ); + mBR->SetBlendMode( blend ); switch(fillmode) { case EE_DRAW_FILL: { @@ -186,9 +186,9 @@ void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat& DrawBatch(); } -void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { mBR->SetTexture( NULL ); - mBR->SetPreBlendFunc( blend ); + mBR->SetBlendMode( blend ); switch(fillmode) { case EE_DRAW_LINE: @@ -214,9 +214,9 @@ void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFlo DrawBatch(); } -void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { +void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { mBR->SetTexture( NULL ); - mBR->SetPreBlendFunc( blend ); + mBR->SetBlendMode( blend ); switch(fillmode) { case EE_DRAW_LINE: @@ -238,9 +238,9 @@ void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& DrawBatch(); } -void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { mBR->SetTexture( NULL ); - mBR->SetPreBlendFunc( blend ); + mBR->SetBlendMode( blend ); switch(fillmode) { case EE_DRAW_LINE: @@ -262,27 +262,27 @@ void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode DrawBatch(); } -void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners) { +void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { DrawRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners); } -void cPrimitives::DrawRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners) { +void cPrimitives::DrawRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { DrawRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); } -void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners) { +void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { DrawRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); } -void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners ) { +void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) { DrawRoundedRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners); } -void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners) { +void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { DrawRoundedRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); } -void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners ) { +void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) { DrawRoundedRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); } @@ -302,39 +302,39 @@ void cPrimitives::SetColor( const eeColorA& Color ) { mColor = Color; } -void cPrimitives::DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { DrawTriangle( t.V[0], t.V[1], t.V[2], mColor, mColor, mColor, fillmode, blend, lineWidth ); } -void cPrimitives::DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { DrawTriangle( t.V[0], t.V[1], t.V[2], Color1, Color2, Color3, fillmode, blend, lineWidth ); } -void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { DrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, Color1, Color2, Color3, fillmode, blend, lineWidth); } -void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { DrawTriangle(x1, y1, x2, y2, x3, y3, mColor, mColor, mColor, fillmode, blend, lineWidth); } -void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { DrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, mColor, mColor, mColor, fillmode, blend, lineWidth); } -void cPrimitives::DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { +void cPrimitives::DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { DrawQuad(x1, y1, x2, y2, x3, y3, x4, y4, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY); } -void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { +void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { DrawQuad(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, Color1, Color2, Color3, Color4, fillmode, blend, lineWidth, OffsetX, OffsetY); } -void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { +void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { DrawQuad(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY); } -void cPrimitives::DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { +void cPrimitives::DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { DrawQuad(q.V[0].x, q.V[0].y, q.V[1].x, q.V[1].y, q.V[2].x, q.V[2].y, q.V[3].x, q.V[3].y, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY); } diff --git a/src/eepp/graphics/cscrollparallax.cpp b/src/eepp/graphics/cscrollparallax.cpp index 873bca716..9db7505b1 100755 --- a/src/eepp/graphics/cscrollparallax.cpp +++ b/src/eepp/graphics/cscrollparallax.cpp @@ -11,7 +11,7 @@ cScrollParallax::cScrollParallax() : cScrollParallax::~cScrollParallax() {} -cScrollParallax::cScrollParallax( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color, const EE_PRE_BLEND_FUNC& Blend ) { +cScrollParallax::cScrollParallax( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color, const EE_BLEND_MODE& Blend ) { Create( SubTexture, DestX, DestY, DestWidth, DestHeight, Speed, Color, Blend ); } @@ -39,7 +39,7 @@ void cScrollParallax::SetAABB() { mAABB = eeRectf( mInitPos.x, mInitPos.y, mInitPos.x + mSize.Width(), mInitPos.y + mSize.Height() ); } -bool cScrollParallax::Create( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color, const EE_PRE_BLEND_FUNC& Blend ) { +bool cScrollParallax::Create( cSubTexture * SubTexture, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeVector2f& Speed, const eeColorA& Color, const EE_BLEND_MODE& Blend ) { mSubTexture = SubTexture; mPos = eeVector2f( DestX, DestY ); mSize = eeSizef( DestWidth, DestHeight ); diff --git a/src/eepp/graphics/csprite.cpp b/src/eepp/graphics/csprite.cpp index 463c812fa..e51915fd6 100755 --- a/src/eepp/graphics/csprite.cpp +++ b/src/eepp/graphics/csprite.cpp @@ -526,7 +526,7 @@ void cSprite::SetReverseFromStart() { mCurrentFrame = Size; } -void cSprite::Draw( const EE_PRE_BLEND_FUNC& Blend, const EE_RENDERTYPE& Effect ) { +void cSprite::Draw( const EE_BLEND_MODE& Blend, const EE_RENDERTYPE& Effect ) { if ( SPR_FGET( SPRITE_FLAG_AUTO_ANIM ) ) Update(); @@ -545,7 +545,7 @@ void cSprite::Draw() { Draw( mBlend, mEffect ); } -void cSprite::Draw( const EE_PRE_BLEND_FUNC& Blend ) { +void cSprite::Draw( const EE_BLEND_MODE& Blend ) { Draw( Blend, mEffect ); } @@ -860,11 +860,11 @@ const EE_RENDERTYPE& cSprite::RenderType() const { return mEffect; } -void cSprite::BlendMode( const EE_PRE_BLEND_FUNC& Blend ) { +void cSprite::BlendMode( const EE_BLEND_MODE& Blend ) { mBlend = Blend; } -const EE_PRE_BLEND_FUNC& cSprite::BlendMode() const { +const EE_BLEND_MODE& cSprite::BlendMode() const { return mBlend; } diff --git a/src/eepp/graphics/csubtexture.cpp b/src/eepp/graphics/csubtexture.cpp index 48dd1115f..aa24af2fc 100644 --- a/src/eepp/graphics/csubtexture.cpp +++ b/src/eepp/graphics/csubtexture.cpp @@ -1,5 +1,6 @@ #include #include +#include #include namespace EE { namespace Graphics { @@ -114,8 +115,8 @@ const Uint32& cSubTexture::Texture() { } void cSubTexture::Texture( const Uint32& TexId ) { - mTexId = TexId; - mTexture = cTextureFactory::instance()->GetTexture( TexId ); + mTexId = TexId; + mTexture = cTextureFactory::instance()->GetTexture( TexId ); } const eeRecti& cSubTexture::SrcRect() const { @@ -164,17 +165,17 @@ void cSubTexture::OffsetY( const Int32& offsety ) { mOffsetY = offsety; } -void cSubTexture::Draw( const eeFloat& X, const eeFloat& Y, const eeColorA& Color, const eeFloat& Angle, const eeFloat& Scale, const EE_PRE_BLEND_FUNC& Blend, const EE_RENDERTYPE& Effect, const bool& ScaleRendered ) { +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_RENDERTYPE& 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 ); } -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_PRE_BLEND_FUNC& Blend, const EE_RENDERTYPE& Effect, const bool& ScaleRendered ) { +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_RENDERTYPE& 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 ); } -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_PRE_BLEND_FUNC& Blend ) { +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 ) { if ( NULL != mTexture ) mTexture->DrawQuadEx( Q, X, Y, Angle, Scale, Color0, Color1, Color2, Color3, Blend, mSrcRect ); } @@ -386,7 +387,7 @@ bool cSubTexture::SaveToFile(const std::string& filepath, const EE_SAVE_TYPE& Fo Lock(); - if ( mTexture ) + if ( NULL != mTexture ) Res = 0 != ( SOIL_save_image ( filepath.c_str(), Format, RealSize().Width(), RealSize().Height(), 4, GetPixelsPtr() ) ); Unlock(); diff --git a/src/eepp/graphics/ctextcache.cpp b/src/eepp/graphics/ctextcache.cpp index dfb40d81d..daaf79677 100644 --- a/src/eepp/graphics/ctextcache.cpp +++ b/src/eepp/graphics/ctextcache.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace EE { namespace Graphics { @@ -126,7 +127,7 @@ const std::vector& cTextCache::LinesWidth() { return mLinesWidth; } -void cTextCache::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, EE_PRE_BLEND_FUNC Effect ) { +void cTextCache::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, EE_BLEND_MODE Effect ) { if ( NULL != mFont ) { if ( mFlags != Flags ) { mFlags = Flags; diff --git a/src/eepp/graphics/ctexture.cpp b/src/eepp/graphics/ctexture.cpp index c01fe1865..666a43251 100755 --- a/src/eepp/graphics/ctexture.cpp +++ b/src/eepp/graphics/ctexture.cpp @@ -200,6 +200,10 @@ void cTexture::SetPixel( const eeUint& x, const eeUint& y, const eeColorA& Color mFlags |= TEX_FLAG_MODIFIED; } +void cTexture::Bind() { + cTextureFactory::instance()->Bind( this ); +} + bool cTexture::SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format ) { bool Res = false; @@ -407,11 +411,11 @@ bool cTexture::Compressed() const { return 0 != ( mFlags & TEX_FLAG_COMPRESSED ); } -void cTexture::Draw( const eeFloat &x, const eeFloat &y, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_PRE_BLEND_FUNC &blend, const EE_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector) { +void cTexture::Draw( const eeFloat &x, const eeFloat &y, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_BLEND_MODE &blend, const EE_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector) { DrawEx( x, y, 0, 0, Angle, Scale, Color, Color, Color, Color, blend, Effect, ScaleCentered, texSector); } -void cTexture::DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angle, const eeFloat& Scale, const eeColorA& Color, const EE_PRE_BLEND_FUNC &blend, const eeFloat &width, const eeFloat &height ) { +void cTexture::DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angle, const eeFloat& Scale, const eeColorA& Color, const EE_BLEND_MODE &blend, const eeFloat &width, const eeFloat &height ) { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); eeFloat w = width, h = height; @@ -419,7 +423,7 @@ void cTexture::DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angl if (!h) h = (eeFloat)ImgHeight(); BR->SetTexture( this ); - BR->SetPreBlendFunc( blend ); + BR->SetBlendMode( blend ); BR->QuadsBegin(); BR->QuadsSetColor( Color ); @@ -432,7 +436,7 @@ void cTexture::DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angl BR->DrawOpt(); } -void cTexture::DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width, const eeFloat &height, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color0, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_PRE_BLEND_FUNC &blend, const EE_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector) { +void cTexture::DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width, const eeFloat &height, 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_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector) { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); bool renderdiv = true; @@ -475,12 +479,12 @@ void cTexture::DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width, renderdiv = false; BR->SetTexture( this ); - BR->SetPreBlendFunc( blend ); + BR->SetBlendMode( blend ); BR->QuadsBegin(); BR->QuadsSetColorFree( Color0, Color1, Color2, Color3 ); - if ( Effect <= 3 ) { + if ( Effect <= RN_FLIPMIRROR ) { if ( ClampMode() == EE_CLAMP_REPEAT ) { if ( Effect == RN_NORMAL ) if ( renderdiv ) { @@ -587,15 +591,15 @@ void cTexture::DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width, BR->DrawOpt(); } -void cTexture::DrawEx2( const eeFloat &x, const eeFloat &y, const eeFloat &width, const eeFloat &height, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_PRE_BLEND_FUNC &blend, const EE_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector ) { +void cTexture::DrawEx2( const eeFloat &x, const eeFloat &y, const eeFloat &width, const eeFloat &height, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_BLEND_MODE &blend, const EE_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector ) { DrawEx( x, y, width, height, Angle, Scale, Color, Color, Color, Color, blend, Effect, ScaleCentered, texSector ); } -void cTexture::DrawQuad( const eeQuad2f& Q, const eeFloat &offsetx, const eeFloat &offsety, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_PRE_BLEND_FUNC &blend, const eeRecti& texSector) { +void cTexture::DrawQuad( const eeQuad2f& Q, const eeFloat &offsetx, const eeFloat &offsety, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_BLEND_MODE &blend, const eeRecti& texSector) { DrawQuadEx( Q, offsetx, offsety, Angle, Scale, Color, Color, Color, Color, blend, texSector); } -void cTexture::DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx, const eeFloat &offsety, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color0, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_PRE_BLEND_FUNC &blend, const eeRecti& texSector ) { +void cTexture::DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx, const eeFloat &offsety, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color0, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_BLEND_MODE &blend, const eeRecti& texSector ) { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); bool renderdiv = true; @@ -619,7 +623,7 @@ void cTexture::DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx, const eeFl renderdiv = false; BR->SetTexture( this ); - BR->SetPreBlendFunc( blend ); + BR->SetBlendMode( blend ); BR->QuadsBegin(); BR->QuadsSetColorFree( Color0, Color1, Color2, Color3 ); diff --git a/src/eepp/graphics/ctexturefactory.cpp b/src/eepp/graphics/ctexturefactory.cpp index 9b0bf098e..c525d71a1 100755 --- a/src/eepp/graphics/ctexturefactory.cpp +++ b/src/eepp/graphics/ctexturefactory.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -16,8 +17,6 @@ cTextureFactory::cTextureFactory() : mTextures.clear(); mTextures.push_back( NULL ); - mAppPath = Sys::GetProcessPath(); - memset( &mCurrentTexture[0], 0, EE_MAX_TEXTURE_UNITS ); } @@ -210,58 +209,6 @@ void cTextureFactory::UngrabTextures() { } } -void cTextureFactory::SetBlendFunc( const EE_BLEND_FUNC& SrcFactor, const EE_BLEND_FUNC& DestFactor ) { - GLi->Enable( GL_BLEND ); - - GLi->BlendFunc( (GLenum)SrcFactor, (GLenum)DestFactor ); - - mLastBlend = ALPHA_CUSTOM; -} - -void cTextureFactory::SetPreBlendFunc( const EE_PRE_BLEND_FUNC& blend, bool force ) { - if ( mLastBlend != blend || force ) { - if (blend == ALPHA_NONE) { - GLi->Disable( GL_BLEND ); - } else { - GLi->Enable( GL_BLEND ); - - switch (blend) { - case ALPHA_NORMAL: - GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); - break; - case ALPHA_BLENDONE: - GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE); - break; - case ALPHA_BLENDTWO: - GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); - GLi->BlendFunc(GL_DST_ALPHA , GL_ONE); - break; - case ALPHA_BLENDTHREE: - GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE); - GLi->BlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA); - break; - case ALPHA_ALPHACHANNELS: - GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); - break; - case ALPHA_DESTALPHA: - GLi->BlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA); - break; - case ALPHA_MULTIPLY: - GLi->BlendFunc(GL_DST_COLOR,GL_ZERO); - break; - case ALPHA_NONE: - // Avoid compiler warning - break; - case ALPHA_CUSTOM: - break; - } - - } - - mLastBlend = blend; - } -} - void cTextureFactory::SetActiveTextureUnit( const Uint32& Unit ) { GLi->ActiveTexture( GL_TEXTURE0 + Unit ); } @@ -284,10 +231,6 @@ void cTextureFactory::SetTextureEnv( const EE_TEXTURE_PARAM& Param, const Int32& #endif } -const EE_PRE_BLEND_FUNC& cTextureFactory::GetPreBlendFunc() const { - return mLastBlend; -} - eeUint cTextureFactory::GetValidTextureSize( const eeUint& Size ) { if ( GLi->IsExtension( EEGL_ARB_texture_non_power_of_two ) ) return Size; diff --git a/src/eepp/graphics/ctexturefont.cpp b/src/eepp/graphics/ctexturefont.cpp index 777cc2c7b..4f906d165 100755 --- a/src/eepp/graphics/ctexturefont.cpp +++ b/src/eepp/graphics/ctexturefont.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/src/eepp/graphics/ctextureloader.cpp b/src/eepp/graphics/ctextureloader.cpp index a8531871e..a48095e5a 100644 --- a/src/eepp/graphics/ctextureloader.cpp +++ b/src/eepp/graphics/ctextureloader.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/src/eepp/graphics/cttffont.cpp b/src/eepp/graphics/cttffont.cpp index 36226a7fd..9147f4946 100755 --- a/src/eepp/graphics/cttffont.cpp +++ b/src/eepp/graphics/cttffont.cpp @@ -1,4 +1,5 @@ #include +#include #include #include using namespace HaikuTTF; diff --git a/src/eepp/graphics/renderer/cgl.cpp b/src/eepp/graphics/renderer/cgl.cpp index 0e878ecf9..d4249fed4 100644 --- a/src/eepp/graphics/renderer/cgl.cpp +++ b/src/eepp/graphics/renderer/cgl.cpp @@ -122,6 +122,7 @@ void cGL::Init() { WriteExtension( EEGL_EXT_texture_compression_s3tc , GLEW_EXT_texture_compression_s3tc ); WriteExtension( EEGL_ARB_vertex_buffer_object , GLEW_ARB_vertex_buffer_object ); WriteExtension( EEGL_ARB_vertex_array_object , GLEW_ARB_vertex_array_object ); + WriteExtension( EEGL_EXT_blend_func_separate , GLEW_EXT_blend_func_separate ); } else #endif @@ -138,6 +139,7 @@ void cGL::Init() { WriteExtension( EEGL_EXT_texture_compression_s3tc , IsExtension( "GL_EXT_texture_compression_s3tc" ) ); WriteExtension( EEGL_ARB_vertex_buffer_object , IsExtension( "GL_ARB_vertex_buffer_object" ) ); WriteExtension( EEGL_ARB_vertex_array_object , IsExtension( "GL_ARB_vertex_array_object" ) ); + WriteExtension( EEGL_EXT_blend_func_separate , IsExtension( "GL_EXT_blend_func_separate" ) ); } } diff --git a/src/eepp/physics/cspace.cpp b/src/eepp/physics/cspace.cpp index 21326ecda..7ea3f8850 100644 --- a/src/eepp/physics/cspace.cpp +++ b/src/eepp/physics/cspace.cpp @@ -288,7 +288,7 @@ void cSpace::Draw() { #ifdef PHYSICS_RENDERER_ENABLED cBatchRenderer * BR = cGlobalBatchRenderer::instance(); - BR->SetPreBlendFunc( ALPHA_NORMAL ); + BR->SetBlendMode( ALPHA_NORMAL ); cPhysicsManager::cDrawSpaceOptions * options = cPhysicsManager::instance()->GetDrawOptions(); diff --git a/src/eepp/ui/cuibackground.cpp b/src/eepp/ui/cuibackground.cpp index 6c9de8bcb..1c9d5edc2 100644 --- a/src/eepp/ui/cuibackground.cpp +++ b/src/eepp/ui/cuibackground.cpp @@ -17,14 +17,14 @@ cUIBackground::cUIBackground( const cUIBackground& Back ) : mColor = b->Colors(); } -cUIBackground::cUIBackground( const eeColorA& Color, const eeUint& Corners, const EE_PRE_BLEND_FUNC& BlendMode ) : +cUIBackground::cUIBackground( const eeColorA& Color, const eeUint& Corners, const EE_BLEND_MODE& BlendMode ) : mBlendMode( BlendMode ), mCorners( Corners ) { mColor.push_back( Color ); } -cUIBackground::cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_PRE_BLEND_FUNC& BlendMode ) : +cUIBackground::cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_BLEND_MODE& BlendMode ) : mBlendMode( BlendMode ), mCorners( Corners ) { @@ -70,11 +70,11 @@ void cUIBackground::Color( const eeColorA& Col ) { mColor[0] = Col; } -const EE_PRE_BLEND_FUNC& cUIBackground::Blend() const { +const EE_BLEND_MODE& cUIBackground::Blend() const { return mBlendMode; } -void cUIBackground::Blend( const EE_PRE_BLEND_FUNC& blend ) { +void cUIBackground::Blend( const EE_BLEND_MODE& blend ) { mBlendMode = blend; } diff --git a/src/eepp/ui/cuicontrol.cpp b/src/eepp/ui/cuicontrol.cpp index f48cce1d1..fed7367a3 100644 --- a/src/eepp/ui/cuicontrol.cpp +++ b/src/eepp/ui/cuicontrol.cpp @@ -444,12 +444,12 @@ void cUIControl::Flags( const Uint32& flags ) { mFlags |= flags; } -void cUIControl::Blend( const EE_PRE_BLEND_FUNC& blend ) { +void cUIControl::Blend( const EE_BLEND_MODE& blend ) { mBlend = static_cast ( blend ); } -EE_PRE_BLEND_FUNC cUIControl::Blend() { - return static_cast ( mBlend ); +EE_BLEND_MODE cUIControl::Blend() { + return static_cast ( mBlend ); } void cUIControl::ToFront() { diff --git a/src/eepp/window/cengine.cpp b/src/eepp/window/cengine.cpp index 473dc8e9b..893e49fe3 100755 --- a/src/eepp/window/cengine.cpp +++ b/src/eepp/window/cengine.cpp @@ -321,7 +321,7 @@ WindowSettings cEngine::CreateWindowSettings( cIniFile * ini, std::string iniKey std::string Icon = ini->GetValue( iniKeyName, "WinIcon", "" ); std::string Caption = ini->GetValue( iniKeyName, "WinCaption", "" ); - WindowSettings WinSettings( Width, Height, BitColor, Style, Icon, Caption, WinBackend ); + WindowSettings WinSettings( Width, Height, Caption, Style, WinBackend, BitColor, Icon ); #if EE_PLATFORM == EE_PLATFORM_IOS //! @TODO: Check if SDL2 default win settings are being forced ( it wasn't working fine some time ago ) diff --git a/src/eepp/window/cwindow.cpp b/src/eepp/window/cwindow.cpp index 0daa023eb..0407c8b7e 100644 --- a/src/eepp/window/cwindow.cpp +++ b/src/eepp/window/cwindow.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -122,7 +123,7 @@ void cWindow::Setup2D( const bool& KeepView ) { mCurrentView->NeedUpdate(); } - cTextureFactory::instance()->SetPreBlendFunc( ALPHA_NORMAL, true ); + BlendMode::SetMode( ALPHA_NORMAL, true ); if ( GLv_3 != GLi->Version() ) { #if !defined( EE_GLES2 ) || defined( EE_GLES_BOTH ) @@ -274,7 +275,11 @@ void cWindow::ViewCheckUpdate() { } } -void cWindow::Display() { +void cWindow::Clear() { + GLi->Clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); +} + +void cWindow::Display( bool clear ) { cGlobalBatchRenderer::instance()->Draw(); if ( mCurrentView->NeedUpdate() ) @@ -282,7 +287,8 @@ void cWindow::Display() { SwapBuffers(); - GLi->Clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); + if ( clear ) + Clear(); GetElapsedTime(); diff --git a/src/examples/empty_window/empty_window.cpp b/src/examples/empty_window/empty_window.cpp index 5c04f008a..30bb369f2 100644 --- a/src/examples/empty_window/empty_window.cpp +++ b/src/examples/empty_window/empty_window.cpp @@ -4,7 +4,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) { // Create a new window - cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, 32, WindowStyle::Default, "", "eepp - Empty Window" ), ContextSettings( ) ); + cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, "eepp - Empty Window" ) ); // Set window background color win->BackColor( eeColor( 50, 50, 50 ) ); @@ -12,38 +12,25 @@ EE_MAIN_FUNC int main (int argc, char * argv []) // Check if created if ( win->Created() ) { - // Get input pointer - cInput * imp = win->GetInput(); + // Create an instance of the primitive renderer + cPrimitives p; - eeFloat ang = 0; + // Change the color + p.SetColor( eeColorA( 0, 255, 0, 150 ) ); // Application loop while ( win->Running() ) { // Update the input - imp->Update(); + win->GetInput()->Update(); // Check if ESCAPE key is pressed - if ( imp->IsKeyDown( KEY_ESCAPE ) ) + if ( win->GetInput()->IsKeyDown( KEY_ESCAPE ) ) { // Close the window win->Close(); } - ang += cEngine::instance()->Elapsed() * 0.01; - - // Create an instance of the primitive renderer - cPrimitives p; - - // Set the primitive color - p.SetColor( eeColorA( 0, 150, 0, 150 ) ); - - // Draw a rectangle - p.DrawRectangle( 100, 100, win->GetWidth() - 200, win->GetHeight() - 200, ang ); - - // Change the color - p.SetColor( eeColorA( 0, 255, 0, 150 ) ); - // Draw a circle p.DrawCircle( win->GetWidth() / 2, win->GetHeight() / 2, 200 ); diff --git a/src/examples/external_shader/external_shader.cpp b/src/examples/external_shader/external_shader.cpp index e01e3b085..c204f4610 100644 --- a/src/examples/external_shader/external_shader.cpp +++ b/src/examples/external_shader/external_shader.cpp @@ -53,7 +53,7 @@ void videoResize() { GLi->EnableClientState( GL_COLOR_ARRAY ); /// Reset the default blend func ( by default eepp use ALPHA_NORMAL ) - cTextureFactory::instance()->SetPreBlendFunc( ALPHA_BLENDONE ); + BlendMode::SetMode( ALPHA_BLENDONE ); /// Set the line width cGlobalBatchRenderer::instance()->SetLineWidth( 2 ); @@ -83,7 +83,7 @@ using namespace Demo_ExternalShader; EE_MAIN_FUNC int main (int argc, char * argv []) { - win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, 32, WindowStyle::Default, "", "eepp - External Shaders" ), ContextSettings( true ) ); + win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, "eepp - External Shaders" ), ContextSettings( true ) ); if ( win->Created() ) { diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 6ed282453..2e4c4433f 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -107,7 +107,7 @@ void cEETest::Init() { WP.Start(); Batch.AllocVertexs( 2048 ); - Batch.SetPreBlendFunc( ALPHA_BLENDONE ); + Batch.SetBlendMode( ALPHA_BLENDONE ); mFBO = cFrameBuffer::CreateNew( 256, 256, false );