diff --git a/ee.linux.cbp b/ee.linux.cbp index f4109e91a..66946c745 100644 --- a/ee.linux.cbp +++ b/ee.linux.cbp @@ -152,6 +152,8 @@ + + diff --git a/src/base.hpp b/src/base.hpp index 802d1244a..f490fb134 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -53,6 +53,10 @@ # define EE_PLATFORM EE_PLATFORM_LINUX #endif +#if EE_PLATFORM == EE_PLATFORM_WIN32 || EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_LINUX +#define EE_GLEW_AVAILABLE +#endif + #ifdef EE_PLATFORM #define EE_SUPPORTED_PLATFORM #endif @@ -91,15 +95,16 @@ #define EE_API #endif +#ifdef EE_GLEW_AVAILABLE #include "helper/glew/glew.h" +#endif + #if EE_PLATFORM == EE_PLATFORM_MACOSX #include #else #include #endif -#include "base/base.hpp" - namespace EE { #define eeARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) ) #define eeSAFE_DELETE(p) { if(p) { eeDelete (p); (p)=NULL; } } @@ -121,4 +126,6 @@ namespace EE { #endif } +#include "base/base.hpp" + #endif diff --git a/src/base/memorymanager.cpp b/src/base/memorymanager.cpp index 5b84a45ac..c2aff6813 100644 --- a/src/base/memorymanager.cpp +++ b/src/base/memorymanager.cpp @@ -4,6 +4,7 @@ namespace EE { +#ifdef EE_MEMORY_MANAGER static std::string SizeToString( const unsigned int& MemSize ) { std::string size = " bytes"; double mem = static_cast( MemSize ); @@ -28,6 +29,7 @@ static std::string SizeToString( const unsigned int& MemSize ) { return std::string( ss.str() + size ); } +#endif tAllocatedPointerMap MemoryManager::mMapPointers; size_t MemoryManager::mTotalMemoryUsage = 0; diff --git a/src/base/stlcontainers.hpp b/src/base/stlcontainers.hpp index 00a52cdd6..55137b5b4 100644 --- a/src/base/stlcontainers.hpp +++ b/src/base/stlcontainers.hpp @@ -57,12 +57,13 @@ namespace EE { #endif }; - typedef eeVector::type eeVectorUint8; - typedef eeVector::type eeVectorUint16; - typedef eeVector::type eeVectorUint32; - typedef eeVector::type eeVectorInt8; - typedef eeVector::type eeVectorInt16; - typedef eeVector::type eeVectorInt32; + typedef eeVector::type eeVectorUint8; + typedef eeVector::type eeVectorUint16; + typedef eeVector::type eeVectorUint32; + typedef eeVector::type eeVectorInt8; + typedef eeVector::type eeVectorInt16; + typedef eeVector::type eeVectorInt32; + typedef eeVector::type eeVectorFloat; } #endif diff --git a/src/gaming/cisomap.cpp b/src/gaming/cisomap.cpp index 8520c0351..77a4bb929 100755 --- a/src/gaming/cisomap.cpp +++ b/src/gaming/cisomap.cpp @@ -149,7 +149,6 @@ void cIsoMap::Draw() { } TF->Bind( T->Layers[L] ); - TF->SetBlendFunc(ALPHA_NORMAL); glColorPointer( 3, GL_UNSIGNED_BYTE, 0, reinterpret_cast( T ) ); glVertexPointer( 2, GL_FLOAT, 0, reinterpret_cast( T ) + sizeof(eeColor) * 4 ); @@ -181,7 +180,7 @@ void cIsoMap::Draw() { if ( Intersect( ScreenAABB, ShadowAABB ) ) { //AABB ShadowAABB_RECT( OffsetX + ObjPos.x, OffsetY + TileCenter.y - Tex->Height(), OffsetX + TileCenter.x + Tex->Width(), OffsetY + TileCenter.y ); - //PR.DrawRectangle( ShadowAABB_RECT, 0, 1, DRAW_LINE ); + //PR.DrawRectangle( ShadowAABB_RECT, 0, 1, EE_DRAW_LINE ); Tex->DrawEx( OffsetX + ObjPos.x, OffsetY + ObjPos.y, (eeFloat)Tex->ImgWidth(), (eeFloat)Tex->ImgHeight(), 0, 1, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC ); } @@ -207,7 +206,7 @@ void cIsoMap::Draw() { } } - PR.DrawQuad( Tile( MouseTilePos.x, MouseTilePos.y ).Q, DRAW_LINE, ALPHA_NORMAL, 1.0f, OffsetX, OffsetY ); + PR.DrawQuad( Tile( MouseTilePos.x, MouseTilePos.y ).Q, EE_DRAW_LINE, ALPHA_NORMAL, 1.0f, OffsetX, OffsetY ); } void cIsoMap::Move( const eeFloat& offsetx, const eeFloat& offsety ) { diff --git a/src/graphics/cbatchrenderer.cpp b/src/graphics/cbatchrenderer.cpp index 341fcf0ff..4ac05d30c 100755 --- a/src/graphics/cbatchrenderer.cpp +++ b/src/graphics/cbatchrenderer.cpp @@ -7,7 +7,7 @@ cBatchRenderer::cBatchRenderer() : mNumVertex(0), mTexture(NULL), mBlend(ALPHA_NORMAL), - mCurrentMode(EE_DT_QUADS), + mCurrentMode(DM_QUADS), mRotation(0.0f), mScale(1.0f), mPosition(0.0f, 0.0f), @@ -23,7 +23,7 @@ cBatchRenderer::cBatchRenderer( const eeUint& Prealloc ) : mNumVertex(0), mTexture(NULL), mBlend(ALPHA_NORMAL), - mCurrentMode(EE_DT_QUADS), + mCurrentMode(DM_QUADS), mRotation(0.0f), mScale(1.0f), mPosition(0.0f, 0.0f), @@ -63,7 +63,7 @@ void cBatchRenderer::SetTexture( const cTexture * Tex ) { mTexture = Tex; } -void cBatchRenderer::SetBlendFunc( const EE_RENDERALPHAS& Blend ) { +void cBatchRenderer::SetPreBlendFunc( const EE_PRE_BLEND_FUNC& Blend ) { mBlend = Blend; } @@ -73,7 +73,7 @@ void cBatchRenderer::AddVertexs( const eeUint& num ) { Flush(); } -void cBatchRenderer::SetBlendMode( EE_DRAW_TYPE Mode, const bool& Force ) { +void cBatchRenderer::SetBlendMode( EE_DRAW_MODE Mode, const bool& Force ) { if ( Force && mCurrentMode != Mode ) { Flush(); mCurrentMode = Mode; @@ -91,9 +91,9 @@ void cBatchRenderer::Flush() { else glDisable( GL_TEXTURE_2D ); - cTextureFactory::instance()->SetBlendFunc( mBlend ); + cTextureFactory::instance()->SetPreBlendFunc( mBlend ); - if ( mCurrentMode == EE_DT_POINTS && NULL != mTexture ) { + if ( mCurrentMode == DM_POINTS && NULL != mTexture ) { glEnable( GL_POINT_SPRITE_ARB ); glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); glPointSize( (GLfloat)mTexture->Width() ); @@ -120,7 +120,7 @@ void cBatchRenderer::Flush() { if ( CreateMatrix ) glPopMatrix(); - if ( mCurrentMode == EE_DT_POINTS && mTexture > 0 ) { + if ( mCurrentMode == DM_POINTS && mTexture > 0 ) { glDisable( GL_POINT_SPRITE_ARB ); } @@ -142,7 +142,7 @@ void cBatchRenderer::BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloa } #ifndef EE_GLES - SetBlendMode( EE_DT_QUADS, mForceBlendMode ); + SetBlendMode( DM_QUADS, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x; @@ -172,7 +172,7 @@ void cBatchRenderer::BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloa mTVertex->color = mVerColor[3]; Rotate(center, &mTVertex->pos, angle); #else - SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode ); + SetBlendMode( DM_TRIANGLE_STRIP, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x; @@ -232,7 +232,7 @@ void cBatchRenderer::BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFl center.y += y; #ifndef EE_GLES - SetBlendMode( EE_DT_QUADS, mForceBlendMode ); + SetBlendMode( DM_QUADS, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = mx; @@ -262,7 +262,7 @@ void cBatchRenderer::BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFl mTVertex->color = mVerColor[3]; Rotate(center, &mTVertex->pos, angle); #else - SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode ); + SetBlendMode( DM_TRIANGLE_STRIP, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = mx; @@ -301,7 +301,7 @@ void cBatchRenderer::BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const return; #ifndef EE_GLES - SetBlendMode( EE_DT_QUADS, mForceBlendMode ); + SetBlendMode( DM_QUADS, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -327,7 +327,7 @@ void cBatchRenderer::BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const mTVertex->tex = mTexCoord[3]; mTVertex->color = mVerColor[3]; #else - SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode ); + SetBlendMode( DM_TRIANGLE_STRIP, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -397,7 +397,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons mQ = RotateQuadCentered( mQ, Angle, QCenter ); #ifndef EE_GLES - SetBlendMode( EE_DT_QUADS, mForceBlendMode ); + SetBlendMode( DM_QUADS, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = mQ[0].x; @@ -423,7 +423,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons mTVertex->tex = mTexCoord[3]; mTVertex->color = mVerColor[3]; #else - SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode ); + SetBlendMode( DM_TRIANGLE_STRIP, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = mQ[0].x; @@ -454,7 +454,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons } void cBatchRenderer::QuadsBegin() { - SetBlendMode( EE_DT_QUADS, true ); + SetBlendMode( DM_QUADS, true ); QuadsSetSubset( 0, 0, 1, 1 ); QuadsSetColor( eeColorA() ); } @@ -495,7 +495,7 @@ void cBatchRenderer::Rotate( const eeVector2f& center, eeVector2f* point, const } void cBatchRenderer::PointsBegin() { - SetBlendMode( EE_DT_POINTS, true ); + SetBlendMode( DM_POINTS, true ); QuadsSetSubset( 0, 0, 1, 1 ); PointSetColor( eeColorA() ); } @@ -508,7 +508,7 @@ void cBatchRenderer::BatchPoint( const eeFloat& x, const eeFloat& y ) { if ( mNumVertex + 1 >= mVertex.size() ) return; - SetBlendMode( EE_DT_POINTS, mForceBlendMode ); + SetBlendMode( DM_POINTS, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x; @@ -520,7 +520,7 @@ void cBatchRenderer::BatchPoint( const eeFloat& x, const eeFloat& y ) { } void cBatchRenderer::LinesBegin() { - SetBlendMode( EE_DT_LINES, true ); + SetBlendMode( DM_LINES, true ); QuadsSetSubset( 0, 0, 1, 1 ); PointSetColor( eeColorA() ); } @@ -537,7 +537,7 @@ void cBatchRenderer::BatchLine( const eeFloat& x0, const eeFloat& y0, const eeFl if ( mNumVertex + 1 >= mVertex.size() ) return; - SetBlendMode( EE_DT_LINES, mForceBlendMode ); + SetBlendMode( DM_LINES, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -555,7 +555,7 @@ void cBatchRenderer::BatchLine( const eeFloat& x0, const eeFloat& y0, const eeFl } void cBatchRenderer::LineLoopBegin() { - SetBlendMode( EE_DT_LINE_LOOP, true ); + SetBlendMode( DM_LINE_LOOP, true ); QuadsSetSubset( 0, 0, 1, 1 ); PointSetColor( eeColorA() ); } @@ -572,7 +572,7 @@ void cBatchRenderer::BatchLineLoop( const eeFloat& x0, const eeFloat& y0, const if ( mNumVertex + 1 >= mVertex.size() ) return; - SetBlendMode( EE_DT_LINE_LOOP, mForceBlendMode ); + SetBlendMode( DM_LINE_LOOP, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -597,7 +597,7 @@ void cBatchRenderer::BatchLineLoop( const eeFloat& x0, const eeFloat& y0 ) { if ( mNumVertex + 1 >= mVertex.size() ) return; - SetBlendMode( EE_DT_LINE_LOOP, mForceBlendMode ); + SetBlendMode( DM_LINE_LOOP, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -613,7 +613,7 @@ void cBatchRenderer::BatchLineLoop( const eeVector2f& vector1 ) { } void cBatchRenderer::TriangleFanBegin() { - SetBlendMode( EE_DT_TRIANGLE_FAN, true ); + SetBlendMode( DM_TRIANGLE_FAN, true ); TriangleFanSetSubset( 0, 0, 0, 1, 1, 1 ); TriangleFanSetColor( eeColorA() ); } @@ -637,7 +637,7 @@ void cBatchRenderer::BatchTriangleFan( const eeFloat& x0, const eeFloat& y0, con if ( mNumVertex + 2 >= mVertex.size() ) return; - SetBlendMode( EE_DT_TRIANGLE_FAN, mForceBlendMode ); + SetBlendMode( DM_TRIANGLE_FAN, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -661,7 +661,7 @@ void cBatchRenderer::BatchTriangleFan( const eeFloat& x0, const eeFloat& y0, con } void cBatchRenderer::TrianglesBegin() { - SetBlendMode( EE_DT_TRIANGLES, true ); + SetBlendMode( DM_TRIANGLES, true ); TrianglesSetSubset( 0, 0, 0, 1, 1, 1 ); TrianglesSetColor( eeColorA() ); } @@ -685,7 +685,7 @@ void cBatchRenderer::BatchTriangle( const eeFloat& x0, const eeFloat& y0, const if ( mNumVertex + 2 >= mVertex.size() ) return; - SetBlendMode( EE_DT_TRIANGLES, mForceBlendMode ); + SetBlendMode( DM_TRIANGLES, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x0; @@ -716,7 +716,7 @@ void cBatchRenderer::BatchPolygon( const eePolygon2f& Polygon ) { if ( Polygon.Size() > mVertex.size() ) return; - SetBlendMode( EE_DT_POLYGON, mForceBlendMode ); + SetBlendMode( DM_POLYGON, mForceBlendMode ); for ( Uint32 i = 0; i < Polygon.Size(); i++ ) { mTVertex = &mVertex[ mNumVertex ]; @@ -734,7 +734,7 @@ void cBatchRenderer::BatchPolygonByPoint( const eeFloat& x, const eeFloat& y ) { if ( mNumVertex + 1 >= mVertex.size() ) return; - SetBlendMode( EE_DT_POLYGON, mForceBlendMode ); + SetBlendMode( DM_POLYGON, mForceBlendMode ); mTVertex = &mVertex[ mNumVertex ]; mTVertex->pos.x = x; diff --git a/src/graphics/cbatchrenderer.hpp b/src/graphics/cbatchrenderer.hpp index 83826acc5..ef24abb87 100755 --- a/src/graphics/cbatchrenderer.hpp +++ b/src/graphics/cbatchrenderer.hpp @@ -6,12 +6,12 @@ namespace EE { namespace Graphics { -typedef struct { +typedef struct eeTexCoordS { eeFloat u; eeFloat v; } eeTexCoord; -typedef struct { +typedef struct eeVertexS { eeVector2f pos; eeTexCoord tex; eeColorA color; @@ -32,8 +32,8 @@ class EE_API cBatchRenderer { /** Set the current texture to render on the batch ( if you change the texture and you have batched something, this will be renderer immediately ) */ void SetTexture( const cTexture * Tex ); - /** Set the blending functions to use on the batch */ - void SetBlendFunc( const EE_RENDERALPHAS& Blend ); + /** Set the predefined blending function to use on the batch */ + void SetPreBlendFunc( const EE_PRE_BLEND_FUNC& Blend ); /** Set if every batch call have to be immediately rendered */ void BatchForceRendering( const bool& force ) { mForceRendering = force; } @@ -71,16 +71,16 @@ class EE_API cBatchRenderer { /** @return The batch center position */ eeVector2f BatchCenter() const { return mCenter; } - /** Add to the batch a quad ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a quad ( this will change your batch rendering method to DM_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ void BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& angle = 0.0f, const eeFloat& scale = 1.0f, const bool& scalefromcenter = true ); - /** Add to the batch a quad ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a quad ( this will change your batch rendering method to DM_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ void BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& angle = 0.0f ); - /** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to DM_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ void BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3 ); - /** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to DM_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ void BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& Angle = 0.0f, const eeFloat& Scale = 1.0f ); /** This will set as the default batch rendering to GL_QUADS. WIll reset the texture subset rendering to the whole texture. Will reset the default color rendering to eeColorA(255,255,255,255). */ @@ -98,16 +98,16 @@ class EE_API cBatchRenderer { /** Set the quad color per vertex */ void QuadsSetColorFree( const eeColorA Color0, const eeColorA Color1, const eeColorA Color2, const eeColorA Color3 ); - /** This will set as the default batch rendering to EE_DT_POINTS. And will reset the point color to eeColorA(255,255,255,255). */ + /** This will set as the default batch rendering to DM_POINTS. And will reset the point color to eeColorA(255,255,255,255). */ void PointsBegin(); /** Set the point color */ void PointSetColor( const eeColorA Color ); - /** Add to the batch a point ( this will change your batch rendering method to EE_DT_POINTS, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a point ( this will change your batch rendering method to DM_POINTS, so if you were using another one will Draw all the batched vertexs first ) */ void BatchPoint( const eeFloat& x, const eeFloat& y ); - /** This will set as the default batch rendering to EE_DT_LINES. And will reset the line color to eeColorA(255,255,255,255). */ + /** This will set as the default batch rendering to DM_LINES. And will reset the line color to eeColorA(255,255,255,255). */ void LinesBegin(); /** Set the line color */ @@ -116,7 +116,7 @@ class EE_API cBatchRenderer { /** Set the line color, per vertex */ void LinesSetColorFree( const eeColorA Color0, const eeColorA Color1 ); - /** Add to the batch a line ( this will change your batch rendering method to EE_DT_LINES, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a line ( this will change your batch rendering method to DM_LINES, so if you were using another one will Draw all the batched vertexs first ) */ void BatchLine( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1 ); /** This will set as the default batch rendering to GL_LINE_LOOP. And will reset the line color to eeColorA(255,255,255,255). */ @@ -128,7 +128,7 @@ class EE_API cBatchRenderer { /** Set the line color, per vertex */ void LineLoopSetColorFree( const eeColorA Color0, const eeColorA Color1 ); - /** Add to the batch a line ( this will change your batch rendering method to EE_DT_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a line ( this will change your batch rendering method to DM_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first ) */ void BatchLineLoop( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1 ); void BatchLineLoop( const eeFloat& x0, const eeFloat& y0); @@ -137,7 +137,7 @@ class EE_API cBatchRenderer { void BatchLineLoop( const eeVector2f& vector1 ); - /** This will set as the default batch rendering to EE_DT_TRIANGLE_FAN. And will reset the line color to eeColorA(255,255,255,255). */ + /** This will set as the default batch rendering to DM_TRIANGLE_FAN. And will reset the line color to eeColorA(255,255,255,255). */ void TriangleFanBegin(); /** Set the triangle fan color */ @@ -149,10 +149,10 @@ class EE_API cBatchRenderer { /** Set the texture sector to be rendered but freely seted */ void TriangleFanSetSubset( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 ); - /** Add to the batch a triangle fan ( this will change your batch rendering method to EE_DT_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a triangle fan ( this will change your batch rendering method to DM_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first ) */ void BatchTriangleFan( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 ); - /** This will set as the default batch rendering to EE_DT_TRIANGLES. And will reset the line color to eeColorA(255,255,255,255). */ + /** This will set as the default batch rendering to DM_TRIANGLES. And will reset the line color to eeColorA(255,255,255,255). */ void TrianglesBegin(); /** Set the triangles color */ @@ -164,13 +164,13 @@ class EE_API cBatchRenderer { /** Set the texture sector to be rendered but freely seted */ void TrianglesSetSubset( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 ); - /** Add to the batch a triangle ( this will change your batch rendering method to EE_DT_TRIANGLES, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a triangle ( this will change your batch rendering method to DM_TRIANGLES, so if you were using another one will Draw all the batched vertexs first ) */ void BatchTriangle( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 ); /** Set the polygon color */ void PolygonSetColor( const eeColorA& Color ); - /** Add to the batch a polygon ( this will change your batch rendering method to EE_DT_POLYGON, so if you were using another one will Draw all the batched vertexs first ) */ + /** Add to the batch a polygon ( this will change your batch rendering method to DM_POLYGON, so if you were using another one will Draw all the batched vertexs first ) */ void BatchPolygon( const eePolygon2f& Polygon ); /** Set the line width */ @@ -192,12 +192,12 @@ class EE_API cBatchRenderer { eeUint mNumVertex; const cTexture * mTexture; - EE_RENDERALPHAS mBlend; + EE_PRE_BLEND_FUNC mBlend; eeTexCoord mTexCoord[4]; eeColorA mVerColor[4]; - EE_DRAW_TYPE mCurrentMode; + EE_DRAW_MODE mCurrentMode; eeFloat mRotation, mScale; eeVector2f mPosition, mCenter; @@ -209,7 +209,7 @@ class EE_API cBatchRenderer { void Init(); void AddVertexs( const eeUint& num ); void Rotate( const eeVector2f& center, eeVector2f* point, const eeFloat& angle ); - void SetBlendMode( EE_DRAW_TYPE Mode, const bool& Force ); + void SetBlendMode( EE_DRAW_MODE Mode, const bool& Force ); }; }} diff --git a/src/graphics/cconsole.cpp b/src/graphics/cconsole.cpp index 1f89687e9..443c1fc75 100755 --- a/src/graphics/cconsole.cpp +++ b/src/graphics/cconsole.cpp @@ -467,24 +467,7 @@ void cConsole::CmdQuit ( const std::vector < std::wstring >& params ) { } void cConsole::CmdGetTextureMemory ( const std::vector < std::wstring >& params ) { - std::wstring size = L" bytes"; - eeDouble mem = static_cast( cTextureFactory::instance()->MemorySize() ); - Uint8 c = 0; - - while ( mem > 1024 ) { - c++; - mem = mem / 1024; - } - - switch (c) { - case 1: size = L" KB"; break; - case 2: size = L" MB"; break; - case 3: size = L" GB"; break; - case 4: size = L" TB"; break; - default: size = L" WTF"; - } - - PushText( L"Total texture memory used: "+ toWStr( mem ) + size ); + PushText( L"Total texture memory used: " + SizeToWString( cTextureFactory::instance()->MemorySize() ) ); } void cConsole::CmdCmdList ( const std::vector < std::wstring >& params ) { diff --git a/src/graphics/cfont.cpp b/src/graphics/cfont.cpp index 77fe68f29..cf9fa3d79 100644 --- a/src/graphics/cfont.cpp +++ b/src/graphics/cfont.cpp @@ -111,24 +111,24 @@ const std::vector& cFont::GetLinesWidth() const { return mLinesWidth; } -void cFont::Draw( const std::string& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_RENDERALPHAS& Effect ) { +void cFont::Draw( const std::string& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect ) { Draw( stringTowstring(Text), X, Y, Flags, Scale, Angle, Effect ); } -void cFont::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_RENDERALPHAS& Effect) { +void cFont::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect) { SubDraw( mText, X, Y, Flags, Scale, Angle, true, Effect ); } -void cFont::Draw( const std::wstring& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_RENDERALPHAS& Effect ) { +void cFont::Draw( const std::wstring& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& 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_RENDERALPHAS& 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 ) { if ( !TextCache.Text().size() ) return; cTextureFactory::instance()->Bind( mTexId ); - cTextureFactory::instance()->SetBlendFunc( Effect ); + cTextureFactory::instance()->SetPreBlendFunc( Effect ); if ( Flags & FONT_DRAW_SHADOW ) { Uint32 f = Flags; @@ -165,79 +165,89 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con std::vector& RenderCoords = TextCache.VertextCoords(); std::vector& Colors = TextCache.Colors(); - switch ( FontHAlignGet( Flags ) ) { - case FONT_DRAW_CENTER: - nX = (eeFloat)( (Int32)( ( TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ] ) * 0.5f ) ); - Line++; - break; - case FONT_DRAW_RIGHT: - nX = TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ]; - Line++; - break; - } - - for ( eeUint i = 0; i < TextCache.Text().size(); i++ ) { - Char = static_cast( TextCache.Text().at(i) ); - eeTexCoords* C = &mTexCoords[ Char ]; - - switch(Char) { - case L'\v': - if (mVerticalDraw) - nY += GetFontHeight(); - else - nX += mGlyphs[ Char ].Advance; + #ifndef EE_GLES + if ( !TextCache.CachedCoords() ) { + #else + if ( true ) { + #endif + switch ( FontHAlignGet( Flags ) ) { + case FONT_DRAW_CENTER: + nX = (eeFloat)( (Int32)( ( TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ] ) * 0.5f ) ); + Line++; break; - case L'\t': - if (mVerticalDraw) - nY += GetFontHeight() * 4; - else - nX += mGlyphs[ Char ].Advance * 4; + case FONT_DRAW_RIGHT: + nX = TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ]; + Line++; break; - case L'\n': - if (mVerticalDraw) { - nX += (GetFontSize() * Scale); - nY = 0; - } else { - if ( i + 1 < TextCache.Text().size() ) { - switch ( FontHAlignGet( Flags ) ) { - case FONT_DRAW_CENTER: - nX = (eeFloat)( (Int32)( ( TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ] ) * 0.5f ) ); - break; - case FONT_DRAW_RIGHT: - nX = TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ]; - break; - default: - nX = 0; + } + + for ( eeUint i = 0; i < TextCache.Text().size(); i++ ) { + Char = static_cast( TextCache.Text().at(i) ); + eeTexCoords* C = &mTexCoords[ Char ]; + + switch(Char) { + case L'\v': + if (mVerticalDraw) + nY += GetFontHeight(); + else + nX += mGlyphs[ Char ].Advance; + break; + case L'\t': + if (mVerticalDraw) + nY += GetFontHeight() * 4; + else + nX += mGlyphs[ Char ].Advance * 4; + break; + case L'\n': + if (mVerticalDraw) { + nX += (GetFontSize() * Scale); + nY = 0; + } else { + if ( i + 1 < TextCache.Text().size() ) { + switch ( FontHAlignGet( Flags ) ) { + case FONT_DRAW_CENTER: + nX = (eeFloat)( (Int32)( ( TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ] ) * 0.5f ) ); + break; + case FONT_DRAW_RIGHT: + nX = TextCache.GetTextWidth() - TextCache.LinesWidth()[ Line ]; + break; + default: + nX = 0; + } } + + nY += (GetFontSize() * Scale); + Line++; } - nY += (GetFontSize() * Scale); - Line++; - } + break; + default: + for ( Uint8 z = 0; z < 8; z+=2 ) { + RenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z]; + RenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ]; + RenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX; + RenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY; + numvert++; + } - break; - default: - for ( Uint8 z = 0; z < 8; z+=2 ) { - RenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z]; - RenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ]; - RenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX; - RenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY; - numvert++; - } + #ifdef EE_GLES + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &Colors[0] ) ); + glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) ); + glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 ); - #ifdef EE_GLES - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &Colors[0] ) ); - glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) ); - glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 ); + glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES ); + #endif - glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES ); - #endif - - if (mVerticalDraw) - nY += GetFontHeight(); - else - nX += mGlyphs[ Char ].Advance; + if (mVerticalDraw) + nY += GetFontHeight(); + else + nX += mGlyphs[ Char ].Advance; + } } + + TextCache.CachedCoords( true ); + } else { + numvert = TextCache.Text().size() * 4; } #ifndef EE_GLES @@ -252,12 +262,12 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con glPopMatrix(); } -void cFont::SubDraw( const std::wstring& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const bool& Cached, const EE_RENDERALPHAS& Effect ) { +void cFont::SubDraw( const std::wstring& 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 ) { if ( !Text.size() ) return; cTextureFactory::instance()->Bind( mTexId ); - cTextureFactory::instance()->SetBlendFunc( Effect ); + cTextureFactory::instance()->SetPreBlendFunc( Effect ); if ( !Cached && ( Text.size() != mRenderCoords.size() / 4 || Angle != 0.f || Scale != 1.f || FontHAlignGet( Flags ) == FONT_DRAW_CENTER || FontHAlignGet( Flags ) == FONT_DRAW_RIGHT ) ) { SetText( Text ); diff --git a/src/graphics/cfont.hpp b/src/graphics/cfont.hpp index f1c543d65..af3cffd6a 100755 --- a/src/graphics/cfont.hpp +++ b/src/graphics/cfont.hpp @@ -15,7 +15,7 @@ namespace EE { namespace Graphics { class EE_API cFont { public: cFont( const Uint32& Type, const std::string& Name ); - + virtual ~cFont(); /** Set a text to render @@ -76,7 +76,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 std::wstring& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags = FONT_DRAW_LEFT, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_RENDERALPHAS& Effect = ALPHA_NORMAL ); + void Draw( const std::wstring& 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 ); /** Draw the string seted on the screen * @param X The start x position @@ -86,7 +86,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_RENDERALPHAS& 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_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); /** Draw a string on the screen * @param Text The text to draw @@ -97,7 +97,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 std::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_RENDERALPHAS& Effect = ALPHA_NORMAL ); + void Draw( const std::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 ); /** Draw a string on the screen from a cached text * @param TextCache The cached text @@ -108,7 +108,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_RENDERALPHAS& 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_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); /** Shrink the wstring to a max width * @param Str The string to shrink @@ -127,19 +127,19 @@ class EE_API cFont { /** @return The font texture id */ const Uint32& GetTexId() const; - + const Uint32& Type() const; - + const std::string& Name() const; - + void Name( const std::string& name ); - + const Uint32& Id(); protected: Uint32 mType; std::string mFontName; Uint32 mFontHash; - + std::wstring mText; bool mCacheData; eeColorA mColor; @@ -160,7 +160,7 @@ class EE_API cFont { void CacheWidth(); void CacheNumLines(); - void SubDraw( const std::wstring& Text, const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const bool& Cached, const EE_RENDERALPHAS& Effect ); + void SubDraw( const std::wstring& 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 ); }; }} diff --git a/src/graphics/cframebuffer.cpp b/src/graphics/cframebuffer.cpp index fa791ea0b..9c3a517be 100644 --- a/src/graphics/cframebuffer.cpp +++ b/src/graphics/cframebuffer.cpp @@ -25,7 +25,7 @@ cFrameBuffer::cFrameBuffer() : cFrameBuffer::~cFrameBuffer() { if ( NULL != mTexture ) - cTextureFactory::instance()->Remove( mTexture->TexId() ); + cTextureFactory::instance()->Remove( mTexture->Id() ); } cTexture * cFrameBuffer::GetTexture() const { diff --git a/src/graphics/cframebufferfbo.cpp b/src/graphics/cframebufferfbo.cpp index 5cd2ca666..ececfa1f4 100644 --- a/src/graphics/cframebufferfbo.cpp +++ b/src/graphics/cframebufferfbo.cpp @@ -1,9 +1,16 @@ #include "cframebufferfbo.hpp" #include "ctexturefactory.hpp" #include "../window/cengine.hpp" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { +bool cFrameBufferFBO::IsSupported() { + return 0 != cGL::instance()->IsExtension( EEGL_EXT_framebuffer_object ); +} + cFrameBufferFBO::cFrameBufferFBO() : cFrameBuffer(), mFrameBuffer(0), @@ -39,10 +46,6 @@ cFrameBufferFBO::~cFrameBufferFBO() { } } -bool cFrameBufferFBO::IsSupported() { - return 0 != GLEW_EXT_framebuffer_object; -} - bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height ) { return Create( Width, Height, false ); } @@ -87,7 +90,7 @@ bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height, bool De return false; } - glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mTexture->Texture(), 0 ); + glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mTexture->Handle(), 0 ); if ( glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT ) { glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); diff --git a/src/graphics/cframebufferpbuffer.cpp b/src/graphics/cframebufferpbuffer.cpp index 5ee016f9e..58161a4e9 100644 --- a/src/graphics/cframebufferpbuffer.cpp +++ b/src/graphics/cframebufferpbuffer.cpp @@ -224,7 +224,7 @@ void cFrameBufferPBuffer::Bind() { #endif if ( ChangeContext ) { - Window::cEngine::instance()->ResetGL2D( true ); + Window::cEngine::instance()->Setup2D( true ); SetBufferView(); } } @@ -233,7 +233,7 @@ void cFrameBufferPBuffer::Unbind() { GLint previousTexture; glGetIntegerv( GL_TEXTURE_BINDING_2D, &previousTexture ); - glBindTexture( GL_TEXTURE_2D, (GLint)mTexture->Texture() ); + glBindTexture( GL_TEXTURE_2D, (GLint)mTexture->Handle() ); glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, mWidth, mHeight ); glBindTexture( GL_TEXTURE_2D, previousTexture ); diff --git a/src/graphics/cparticlesystem.cpp b/src/graphics/cparticlesystem.cpp index cfc23fafc..a21573fa5 100755 --- a/src/graphics/cparticlesystem.cpp +++ b/src/graphics/cparticlesystem.cpp @@ -1,4 +1,7 @@ #include "cparticlesystem.hpp" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { @@ -13,7 +16,7 @@ cParticleSystem::~cParticleSystem() { void cParticleSystem::Create(const EE_PARTICLE_EFFECT& Effect, const Uint32& NumParticles, const Uint32& TexId, const eeFloat& X, const eeFloat& Y, const eeFloat& PartSize, const bool& AnimLoop, const Uint32& NumLoops, const eeColorAf& Color, const eeFloat& X2, const eeFloat& Y2, const eeFloat& AlphaDecay, const eeFloat& XSpeed, const eeFloat& YSpeed, const eeFloat& XAcceleration, const eeFloat& YAcceleration) { mParticle.clear(); - mPointsSup = EE->PointSpriteSuppported(); + mPointsSup = cGL::instance()->PointSpriteSupported(); mEffect = Effect; mX = X; @@ -235,7 +238,7 @@ void cParticleSystem::Reset(cParticle* P) { void cParticleSystem::Draw() { TF->Bind( mTexId ); - TF->SetBlendFunc( ALPHA_BLENDONE ); + TF->SetPreBlendFunc( ALPHA_BLENDONE ); if ( mPointsSup ) { glEnable( GL_POINT_SPRITE_ARB ); @@ -258,7 +261,7 @@ void cParticleSystem::Draw() { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); BR->SetTexture( Tex ); - BR->SetBlendFunc( ALPHA_BLENDONE ); + BR->SetPreBlendFunc( ALPHA_BLENDONE ); BR->QuadsBegin(); for ( Uint32 i = 0; i < mParticle.size(); i++ ) { @@ -268,7 +271,7 @@ void cParticleSystem::Draw() { if ( P->Used() ) { TL.x = P->X() - mHSize; TL.y = P->Y() - mHSize; - + /** FIXME: Optimize */ BR->QuadsSetColor( eeColorA( static_cast ( P->R() * 255 ), static_cast ( P->G() * 255 ), static_cast( P->B() * 255 ), static_cast( P->A() * 255 ) ) ); BR->BatchQuad( TL.x, TL.y, mSize, mSize ); diff --git a/src/graphics/cprimitives.cpp b/src/graphics/cprimitives.cpp index d3afba588..cb67263cb 100755 --- a/src/graphics/cprimitives.cpp +++ b/src/graphics/cprimitives.cpp @@ -11,9 +11,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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners ) { BR->SetTexture( NULL ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); eeUint i; eeFloat xscalediff = width * Scale - width; @@ -25,7 +25,7 @@ void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const Poly.Rotate( Angle, Center ); switch(fillmode) { - case DRAW_FILL: { + case EE_DRAW_FILL: { if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) { BR->PolygonSetColor( TopLeft ); @@ -51,7 +51,7 @@ void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const break; } - case DRAW_LINE: + case EE_DRAW_LINE: BR->SetLineWidth( lineWidth ); BR->LineLoopBegin(); @@ -85,23 +85,23 @@ void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const BR->Draw(); } -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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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; } BR->SetTexture( NULL ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); switch(fillmode) { - case DRAW_FILL: { + case EE_DRAW_FILL: { BR->QuadsBegin(); BR->QuadsSetColorFree( TopLeft, BottomLeft, BottomRight, TopRight ); BR->BatchQuadEx( x, y, width, height, Angle, Scale ); break; } - case DRAW_LINE: + case EE_DRAW_LINE: BR->SetLineWidth( lineWidth ); BR->LineLoopBegin(); @@ -155,14 +155,14 @@ void cPrimitives::DrawPoint( const eeFloat& x, const eeFloat& y, const eeFloat& BR->Draw(); } -void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat& radius, Uint32 points, const EE_FILLMODE& fillmode, const eeFloat& lineWidth ) { +void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat& radius, Uint32 points, const EE_FILL_MODE& fillmode, const eeFloat& lineWidth ) { if(points < 6) points = 6; eeFloat angle_shift = 360 / static_cast(points); BR->SetTexture( NULL ); switch( fillmode ) { - case DRAW_LINE: + case EE_DRAW_LINE: BR->SetLineWidth( lineWidth ); BR->LineLoopBegin(); BR->LineLoopSetColor( mColor ); @@ -171,7 +171,7 @@ void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat& BR->BatchLineLoop( x + radius * sinAng(i), y + radius * cosAng(i), x + radius * sinAng( i + angle_shift ), y + radius * cosAng( i + angle_shift ) ); break; - case DRAW_FILL: + case EE_DRAW_FILL: BR->TriangleFanBegin(); BR->TriangleFanSetColor( mColor ); @@ -184,12 +184,12 @@ void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat& BR->Draw(); } -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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { BR->SetTexture( NULL ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); switch(fillmode) { - case DRAW_LINE: + case EE_DRAW_LINE: BR->SetLineWidth( lineWidth ); BR->LineLoopBegin(); @@ -200,7 +200,7 @@ void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFlo BR->BatchLineLoop( x2, y2, x3, y3 ); break; default: - case DRAW_FILL: + case EE_DRAW_FILL: BR->TrianglesBegin(); BR->TrianglesSetColorFree( Color1, Color2, Color3 ); @@ -212,12 +212,12 @@ void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFlo BR->Draw(); } -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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { BR->SetTexture( NULL ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); switch(fillmode) { - case DRAW_LINE: + case EE_DRAW_LINE: BR->SetLineWidth( lineWidth ); BR->LineLoopBegin(); @@ -226,7 +226,7 @@ void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& BR->LineLoopSetColorFree( Color2, Color3 ); BR->BatchLineLoop( OffsetX + x3, OffsetY + y3, OffsetX + x4, OffsetY + y4 ); break; - case DRAW_FILL: + case EE_DRAW_FILL: BR->QuadsBegin(); BR->QuadsSetColorFree( Color1, Color2, Color3, Color4 ); BR->BatchQuadFree( OffsetX + x1, OffsetY + y1, OffsetX + x2, OffsetY + y2, OffsetX + x3, OffsetY + y3, OffsetX + x4, OffsetY + y4 ); @@ -236,12 +236,12 @@ void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& BR->Draw(); } -void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILLMODE& fillmode, const EE_RENDERALPHAS& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth) { BR->SetTexture( NULL ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); switch(fillmode) { - case DRAW_LINE: + case EE_DRAW_LINE: BR->SetLineWidth( lineWidth ); BR->LineLoopBegin(); @@ -251,7 +251,7 @@ void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILLMODE& fillmode, BR->BatchLineLoop( p[i].x, p[i].y, p[i+1].x, p[i+1].y ); break; - case DRAW_FILL: + case EE_DRAW_FILL: BR->PolygonSetColor( mColor ); BR->BatchPolygon( p ); break; @@ -260,27 +260,27 @@ void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILLMODE& fillmode, BR->Draw(); } -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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend, const eeFloat& lineWidth, const eeUint& Corners ) { DrawRoundedRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); } @@ -292,7 +292,7 @@ void cPrimitives::DrawPoint(const eeVector2f& p, const eeFloat& pointSize) { DrawPoint(p.x, p.y, pointSize); } -void cPrimitives::DrawCircle(const eeVector2f& p, const eeFloat& radius, Uint32 points, const EE_FILLMODE& fillmode, const eeFloat& lineWidth) { +void cPrimitives::DrawCircle(const eeVector2f& p, const eeFloat& radius, Uint32 points, const EE_FILL_MODE& fillmode, const eeFloat& lineWidth) { DrawCircle(p.x, p.y, radius, points, fillmode, lineWidth); } @@ -301,39 +301,39 @@ void cPrimitives::SetColor( const eeColorA& Color ) { glColor4ub( mColor.R(), mColor.G(), mColor.B(), mColor.A() ); } -void cPrimitives::DrawTriangle(const eeTriangle2f& t, const EE_FILLMODE& fillmode, const EE_RENDERALPHAS& blend, const eeFloat& lineWidth) { +void cPrimitives::DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode, const EE_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& blend, const eeFloat& 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) { 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode, const EE_RENDERALPHAS& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& 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 ) { 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/graphics/cprimitives.hpp b/src/graphics/cprimitives.hpp index 14bbbb5a3..e9bb3c09a 100755 --- a/src/graphics/cprimitives.hpp +++ b/src/graphics/cprimitives.hpp @@ -49,7 +49,7 @@ class EE_API cPrimitives { * @param fillmode Draw filled or only lines * @param lineWidth The line width ( default 1.0f ) */ - void DrawCircle(const eeVector2f& p, const eeFloat& radius, Uint32 points = 360, const EE_FILLMODE& fillmode = DRAW_FILL, const eeFloat& lineWidth = 1.0f); + void DrawCircle(const eeVector2f& p, const eeFloat& radius, Uint32 points = 360, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const eeFloat& lineWidth = 1.0f); /** Draw a circle on the screen * @param x Point x axis @@ -59,7 +59,7 @@ class EE_API cPrimitives { * @param fillmode Draw filled or only lines * @param lineWidth The line width ( default 1.0f ) */ - void DrawCircle(const eeFloat& x, const eeFloat& y, const eeFloat& radius, Uint32 points = 360, const EE_FILLMODE& fillmode = DRAW_FILL, const eeFloat& lineWidth = 1.0f); + void DrawCircle(const eeFloat& x, const eeFloat& y, const eeFloat& radius, Uint32 points = 360, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param x1 First Point x axis @@ -75,7 +75,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param x1 First Point x axis @@ -88,7 +88,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param p1 First Point axis @@ -101,7 +101,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param p1 First Point axis @@ -111,7 +111,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a triangle on the screen * @param t The Triangle (eeTriangle2f) @@ -119,7 +119,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 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); /** Draw a triangle on the screen * @param t The Triangle (eeTriangle2f) @@ -130,7 +130,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); /** Draw a rectangle on the screen * @param x Screen x axis @@ -143,9 +143,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a rectangle on the screen * @param x Screen x axis @@ -162,9 +162,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a rectangle on the screen * @param R The Rectangle eeRectf @@ -174,9 +174,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); /** Draw a rectangle on the screen * @param R The Rectangle eeRectf @@ -190,9 +190,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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 @@ -211,7 +211,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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 @@ -226,7 +226,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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 @@ -241,7 +241,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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 @@ -252,7 +252,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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 @@ -260,7 +260,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& 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_PRE_BLEND_FUNC& 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 @@ -268,7 +268,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_FILLMODE& fillmode = DRAW_FILL, const EE_RENDERALPHAS& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 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); /** Set the current color for drawing primitives */ void SetColor( const eeColorA& Color ); diff --git a/src/graphics/cscrollparallax.cpp b/src/graphics/cscrollparallax.cpp index 5c249277b..f1bdebb9a 100755 --- a/src/graphics/cscrollparallax.cpp +++ b/src/graphics/cscrollparallax.cpp @@ -8,12 +8,12 @@ cScrollParallax::cScrollParallax() { cScrollParallax::~cScrollParallax() {} -cScrollParallax::cScrollParallax( const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT, const eeRGBA& Color, const Uint8& Alpha, const EE_RENDERALPHAS& Effect ) { +cScrollParallax::cScrollParallax( const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT, const eeRGBA& Color, const Uint8& Alpha, const EE_PRE_BLEND_FUNC& Effect ) { TF = cTextureFactory::instance(); Create( TexId, DestX, DestY, DestWidth, DestHeight, SrcRECT, Color, Alpha, Effect ); } -bool cScrollParallax::Create(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT, const eeRGBA& Color, const Uint8& Alpha, const EE_RENDERALPHAS& Effect ) { +bool cScrollParallax::Create(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT, const eeRGBA& Color, const Uint8& Alpha, const EE_PRE_BLEND_FUNC& Effect ) { cTexture * Tex = TF->GetTexture( TexId ); if ( NULL == Tex ) diff --git a/src/graphics/cscrollparallax.hpp b/src/graphics/cscrollparallax.hpp index e6957e936..3d28db875 100755 --- a/src/graphics/cscrollparallax.hpp +++ b/src/graphics/cscrollparallax.hpp @@ -14,7 +14,7 @@ class EE_API cScrollParallax { ~cScrollParallax(); /** Constructor that create's the Scroll Parallax */ - cScrollParallax(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT = eeRecti(0, 0, 0, 0), const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const Uint8& Alpha = 255, const EE_RENDERALPHAS& Effect = ALPHA_NORMAL); + cScrollParallax(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT = eeRecti(0, 0, 0, 0), const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const Uint8& Alpha = 255, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL); /** Create's the Scroll Parallax * @param TexId The Internal Texture Id @@ -28,7 +28,7 @@ class EE_API cScrollParallax { * @param Effect The Blend Mode ( default ALPHA_NORMAL ) * @return True if success */ - bool Create(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT = eeRecti(0, 0, 0, 0), const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const Uint8& Alpha = 255, const EE_RENDERALPHAS& Effect = ALPHA_NORMAL); + bool Create(const Uint32& TexId, const eeFloat& DestX, const eeFloat& DestY, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeRecti& SrcRECT = eeRecti(0, 0, 0, 0), const eeRGBA& Color = eeRGBA(255, 255, 255, 255), const Uint8& Alpha = 255, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL); /** Set the Alpha */ void Alpha( const Uint8& Alpha ) { mSpr.Alpha( Alpha ); } @@ -43,7 +43,7 @@ class EE_API cScrollParallax { eeRGBA Color() const { return mSpr.Color(); } /** Set the Blend Mode */ - void SetRenderAlphas( const EE_RENDERALPHAS& Effect ) { mSpr.SetRenderAlphas( Effect ); } + void SetRenderAlphas( const EE_PRE_BLEND_FUNC& Effect ) { mSpr.SetRenderAlphas( Effect ); } /** Draw the Scroll Parallax * @param XDirVel X Direction Speed to move the parallax. diff --git a/src/graphics/cshaderprogram.cpp b/src/graphics/cshaderprogram.cpp index b4e0ed0b3..a25d74d67 100644 --- a/src/graphics/cshaderprogram.cpp +++ b/src/graphics/cshaderprogram.cpp @@ -1,8 +1,8 @@ #include "cshaderprogram.hpp" -#include "../window/cengine.hpp" #include "cshaderprogrammanager.hpp" +#include "glhelper.hpp" -using namespace EE::Window; +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { @@ -111,7 +111,7 @@ void cShaderProgram::RemoveFromManager() { } void cShaderProgram::Init() { - if ( cEngine::instance()->ShadersSupported() && 0 == Id() ) { + if ( cGL::instance()->ShadersSupported() && 0 == Id() ) { mGLId = glCreateProgram(); mValid = false; mUniformLocations.clear(); diff --git a/src/graphics/cshape.cpp b/src/graphics/cshape.cpp index 787c2a1a5..435738e0f 100644 --- a/src/graphics/cshape.cpp +++ b/src/graphics/cshape.cpp @@ -159,12 +159,12 @@ void cShape::OffsetY( const eeFloat& offsety ) { mOffSetY = offsety; } -void cShape::Draw( const eeFloat& X, const eeFloat& Y, const eeRGBA& Color, const eeFloat& Angle, const eeFloat& Scale, const EE_RENDERALPHAS& Blend, const EE_RENDERTYPE& Effect, const bool& ScaleRendered ) { +void cShape::Draw( const eeFloat& X, const eeFloat& Y, const eeRGBA& Color, const eeFloat& Angle, const eeFloat& Scale, const EE_PRE_BLEND_FUNC& 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 cShape::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Angle, const eeFloat& Scale, const eeRGBA& Color0, const eeRGBA& Color1, const eeRGBA& Color2, const eeRGBA& Color3, const EE_RENDERALPHAS& Blend, const EE_RENDERTYPE& Effect, const bool& ScaleRendered ) { +void cShape::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Angle, const eeFloat& Scale, const eeRGBA& Color0, const eeRGBA& Color1, const eeRGBA& Color2, const eeRGBA& Color3, const EE_PRE_BLEND_FUNC& 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 ); } @@ -325,8 +325,8 @@ bool cShape::Unlock( const bool& KeepData, const bool& Modified ) { GLint PreviousTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture); - if ( PreviousTexture != (Int32)mTexture->Texture() ) - glBindTexture(GL_TEXTURE_2D, mTexture->Texture() ); + if ( PreviousTexture != (Int32)mTexture->Handle() ) + glBindTexture(GL_TEXTURE_2D, mTexture->Handle() ); Uint32 Channels = mTexture->Channels(); Uint32 Channel = GL_RGBA; @@ -340,7 +340,7 @@ bool cShape::Unlock( const bool& KeepData, const bool& Modified ) { glTexSubImage2D( GL_TEXTURE_2D, 0, mSrcRect.Left, mSrcRect.Top, mSrcRect.Size().Width(), mSrcRect.Size().Height(), Channel, GL_UNSIGNED_BYTE, reinterpret_cast ( &mPixels[0] ) ); - if ( PreviousTexture != (Int32)mTexture->Texture() ) + if ( PreviousTexture != (Int32)mTexture->Handle() ) glBindTexture(GL_TEXTURE_2D, PreviousTexture); } diff --git a/src/graphics/cshape.hpp b/src/graphics/cshape.hpp index e30c48016..df31cccdf 100644 --- a/src/graphics/cshape.hpp +++ b/src/graphics/cshape.hpp @@ -51,9 +51,9 @@ class EE_API cShape { void OffsetY( const eeFloat& offsety ); - void Draw( const eeFloat& X, const eeFloat& Y, const eeRGBA& Color = eeRGBA(), const eeFloat& Angle = 0.f, const eeFloat& Scale = 1.f, const EE_RENDERALPHAS& Blend = ALPHA_NORMAL, const EE_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); + void Draw( const eeFloat& X, const eeFloat& Y, const eeRGBA& Color = eeRGBA(), 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 eeFloat& Angle, const eeFloat& Scale, const eeRGBA& Color0 = eeRGBA(), const eeRGBA& Color1 = eeRGBA(), const eeRGBA& Color2 = eeRGBA(), const eeRGBA& Color3 = eeRGBA(), const EE_RENDERALPHAS& 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 eeRGBA& Color0 = eeRGBA(), const eeRGBA& Color1 = eeRGBA(), const eeRGBA& Color2 = eeRGBA(), const eeRGBA& Color3 = eeRGBA(), const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL, const EE_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true ); cTexture * GetTexture(); diff --git a/src/graphics/csprite.cpp b/src/graphics/csprite.cpp index 3fc3096a1..99b04af19 100755 --- a/src/graphics/csprite.cpp +++ b/src/graphics/csprite.cpp @@ -166,7 +166,7 @@ void cSprite::Update( const eeFloat& x, const eeFloat& y, const eeFloat& Scale, Uint32 cSprite::GetTexture(const eeUint& FrameNum, const eeUint& SubFrameNum) { if ( FrameNum < mFrames.size() && SubFrameNum < mFrameData.SubFrames ) - return mFrames[FrameNum].Spr[SubFrameNum]->Texture(); + return mFrames[FrameNum].Spr[SubFrameNum]->Id(); return 0; } @@ -316,7 +316,7 @@ void cSprite::Animate( const eeFloat& ElapsedTime ) { mFrameData.CurrentFrame = (eeUint)mFrameData.fCurrentFrame; - if ( !mReverseAnim && mFrameData.fCurrentFrame > Size + 1.0f ) { + if ( !mReverseAnim && mFrameData.fCurrentFrame >= Size + 1.0f ) { if ( mRepeations < 0 ) { mFrameData.fCurrentFrame = 0.0f; mFrameData.CurrentFrame = 0; @@ -376,7 +376,7 @@ void cSprite::SetReverseFromStart() { mFrameData.CurrentFrame = Size; } -void cSprite::Draw( const EE_RENDERALPHAS& Blend, const EE_RENDERTYPE& Effect, const eeFloat& ElapsedTime ) { +void cSprite::Draw( const EE_PRE_BLEND_FUNC& Blend, const EE_RENDERTYPE& Effect, const eeFloat& ElapsedTime ) { Animate( ElapsedTime ); cShape * S = GetCurrentShape(); @@ -394,7 +394,7 @@ void cSprite::Draw() { Draw(mBlend, mEffect); } -void cSprite::Draw( const EE_RENDERALPHAS& Blend ) { +void cSprite::Draw( const EE_PRE_BLEND_FUNC& Blend ) { Draw(Blend, mEffect); } diff --git a/src/graphics/csprite.hpp b/src/graphics/csprite.hpp index 360a1c7d9..8893c6e70 100755 --- a/src/graphics/csprite.hpp +++ b/src/graphics/csprite.hpp @@ -117,7 +117,7 @@ class EE_API cSprite { void SetRenderType( const EE_RENDERTYPE& Effect ) { mEffect = Effect; } /** Set the Blend Mode */ - void SetRenderAlphas( const EE_RENDERALPHAS& Blend ) { mBlend = Blend; } + void SetRenderAlphas( const EE_PRE_BLEND_FUNC& Blend ) { mBlend = Blend; } /** Reset the sprite as a new one. */ void Reset(); @@ -247,12 +247,12 @@ class EE_API cSprite { * @param Effect The Render Type * @param ElapsedTime The Elapsed Time for the animation ( -99999.f will take the elapsed time counted by the engine ) */ - void Draw( const EE_RENDERALPHAS& Blend, const EE_RENDERTYPE& Effect, const eeFloat& ElapsedTime = -99999.f ); + void Draw( const EE_PRE_BLEND_FUNC& Blend, const EE_RENDERTYPE& Effect, const eeFloat& ElapsedTime = -99999.f ); /** Draw the sprite to the screen forcing the Blend Mode * @param Blend The Blend Mode */ - void Draw( const EE_RENDERALPHAS& Blend ); + void Draw( const EE_PRE_BLEND_FUNC& Blend ); /** Draw the sprite to the screen forcing the Render Type * @param Effect The Render Type @@ -317,7 +317,7 @@ class EE_API cSprite { eeFloat mX, mY, mAngle, mScale, mAnimSpeed; bool mAutoAnim; bool mScaleCentered; - EE_RENDERALPHAS mBlend; + EE_PRE_BLEND_FUNC mBlend; EE_RENDERTYPE mEffect; eeRGBA mColor, mColor0, mColor1, mColor2, mColor3; diff --git a/src/graphics/ctextcache.cpp b/src/graphics/ctextcache.cpp index 6d6cccecc..2938cf23c 100644 --- a/src/graphics/ctextcache.cpp +++ b/src/graphics/ctextcache.cpp @@ -8,7 +8,9 @@ cTextCache::cTextCache() : mCachedWidth(0.f), mNumLines(1), mFontColor(0xFFFFFFFF), - mFontShadowColor(0xFF000000) + mFontShadowColor(0xFF000000), + mCachedCoords(false), + mFlags(0) { } @@ -96,6 +98,8 @@ void cTextCache::Cache() { mFont->CacheWidth( mText, mLinesWidth, mCachedWidth, mNumLines ); else mCachedWidth = 0; + + mCachedCoords = false; } eeFloat cTextCache::GetTextWidth() { @@ -110,7 +114,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, const EE_RENDERALPHAS& Effect ) { +void cTextCache::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect ) { if ( NULL != mFont ) { eeColorA FontColor = mFont->Color(); eeColorA FontShadowColor = mFont->ShadowColor(); @@ -118,11 +122,28 @@ void cTextCache::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, mFont->Color( mFontColor ); mFont->ShadowColor( mFontShadowColor ); - mFont->Draw( *this, X, Y, Flags, Scale, Angle, Effect ); + if ( mFlags != Flags ) { + mFlags = Flags; + mCachedCoords = false; + } + + glTranslatef( X, Y, 0.f ); + + mFont->Draw( *this, 0, 0, Flags, Scale, Angle, Effect ); + + glTranslatef( -X, -Y, 0.f ); mFont->Color( FontColor ); mFont->ShadowColor( FontShadowColor ); } } +const bool& cTextCache::CachedCoords() const { + return mCachedCoords; +} + +void cTextCache::CachedCoords( const bool& cached ) { + mCachedCoords = cached; +} + }} diff --git a/src/graphics/ctextcache.hpp b/src/graphics/ctextcache.hpp index 3e7a969b4..854a45bec 100644 --- a/src/graphics/ctextcache.hpp +++ b/src/graphics/ctextcache.hpp @@ -37,7 +37,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, const EE_RENDERALPHAS& Effect = ALPHA_NORMAL ); + void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = 0, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); void Cache(); @@ -53,6 +53,8 @@ class EE_API cTextCache { /** Set the shadow color of the string rendered */ void ShadowColor(const eeColorA& Color); protected: + friend class cFont; + std::wstring mText; cFont * mFont; std::vector mLinesWidth; @@ -64,8 +66,14 @@ class EE_API cTextCache { std::vector mRenderCoords; std::vector mColors; + bool mCachedCoords; + Uint32 mFlags; void UpdateCoords(); + + const bool& CachedCoords() const; + + void CachedCoords( const bool& cached ); }; }} diff --git a/src/graphics/ctexture.cpp b/src/graphics/ctexture.cpp index fc2dc873b..271fe8bfc 100755 --- a/src/graphics/ctexture.cpp +++ b/src/graphics/ctexture.cpp @@ -13,7 +13,7 @@ cTexture::cTexture() : mFlags(0), mColorKey(eeRGB(true)), mClampMode( EE_CLAMP_TO_EDGE ), - mFilter( TEX_LINEAR ) + mFilter( EE_TEX_LINEAR ) { } @@ -90,7 +90,7 @@ void cTexture::Create( const Uint32& texture, const eeUint& width, const eeUint& mSize = MemSize; mColorKey = ColorKey; mClampMode = ClampMode; - mFilter = TEX_LINEAR; + mFilter = EE_TEX_LINEAR; if ( UseMipmap ) mFlags |= TEX_FLAG_MIPMAP; @@ -235,12 +235,12 @@ void cTexture::SetTextureFilter(const EE_TEX_FILTER& filter) { if ( PreviousTexture != (GLint)mTexture ) glBindTexture(GL_TEXTURE_2D, mTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (mFilter == TEX_LINEAR) ? GL_LINEAR : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (mFilter == EE_TEX_LINEAR) ? GL_LINEAR : GL_NEAREST); if ( mFlags & TEX_FLAG_MIPMAP ) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mFilter == TEX_LINEAR) ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mFilter == EE_TEX_LINEAR) ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST); else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mFilter == TEX_LINEAR) ? GL_LINEAR : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mFilter == EE_TEX_LINEAR) ? GL_LINEAR : GL_NEAREST); if ( PreviousTexture != (GLint)mTexture ) glBindTexture(GL_TEXTURE_2D, PreviousTexture); @@ -332,11 +332,11 @@ void cTexture::ApplyClampMode() { } } -void cTexture::TexId( const Uint32& id ) { +void cTexture::Id( const Uint32& id ) { mTexId = id; } -const Uint32& cTexture::TexId() const { +const Uint32& cTexture::Id() const { return mTexId; } @@ -371,7 +371,7 @@ void cTexture::Reload() { } } -const Uint32& cTexture::Id() const { +const Uint32& cTexture::HashName() const { return mId; } @@ -407,11 +407,11 @@ bool cTexture::Compressed() const { return mFlags & TEX_FLAG_COMPRESSED; } -void cTexture::Draw( const eeFloat &x, const eeFloat &y, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_RENDERALPHAS &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_PRE_BLEND_FUNC &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_RENDERALPHAS &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_PRE_BLEND_FUNC &blend, const eeFloat &width, const eeFloat &height ) { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); eeFloat w = width, h = height; @@ -419,7 +419,7 @@ void cTexture::DrawFast( const eeFloat& x, const eeFloat& y, const eeFloat& Angl if (!h) h = (eeFloat)ImgHeight(); BR->SetTexture( this ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); BR->QuadsBegin(); BR->QuadsSetColor( Color ); @@ -432,7 +432,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_RENDERALPHAS &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_PRE_BLEND_FUNC &blend, const EE_RENDERTYPE &Effect, const bool &ScaleCentered, const eeRecti& texSector) { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); bool renderdiv = true; @@ -475,7 +475,7 @@ void cTexture::DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width, renderdiv = false; BR->SetTexture( this ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); BR->QuadsBegin(); BR->QuadsSetColorFree( Color0, Color1, Color2, Color3 ); @@ -540,11 +540,11 @@ void cTexture::DrawEx( const eeFloat &x, const eeFloat &y, const eeFloat &width, BR->DrawOpt(); } -void cTexture::DrawQuad( const eeQuad2f& Q, const eeFloat &offsetx, const eeFloat &offsety, const eeFloat &Angle, const eeFloat &Scale, const eeColorA& Color, const EE_RENDERALPHAS &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_PRE_BLEND_FUNC &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_RENDERALPHAS &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_PRE_BLEND_FUNC &blend, const eeRecti& texSector ) { cBatchRenderer * BR = cGlobalBatchRenderer::instance(); bool renderdiv = true; @@ -568,7 +568,7 @@ void cTexture::DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx, const eeFl renderdiv = false; BR->SetTexture( this ); - BR->SetBlendFunc( blend ); + BR->SetPreBlendFunc( blend ); BR->QuadsBegin(); BR->QuadsSetColorFree( Color0, Color1, Color2, Color3 ); diff --git a/src/graphics/ctexture.hpp b/src/graphics/ctexture.hpp index e166208e6..3cc6f9ef2 100755 --- a/src/graphics/ctexture.hpp +++ b/src/graphics/ctexture.hpp @@ -40,14 +40,14 @@ class EE_API cTexture : public cImage { */ 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 eeRGB& ColorKey, const EE_CLAMP_MODE& ClampMode, const bool& CompressedTexture, const Uint32& MemSize = 0, const Uint8* data = NULL ); - /** Set the OpenGL Texture Id (texture handler) */ - void Texture( const Uint32& texture ) { mTexture = texture; } + /** Set the OpenGL Texture Id (texture handle) */ + void Handle( const Uint32& texture ) { mTexture = texture; } - /** @return The OpenGL Texture Id (texture handler) */ - Uint32 Texture() const { return mTexture; } + /** @return The OpenGL Texture Id (texture handle) */ + Uint32 Handle() const { return mTexture; } - /** @return The id of the texture ( that is the hash of the filename ) */ - const Uint32& Id() const; + /** @return The hash of the filename */ + const Uint32& HashName() const; /** Set the Texture File Path */ void Filepath( const std::string& filepath ) { mFilepath = filepath; } @@ -140,7 +140,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_RENDERALPHAS &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_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const eeFloat &width = 0, const eeFloat &height = 0 ); /** Render the texture on screen * @param x The x position on screen @@ -155,7 +155,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_RENDERALPHAS &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_PRE_BLEND_FUNC &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 @@ -173,7 +173,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_RENDERALPHAS &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_PRE_BLEND_FUNC &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 @@ -185,7 +185,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_RENDERALPHAS &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_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Render a GL_QUAD on Screen * @param Q The eeQuad2f @@ -200,13 +200,13 @@ 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_RENDERALPHAS &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_PRE_BLEND_FUNC &blend = ALPHA_NORMAL, const eeRecti& texSector = eeRecti(0,0,0,0) ); /** Set the texture factory internal id of the texture */ - void TexId( const Uint32& id ); + void Id( const Uint32& id ); /** @return The texture factory internal id of the texture */ - const Uint32& TexId() const; + const Uint32& Id() const; /** Reload the texture from the current local copy. */ void Reload(); diff --git a/src/graphics/ctexturefactory.cpp b/src/graphics/ctexturefactory.cpp index b3aa5a65f..d341a20ea 100755 --- a/src/graphics/ctexturefactory.cpp +++ b/src/graphics/ctexturefactory.cpp @@ -1,20 +1,23 @@ #include "ctexturefactory.hpp" #include "../window/cengine.hpp" #include "ctextureloader.hpp" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; using namespace EE::Window; namespace EE { namespace Graphics { cTextureFactory::cTextureFactory() : - mCurrentTexture(0), - mIsCalcPowOfTwo(false), mMemSize(0) { mTextures.clear(); mTextures.push_back( NULL ); mAppPath = AppPath(); + + memset( &mCurrentTexture[0], 0, EE_MAX_TEXTURE_UNITS ); } cTextureFactory::~cTextureFactory() { @@ -69,7 +72,7 @@ Uint32 cTextureFactory::PushTexture( const std::string& Filepath, const Uint32& Tex = mTextures[ Pos ] = eeNew( cTexture, () ); Tex->Create( TexId, Width, Height, MyWidth, MyHeight, Mipmap, Channels, FPath, ColorKey, ClampMode, CompressTexture, MemSize ); - Tex->TexId( Pos ); + Tex->Id( Pos ); if ( !ColorKey.voidRGB ) Tex->CreateMaskFromColor( eeColor( ColorKey.R(), ColorKey.G(), ColorKey.B() ) , 0 ); @@ -102,15 +105,22 @@ Uint32 cTextureFactory::FindFreeSlot() { return (Uint32)mTextures.size() - 1; } -void cTextureFactory::Bind( const cTexture* Tex ) { - if( NULL != Tex && mCurrentTexture != (Int32)Tex->Texture() ) { - glBindTexture( GL_TEXTURE_2D, Tex->Texture() ); - mCurrentTexture = Tex->Texture(); +void cTextureFactory::Bind( const cTexture* Tex, const Uint32& TextureUnit ) { + if( NULL != Tex && mCurrentTexture[ TextureUnit ] != (Int32)Tex->Handle() ) { + if ( cGL::instance()->IsExtension( EEGL_ARB_multitexture ) ) + glActiveTextureARB( GL_TEXTURE0_ARB + TextureUnit ); + + glBindTexture( GL_TEXTURE_2D, Tex->Handle() ); + + mCurrentTexture[ TextureUnit ] = Tex->Handle(); + + if ( cGL::instance()->IsExtension( EEGL_ARB_multitexture ) ) + glActiveTextureARB( GL_TEXTURE0_ARB ); } } -void cTextureFactory::Bind( const Uint32& TexId ) { - Bind( GetTexture( TexId ) ); +void cTextureFactory::Bind( const Uint32& TexId, const Uint32& TextureUnit ) { + Bind( GetTexture( TexId ), TextureUnit ); } void cTextureFactory::UnloadTextures() { @@ -130,12 +140,14 @@ bool cTextureFactory::Remove( const Uint32& TexId ) { if ( TexId < mTextures.size() && NULL != mTextures[ TexId ] ) { mMemSize -= GetTexMemSize( TexId ); - GLint glTexId = mTextures[ TexId ]->Texture(); + GLint glTexId = mTextures[ TexId ]->Handle(); eeSAFE_DELETE( mTextures[ TexId ] ); - if ( mCurrentTexture == (Int32)glTexId ) - mCurrentTexture = 0; + for ( Uint32 i = 0; i < EE_MAX_TEXTURE_UNITS; i++ ) { + if ( mCurrentTexture[ i ] == (Int32)glTexId ) + mCurrentTexture[ i ] = 0; + } mVectorFreeSlots.push( TexId ); @@ -145,12 +157,14 @@ bool cTextureFactory::Remove( const Uint32& TexId ) { return false; } -GLint cTextureFactory::GetCurrentTexture() const { - return mCurrentTexture; +GLint cTextureFactory::GetCurrentTexture( const Uint32& TextureUnit ) const { + //assert( TextureUnit < MAX_TEXTURE_UNITS ); + return mCurrentTexture[ TextureUnit ]; } -void cTextureFactory::SetCurrentTexture( const GLint& TexId ) { - mCurrentTexture = TexId; +void cTextureFactory::SetCurrentTexture( const GLint& TexId, const Uint32& TextureUnit ) { + //assert( TextureUnit < MAX_TEXTURE_UNITS ); + mCurrentTexture[ TextureUnit ] = TexId; } void cTextureFactory::ReloadAllTextures() { @@ -190,12 +204,21 @@ void cTextureFactory::UngrabTextures() { } } -void cTextureFactory::SetBlendFunc( const EE_RENDERALPHAS& blend, const bool& force ) { +void cTextureFactory::SetBlendFunc( const EE_BLEND_FUNC& SrcFactor, const EE_BLEND_FUNC& DestFactor ) { + glEnable( GL_BLEND ); + + glBlendFunc( (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) + if (blend == ALPHA_NONE) { glDisable( GL_BLEND ); - else { + } else { glEnable( GL_BLEND ); + switch (blend) { case ALPHA_NORMAL: glBlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); @@ -223,29 +246,50 @@ void cTextureFactory::SetBlendFunc( const EE_RENDERALPHAS& blend, const bool& fo case ALPHA_NONE: // AVOID COMPILER WARNING break; + case ALPHA_CUSTOM: + break; } } + mLastBlend = blend; } } -eeUint cTextureFactory::GetValidTextureSize(const eeUint& Size) { - if (!mIsCalcPowOfTwo) { - if ( cEngine::instance()->Running() ) { // This need the GL context initialized - char *extensions = (char *)glGetString(GL_EXTENSIONS); +void cTextureFactory::SetActiveTextureUnit( const Uint32& Unit ) { + glActiveTextureARB( GL_TEXTURE0_ARB + Unit ); +} - if ( strstr(extensions, "GL_ARB_texture_non_power_of_two") ) - mPowOfTwo = false; - else - mPowOfTwo = true; +void cTextureFactory::SetTextureConstantColor( const eeColorA& Color ) { + SetTextureConstantColor( eeColorAf( (eeFloat)Color.R() / 255.f, (eeFloat)Color.G() / 255.f, (eeFloat)Color.B() / 255.f, (eeFloat)Color.A() / 255.f ) ); +} - mIsCalcPowOfTwo = true; - } else - mPowOfTwo = false; +void cTextureFactory::SetTextureConstantColor( const eeColorAf& Color ) { + glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const GLfloat*)(&Color.Red) ); +} + +void cTextureFactory::SetTextureEnv( const EE_TEXTURE_PARAM& Param, const Int32& Val ) { + GLenum lParam = (GLenum)cGL::instance()->GetTextureParamEnum( Param ); + + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); + + if( Param == TEX_PARAM_COLOR_FUNC || Param == TEX_PARAM_ALPHA_FUNC ) { + glTexEnvi( GL_TEXTURE_ENV, lParam, cGL::instance()->GetTextureFuncEnum( (EE_TEXTURE_FUNC)Val ) ); + } else if( Param >= TEX_PARAM_COLOR_SOURCE_0 && Param <= TEX_PARAM_ALPHA_SOURCE_2 ) { + glTexEnvi( GL_TEXTURE_ENV, lParam, cGL::instance()->GetTextureSourceEnum( (EE_TEXTURE_SOURCE)Val ) ); + } else if( Param >= TEX_PARAM_COLOR_OP_0 && Param <= TEX_PARAM_ALPHA_OP_2 ) { + glTexEnvi( GL_TEXTURE_ENV, lParam, cGL::instance()->GetTextureOpEnum( (EE_TEXTURE_OP)Val ) ); + } else { + glTexEnvi( GL_TEXTURE_ENV, lParam, Val ); } +} - if ( !mPowOfTwo ) +const EE_PRE_BLEND_FUNC& cTextureFactory::GetPreBlendFunc() const { + return mLastBlend; +} + +eeUint cTextureFactory::GetValidTextureSize(const eeUint& Size) { + if ( cGL::instance()->IsExtension( EEGL_ARB_texture_non_power_of_two ) ) return Size; else return NextPowOfTwo(Size); @@ -313,7 +357,7 @@ cTexture * cTextureFactory::GetByHash( const Uint32& Hash ) { for ( Uint32 i = (Uint32)mTextures.size() - 1; i > 0; i-- ) { tTex = mTextures[ i ]; - if ( NULL != tTex && tTex->Id() == Hash ) + if ( NULL != tTex && tTex->HashName() == Hash ) return mTextures[ i ]; } diff --git a/src/graphics/ctexturefactory.hpp b/src/graphics/ctexturefactory.hpp index 1a437d2b4..c7605d41c 100755 --- a/src/graphics/ctexturefactory.hpp +++ b/src/graphics/ctexturefactory.hpp @@ -88,13 +88,15 @@ class EE_API cTextureFactory: public tSingleton, protected cMut /** Bind the the internal Texture Id indicated. This is usefull if you are rendering a texture outside this class. * @param TexId The internal Texture Id + * @param TextureUnit The Texture Unit binded */ - void Bind( const Uint32& TexId ); + void Bind( const Uint32& TexId, const Uint32& TextureUnit = 0 ); /** Bind the the Texture indicated. This is usefull if you are rendering a texture outside this class. * @param Tex The Texture Pointer + * @param TextureUnit The Texture Unit binded */ - void Bind( const cTexture* Tex ); + void Bind( const cTexture* Tex, const Uint32& TextureUnit = 0 ); /** * @param TexId The internal Texture Id @@ -104,22 +106,48 @@ class EE_API cTextureFactory: public tSingleton, protected cMut /** * @return The real current texture id (OpenGL Texture Id) + * @param TextureUnit The Texture Unit binded */ - GLint GetCurrentTexture() const; + GLint GetCurrentTexture( const Uint32& TextureUnit = 0 ) const; /** Set the current internal texture id. This will set the TexId as the current texture binded. * @param TexId The internal Texture Id + * @param TextureUnit The Texture Unit binded */ - void SetCurrentTexture( const GLint& TexId ); + void SetCurrentTexture( const GLint& TexId, const Uint32& TextureUnit ); /** Returns the number of textures loaded */ Uint32 GetNumTextures() const { return (Uint32)mTextures.size(); } - /** Set the Blend Function + /** Set a blend function. + * @SrcFactor Source Factor + * @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 SetBlendFunc( const EE_RENDERALPHAS& blend, const bool& force = false ); + 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 The texture param + * @Val The EE_TEXTURE_OP or EE_TEXTURE_FUNC or EE_TEXTURE_SOURCE + */ + void SetTextureEnv( const EE_TEXTURE_PARAM& Param, const Int32& Val ); + + /** Active a texture unit */ + void SetActiveTextureUnit( const Uint32& Unit ); + + /** Set a texture constant ( env ) color */ + void SetTextureConstantColor( const eeColorAf& Color ); + + /** Set a texture constant ( env ) color */ + void SetTextureConstantColor( const eeColorA& Color ); /** * @param Size @@ -186,11 +214,9 @@ class EE_API cTextureFactory: public tSingleton, protected cMut protected: cTextureFactory(); - GLint mCurrentTexture; + GLint mCurrentTexture[ EE_MAX_TEXTURE_UNITS ]; - EE_RENDERALPHAS mLastBlend; - - bool mPowOfTwo, mIsCalcPowOfTwo; + EE_PRE_BLEND_FUNC mLastBlend; std::vector mTextures; diff --git a/src/graphics/ctexturegrouploader.cpp b/src/graphics/ctexturegrouploader.cpp index add109d26..ca9e55277 100644 --- a/src/graphics/ctexturegrouploader.cpp +++ b/src/graphics/ctexturegrouploader.cpp @@ -194,7 +194,7 @@ void cTextureGroupLoader::CreateShapes() { eeRecti tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height ); - cShape * tShape = eeNew( cShape, ( tTex->TexId(), tRect, tSh->DestWidth, tSh->DestHeight, tSh->OffsetX, tSh->OffsetY, ShapeName ) ); + cShape * tShape = eeNew( cShape, ( tTex->Id(), tRect, tSh->DestWidth, tSh->DestHeight, tSh->OffsetX, tSh->OffsetY, ShapeName ) ); //if ( tSh->Flags & HDR_SHAPE_FLAG_FLIPED ) // Should rotate the shape, but.. shape rotation is not stored. diff --git a/src/graphics/ctextureloader.cpp b/src/graphics/ctextureloader.cpp index 996a0db21..38f8d2290 100644 --- a/src/graphics/ctextureloader.cpp +++ b/src/graphics/ctextureloader.cpp @@ -3,6 +3,9 @@ #define STBI_TYPE_SPECIFIC_FUNCTIONS #include "../helper/SOIL/stb_image.h" #include "../helper/SOIL/SOIL.h" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { @@ -155,7 +158,7 @@ void cTextureLoader::Start() { void cTextureLoader::LoadFromPath() { if ( FileExists( mFilepath ) ) { - if ( GLEW_EXT_texture_compression_s3tc ) + if ( cGL::instance()->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) mIsDDS = 0 != stbi_dds_test_filename( mFilepath.c_str() ); if ( mIsDDS ) { @@ -187,7 +190,7 @@ void cTextureLoader::LoadFromPack() { } void cTextureLoader::LoadFromMemory() { - if ( GLEW_EXT_texture_compression_s3tc ) + if ( cGL::instance()->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) mIsDDS = 0 != stbi_dds_test_memory( mImagePtr, mSize ); if ( mIsDDS ) { diff --git a/src/graphics/cttffont.cpp b/src/graphics/cttffont.cpp index eb9ece344..2b874137c 100755 --- a/src/graphics/cttffont.cpp +++ b/src/graphics/cttffont.cpp @@ -19,13 +19,13 @@ cTTFFont::~cTTFFont() { hkFontManager::instance()->Destroy(); } -bool cTTFFont::LoadFromPack( cPack* Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) { +bool cTTFFont::LoadFromPack( cPack* Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) { std::vector TmpData; if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, TmpData ) ) { mFilepath = FilePackPath; - return LoadFromMemory( reinterpret_cast (&TmpData[0]), (eeUint)TmpData.size(), Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor ); + return LoadFromMemory( reinterpret_cast (&TmpData[0]), (eeUint)TmpData.size(), Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator ); } TmpData.clear(); @@ -33,7 +33,7 @@ bool cTTFFont::LoadFromPack( cPack* Pack, const std::string& FilePackPath, const return false; } -bool cTTFFont::LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) { +bool cTTFFont::LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) { if ( !mFilepath.size() ) mFilepath = "from memory"; @@ -41,25 +41,32 @@ bool cTTFFont::LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const mFont = hkFontManager::instance()->OpenFromMemory( reinterpret_cast(&TTFData[0]), TTFDataSize, Size, 0, NumCharsToGen ); - return iLoad( Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor ); + return iLoad( Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator ); } -bool cTTFFont::Load( const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) { +bool cTTFFont::Load( const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) { mFilepath = Filepath; mLoadedFromMemory = false; mFont = hkFontManager::instance()->OpenFromFile( Filepath.c_str(), Size, 0, NumCharsToGen ); - return iLoad( Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor ); + return iLoad( Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator ); } -bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) { +bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, Uint8 OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) { eeRect CurrentPos; eeSize GlyphRect; unsigned char * TempGlyphSurface; eeFloat Top, Bottom; + + // Change the outline size to add a pixel separating the character from the around characters to prevent ugly zooming of characters + Uint32 PixelSep = 0; + + if ( AddPixelSeparator ) + PixelSep = 1; + Uint8 OutlineTotal = OutlineSize * 2; Uint32 TexSize; @@ -72,33 +79,49 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve mFont->Style( Style ); - mVerticalDraw = VerticalDraw; - mSize = Size; - mNumChars = NumCharsToGen; - - mFontColor = FontColor; - mOutlineColor = OutlineColor; - - mStyle = Style; + mVerticalDraw = VerticalDraw; + mSize = Size; + mHeight = mFont->Height() + OutlineTotal; + mNumChars = NumCharsToGen; + mFontColor = FontColor; + mOutlineColor = OutlineColor; + mStyle = Style; + mTexWidth = 128; + mTexHeight = 128; mGlyphs.clear(); mGlyphs.resize( mNumChars ); - mTexWidth = (eeFloat)NextPowOfTwo( mSize * 16 ); - mTexHeight = mTexWidth; + bool lastWasWidth = false; + Uint32 ReqSize; + + // Find the best size for the texture ( aprox ) + + mSize += PixelSep; + + do { + ReqSize = mNumChars * mSize * mSize; + TexSize = (Uint32)mTexWidth * (Uint32)mTexHeight; + + if ( TexSize < ReqSize ) { + if ( !lastWasWidth ) + mTexWidth *= 2; + else + mTexHeight *= 2; + + lastWasWidth = !lastWasWidth; + } + } while ( TexSize < ReqSize ); + + mSize -= PixelSep; TexSize = (Uint32)mTexWidth * (Uint32)mTexHeight; - if ( ( mSize >= 60 && mNumChars > 256 ) || ( OutlineSize > 2 && mNumChars >= 512 && mSize >= 24 ) ) - mTexHeight *= 2; - - mHeight = mFont->Height() + OutlineTotal; - mPixels = eeNewArray( eeColorA, TexSize ); memset( mPixels, 0x00000000, TexSize * 4 ); CurrentPos.Left = OutlineSize; - CurrentPos.Top = OutlineSize; + CurrentPos.Top = OutlineSize; //Loop through all chars for ( eeUint i = 0; i < mNumChars; i++) { @@ -115,10 +138,10 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve GlyphRect.y = mFont->Current()->Pixmap()->rows; //Set size of current position rect - CurrentPos.Right = CurrentPos.Left + TempGlyph.MaxX; - CurrentPos.Bottom = CurrentPos.Top + TempGlyph.MaxY; + CurrentPos.Right = CurrentPos.Left + TempGlyph.MaxX; + CurrentPos.Bottom = CurrentPos.Top + TempGlyph.MaxY; - if (CurrentPos.Right >= mTexWidth) { + if ( CurrentPos.Right >= mTexWidth ) { CurrentPos.Left = 0 + OutlineSize; CurrentPos.Top += mHeight; } @@ -144,8 +167,8 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve } // Fixes the width and height of the current pos - CurrentPos.Right = GlyphRect.x; - CurrentPos.Bottom = GlyphRect.y; + CurrentPos.Right = GlyphRect.x; + CurrentPos.Bottom = GlyphRect.y; // Set texture coordinates to te list eeRectf tR; @@ -173,10 +196,10 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve TempGlyph.GlyphH = GlyphRect.y + OutlineSize; //Position xpos ready for next glyph - CurrentPos.Left += GlyphRect.x + OutlineTotal; + CurrentPos.Left += GlyphRect.x + OutlineTotal + PixelSep; //If the next character will run off the edge of the glyph sheet, advance to next row - if (CurrentPos.Left + CurrentPos.Right > mTexWidth) { + if ( CurrentPos.Left + CurrentPos.Right > mTexWidth ) { CurrentPos.Left = 0 + OutlineSize; CurrentPos.Top += mHeight; } diff --git a/src/graphics/cttffont.hpp b/src/graphics/cttffont.hpp index b25c77780..8b02bc0cb 100755 --- a/src/graphics/cttffont.hpp +++ b/src/graphics/cttffont.hpp @@ -27,7 +27,7 @@ class EE_API cTTFFont : public cFont { * @param OutlineColor The Outline Color * @return If success */ - bool Load( const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) ); + bool Load( const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); /** Load Font from pack * @param Pack Pointer to the pack instance @@ -41,7 +41,7 @@ class EE_API cTTFFont : public cFont { * @param OutlineColor The Outline Color * @return If success */ - bool LoadFromPack( cPack* Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) ); + bool LoadFromPack( cPack* Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); /** Load a True Type Font from memory * @param TTFData The pointer to the data @@ -55,7 +55,7 @@ class EE_API cTTFFont : public cFont { * @param OutlineColor The Outline Color * @return If success */ - bool LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) ); + bool LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); /** Save the texture generated from the TTF file to disk */ bool SaveTexture( const std::string& Filepath, const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_PNG ); @@ -94,7 +94,7 @@ class EE_API cTTFFont : public cFont { bool mThreadedLoading; bool mTexReady; - bool iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ); + bool iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, Uint8 OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ); void MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h); void RebuildFromGlyphs(); }; diff --git a/src/graphics/cttffontloader.cpp b/src/graphics/cttffontloader.cpp index 6e47ebfb4..3f51ebce4 100644 --- a/src/graphics/cttffontloader.cpp +++ b/src/graphics/cttffontloader.cpp @@ -2,7 +2,7 @@ namespace EE { namespace Graphics { -cTTFFontLoader::cTTFFontLoader( const std::string& FontName, const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) : +cTTFFontLoader::cTTFFontLoader( const std::string& FontName, const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) : cObjectLoader( FontTTFLoader ), mLoadType( TTF_LT_PATH ), mFontName( FontName ), @@ -14,11 +14,12 @@ cTTFFontLoader::cTTFFontLoader( const std::string& FontName, const std::string& mFontColor( FontColor ), mOutlineSize( OutlineSize ), mOutlineColor( OutlineColor ), + mAddPixelSeparator( AddPixelSeparator ), mFontLoaded( false ) { } -cTTFFontLoader::cTTFFontLoader( const std::string& FontName, cPack * Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) : +cTTFFontLoader::cTTFFontLoader( const std::string& FontName, cPack * Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) : cObjectLoader( FontTTFLoader ), mLoadType( TTF_LT_PACK ), mFontName( FontName ), @@ -30,12 +31,13 @@ cTTFFontLoader::cTTFFontLoader( const std::string& FontName, cPack * Pack, const mFontColor( FontColor ), mOutlineSize( OutlineSize ), mOutlineColor( OutlineColor ), + mAddPixelSeparator( AddPixelSeparator ), mPack( Pack ), mFontLoaded( false ) { } -cTTFFontLoader::cTTFFontLoader( const std::string& FontName, Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor ) : +cTTFFontLoader::cTTFFontLoader( const std::string& FontName, Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) : cObjectLoader( FontTTFLoader ), mLoadType( TTF_LT_MEM ), mFontName( FontName ), @@ -46,6 +48,7 @@ cTTFFontLoader::cTTFFontLoader( const std::string& FontName, Uint8* TTFData, con mFontColor( FontColor ), mOutlineSize( OutlineSize ), mOutlineColor( OutlineColor ), + mAddPixelSeparator( AddPixelSeparator ), mData( TTFData ), mDataSize( TTFDataSize ), mFontLoaded( false ) @@ -88,15 +91,15 @@ const std::string& cTTFFontLoader::Id() const { } void cTTFFontLoader::LoadFromPath() { - mFont->Load( mFilepath, mSize, mStyle, mVerticalDraw, mNumCharsToGen, mFontColor, mOutlineSize, mOutlineColor ); + mFont->Load( mFilepath, mSize, mStyle, mVerticalDraw, mNumCharsToGen, mFontColor, mOutlineSize, mOutlineColor, mAddPixelSeparator ); } void cTTFFontLoader::LoadFromMemory() { - mFont->LoadFromMemory( mData, mDataSize, mSize, mStyle, mVerticalDraw, mNumCharsToGen, mFontColor, mOutlineSize, mOutlineColor ); + mFont->LoadFromMemory( mData, mDataSize, mSize, mStyle, mVerticalDraw, mNumCharsToGen, mFontColor, mOutlineSize, mOutlineColor, mAddPixelSeparator ); } void cTTFFontLoader::LoadFromPack() { - mFont->LoadFromPack( mPack, mFilepath, mSize, mStyle, mVerticalDraw, mNumCharsToGen, mFontColor, mOutlineSize, mOutlineColor ); + mFont->LoadFromPack( mPack, mFilepath, mSize, mStyle, mVerticalDraw, mNumCharsToGen, mFontColor, mOutlineSize, mOutlineColor, mAddPixelSeparator ); } cFont * cTTFFontLoader::Font() const { diff --git a/src/graphics/cttffontloader.hpp b/src/graphics/cttffontloader.hpp index ae241f94a..a58370390 100644 --- a/src/graphics/cttffontloader.hpp +++ b/src/graphics/cttffontloader.hpp @@ -14,11 +14,11 @@ namespace EE { namespace Graphics { class EE_API cTTFFontLoader : public cObjectLoader { public: - cTTFFontLoader( const std::string& FontName, const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) ); + cTTFFontLoader( const std::string& FontName, const std::string& Filepath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); - cTTFFontLoader( const std::string& FontName, cPack * Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) ); + cTTFFontLoader( const std::string& FontName, cPack * Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); - cTTFFontLoader( const std::string& FontName, Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) ); + cTTFFontLoader( const std::string& FontName, Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0), const bool& AddPixelSeparator = true ); ~cTTFFontLoader(); @@ -41,6 +41,7 @@ class EE_API cTTFFontLoader : public cObjectLoader { eeColor mFontColor; Uint8 mOutlineSize; eeColor mOutlineColor; + bool mAddPixelSeparator; cPack * mPack; Uint8 * mData; eeUint mDataSize; diff --git a/src/graphics/cvertexbuffer.cpp b/src/graphics/cvertexbuffer.cpp index 5910a7375..b34a830d2 100644 --- a/src/graphics/cvertexbuffer.cpp +++ b/src/graphics/cvertexbuffer.cpp @@ -1,17 +1,20 @@ #include "cvertexbuffer.hpp" #include "cvertexbufferogl.hpp" #include "cvertexbuffervbo.hpp" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { -cVertexBuffer * cVertexBuffer::Create( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) { - if ( GLEW_ARB_vertex_buffer_object ) +cVertexBuffer * cVertexBuffer::Create( const Uint32& VertexFlags, EE_DRAW_MODE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) { + if ( cGL::instance()->IsExtension( GLEW_ARB_vertex_buffer_object ) ) return eeNew( cVertexBufferVBO, ( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ) ); return eeNew( cVertexBufferOGL, ( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ) ); } -cVertexBuffer::cVertexBuffer( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) : +cVertexBuffer::cVertexBuffer( const Uint32& VertexFlags, EE_DRAW_MODE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) : mVertexFlags( VertexFlags ), mDrawType( DrawType ), mUsageType( UsageType ), @@ -140,15 +143,15 @@ const Int32& cVertexBuffer::GetElementNum() const { void cVertexBuffer::Unbind() { if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) { - glEnableClientState( GL_VERTEX_ARRAY ); + //glEnableClientState( GL_VERTEX_ARRAY ); } if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) { - glEnableClientState( GL_COLOR_ARRAY ); + //glEnableClientState( GL_COLOR_ARRAY ); } if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) { - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + //glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glEnable( GL_TEXTURE_2D ); } } diff --git a/src/graphics/cvertexbuffer.hpp b/src/graphics/cvertexbuffer.hpp index 1fb0c763f..ac8fe937c 100644 --- a/src/graphics/cvertexbuffer.hpp +++ b/src/graphics/cvertexbuffer.hpp @@ -8,9 +8,9 @@ namespace EE { namespace Graphics { class cVertexBuffer { public: - static cVertexBuffer * Create( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); + static cVertexBuffer * Create( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_MODE DrawType = DM_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); - cVertexBuffer( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); + cVertexBuffer( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_MODE DrawType = DM_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); virtual ~cVertexBuffer(); @@ -57,7 +57,7 @@ class cVertexBuffer { virtual bool Compile() = 0; protected: Uint32 mVertexFlags; - EE_DRAW_TYPE mDrawType; + EE_DRAW_MODE mDrawType; EE_VBO_USAGE_TYPE mUsageType; Int32 mElemDraw; std::vector mVertexArray[ VERTEX_FLAGS_COUNT - 1 ]; diff --git a/src/graphics/cvertexbufferogl.cpp b/src/graphics/cvertexbufferogl.cpp index f606cb49b..3cc00e28c 100644 --- a/src/graphics/cvertexbufferogl.cpp +++ b/src/graphics/cvertexbufferogl.cpp @@ -1,8 +1,11 @@ #include "cvertexbufferogl.hpp" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { -cVertexBufferOGL::cVertexBufferOGL( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) : +cVertexBufferOGL::cVertexBufferOGL( const Uint32& VertexFlags, EE_DRAW_MODE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) : cVertexBuffer( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ) { } @@ -37,7 +40,7 @@ void cVertexBufferOGL::SetVertexStates() { glEnableClientState( GL_VERTEX_ARRAY ); glVertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_POSITION ], &mVertexArray[ VERTEX_FLAG_POSITION ][0] ); } else { - glDisableClientState( GL_VERTEX_ARRAY ); + //glDisableClientState( GL_VERTEX_ARRAY ); } /// COLOR @@ -45,22 +48,34 @@ void cVertexBufferOGL::SetVertexStates() { glEnableClientState( GL_COLOR_ARRAY ); glColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, sizeof(Uint8) * eeVertexElements[ VERTEX_FLAG_COLOR ], &mColorArray[0] ); } else { - glDisableClientState( GL_COLOR_ARRAY ); + //glDisableClientState( GL_COLOR_ARRAY ); } /// TEXTURES - for ( Int32 i = 0; i < 5; i++ ) { - if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) { - glClientActiveTextureARB( GL_TEXTURE0_ARB ); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + if ( cGL::instance()->IsExtension( EEGL_ARB_multitexture ) ) { + for ( Int32 i = 0; i < 5; i++ ) { + if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) { + glClientActiveTextureARB( GL_TEXTURE0_ARB + i ); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 + i ][0] ); + glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 + i ][0] ); + } else { + //glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + glDisable( GL_TEXTURE_2D ); + } + } + } else { + if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) { + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 ][0] ); } else { - //glClientActiveTextureARB( GL_TEXTURE0_ARB ); - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + //glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glDisable( GL_TEXTURE_2D ); } } + + glActiveTextureARB( GL_TEXTURE0_ARB ); + glClientActiveTextureARB( GL_TEXTURE0_ARB ); } }} diff --git a/src/graphics/cvertexbufferogl.hpp b/src/graphics/cvertexbufferogl.hpp index 4b67f418d..cd41cdcf2 100644 --- a/src/graphics/cvertexbufferogl.hpp +++ b/src/graphics/cvertexbufferogl.hpp @@ -7,7 +7,7 @@ namespace EE { namespace Graphics { class cVertexBufferOGL : public cVertexBuffer { public: - cVertexBufferOGL( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); + cVertexBufferOGL( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_MODE DrawType = DM_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); virtual ~cVertexBufferOGL(); diff --git a/src/graphics/cvertexbuffervbo.cpp b/src/graphics/cvertexbuffervbo.cpp index c8ad0f495..43fbcc0fe 100644 --- a/src/graphics/cvertexbuffervbo.cpp +++ b/src/graphics/cvertexbuffervbo.cpp @@ -1,8 +1,11 @@ #include "cvertexbuffervbo.hpp" +#include "glhelper.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { -cVertexBufferVBO::cVertexBufferVBO( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) : +cVertexBufferVBO::cVertexBufferVBO( const Uint32& VertexFlags, EE_DRAW_MODE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) : cVertexBuffer( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ), mCompiled( false ), mElementHandle( 0 ) @@ -103,7 +106,7 @@ void cVertexBufferVBO::SetVertexStates() { glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_POSITION ] ); glVertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, 0, (char*)NULL ); } else { - glDisableClientState( GL_VERTEX_ARRAY ); + //glDisableClientState( GL_VERTEX_ARRAY ); } /// COLOR @@ -112,23 +115,36 @@ void cVertexBufferVBO::SetVertexStates() { glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_COLOR ] ); glColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, 0, (char*)NULL ); } else { - glDisableClientState( GL_COLOR_ARRAY ); + //glDisableClientState( GL_COLOR_ARRAY ); } /// TEXTURES - for ( Int32 i = 0; i < 5; i++ ) { - if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) { - glClientActiveTextureARB( GL_TEXTURE0_ARB ); + if ( cGL::instance()->IsExtension( EEGL_ARB_multitexture ) ) { + for ( Int32 i = 0; i < 5; i++ ) { + if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) { + glClientActiveTextureARB( GL_TEXTURE0_ARB + i ); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_TEXTURE0 + i ] ); + glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, 0, (char*)NULL ); + } else { + //glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + glDisable( GL_TEXTURE_2D ); + } + } + } else { + if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) { glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_TEXTURE0 + i ] ); - glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, 0, (char*)NULL ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_TEXTURE0 ] ); + glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FLOAT, 0, (char*)NULL ); } else { - //glClientActiveTextureARB( GL_TEXTURE0_ARB ); - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + //glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glDisable( GL_TEXTURE_2D ); } } + glActiveTextureARB( GL_TEXTURE0_ARB ); + glClientActiveTextureARB( GL_TEXTURE0_ARB ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } diff --git a/src/graphics/cvertexbuffervbo.hpp b/src/graphics/cvertexbuffervbo.hpp index 9075298cc..95af48d2c 100644 --- a/src/graphics/cvertexbuffervbo.hpp +++ b/src/graphics/cvertexbuffervbo.hpp @@ -7,7 +7,7 @@ namespace EE { namespace Graphics { class cVertexBufferVBO : public cVertexBuffer { public: - cVertexBufferVBO( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); + cVertexBufferVBO( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_MODE DrawType = DM_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC ); virtual ~cVertexBufferVBO(); diff --git a/src/graphics/fonthelper.hpp b/src/graphics/fonthelper.hpp index 6116ef87a..ef7e9ab12 100644 --- a/src/graphics/fonthelper.hpp +++ b/src/graphics/fonthelper.hpp @@ -26,17 +26,17 @@ inline Uint32 FontVAlignGet( Uint32 Flags ) { /** Basic Glyph structure used by the engine */ -typedef struct { +typedef struct eeGlyphS { Int32 MinX, MaxX, MinY, MaxY, Advance; Uint16 CurX, CurY, CurW, CurH, GlyphH; } eeGlyph; -typedef struct { +typedef struct eeVertexCoordsS { eeFloat TexCoords[2]; eeFloat Vertex[2]; } eeVertexCoords; -typedef struct { +typedef struct eeTexCoordsS { eeFloat TexCoords[8]; eeFloat Vertex[8]; } eeTexCoords; diff --git a/src/graphics/glhelper.cpp b/src/graphics/glhelper.cpp new file mode 100644 index 000000000..1d531c8ef --- /dev/null +++ b/src/graphics/glhelper.cpp @@ -0,0 +1,147 @@ +#include "glhelper.hpp" + +namespace EE { namespace Graphics { namespace Private { + +static void _WriteBit( Uint32 * Key, Uint8 Pos, Uint32 BitWrite ) { + if ( BitWrite ) + ( * Key ) |= ( 1 << Pos ); + else { + if ( ( * Key ) & ( 1 << Pos ) ) + ( * Key ) &= ~( 1 << Pos ); + } +} + +cGL::cGL() : + mExtensions(0) +{ + +} + +cGL::~cGL() { + +} + +void cGL::WriteExtension( Uint8 Pos, Uint32 BitWrite ) { + _WriteBit( &mExtensions, Pos, BitWrite ); +} + +void cGL::Init() { + bool glewOn = false; + + #ifdef EE_GLEW_AVAILABLE + glewOn = ( GLEW_OK == glewInit() ); + + if ( glewOn ) { + WriteExtension( EEGL_ARB_texture_non_power_of_two , GLEW_ARB_texture_non_power_of_two ); + WriteExtension( EEGL_ARB_point_parameters , GLEW_ARB_point_parameters ); + WriteExtension( EEGL_ARB_point_sprite , GLEW_ARB_point_sprite ); + WriteExtension( EEGL_ARB_shading_language_100 , GLEW_ARB_shading_language_100 ); + WriteExtension( EEGL_ARB_shader_objects , GLEW_ARB_shader_objects ); + WriteExtension( EEGL_ARB_vertex_shader , GLEW_ARB_vertex_shader ); + WriteExtension( EEGL_ARB_fragment_shader , GLEW_ARB_fragment_shader ); + WriteExtension( EEGL_EXT_framebuffer_object , GLEW_EXT_framebuffer_object ); + WriteExtension( EEGL_ARB_multitexture , GLEW_ARB_multitexture ); + WriteExtension( EEGL_EXT_texture_compression_s3tc , GLEW_EXT_texture_compression_s3tc ); + } + #endif + + if ( !glewOn ) { + WriteExtension( EEGL_ARB_texture_non_power_of_two , GetExtension( "GL_ARB_texture_non_power_of_two" ) ); + WriteExtension( EEGL_ARB_point_parameters , GetExtension( "GL_ARB_point_parameters" ) ); + WriteExtension( EEGL_ARB_point_sprite , GetExtension( "GL_ARB_point_sprite" ) ); + WriteExtension( EEGL_ARB_shading_language_100 , GetExtension( "GL_ARB_shading_language_100" ) ); + WriteExtension( EEGL_ARB_shader_objects , GetExtension( "GL_ARB_shader_objects" ) ); + WriteExtension( EEGL_ARB_vertex_shader , GetExtension( "GL_ARB_vertex_shader" ) ); + WriteExtension( EEGL_ARB_fragment_shader , GetExtension( "GL_ARB_fragment_shader" ) ); + WriteExtension( EEGL_EXT_framebuffer_object , GetExtension( "GL_EXT_framebuffer_object" ) ); + WriteExtension( EEGL_ARB_multitexture , GetExtension( "GL_ARB_multitexture" ) ); + WriteExtension( EEGL_EXT_texture_compression_s3tc , GetExtension( "GL_EXT_texture_compression_s3tc" ) ); + } +} + +Uint32 cGL::GetExtension( const char * name ) { +#ifdef EE_GLEW_AVAILABLE + return glewIsSupported( name ); +#else + char *Exts = (char *)glGetString(GL_EXTENSIONS); + + if ( strstr( Exts, name ) ) + return 1; + + return 0; +#endif +} + +bool cGL::IsExtension( Uint32 name ) { + return 0 != ( mExtensions & ( 1 << name ) ); +} + +bool cGL::PointSpriteSupported() { + return IsExtension( EEGL_ARB_point_parameters ) && IsExtension( EEGL_ARB_point_sprite ); +} + +bool cGL::ShadersSupported() { + return IsExtension( EEGL_ARB_shading_language_100 ) && IsExtension( EEGL_ARB_shader_objects ) && IsExtension( EEGL_ARB_vertex_shader ) && IsExtension( EEGL_ARB_fragment_shader ); +} + +Uint32 cGL::GetTextureParamEnum( const EE_TEXTURE_PARAM& Type ) { + switch( Type ) { + case TEX_PARAM_COLOR_FUNC: return GL_COMBINE_RGB_ARB; + case TEX_PARAM_ALPHA_FUNC: return GL_COMBINE_ALPHA_ARB; + case TEX_PARAM_COLOR_SOURCE_0: return GL_SOURCE0_RGB_ARB; + case TEX_PARAM_COLOR_SOURCE_1: return GL_SOURCE1_RGB_ARB; + case TEX_PARAM_COLOR_SOURCE_2: return GL_SOURCE2_RGB_ARB; + case TEX_PARAM_ALPHA_SOURCE_0: return GL_SOURCE0_ALPHA_ARB; + case TEX_PARAM_ALPHA_SOURCE_1: return GL_SOURCE1_ALPHA_ARB; + case TEX_PARAM_ALPHA_SOURCE_2: return GL_SOURCE2_ALPHA_ARB; + case TEX_PARAM_COLOR_OP_0: return GL_OPERAND0_RGB_ARB; + case TEX_PARAM_COLOR_OP_1: return GL_OPERAND1_RGB_ARB; + case TEX_PARAM_COLOR_OP_2: return GL_OPERAND2_RGB_ARB; + case TEX_PARAM_ALPHA_OP_0: return GL_OPERAND0_ALPHA_ARB; + case TEX_PARAM_ALPHA_OP_1: return GL_OPERAND1_ALPHA_ARB; + case TEX_PARAM_ALPHA_OP_2: return GL_OPERAND2_ALPHA_ARB; + case TEX_PARAM_COLOR_SCALE: return GL_RGB_SCALE_ARB; + case TEX_PARAM_ALPHA_SCALE: return GL_ALPHA_SCALE; + } + + return 0; +} + +Uint32 cGL::GetTextureFuncEnum( const EE_TEXTURE_FUNC& Type ) { + switch( Type ) { + case TEX_FUNC_MODULATE: return GL_MODULATE; + case TEX_FUNC_REPLACE: return GL_REPLACE; + case TEX_FUNC_ADD: return GL_ADD; + case TEX_FUNC_SUBSTRACT: return GL_SUBTRACT_ARB; + case TEX_FUNC_ADD_SIGNED: return GL_ADD_SIGNED_ARB; + case TEX_FUNC_INTERPOLATE: return GL_INTERPOLATE_ARB; + case TEX_FUNC_DOT3_RGB: return GL_DOT3_RGB_ARB; + case TEX_FUNC_DOT3_RGBA: return GL_DOT3_RGBA_ARB; + } + + return 0; +} + +Uint32 cGL::GetTextureSourceEnum( const EE_TEXTURE_SOURCE& Type ) { + switch( Type) { + case TEX_SRC_TEXTURE: return GL_TEXTURE; + case TEX_SRC_CONSTANT: return GL_CONSTANT_ARB; + case TEX_SRC_PRIMARY: return GL_PRIMARY_COLOR_ARB; + case TEX_SRC_PREVIOUS: return GL_PREVIOUS_ARB; + } + + return 0; +} + +Uint32 cGL::GetTextureOpEnum( const EE_TEXTURE_OP& Type ) { + switch( Type ) { + case TEX_OP_COLOR: return GL_SRC_COLOR; + case TEX_OP_ONE_MINUS_COLOR: return GL_ONE_MINUS_SRC_COLOR; + case TEX_OP_ALPHA: return GL_SRC_ALPHA; + case TEX_OP_ONE_MINUS_ALPHA: return GL_ONE_MINUS_SRC_ALPHA; + } + + return 0; +} + +}}} diff --git a/src/graphics/glhelper.hpp b/src/graphics/glhelper.hpp new file mode 100644 index 000000000..281525926 --- /dev/null +++ b/src/graphics/glhelper.hpp @@ -0,0 +1,52 @@ +#ifndef EE_GRAPHICSGLHELPER_HPP +#define EE_GRAPHICSGLHELPER_HPP + +#include "base.hpp" +#include "renders.hpp" + +namespace EE { namespace Graphics { namespace Private { + +#define EEGL_ARB_texture_non_power_of_two (0) +#define EEGL_ARB_point_parameters (1) +#define EEGL_ARB_point_sprite (2) +#define EEGL_ARB_shading_language_100 (3) +#define EEGL_ARB_shader_objects (4) +#define EEGL_ARB_vertex_shader (5) +#define EEGL_ARB_fragment_shader (6) +#define EEGL_EXT_framebuffer_object (7) +#define EEGL_ARB_multitexture (8) +#define EEGL_EXT_texture_compression_s3tc (9) + +class cGL : public tSingleton { + friend class tSingleton; + public: + cGL(); + + virtual ~cGL(); + + void Init(); + + Uint32 GetExtension( const char * name ); + + bool IsExtension( Uint32 name ); + + bool PointSpriteSupported(); + + bool ShadersSupported(); + + Uint32 GetTextureParamEnum( const EE_TEXTURE_PARAM& Type ); + + Uint32 GetTextureFuncEnum( const EE_TEXTURE_FUNC& Type ); + + Uint32 GetTextureSourceEnum( const EE_TEXTURE_SOURCE& Type ); + + Uint32 GetTextureOpEnum( const EE_TEXTURE_OP& Type ); + protected: + Uint32 mExtensions; + private: + void WriteExtension( Uint8 Pos, Uint32 BitWrite ); +}; + +}}} + +#endif diff --git a/src/graphics/renders.hpp b/src/graphics/renders.hpp index a25e9000e..29ad38509 100755 --- a/src/graphics/renders.hpp +++ b/src/graphics/renders.hpp @@ -3,28 +3,31 @@ namespace EE { namespace Graphics { -/** @enum EE_FILLMODE Defines the fill mode for the primitives. */ -enum EE_FILLMODE { - DRAW_LINE, //!< Draw only lines - DRAW_FILL //!< Draw filled objects +#define EE_MAX_TEXTURE_UNITS 8 + +/** @enum EE_FILL_MODE Defines the fill mode for the primitives. */ +enum EE_FILL_MODE { + EE_DRAW_LINE, //!< Draw only lines + EE_DRAW_FILL //!< Draw filled objects }; /** @enum EE_TEX_FILTER Defines the texture filter used. */ enum EE_TEX_FILTER { - TEX_LINEAR, //!< Linear filtering (Smoothed Zoom) - TEX_NEAREST //!< No filtering (Pixeled Zoom) + EE_TEX_LINEAR, //!< Linear filtering (Smoothed Zoom) + EE_TEX_NEAREST //!< No filtering (Pixeled Zoom) }; -/** @enum EE_RENDERALPHAS Defines the Blend Function to use */ -enum EE_RENDERALPHAS { - ALPHA_NONE, //!< Disable the GL_BLEND - ALPHA_NORMAL, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); - ALPHA_BLENDONE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE); - ALPHA_BLENDTWO, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); \n glBlendFunc(GL_DST_ALPHA , GL_ONE); - ALPHA_BLENDTHREE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE); \n glBlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA); - ALPHA_ALPHACHANNELS, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); - ALPHA_DESTALPHA, //!< glBlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA); - ALPHA_MULTIPLY //!< glBlendFunc(GL_DST_COLOR,GL_ZERO); +/** @enum EE_PRE_BLEND_FUNC Predefined blend functions */ +enum EE_PRE_BLEND_FUNC { + ALPHA_NONE, //!< Disable the blend + ALPHA_NORMAL, //!< src SRC_ALPHA dst ONE_MINUS_SRC_ALPHA + ALPHA_BLENDONE, //!< src SRC_ALPHA dst ONE + ALPHA_BLENDTWO, //!< src SRC_ALPHA dst SRC_ALPHA \n src DST_ALPHA dst ONE + ALPHA_BLENDTHREE, //!< src SRC_ALPHA dst ONE \n src DST_ALPHA dst SRC_ALPHA + 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. }; /** @enum EE_RENDERTYPE Defines the method to use to render a texture. */ @@ -60,22 +63,95 @@ enum EE_CLAMP_MODE { EE_CLAMP_REPEAT }; -/** @enum EE_DRAW_TYPE The batch renderer, rendering methods */ -enum EE_DRAW_TYPE { - EE_DT_POINTS = 0x0000, - EE_DT_LINES = 0x0001, - EE_DT_LINE_LOOP = 0x0002, - EE_DT_LINE_STRIP = 0x0003, - EE_DT_TRIANGLES = 0x0004, - EE_DT_TRIANGLE_STRIP = 0x0005, - EE_DT_TRIANGLE_FAN = 0x0006, - EE_DT_QUADS = 0x0007, - EE_DT_QUAD_STRIP = 0x0008, - EE_DT_POLYGON = 0x0009 +/** @enum EE_DRAW_MODE The batch renderer, rendering methods */ +enum EE_DRAW_MODE { + DM_POINTS = 0x0000, + DM_LINES = 0x0001, + DM_LINE_LOOP = 0x0002, + DM_LINE_STRIP = 0x0003, + DM_TRIANGLES = 0x0004, + DM_TRIANGLE_STRIP = 0x0005, + DM_TRIANGLE_FAN = 0x0006, + DM_QUADS = 0x0007, + DM_QUAD_STRIP = 0x0008, + DM_POLYGON = 0x0009 }; -} +/** @enum EE_BLEND_FUNC Blend functions */ +enum EE_BLEND_FUNC { + BF_ZERO = 0, + BF_ONE = 1, + BF_SRC_COLOR = 0x0300, + BF_ONE_MINUS_SRC_COLOR = 0x0301, + BF_SRC_ALPHA = 0x0302, + BF_ONE_MINUS_SRC_ALPHA = 0x0303, + BF_DST_ALPHA = 0x0304, + BF_ONE_MINUS_DST_ALPHA = 0x0305, + BF_DST_COLOR = 0x0306, + BF_ONE_MINUS_DST_COLOR = 0x0307, + BF_SRC_ALPHA_SATURATE = 0x0308 +}; -} +/** @enum EE_TEXTURE_PARAM Texture Params */ +enum EE_TEXTURE_PARAM { + TEX_PARAM_COLOR_FUNC, + TEX_PARAM_ALPHA_FUNC, + TEX_PARAM_COLOR_SOURCE_0, + TEX_PARAM_COLOR_SOURCE_1, + TEX_PARAM_COLOR_SOURCE_2, + TEX_PARAM_ALPHA_SOURCE_0, + TEX_PARAM_ALPHA_SOURCE_1, + TEX_PARAM_ALPHA_SOURCE_2, + TEX_PARAM_COLOR_OP_0, + TEX_PARAM_COLOR_OP_1, + TEX_PARAM_COLOR_OP_2, + TEX_PARAM_ALPHA_OP_0, + TEX_PARAM_ALPHA_OP_1, + TEX_PARAM_ALPHA_OP_2, + TEX_PARAM_COLOR_SCALE, + TEX_PARAM_ALPHA_SCALE +}; + +/** @enum EE_TEXTURE_OP Texture Env Op */ +enum EE_TEXTURE_OP { + TEX_OP_COLOR, + TEX_OP_ONE_MINUS_COLOR, + TEX_OP_ALPHA, + TEX_OP_ONE_MINUS_ALPHA +}; + +/** @enum EE_TEXTURE_FUNC Texture functions */ +enum EE_TEXTURE_FUNC { + TEX_FUNC_MODULATE, + TEX_FUNC_REPLACE, + TEX_FUNC_ADD, + TEX_FUNC_SUBSTRACT, + TEX_FUNC_ADD_SIGNED, + TEX_FUNC_INTERPOLATE, + TEX_FUNC_DOT3_RGB, + TEX_FUNC_DOT3_RGBA +}; + +/** @enum EE_ALPHA_TEST_FUNC Alpha test functions */ +enum EE_ALPHA_TEST_FUNC { + ALPHA_FUNC_NEVER, + ALPHA_FUNC_LESS, + ALPHA_FUNC_LEQUAL, + ALPHA_FUNC_GREATER, + ALPHA_FUNC_GEQUAL, + ALPHA_FUNC_EQUAL, + ALPHA_FUNC_NOTEQUAL, + ALPHA_FUNC_ALWAYS +}; + +/** @enum EE_TEXTURE_SOURCE The Texture Source */ +enum EE_TEXTURE_SOURCE { + TEX_SRC_TEXTURE, + TEX_SRC_CONSTANT, + TEX_SRC_PRIMARY, + TEX_SRC_PREVIOUS +}; + +}} #endif diff --git a/src/test/ee.cpp b/src/test/ee.cpp index b5fd462c2..3cabde64a 100644 --- a/src/test/ee.cpp +++ b/src/test/ee.cpp @@ -1,8 +1,6 @@ #include "../ee.h" /** -@TODO Add a memory manager ( and a STL Allocator implemented in all the engine ). -@TODO Support multitexturing. @TODO Create a basic UI system ( add basic controls, add skinning support ). @TODO Add some Surface Grid class, to create special effects ( waved texture, and stuff like that ). @TODO Add Scripting support ( lua or squirrel ). @@ -168,6 +166,7 @@ class cEETest : private cThread { eeInt mHeight; std::wstring mBuda; + cTextCache * mBudaTC; bool mTextureLoaded; cResourceLoader mResLoad; @@ -283,7 +282,7 @@ void cEETest::Init() { WP.Start(); Batch.AllocVertexs( 1024 ); - Batch.SetBlendFunc( ALPHA_BLENDONE ); + Batch.SetPreBlendFunc( ALPHA_BLENDONE ); mFB = cFrameBuffer::CreateNew( 256, 256, false ); @@ -293,7 +292,7 @@ void cEETest::Init() { eePolygon2f Poly = CreateRoundedPolygon( 0.f, 0.f, 250.f, 50.f ); - mVBO = cVertexBuffer::Create( VERTEX_FLAG_GET( VERTEX_FLAG_POSITION ) | VERTEX_FLAG_GET( VERTEX_FLAG_COLOR ), EE_DT_POLYGON ); + mVBO = cVertexBuffer::Create( VERTEX_FLAG_GET( VERTEX_FLAG_POSITION ) | VERTEX_FLAG_GET( VERTEX_FLAG_COLOR ), DM_POLYGON ); for ( Uint32 i = 0; i < Poly.Size(); i++ ) { mVBO->AddVertex( Poly[i] ); @@ -313,7 +312,7 @@ void cEETest::Init() { void cEETest::LoadFonts() { mFontLoader.Add( eeNew( cTextureFontLoader, ( "conchars", eeNew( cTextureLoader, ( &PAK, "conchars.png", false, eeRGB(0,0,0) ) ), (eeUint)32 ) ) ); mFontLoader.Add( eeNew( cTextureFontLoader, ( "ProggySquareSZ", eeNew( cTextureLoader, ( &PAK, "ProggySquareSZ.png" ) ), &PAK, "ProggySquareSZ.dat" ) ) ); - mFontLoader.Add( eeNew( cTTFFontLoader, ( "arial", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 512, eeColor(255,255,255), 1, eeColor(0,0,0) ) ) ); + mFontLoader.Add( eeNew( cTTFFontLoader, ( "arial", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 256, eeColor(255,255,255), 1, eeColor(0,0,0), true ) ) ); mFontLoader.Load( boost::bind( &cEETest::OnFontLoaded, this, _1 ) ); } @@ -322,8 +321,6 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) { FF2 = reinterpret_cast ( cFontManager::instance()->GetByName( "ProggySquareSZ" ) ); TTF = reinterpret_cast ( cFontManager::instance()->GetByName( "arial" ) ); - TF->GetTexture( TTF->GetTexId() )->SetTextureFilter( TEX_NEAREST ); - Con.Create( FF, true ); Con.IgnoreCharOnPrompt( 186 ); // L'º' @@ -420,6 +417,8 @@ void cEETest::CreateUI() { mBuda = L"El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde.\nPowered by Text Shrinker =)"; TTF->ShrinkText( mBuda, 400 ); + + mBudaTC = eeNew( cTextCache, ( TTF, mBuda, eeColorA(255,255,255,255) ) ); } void cEETest::CmdSetPartsNum ( const std::vector < std::wstring >& params ) { @@ -743,9 +742,9 @@ void cEETest::Screen2() { CL1.Draw(); CL2.Draw(); - PR.DrawRectangle( CL1.GetAABB(), 0.0f, 1.0f, DRAW_LINE ); + PR.DrawRectangle( CL1.GetAABB(), 0.0f, 1.0f, EE_DRAW_LINE ); - PR.DrawQuad( CL1.GetQuad(), DRAW_LINE ); + PR.DrawQuad( CL1.GetQuad(), EE_DRAW_LINE ); Ang = Ang + EE->Elapsed() * 0.1f; if (Ang > 360.f) Ang = 1.f; @@ -766,14 +765,14 @@ void cEETest::Screen2() { else if (iL2) PR.SetColor( eeColorA(255, 255, 0, 255) ); - PR.DrawCircle(Mousef.x, Mousef.y, 80.f, (Uint32)(Ang/3), DRAW_LINE); + PR.DrawCircle(Mousef.x, Mousef.y, 80.f, (Uint32)(Ang/3), EE_DRAW_LINE); - PR.DrawTriangle( eeVector2f( Mousef.x, Mousef.y - 10.f ), eeVector2f( Mousef.x - 10.f, Mousef.y + 10.f ), eeVector2f( Mousef.x + 10.f, Mousef.y + 10.f ), DRAW_LINE ); + PR.DrawTriangle( eeVector2f( Mousef.x, Mousef.y - 10.f ), eeVector2f( Mousef.x - 10.f, Mousef.y + 10.f ), eeVector2f( Mousef.x + 10.f, Mousef.y + 10.f ), EE_DRAW_LINE ); PR.DrawLine( eeVector2f(Mousef.x - 80.f, Mousef.y - 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y + 80.f) ); PR.DrawLine( eeVector2f(Mousef.x - 80.f, Mousef.y + 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y - 80.f) ); PR.DrawLine( eeVector2f((eeFloat)EE->GetWidth(), 0.f), eeVector2f( 0.f, (eeFloat)EE->GetHeight() ) ); PR.DrawQuad( eeVector2f(0.f, 0.f), eeVector2f(0.f, 100.f), eeVector2f(150.f, 150.f), eeVector2f(200.f, 150.f), eeColorA(220, 240, 0, 125), eeColorA(100, 0, 240, 125), eeColorA(250, 50, 25, 125), eeColorA(50, 150, 150, 125) ); - PR.DrawRectangle(Mousef.x - 80.f, Mousef.y - 80.f, 160.f, 160.f, 45.f, 1.f, DRAW_LINE); + PR.DrawRectangle(Mousef.x - 80.f, Mousef.y - 80.f, 160.f, 160.f, 45.f, 1.f, EE_DRAW_LINE); PR.DrawLine( eeVector2f(0.f, 0.f), eeVector2f( (eeFloat)EE->GetWidth(), (eeFloat)EE->GetHeight() ) ); TNP[3]->DrawQuadEx( eeQuad2f( eeVector2f(0.f, 0.f), eeVector2f(0.f, 100.f), eeVector2f(150.f, 150.f), eeVector2f(200.f, 150.f) ), 0.0f, 0.0f, ang, scale, eeColorA(220, 240, 0, 125), eeColorA(100, 0, 240, 125), eeColorA(250, 50, 25, 125), eeColorA(50, 150, 150, 125) ); @@ -810,12 +809,12 @@ void cEETest::Render() { if ( eeGetTicks() - lasttick >= 50 ) { lasttick = eeGetTicks(); - mInfo = StrFormated( "EE - FPS: %d Elapsed Time: %4.8f\nMouse X: %d Mouse Y: %d\nTexture Memory Size: %d", + mInfo = StrFormated( "EE - FPS: %d Elapsed Time: %4.8f\nMouse X: %d Mouse Y: %d\nTexture Memory Size: %s", EE->FPS(), et, (Int32)Mouse.x, (Int32)Mouse.y, - (Int32)TF->MemorySize() + SizeToString( TF->MemorySize() ).c_str() ); } @@ -875,8 +874,7 @@ void cEETest::Render() { FF2->Draw( L"_", 6.f + FF2->GetTextWidth(), 24.f + (eeFloat)LineNum * (eeFloat)FF2->GetFontSize() ); } - TTF->SetText( mBuda ); - TTF->Draw( 0.f, 50.f ); + mBudaTC->Draw( 0.f, 50.f ); cTexture * TexFace = TF->GetTexture( mFace ); if ( TexFace ) @@ -1157,6 +1155,7 @@ void cEETest::End() { eeSAFE_DELETE( mTGL ); eeSAFE_DELETE( mFB ); eeSAFE_DELETE( mVBO ); + eeSAFE_DELETE( mBudaTC ); cEngine::DestroySingleton(); } diff --git a/src/ui/cuibackground.cpp b/src/ui/cuibackground.cpp index 4e03b78e9..730362073 100644 --- a/src/ui/cuibackground.cpp +++ b/src/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_RENDERALPHAS& BlendMode ) : +cUIBackground::cUIBackground( const eeColorA& Color, const eeUint& Corners, const EE_PRE_BLEND_FUNC& 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_RENDERALPHAS& BlendMode ) : +cUIBackground::cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_PRE_BLEND_FUNC& BlendMode ) : mBlendMode( BlendMode ), mCorners( Corners ) { @@ -70,11 +70,11 @@ void cUIBackground::Color( const eeColorA& Col ) { mColor[0] = Col; } -const EE_RENDERALPHAS& cUIBackground::Blend() const { +const EE_PRE_BLEND_FUNC& cUIBackground::Blend() const { return mBlendMode; } -void cUIBackground::Blend( const EE_RENDERALPHAS& blend ) { +void cUIBackground::Blend( const EE_PRE_BLEND_FUNC& blend ) { mBlendMode = blend; } diff --git a/src/ui/cuibackground.hpp b/src/ui/cuibackground.hpp index fbb3a3393..c976571e2 100644 --- a/src/ui/cuibackground.hpp +++ b/src/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_RENDERALPHAS& BlendMode = ALPHA_NORMAL ); + cUIBackground( const eeColorA& Color, const eeUint& Corners = 0, const EE_PRE_BLEND_FUNC& 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_RENDERALPHAS& BlendMode ); + cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_PRE_BLEND_FUNC& BlendMode ); eeColorA& Color( const eeUint& index = 0 ); @@ -22,15 +22,15 @@ class EE_API cUIBackground { void ColorsTo( const eeColorA& Color ); - const EE_RENDERALPHAS& Blend() const; - void Blend( const EE_RENDERALPHAS& blend ); + const EE_PRE_BLEND_FUNC& Blend() const; + void Blend( const EE_PRE_BLEND_FUNC& blend ); const eeUint& Corners() const; void Corners( const eeUint& corners ); protected: std::vector mColor; - EE_RENDERALPHAS mBlendMode; + EE_PRE_BLEND_FUNC mBlendMode; eeUint mCorners; }; diff --git a/src/ui/cuicontrol.cpp b/src/ui/cuicontrol.cpp index 4c44f8257..00cac60dc 100644 --- a/src/ui/cuicontrol.cpp +++ b/src/ui/cuicontrol.cpp @@ -353,11 +353,11 @@ void cUIControl::Flags( const Uint32& flags ) { mFlags |= flags; } -void cUIControl::Blend( const EE_RENDERALPHAS& blend ) { +void cUIControl::Blend( const EE_PRE_BLEND_FUNC& blend ) { mBlend = blend; } -EE_RENDERALPHAS& cUIControl::Blend() { +EE_PRE_BLEND_FUNC& cUIControl::Blend() { return mBlend; } @@ -407,9 +407,9 @@ void cUIControl::BackgroundDraw() { P.SetColor( mBackground.Color() ); if ( 4 == mBackground.Colors().size() ) { - P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), mBackground.Colors()[0], mBackground.Colors()[1], mBackground.Colors()[2], mBackground.Colors()[3], 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); + P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), mBackground.Colors()[0], mBackground.Colors()[1], mBackground.Colors()[2], mBackground.Colors()[3], 0.f, 1.f, EE_DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); } else { - P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); + P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); } } @@ -419,7 +419,11 @@ void cUIControl::BorderDraw() { cPrimitives P; P.SetColor( mBorder.Color() ); - P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() ); + + if ( IsClipped() ) + P.DrawRectangle( (eeFloat)Pos.x + 0.1f, (eeFloat)Pos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() ); + else + P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() ); } const Uint32& cUIControl::ControlFlags() const { @@ -491,8 +495,12 @@ void cUIControl::InternalDraw() { } void cUIControl::ClipMe() { - if ( IsClipped() ) - cUIManager::instance()->ClipEnable( mScreenPos.x, mScreenPos.y, mSize.Width(), mSize.Height() ); + if ( IsClipped() ) { + if ( mFlags & UI_BORDER ) + cUIManager::instance()->ClipEnable( mScreenPos.x, mScreenPos.y, mSize.Width(), mSize.Height() + 1 ); + else + cUIManager::instance()->ClipEnable( mScreenPos.x, mScreenPos.y, mSize.Width(), mSize.Height() ); + } } void cUIControl::ClipDisable() { diff --git a/src/ui/cuicontrol.hpp b/src/ui/cuicontrol.hpp index 8b10b7e48..2b871e2aa 100644 --- a/src/ui/cuicontrol.hpp +++ b/src/ui/cuicontrol.hpp @@ -25,7 +25,7 @@ class EE_API cUIControl { const eeVector2i& pos = eeVector2i( 0, 0 ), const eeSize& size = eeSize( -1, -1 ), const Uint32& flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER, - const EE_RENDERALPHAS& blend = ALPHA_NORMAL, + const EE_PRE_BLEND_FUNC& blend = ALPHA_NORMAL, const cUIBackground& Back = cUIBackground(), const cUIBorder& Bord = cUIBorder() ) : @@ -61,7 +61,7 @@ class EE_API cUIControl { Uint32 Flags; cUIBackground Background; cUIBorder Border; - EE_RENDERALPHAS Blend; + EE_PRE_BLEND_FUNC Blend; }; cUIControl( const CreateParams& Params ); @@ -170,9 +170,9 @@ class EE_API cUIControl { void Flags( const Uint32& flags ); - void Blend( const EE_RENDERALPHAS& blend ); + void Blend( const EE_PRE_BLEND_FUNC& blend ); - EE_RENDERALPHAS& Blend(); + EE_PRE_BLEND_FUNC& Blend(); void ToFront(); @@ -217,7 +217,7 @@ class EE_API cUIControl { cUIBorder mBorder; Uint32 mControlFlags; - EE_RENDERALPHAS mBlend; + EE_PRE_BLEND_FUNC mBlend; eeQuad2f mQuad; eeVector2f mCenter; diff --git a/src/ui/cuicontrolanim.cpp b/src/ui/cuicontrolanim.cpp index 113810a54..6997adf5e 100644 --- a/src/ui/cuicontrolanim.cpp +++ b/src/ui/cuicontrolanim.cpp @@ -206,9 +206,9 @@ void cUIControlAnim::BackgroundDraw() { P.SetColor( GetColor( mBackground.Color() ) ); if ( 4 == mBackground.Colors().size() ) { - P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), GetColor( mBackground.Colors()[0] ), GetColor( mBackground.Colors()[1] ), GetColor( mBackground.Colors()[2] ), GetColor( mBackground.Colors()[3] ), 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); + P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), GetColor( mBackground.Colors()[0] ), GetColor( mBackground.Colors()[1] ), GetColor( mBackground.Colors()[2] ), GetColor( mBackground.Colors()[3] ), 0.f, 1.f, EE_DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); } else { - P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); + P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() ); } } @@ -218,7 +218,11 @@ void cUIControlAnim::BorderDraw() { cPrimitives P; P.SetColor( GetColor( mBorder.Color() ) ); - P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() ); + + if ( IsClipped() ) + P.DrawRectangle( (eeFloat)Pos.x + 0.1f, (eeFloat)Pos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() ); + else + P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() ); } eeColorA cUIControlAnim::GetColor( const eeColorA& Col ) { diff --git a/src/ui/cuitextbox.cpp b/src/ui/cuitextbox.cpp index 03a9420bb..36e0e31f0 100644 --- a/src/ui/cuitextbox.cpp +++ b/src/ui/cuitextbox.cpp @@ -84,8 +84,9 @@ void cUITextBox::Alpha( const eeFloat& alpha ) { } void cUITextBox::AutoShrink() { - if ( Flags() & UI_AUTO_SHRINK_TEXT ) + if ( Flags() & UI_AUTO_SHRINK_TEXT ) { mTextCache.Font()->ShrinkText( mTextCache.Text(), mSize.Width() ); + } } void cUITextBox::AutoSize() { @@ -127,6 +128,8 @@ void cUITextBox::OnSizeChange() { AutoAlign(); cUIControlAnim::OnSizeChange(); + + mTextCache.Cache(); } void cUITextBox::OnTextChanged() { diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index da136d712..e9a8593a3 100755 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -455,4 +455,26 @@ std::string SizeToString( const Uint32& MemSize ) { return std::string( toStr( mem ) + size ); } +std::wstring SizeToWString( const Uint32& MemSize ) { + std::wstring size = L" bytes"; + eeDouble mem = static_cast( MemSize ); + Uint8 c = 0; + + while ( mem > 1024 ) { + c++; + mem = mem / 1024; + } + + switch (c) { + case 0: size = L" bytes"; break; + case 1: size = L" KB"; break; + case 2: size = L" MB"; break; + case 3: size = L" GB"; break; + case 4: size = L" TB"; break; + default: size = L" WTF"; + } + + return std::wstring( toWStr( mem ) + size ); +} + }} diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index bd9ca1f2f..f0a139738 100755 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -97,6 +97,11 @@ namespace EE { namespace Utils { * @example 10485760 -> "10.0 MB" */ std::string SizeToString( const Uint32& MemSize ); + + /** Convert a size represented in bytes, to a wstring converted in byes/kb/mb/tb. + * @example 10485760 -> "10.0 MB" + */ + std::wstring SizeToWString( const Uint32& MemSize ); } } diff --git a/src/window/cengine.cpp b/src/window/cengine.cpp index dfd4c6ded..841c20702 100755 --- a/src/window/cengine.cpp +++ b/src/window/cengine.cpp @@ -8,8 +8,10 @@ #include "../graphics/cshapegroupmanager.hpp" #include "../ui/cuimanager.hpp" #include "../audio/caudiolistener.hpp" +#include "../graphics/glhelper.hpp" using namespace EE::Graphics; +using namespace EE::Graphics::Private; #define T(A, B, C, D) (int)((A<<24)|(B<<16)|(C<<8)|(D<<0)) #define FORMAT_PREFIX "SDL_scrap_0x" @@ -105,6 +107,8 @@ cEngine::~cEngine() { Audio::cAudioListener::DestroySingleton(); + Graphics::Private::cGL::DestroySingleton(); + cLog::DestroySingleton(); SDL_Quit(); @@ -123,7 +127,6 @@ bool cEngine::Init(const Uint32& Width, const Uint32& Height, const Uint8& BitCo mVideoInfo.VSync = VSync; mVideoInfo.NoFrame = NoFrame; mVideoInfo.LineSmooth = true; - mVideoInfo.SupShaders = false; mOldWinPos = eeVector2i( 0, 0 ); if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { @@ -209,14 +212,7 @@ bool cEngine::Init(const Uint32& Width, const Uint32& Height, const Uint8& BitCo if ( mVideoInfo.Windowed ) mOldWinPos = GetWindowPosition(); - mGLEWinit = glewInit(); - - if ( GLEW_OK == mGLEWinit ) { - mVideoInfo.SupARB_point = GLEW_ARB_point_parameters && GLEW_ARB_point_sprite; - mVideoInfo.SupShaders = GLEW_ARB_shading_language_100 && GLEW_ARB_shader_objects && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader; - } else { - // die - } + cGL::instance()->Init(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); @@ -225,7 +221,7 @@ bool cEngine::Init(const Uint32& Width, const Uint32& Height, const Uint8& BitCo mDefaultView.SetView( 0, 0, mVideoInfo.Width, mVideoInfo.Height ); mCurrentView = &mDefaultView; - ResetGL2D(); + Setup2D(); SetWindowCaption("EEPP"); @@ -264,7 +260,7 @@ const cView& cEngine::GetView() const { return *mCurrentView; } -void cEngine::ResetGL2D( const bool& KeepView ) { +void cEngine::Setup2D( const bool& KeepView ) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1); @@ -281,8 +277,8 @@ void cEngine::ResetGL2D( const bool& KeepView ) { glDisable( GL_DEPTH_TEST ); glDisable( GL_LIGHTING ); - cTextureFactory::instance()->SetBlendFunc( ALPHA_BLENDONE ); // This is to fix a little bug on windows when the resolution change. I don't know why it happens, but this line fix it. - cTextureFactory::instance()->SetBlendFunc( ALPHA_NORMAL ); + cTextureFactory::instance()->SetPreBlendFunc( ALPHA_BLENDONE ); // This is to fix a little bug on windows when the resolution change. I don't know why it happens, but this line fix it. + cTextureFactory::instance()->SetPreBlendFunc( ALPHA_NORMAL ); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); @@ -371,7 +367,7 @@ void cEngine::ChangeRes( const Uint16& width, const Uint16& height, const bool& else mVideoInfo.Screen = SDL_SetVideoMode( mVideoInfo.Width, mVideoInfo.Height, mVideoInfo.ColorDepth, mVideoInfo.Flags | SDL_FULLSCREEN ); - ResetGL2D(); + Setup2D(); #if EE_PLATFORM == EE_PLATFORM_WIN32 || EE_PLATFORM == EE_PLATFORM_MACOSX if ( Reload ) { @@ -510,6 +506,10 @@ std::vector< std::pair > cEngine::GetPossibleResolut return result; } +bool cEngine::ShadersSupported() const { + return cGL::instance()->ShadersSupported(); +} + void cEngine::SetGamma( const eeFloat& Red, const eeFloat& Green, const eeFloat& Blue ) { if ( Red >= 0.1f && Red <= 10.0f && Green >= 0.1f && Green <= 10.0f && Blue >= 0.1f && Blue <= 10.0f ) SDL_SetGamma( Red, Green, Blue ); @@ -523,8 +523,8 @@ void cEngine::SetLineSmooth( const bool& Enable ) { glDisable( GL_LINE_SMOOTH ); } -void cEngine::SetPolygonMode( const EE_FILLMODE& Mode ) { - if ( Mode == DRAW_FILL ) +void cEngine::SetPolygonMode( const EE_FILL_MODE& Mode ) { + if ( Mode == EE_DRAW_FILL ) glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); else glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); @@ -552,7 +552,7 @@ std::string cEngine::GetVersion() { } bool cEngine::GetExtension( const std::string& Ext ) { - return 0 != glewIsSupported( Ext.c_str() ); + return 0 != cGL::instance()->GetExtension( Ext.c_str() ); } SDL_Cursor* cEngine::CreateCursor( const Uint32& TexId, const eeVector2i& HotSpot ) { diff --git a/src/window/cengine.hpp b/src/window/cengine.hpp index f44644427..b5fd544bb 100755 --- a/src/window/cengine.hpp +++ b/src/window/cengine.hpp @@ -112,7 +112,7 @@ class EE_API cEngine : public tSingleton { void SetLineSmooth( const bool& Enable ); /** Set the polygon fill mode ( wireframe or filled ) */ - void SetPolygonMode( const EE_FILLMODE& Mode ); + void SetPolygonMode( const EE_FILL_MODE& Mode ); /** @return If the screen is windowed */ bool Windowed() const; @@ -120,11 +120,8 @@ class EE_API cEngine : public tSingleton { /** @return If the extension passed is supported by the GPU */ bool GetExtension( const std::string& Ext ); - /** @return If "GL_ARB_point_parameters" is supported (added for Particle System, faster way to get this. */ - bool PointSpriteSuppported() const { return mVideoInfo.SupARB_point; }; - /** @return True if shaders are supported by the GPU */ - bool ShadersSupported() const { return mVideoInfo.SupShaders; } + bool ShadersSupported() const; /** Set a Cursor from a Texture (B/W Cursor) */ void SetCursor( const Uint32& TexId, const eeVector2i& HotSpot = eeVector2i() ); @@ -170,9 +167,7 @@ class EE_API cEngine : public tSingleton { bool Windowed; bool DoubleBuffering; bool VSync; - bool SupARB_point; bool LineSmooth; - bool SupShaders; Int32 WWidth; Int32 WHeight; @@ -205,7 +200,7 @@ class EE_API cEngine : public tSingleton { bool WindowVisible(); /** This will set the default rendering states and view to render in 2D mode */ - void ResetGL2D( const bool& KeepView = false ); + void Setup2D( const bool& KeepView = false ); /** Set the current active view @param View New view to use (pass GetDefaultView() to set the default view) @@ -275,8 +270,6 @@ class EE_API cEngine : public tSingleton { cView mDefaultView; const cView * mCurrentView; - GLenum mGLEWinit; - #if EE_PLATFORM == EE_PLATFORM_WIN32 HGLRC mContext; #elif EE_PLATFORM == EE_PLATFORM_LINUX