From 6ebce7964108990bea798e91992b4da11f0c6992 Mon Sep 17 00:00:00 2001 From: spartanj Date: Fri, 4 Feb 2011 02:23:57 -0300 Subject: [PATCH] Fixed glClipPlane for OpenGL 3 renderer. Replaced some math funcs with the correct eemathfuncs. --- src/base.hpp | 4 +- src/gaming/cisomap.cpp | 250 ++++++++++--------- src/gaming/cisomap.hpp | 95 ++++--- src/gaming/clight.cpp | 118 ++++++--- src/gaming/clight.hpp | 48 ++-- src/graphics/base.hpp | 9 + src/graphics/cbatchrenderer.cpp | 19 +- src/graphics/cglobalbatchrenderer.hpp | 1 + src/graphics/cparticlesystem.cpp | 60 ++--- src/graphics/csprite.hpp | 2 +- src/graphics/ctexture.cpp | 8 +- src/graphics/ctexturefactory.cpp | 20 +- src/graphics/ctexturefactory.hpp | 6 - src/graphics/renderer/cgl.cpp | 6 - src/graphics/renderer/cgl.hpp | 18 +- src/graphics/renderer/crenderergl.cpp | 32 ++- src/graphics/renderer/crenderergl.hpp | 12 +- src/graphics/renderer/crenderergl3.cpp | 330 ++++++++++++++++--------- src/graphics/renderer/crenderergl3.hpp | 20 +- src/math/math.cpp | 12 +- src/math/math.hpp | 6 +- src/physics/cshapesegment.cpp | 1 + src/physics/cspace.cpp | 4 +- src/test/ee.cpp | 21 +- src/utils/cinterpolation.cpp | 26 +- src/utils/cperlinnoise.cpp | 4 +- src/utils/easing.cpp | 30 +-- src/utils/polygon2.hpp | 8 +- src/utils/quad2.hpp | 10 +- src/window/cengine.cpp | 10 +- 30 files changed, 708 insertions(+), 482 deletions(-) diff --git a/src/base.hpp b/src/base.hpp index f74fc2377..88ad2e9f0 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -153,9 +153,10 @@ namespace EE { #define eeatan2 atan2 #define eemod fmod #define eeexp exp - #define efow pow + #define eepow pow #define eefloor floor #define eeceil ceil + #define eeabs abs #else typedef float eeFloat; //! The internal floating point used on EE++. \n This can help to improve compatibility with some platforms. \n And helps for an easy change from single precision to double precision. #define eesqrt sqrtf @@ -168,6 +169,7 @@ namespace EE { #define eepow powf #define eefloor floorf #define eeceil ceilf + #define eeabs fabs #endif template T eemax( T a, T b ) { diff --git a/src/gaming/cisomap.cpp b/src/gaming/cisomap.cpp index aa9ae22ed..a538d0fa6 100755 --- a/src/gaming/cisomap.cpp +++ b/src/gaming/cisomap.cpp @@ -2,157 +2,141 @@ namespace EE { namespace Gaming { -cIsoMap::cIsoMap() : OffsetX(0), OffsetY(0) { - EE = cEngine::instance(); - TF = cTextureFactory::instance(); +cIsoMap::cIsoMap() : + mOffsetX(0), + mOffsetY(0), + mFont(NULL) +{ + mEE = cEngine::instance(); } cIsoMap::~cIsoMap() { - for ( eeUint x = 0; x < MapWidth; x++ ) - for ( eeUint y = 0; y < MapHeight; y++ ) - Tile(x, y).Layers.clear(); - - Map.clear(); } void cIsoMap::Create( const eeUint& MapTilesX, const eeUint& MapTilesY, const eeUint& NumLayers, const eeUint TilesWidth, const eeUint TilesHeight, const eeColor& AmbientCol ) { - MapWidth = MapTilesX; - MapHeight = MapTilesY; - MapLayers = NumLayers; + mMapWidth = MapTilesX; + mMapHeight = MapTilesY; + mMapLayers = NumLayers; - TileWidth = TilesWidth; - TileHeight = TilesHeight; + mTileWidth = TilesWidth; + mTileHeight = TilesHeight; - TileHWidth = TileWidth * 0.5f; - TileHHeight = TileHeight * 0.5f; - TileAltitude = TileHeight * 0.25f; + mTileHWidth = mTileWidth * 0.5f; + mTileHHeight = mTileHeight * 0.5f; + mTileAltitude = mTileHeight * 0.25f; - MapAmbientColor = AmbientCol; + mMapAmbientColor = AmbientCol; + + Map.resize( mMapWidth * mMapHeight ); - Map.resize( MapWidth * MapHeight ); CreateBaseVertexBuffer(); - TilesRange = 10; + mTilesRange = 10; - Light.Create( 250.0f, 0, 0, eeColor(255,255,255), LIGHT_ISOMETRIC ); + mLight.Create( 250.0f, 0, 0, eeColor(255,255,255), LIGHT_ISOMETRIC ); - DrawFont = false; + mDrawFont = false; } void cIsoMap::CreateBaseVertexBuffer() { - eeFloat dX, dY, pX, pY; eeUint i; - for ( eeUint x = 0; x < MapWidth; x++ ) { - for ( eeUint y = 0; y < MapHeight; y++ ) { + for ( eeUint x = 0; x < mMapWidth; x++ ) { + for ( eeUint y = 0; y < mMapHeight; y++ ) { cIsoTile * T = &Tile(x, y); if ( T->Layers.size() < 1 ) - T->Layers.resize( MapLayers ); + T->Layers.resize( mMapLayers ); - if ( (x % 2) == 0) { - dX = -TileHWidth; - dY = -TileHHeight; - } else { - dX = -TileHWidth; - dY = 0; - } - pX = x * TileHWidth + dX; - pY = y * TileHWidth + dY; - - T->Q.V[0] = eeVector2f( pX + TileHWidth, pY ); // Left Top Vertex - T->Q.V[1] = eeVector2f( pX, pY + TileHHeight ); // Left Bottom Vertex - T->Q.V[2] = eeVector2f( pX + TileHWidth, pY + TileHeight ); // Top Left Vertex - T->Q.V[3] = eeVector2f( pX + TileWidth, pY + TileHHeight ); // Top Bottom Vertex - - T->TilePosStr = stringTowstring( intToStr( x ) + "-" + intToStr( y ) ); - T->Box = Quad2toAABB( T->Q ); + T->Q = TileQBaseCoords( x, y ); + T->Box = Quad2toAABB( T->Q ); + T->TilePosStr = stringTowstring( intToStr( x ) + "-" + intToStr( y ) ); for ( i = 0; i < 4; i++ ) - T->Color[i] = MapAmbientColor; + T->Color[i] = mMapAmbientColor; - for ( i = 1; i < MapLayers; i++ ) - Layer( x, y, i, 0 ); + for ( i = 1; i < mMapLayers; i++ ) + Layer( x, y, i, NULL ); } } } cIsoTile& cIsoMap::Tile( const eeUint& MapTileX, const eeUint& MapTileY ) { - if ( MapTileX >= MapWidth || MapTileY >= MapHeight ) - return Map[0]; - - return Map[ MapTileX + MapTileY * MapWidth ]; + eeASSERT ( MapTileX < mMapWidth && MapTileY < mMapHeight ); + return Map[ MapTileX + MapTileY * mMapWidth ]; } void cIsoMap::Layer( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& LayerNum, cShape * LayerData ) { - if( LayerNum < MapLayers ) + if( LayerNum < mMapLayers ) Tile(MapTileX, MapTileY).Layers[LayerNum] = LayerData; } void cIsoMap::Draw() { eeAABB TileAABB; + cIsoTile * T; - ScreenAABB = eeAABB( -OffsetX, -OffsetY, EE->GetWidth() - OffsetX, EE->GetHeight() - OffsetY ); // Screen AABB to MAP AABB + mScreenAABB = eeAABB( -mOffsetX, -mOffsetY, mEE->GetWidth() - mOffsetX, mEE->GetHeight() - mOffsetY ); // Screen AABB to MAP AABB - MouseMapPos = eeVector2f( cInput::instance()->MouseX() - OffsetX, cInput::instance()->MouseY() - OffsetY ); + mMouseMapPos = eeVector2f( cInput::instance()->MouseX() - mOffsetX, cInput::instance()->MouseY() - mOffsetY ); - Light.UpdatePos( MouseMapPos ); + mLight.UpdatePos( mMouseMapPos ); - if (OffsetX > 0) - OffsetX = 0; + if (mOffsetX > 0) + mOffsetX = 0; - if (OffsetY > 0) - OffsetY = 0; + if (mOffsetY > 0) + mOffsetY = 0; - if ( -OffsetX > Tile( MapWidth-1, MapHeight-1 ).Q.V[1].x - EE->GetWidth() ) - OffsetX = -(Tile( MapWidth-1, MapHeight-1 ).Q.V[1].x - EE->GetWidth()); + if ( -mOffsetX > Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].x - mEE->GetWidth() ) + mOffsetX = -(Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].x - mEE->GetWidth()); - if ( -OffsetY > Tile( MapWidth-1, MapHeight-1 ).Q.V[1].y - EE->GetHeight() ) - OffsetY = -(Tile( MapWidth-1, MapHeight-1 ).Q.V[1].y - EE->GetHeight()); + if ( -mOffsetY > Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].y - mEE->GetHeight() ) + mOffsetY = -(Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].y - mEE->GetHeight()); - Tx = (Int32)( -OffsetX / (eeFloat)TileHeight ) - TilesRange; - Ty = (Int32)( -OffsetY / (eeFloat)TileHeight ) - TilesRange; + Tx = (Int32)( -mOffsetX / (eeFloat)mTileHeight ) - mTilesRange; + Ty = (Int32)( -mOffsetY / (eeFloat)mTileHeight ) - mTilesRange; if (Tx < 0) Tx = 0; - if (Tx >= (eeInt)MapWidth) Tx = MapWidth-1; + if (Tx >= (eeInt)mMapWidth) Tx = mMapWidth-1; if (Ty < 0) Ty = 0; - if (Ty >= (eeInt)MapHeight) Ty = MapHeight-1; + if (Ty >= (eeInt)mMapHeight) Ty = mMapHeight-1; - Tx2 = ( Tx + TilesRange + (eeInt)( EE->GetWidth() / (eeFloat)TileHeight ) + TilesRange ); - Ty2 = ( Ty + TilesRange + (eeInt)(EE->GetHeight() / (eeFloat)TileHeight) + TilesRange ); + Tx2 = ( Tx + mTilesRange + (eeInt)( mEE->GetWidth() / (eeFloat)mTileHeight ) + mTilesRange ); + Ty2 = ( Ty + mTilesRange + (eeInt)( mEE->GetHeight() / (eeFloat)mTileHeight) + mTilesRange ); eeColorA SC(50,50,50,100); cGlobalBatchRenderer::instance()->Draw(); + GLi->LoadIdentity(); GLi->PushMatrix(); - GLi->Translatef( OffsetX, OffsetY, 0.0f ); + GLi->Translatef( mOffsetX, mOffsetY, 0.0f ); - for ( eeUint L = 0; L < MapLayers; L++ ) { + for ( eeUint L = 0; L < mMapLayers; L++ ) { for ( eeInt y = Ty; y < Ty2; y++ ) { for ( eeInt x = Tx; x < Tx2; x++ ) { - cIsoTile* T = &Tile( (eeUint)x, (eeUint)y ); + T = &Tile( (eeUint)x, (eeUint)y ); if ( L == 0 ) { TileAABB = T->Box; - if ( Intersect( ScreenAABB, TileAABB ) ) { - T->Color[0] = T->Color[1] = T->Color[2] = T->Color[3] = MapAmbientColor; + if ( Intersect( mScreenAABB, TileAABB ) ) { + T->Color[0] = T->Color[1] = T->Color[2] = T->Color[3] = mMapAmbientColor; - if ( Intersect( Light.GetAABB(), TileAABB ) ) { - T->Color[0] = Light.ProcessVertex( T->Q.V[0].x, T->Q.V[0].y, T->Color[0], T->Color[0] ); // Left - Top Vertex - T->Color[1] = Light.ProcessVertex( T->Q.V[1].x, T->Q.V[1].y, T->Color[1], T->Color[1] ); // Left - Bottom Vertex - T->Color[2] = Light.ProcessVertex( T->Q.V[2].x, T->Q.V[2].y, T->Color[2], T->Color[2] ); // Right - Bottom Vertex - T->Color[3] = Light.ProcessVertex( T->Q.V[3].x, T->Q.V[3].y, T->Color[3], T->Color[3] ); // Right - Top Vertex + if ( Intersect( mLight.GetAABB(), TileAABB ) ) { + T->Color[0] = mLight.ProcessVertex( T->Q.V[0].x, T->Q.V[0].y, T->Color[0], T->Color[0] ); // Left - Top Vertex + T->Color[1] = mLight.ProcessVertex( T->Q.V[1].x, T->Q.V[1].y, T->Color[1], T->Color[1] ); // Left - Bottom Vertex + T->Color[2] = mLight.ProcessVertex( T->Q.V[2].x, T->Q.V[2].y, T->Color[2], T->Color[2] ); // Right - Bottom Vertex + T->Color[3] = mLight.ProcessVertex( T->Q.V[3].x, T->Q.V[3].y, T->Color[3], T->Color[3] ); // Right - Top Vertex } T->Layers[L]->Draw( T->Q, 0.f, 0.f, 0.f, 1.f, T->Color[0], T->Color[1], T->Color[2], T->Color[3] ); - if ( TileAABB.Contains( MouseMapPos ) ) { - if ( IntersectQuad2( T->Q, eeQuad2f( MouseMapPos, MouseMapPos, MouseMapPos, MouseMapPos ) ) ) { - MouseTilePos.x = x; - MouseTilePos.y = y; + if ( TileAABB.Contains( mMouseMapPos ) ) { + if ( IntersectQuad2( T->Q, eeQuad2f( mMouseMapPos, mMouseMapPos, mMouseMapPos, mMouseMapPos ) ) ) { + mMouseTilePos.x = x; + mMouseTilePos.y = y; } } } @@ -167,38 +151,39 @@ void cIsoMap::Draw() { eeAABB LayerAABB( TileCenter.x - Shape->DestWidth() * 0.5f, TileCenter.y - Shape->DestHeight(), TileCenter.x + Shape->DestWidth() * 0.5f, TileCenter.y ); eeAABB ShadowAABB( ObjPos.x, TileCenter.y - Shape->DestHeight(), TileCenter.x + Shape->DestWidth(), TileCenter.y ); - if ( Intersect( ScreenAABB, ShadowAABB ) ) - Shape->Draw( OffsetX + ObjPos.x, OffsetY + ObjPos.y, 0, 1, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC ); + if ( Intersect( mScreenAABB, ShadowAABB ) ) + Shape->Draw( mOffsetX + ObjPos.x, mOffsetY + ObjPos.y, 0, 1, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC ); - if ( Intersect( ScreenAABB, LayerAABB ) ) - Shape->Draw( OffsetX + TileCenter.x - (eeFloat)Shape->DestWidth() * 0.5f, OffsetY + TileCenter.y - (eeFloat)Shape->DestHeight(), 0, 1, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) ); + if ( Intersect( mScreenAABB, LayerAABB ) ) + Shape->Draw( mOffsetX + TileCenter.x - (eeFloat)Shape->DestWidth() * 0.5f, mOffsetY + TileCenter.y - (eeFloat)Shape->DestHeight(), 0, 1, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) ); } } } } } + cGlobalBatchRenderer::instance()->Draw(); + if ( L == 0 ) { - cGlobalBatchRenderer::instance()->Draw(); GLi->PopMatrix(); } } - if ( DrawFont ) { + if ( mDrawFont ) { for ( eeInt y = Ty; y < Ty2; y++ ) { for ( eeInt x = Tx; x < Tx2; x++ ) { - cIsoTile* T = &Tile( (eeUint)x, (eeUint)y ); - myFont->Draw( T->TilePosStr, OffsetX + T->Q.V[1].x + ( T->Q.V[3].x - T->Q.V[1].x ) * 0.5f - T->TilePosStr.size() * myFont->GetFontSize() * 0.5f, OffsetY + T->Q.V[0].y + ( T->Q.V[2].y - T->Q.V[0].y ) * 0.5f - myFont->GetFontHeight() * 0.5f ); + T = &Tile( (eeUint)x, (eeUint)y ); + mFont->Draw( T->TilePosStr, mOffsetX + T->Q.V[1].x + ( T->Q.V[3].x - T->Q.V[1].x ) * 0.5f - T->TilePosStr.size() * mFont->GetFontSize() * 0.5f, mOffsetY + T->Q.V[0].y + ( T->Q.V[2].y - T->Q.V[0].y ) * 0.5f - mFont->GetFontHeight() * 0.5f ); } } } - PR.DrawQuad( Tile( MouseTilePos.x, MouseTilePos.y ).Q, EE_DRAW_LINE, ALPHA_NORMAL, 1.0f, OffsetX, OffsetY ); + mPR.DrawQuad( Tile( mMouseTilePos.x, mMouseTilePos.y ).Q, EE_DRAW_LINE, ALPHA_NORMAL, 1.0f, mOffsetX, mOffsetY ); } void cIsoMap::Move( const eeFloat& offsetx, const eeFloat& offsety ) { - OffsetX += offsetx; - OffsetY += offsety; + mOffsetX += offsetx; + mOffsetY += offsety; } void cIsoMap::SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& Level, const bool& JointUp ) { @@ -210,10 +195,10 @@ void cIsoMap::SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, con void cIsoMap::SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum, const eeUint& Level, const bool& JointUp ) { eeFloat AltitudeModif = ( JointUp ) ? -1.f : 1.f; - eeFloat VertexHeight = (TileAltitude * AltitudeModif) * (eeFloat)Level; + eeFloat VertexHeight = (mTileAltitude * AltitudeModif) * (eeFloat)Level; eeFloat NJHeight; - if ( MapTileX >= MapWidth || MapTileY >= MapHeight ) + if ( MapTileX >= mMapWidth || MapTileY >= mMapHeight ) return; cIsoTile * T = &Tile( MapTileX, MapTileY ); @@ -271,7 +256,7 @@ void cIsoMap::SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, co } void cIsoMap::VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY, const eeUint& JointNum, const eeFloat& Height, const eeFloat& NewJointHeight, const bool& JointUp ) { - if ( ( MapTileX >= 0 && MapTileX < (eeInt)MapWidth ) && ( MapTileY >= 0 && MapTileY < (eeInt)MapHeight ) ) { + if ( ( MapTileX >= 0 && MapTileX < (eeInt)mMapWidth ) && ( MapTileY >= 0 && MapTileY < (eeInt)mMapHeight ) ) { cIsoTile * T = &Tile( MapTileX, MapTileY ); if ( ( JointUp && T->Q.V[JointNum].y >= NewJointHeight ) || ( !JointUp && T->Q.V[JointNum].y <= NewJointHeight ) ) { @@ -285,28 +270,21 @@ eeVector2f cIsoMap::TileBaseCoords( const eeUint& MapTileX, const eeUint& MapTil eeFloat dX, dY, pX, pY; if ( (MapTileX % 2) == 0) { - dX = -TileHWidth; - dY = -TileHHeight; + dX = -mTileHWidth; + dY = -mTileHHeight; } else { - dX = -TileHWidth; + dX = -mTileHWidth; dY = 0; } - pX = MapTileX * TileHWidth + dX; - pY = MapTileY * TileHWidth + dY; + + pX = MapTileX * mTileHWidth + dX; + pY = MapTileY * mTileHWidth + dY; switch( JointNum ) { - case 0: - return eeVector2f( pX + TileHWidth, pY ); // Left Top Vertex - break; - case 1: - return eeVector2f( pX, pY + TileHHeight ); // Left Bottom Vertex - break; - case 2: - return eeVector2f( pX + TileHWidth, pY + TileHeight ); // Top Left Vertex - break; - case 3: - return eeVector2f( pX + TileWidth, pY + TileHHeight ); // Top Bottom Vertex - break; + case 0: return eeVector2f( pX + mTileHWidth, pY ); // Left Top Vertex + case 1: return eeVector2f( pX, pY + mTileHHeight ); // Left Bottom Vertex + case 2: return eeVector2f( pX + mTileHWidth, pY + mTileHeight ); // Top Left Vertex + case 3: return eeVector2f( pX + mTileWidth, pY + mTileHHeight ); // Top Bottom Vertex } return eeVector2f(0,0); @@ -320,4 +298,52 @@ void cIsoMap::Reset() { CreateBaseVertexBuffer(); } +void cIsoMap::Font( cFont * font ) { + mFont = font; +} + +cFont * cIsoMap::Font() const { + return mFont; +} + +cLight& cIsoMap::BaseLight() { + return mLight; +} + +void cIsoMap::DrawFont( bool draw ) { + mDrawFont = draw; +} + +bool cIsoMap::DrawFont() const { + return mDrawFont; +} + +Uint32 cIsoMap::Width() const { + return mMapWidth; +} + +Uint32 cIsoMap::Height() const { + return mMapHeight; +} + +void cIsoMap::AmbientColor( const eeColor& AC ) { + mMapAmbientColor = AC; +} + +eeColor cIsoMap::AmbientColor() const { + return mMapAmbientColor; +} + +eeVector2i cIsoMap::GetMouseTilePos() const { + return mMouseTilePos; +} + +eeVector2f cIsoMap::GetMouseMapCoords() const { + return mMouseMapPos; +} + +eeAABB cIsoMap::GetScreenMapCoords() const { + return mScreenAABB; +} + }} diff --git a/src/gaming/cisomap.hpp b/src/gaming/cisomap.hpp index 385ddbe06..57ad2292f 100755 --- a/src/gaming/cisomap.hpp +++ b/src/gaming/cisomap.hpp @@ -1,5 +1,5 @@ -#ifndef EE_GAMINGCISOMAP_H -#define EE_GAMINGCISOMAP_H +#ifndef mEE_GAMINGCISOMAP_H +#define mEE_GAMINGCISOMAP_H #include "base.hpp" #include "clight.hpp" @@ -15,63 +15,90 @@ class EE_API cIsoTile { eeAABB Box; }; -class EE_API cIsoMap{ +class EE_API cIsoMap { public: cIsoMap(); + ~cIsoMap(); void Create( const eeUint& MapTilesX, const eeUint& MapTilesY, const eeUint& NumLayers = 1, const eeUint TilesWidth = 64, const eeUint TilesHeight = 32, const eeColor& AmbientCol = eeColor(255,255,255) ); + cIsoTile& Tile( const eeUint& MapTileX, const eeUint& MapTileY ); + void Layer( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& LayerNum, cShape * LayerData ); + void Draw(); + void Move( const eeFloat& offsetx, const eeFloat& offsety ); - Uint32 Width() const { return MapWidth; } - Uint32 Height() const { return MapHeight; } - - void AmbientColor( const eeColor& AC ) { MapAmbientColor = AC; } - eeColor AmbientColor() const { return MapAmbientColor; } - void SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum, const eeUint& Level = 1, const bool& JointUp = true ); + void SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& Level = 1, const bool& JointUp = true ); - eeVector2i GetMouseTilePos() const { return MouseTilePos; } - eeVector2f GetMouseMapCoords() const { return MouseMapPos; } - eeAABB GetScreenMapCoords() const { return ScreenAABB; } - eeVector2f TileBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum); + eeQuad2f TileQBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY ); - cFont* myFont; - bool DrawFont; - cLight Light; + Uint32 Width() const; + + Uint32 Height() const; + + void AmbientColor( const eeColor& AC ); + + eeColor AmbientColor() const; + + eeVector2i GetMouseTilePos() const; + + eeVector2f GetMouseMapCoords() const; + + eeAABB GetScreenMapCoords() const; void Reset(); + + void Font( cFont * font ); + + cFont * Font() const; + + cLight& BaseLight(); + + void DrawFont( bool draw ); + + bool DrawFont() const; protected: std::vector Map; - // Map Ambient Color - eeColor MapAmbientColor; - - // Map Basic Data - eeUint MapWidth, MapHeight, MapLayers, TileWidth, TileHeight, TilesRange; - eeFloat TileHWidth, TileHHeight, TileAltitude; - - eeVector2i MouseTilePos; - eeVector2f MouseMapPos; - eeAABB ScreenAABB; - - eeInt Tx, Ty, Tx2, Ty2; - - // Camera on Map - eeFloat OffsetX, OffsetY; + eeColor mMapAmbientColor; + eeUint mMapWidth; + eeUint mMapHeight; + eeUint mMapLayers; + eeUint mTileWidth; + eeUint mTileHeight; + eeUint mTilesRange; + eeFloat mTileHWidth; + eeFloat mTileHHeight; + eeFloat mTileAltitude; + eeVector2i mMouseTilePos; + eeVector2f mMouseMapPos; + eeAABB mScreenAABB; + eeInt Tx; + eeInt Ty; + eeInt Tx2; + eeInt Ty2; + eeFloat mOffsetX; + eeFloat mOffsetY; // Fast access to classes - cEngine* EE; - cTextureFactory* TF; - cPrimitives PR; + cEngine * mEE; + cPrimitives mPR; + + cFont * mFont; + + cLight mLight; + + bool mDrawFont; void CreateBaseVertexBuffer(); + void VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY, const eeUint& JointNum, const eeFloat& Height, const eeFloat& NewJointHeight, const bool& JointUp ); }; diff --git a/src/gaming/clight.cpp b/src/gaming/clight.cpp index 4306f8acc..b46f067e0 100755 --- a/src/gaming/clight.cpp +++ b/src/gaming/clight.cpp @@ -2,22 +2,29 @@ namespace EE { namespace Gaming { -cLight::cLight() : mActive(true), mCalculated(false), mRadio(0.0f), mColor(255,255,255), mType(LIGHT_NORMAL) { +cLight::cLight() : + mRadius( 0 ), + mColor( 255, 255, 255 ), + mType( LIGHT_NORMAL ), + mActive( true ) +{ } cLight::~cLight() { } -cLight::cLight( const eeFloat& Radio, const eeFloat& x, const eeFloat& y, const eeColor& Color, LIGHT_TYPE Type ) : mActive(true), mCalculated(false) { - Create( Radio, x, y, Color, Type ); +cLight::cLight( const eeFloat& Radius, const eeFloat& x, const eeFloat& y, const eeColor& Color, LIGHT_TYPE Type ) : + mActive( true ) +{ + Create( Radius, x, y, Color, Type ); } -void cLight::Create( const eeFloat& Radio, const eeFloat& x, const eeFloat& y, const eeColor& Color, LIGHT_TYPE Type ) { - mRadio = Radio; - mPos.x = x; - mPos.y = y; - mColor = Color; - mType = Type; +void cLight::Create( const eeFloat& Radius, const eeFloat& x, const eeFloat& y, const eeColor& Color, LIGHT_TYPE Type ) { + mRadius = Radius; + mColor = Color; + mType = Type; + + UpdatePos( x, y ); } eeColor cLight::ProcessVertex( const eeFloat& PointX, const eeFloat& PointY, const eeColor& VertexColor, const eeColor& BaseColor ) { @@ -25,37 +32,38 @@ eeColor cLight::ProcessVertex( const eeFloat& PointX, const eeFloat& PointY, con if ( mActive ) { if ( mType == LIGHT_NORMAL ) - VertexDist = fabs( Distance( mPos.x, mPos.y, PointX, PointY ) ); + VertexDist = eeabs( Distance( mPos.x, mPos.y, PointX, PointY ) ); else { - eeFloat XDist = fabs(mPos.x - PointX); - eeFloat YDist = fabs(mPos.y - PointY); - VertexDist = sqrt( (XDist * 0.5f) * (XDist * 0.5f) + YDist * YDist ) * 2.0f; + eeFloat XDist = eeabs(mPos.x - PointX) * 0.5f; + eeFloat YDist = eeabs(mPos.y - PointY); + VertexDist = eesqrt( XDist * XDist + YDist * YDist ) * 2.0f; } - if ( VertexDist <= mRadio ) { - eeColor TmpRGB; - Uint8 TmpColor; - eeFloat LightC; + if ( VertexDist <= mRadius ) { + eeColor TmpRGB; + Uint8 TmpColor; + eeFloat LightC; - LightC = fabs( static_cast ( mColor.R() - BaseColor.R() ) ) / mRadio; - TmpColor = Uint8( (eeFloat)mColor.R() - (VertexDist * LightC) ); - TmpRGB.Red = VertexColor.R() + ( TmpColor - VertexColor.R() ); + LightC = eeabs( static_cast ( mColor.R() - BaseColor.R() ) ) / mRadius; + TmpColor = Uint8( (eeFloat)mColor.R() - (VertexDist * LightC) ); + TmpRGB.Red = VertexColor.R() + ( TmpColor - VertexColor.R() ); - LightC = fabs( static_cast ( mColor.G() - BaseColor.G() ) ) / mRadio; - TmpColor = Uint8( (eeFloat)mColor.G() - (VertexDist * LightC) ); - TmpRGB.Green = VertexColor.G() + ( TmpColor - VertexColor.G() ); + LightC = eeabs( static_cast ( mColor.G() - BaseColor.G() ) ) / mRadius; + TmpColor = Uint8( (eeFloat)mColor.G() - (VertexDist * LightC) ); + TmpRGB.Green = VertexColor.G() + ( TmpColor - VertexColor.G() ); - LightC = fabs( static_cast ( mColor.B() - BaseColor.B() ) ) / mRadio; - TmpColor = Uint8( (eeFloat)mColor.B() - (VertexDist * LightC) ); - TmpRGB.Blue = VertexColor.B() + ( TmpColor - VertexColor.B() ); + LightC = eeabs( static_cast ( mColor.B() - BaseColor.B() ) ) / mRadius; + TmpColor = Uint8( (eeFloat)mColor.B() - (VertexDist * LightC) ); + TmpRGB.Blue = VertexColor.B() + ( TmpColor - VertexColor.B() ); - if ( TmpRGB.R() < VertexColor.R() ) TmpRGB.Red = VertexColor.R(); - if ( TmpRGB.G() < VertexColor.G() ) TmpRGB.Green = VertexColor.G(); - if ( TmpRGB.B() < VertexColor.B() ) TmpRGB.Blue = VertexColor.B(); + if ( TmpRGB.R() < VertexColor.R() ) TmpRGB.Red = VertexColor.R(); + if ( TmpRGB.G() < VertexColor.G() ) TmpRGB.Green = VertexColor.G(); + if ( TmpRGB.B() < VertexColor.B() ) TmpRGB.Blue = VertexColor.B(); return TmpRGB; } } + return BaseColor; } @@ -66,22 +74,62 @@ eeColor cLight::ProcessVertex( const eeVector2f& Pos, const eeColor& VertexColor void cLight::UpdatePos( const eeFloat& x, const eeFloat& y ) { mPos.x = x; mPos.y = y; + UpdateAABB(); } void cLight::UpdatePos( const eeVector2f& newPos ) { - mPos = newPos; + UpdatePos( newPos.x, newPos.y ); } void cLight::Move( const eeFloat& addtox, const eeFloat& addtoy ) { - mPos.x += addtox; - mPos.y += addtoy; + UpdatePos( mPos.x + addtox, mPos.y + addtoy ); } -eeAABB cLight::GetAABB() { +const eeAABB& cLight::GetAABB() const { + return mAABB; +} + +void cLight::UpdateAABB() { if ( mType == LIGHT_NORMAL ) - return eeAABB( mPos.x - mRadio, mPos.y - mRadio, mPos.x + mRadio, mPos.y + mRadio ); + mAABB = eeAABB( mPos.x - mRadius, mPos.y - mRadius, mPos.x + mRadius, mPos.y + mRadius ); else - return eeAABB( mPos.x - mRadio, mPos.y - mRadio * 0.5f, mPos.x + mRadio, mPos.y + mRadio * 0.5f ); + mAABB = eeAABB( mPos.x - mRadius, mPos.y - mRadius * 0.5f, mPos.x + mRadius, mPos.y + mRadius * 0.5f ); +} + +const eeFloat& cLight::Radius() const { + return mRadius; +} + +void cLight::Radius( const eeFloat& radius ) { + mRadius = radius; +} + +const bool& cLight::Active() const { + return mActive; +} + +void cLight::Active( const bool& active ) { + mActive = active; +} + +void cLight::Color( const eeColor& color ) { + mColor = color; +} + +const eeColor& cLight::Color() const { + return mColor; +} + +void cLight::Type( const LIGHT_TYPE& type ) { + mType = type; +} + +const LIGHT_TYPE& cLight::Type() const { + return mType; +} + +const eeVector2f& cLight::Position() const { + return mPos; } }} diff --git a/src/gaming/clight.hpp b/src/gaming/clight.hpp index cc5748c77..3a70f745c 100644 --- a/src/gaming/clight.hpp +++ b/src/gaming/clight.hpp @@ -7,46 +7,58 @@ namespace EE { namespace Gaming { /** @enum LIGHT_TYPE Define the light spot type */ enum LIGHT_TYPE { - LIGHT_NORMAL = 0, + LIGHT_NORMAL = 0, LIGHT_ISOMETRIC = 1 }; class EE_API cLight { public: cLight(); + + cLight( const eeFloat& Radius, const eeFloat& x, const eeFloat& y, const eeColor& Color = eeColor(255,255,255), LIGHT_TYPE Type = LIGHT_NORMAL ); + virtual ~cLight(); - cLight( const eeFloat& Radio, const eeFloat& x, const eeFloat& y, const eeColor& Color = eeColor(255,255,255), LIGHT_TYPE Type = LIGHT_NORMAL ); - void Create( const eeFloat& Radio, const eeFloat& x, const eeFloat& y, const eeColor& Color = eeColor(255,255,255), LIGHT_TYPE Type = LIGHT_NORMAL ); + void Create( const eeFloat& Radius, const eeFloat& x, const eeFloat& y, const eeColor& Color = eeColor(255,255,255), LIGHT_TYPE Type = LIGHT_NORMAL ); virtual eeColor ProcessVertex( const eeFloat& PointX, const eeFloat& PointY, const eeColor& VertexColor, const eeColor& BaseColor ); + eeColor ProcessVertex( const eeVector2f& Pos, const eeColor& VertexColor, const eeColor& BaseColor ); void Move( const eeFloat& addtox, const eeFloat& addtoy ); + void UpdatePos( const eeFloat& x, const eeFloat& y ); + void UpdatePos( const eeVector2f& newPos ); - eeFloat Radio() const { return mRadio; } - void Radio( const eeFloat& radio ) { mRadio = radio; } + const eeAABB& GetAABB() const; - bool Active() const { return mActive; } - void Active( const bool& active ) { mActive = active; } + const eeFloat& Radius() const; - void Color( const eeColor& color ) { mColor = color; } - eeColor Color() const { return mColor; } + void Radius( const eeFloat& radio ); - void Type( const LIGHT_TYPE& type ) { mType = type; } - LIGHT_TYPE Type() const { return mType; } + const bool& Active() const; - eeAABB GetAABB(); + void Active( const bool& active ); - eeVector2f Position() const { return mPos; } + void Color( const eeColor& color ); + + const eeColor& Color() const; + + void Type( const LIGHT_TYPE& type ); + + const LIGHT_TYPE& Type() const; + + const eeVector2f& Position() const; protected: - bool mActive, mCalculated; - eeFloat mRadio; - eeVector2f mPos; - eeColor mColor; - LIGHT_TYPE mType; + eeFloat mRadius; + eeVector2f mPos; + eeColor mColor; + LIGHT_TYPE mType; + eeAABB mAABB; + bool mActive; + + void UpdateAABB(); }; }} diff --git a/src/graphics/base.hpp b/src/graphics/base.hpp index 47f63b534..f0ea5f952 100644 --- a/src/graphics/base.hpp +++ b/src/graphics/base.hpp @@ -65,6 +65,15 @@ typedef char GLchar; #define GL_FILL 0x1B02 #define GL_LINE_SMOOTH 0x0B20 #define GL_LIGHTING 0x0B50 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_POINT_SPRITE 0x8861 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +typedef GLfloat GLdouble; #endif #include "../helper/SOIL/SOIL.h" diff --git a/src/graphics/cbatchrenderer.cpp b/src/graphics/cbatchrenderer.cpp index 5f3ac8f65..3beaeec54 100755 --- a/src/graphics/cbatchrenderer.cpp +++ b/src/graphics/cbatchrenderer.cpp @@ -107,11 +107,8 @@ void cBatchRenderer::Flush() { cTextureFactory::instance()->SetPreBlendFunc( mBlend ); if ( mCurrentMode == DM_POINTS && NULL != mTexture ) { - #ifndef EE_GLES2 GLi->Enable( GL_POINT_SPRITE ); - glTexEnvf( GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE ); GLi->PointSize( (GLfloat)mTexture->Width() ); - #endif } if ( CreateMatrix ) { @@ -152,9 +149,7 @@ void cBatchRenderer::Flush() { } if ( mCurrentMode == DM_POINTS && mTexture > 0 ) { - #ifndef EE_GLES2 GLi->Disable( GL_POINT_SPRITE ); - #endif } if ( mTexture == 0 ) { @@ -468,14 +463,14 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons if ( Scale != 1.0f ) { for (Uint8 i = 0; i < 4; i++ ) { if ( mQ.V[i].x < QCenter.x ) - mQ.V[i].x = QCenter.x - fabs(QCenter.x - mQ.V[i].x) * Scale; + mQ.V[i].x = QCenter.x - eeabs(QCenter.x - mQ.V[i].x) * Scale; else - mQ.V[i].x = QCenter.x + fabs(QCenter.x - mQ.V[i].x) * Scale; + mQ.V[i].x = QCenter.x + eeabs(QCenter.x - mQ.V[i].x) * Scale; if ( mQ.V[i].y < QCenter.y ) - mQ.V[i].y = QCenter.y - fabs(QCenter.y - mQ.V[i].y) * Scale; + mQ.V[i].y = QCenter.y - eeabs(QCenter.y - mQ.V[i].y) * Scale; else - mQ.V[i].y = QCenter.y + fabs(QCenter.y - mQ.V[i].y) * Scale; + mQ.V[i].y = QCenter.y + eeabs(QCenter.y - mQ.V[i].y) * Scale; } } @@ -862,11 +857,7 @@ void cBatchRenderer::SetPointSize( const eeFloat& pointSize ) { } eeFloat cBatchRenderer::GetPointSize() { - float ps = 1; - #ifndef EE_GLES2 - glGetFloatv( GL_POINT_SIZE, &ps ); - #endif - return ps; + return GLi->PointSize(); } void cBatchRenderer::ForceBlendModeChange( const bool& Force ) { diff --git a/src/graphics/cglobalbatchrenderer.hpp b/src/graphics/cglobalbatchrenderer.hpp index 8f5c80855..75ae53835 100755 --- a/src/graphics/cglobalbatchrenderer.hpp +++ b/src/graphics/cglobalbatchrenderer.hpp @@ -11,6 +11,7 @@ class EE_API cGlobalBatchRenderer : public tSingleton, pub friend class tSingleton; public: cGlobalBatchRenderer(); + ~cGlobalBatchRenderer(); }; diff --git a/src/graphics/cparticlesystem.cpp b/src/graphics/cparticlesystem.cpp index 52390ae3e..41803c994 100755 --- a/src/graphics/cparticlesystem.cpp +++ b/src/graphics/cparticlesystem.cpp @@ -163,8 +163,8 @@ void cParticleSystem::Reset(cParticle* P) { mProgression = (int) eeRandf() * 10; radio = (P->Id() * 0.125f) * mProgression; - x = mX + (radio * cos( (eeFloat)P->Id() )); - y = mY + (radio * sin( (eeFloat)P->Id() )); + x = mX + (radio * eecos( (eeFloat)P->Id() )); + y = mY + (radio * eesin( (eeFloat)P->Id() )); P->Reset(x, y, VarB[0], VarB[1], VarB[2], VarB[3]); P->SetColor( eeColorAf(1.f, 0.6f, 0.3f, 1.f), 0.02f + eeRandf() * 0.3f ); @@ -176,47 +176,47 @@ void cParticleSystem::Reset(cParticle* P) { if (mProgression > 50) mDirection =-1; if (mProgression < -50) mDirection = 1; q = (P->Id() * 0.01f) + mProgression; - x = mX - w * sin((eeFloat)q * 2); - y = mY - z * cos((eeFloat)q * 2); + x = mX - w * eesin((eeFloat)q * 2); + y = mY - z * eecos((eeFloat)q * 2); P->Reset(x, y, 1, 1, 0, 0); P->SetColor( eeColorAf(1.f, 0.25f, 0.25f, 1), 0.6f + eeRandf() * 0.3f ); break; case Flower: - radio = cos( 2 * ( (eeFloat)P->Id() * 0.1f ) ) * 50; - x = mX + radio * cos( (eeFloat)P->Id() * 0.1f ); - y = mY + radio * sin( (eeFloat)P->Id() * 0.1f ); + radio = eecos( 2 * ( (eeFloat)P->Id() * 0.1f ) ) * 50; + x = mX + radio * eecos( (eeFloat)P->Id() * 0.1f ); + y = mY + radio * eesin( (eeFloat)P->Id() * 0.1f ); P->Reset(x, y, 1, 1, 0 , 0); P->SetColor( eeColorAf(1.f, 0.25f, 0.1f, 0.1f), 0.3f + (0.2f * eeRandf()) + eeRandf() * 0.3f ); break; case Galaxy: - radio = (eeRandf(1.f, 1.2f) + sin( 20.f / (eeFloat)P->Id() )) * 60; - x = mX + radio * cos( (eeFloat)P->Id() ); - y = mY + radio * sin( (eeFloat)P->Id() ); + radio = (eeRandf(1.f, 1.2f) + eesin( 20.f / (eeFloat)P->Id() )) * 60; + x = mX + radio * eecos( (eeFloat)P->Id() ); + y = mY + radio * eesin( (eeFloat)P->Id() ); P->Reset(x, y, 0, 0, 0, 0); P->SetColor( eeColorAf(0.2f, 0.2f, 0.6f + 0.4f * eeRandf(), 1.f), eeRandf(0.05f, 0.15f) ); break; case Heart: q = P->Id() * 0.01f; - x = mX - 50 * sin(q * 2) * sqrt( fabs( cos(q) ) ); - y = mY - 50 * cos(q * 2) * sqrt( fabs( sin(q) ) ); + x = mX - 50 * eesin(q * 2) * eesqrt( eeabs( eecos(q) ) ); + y = mY - 50 * eecos(q * 2) * eesqrt( eeabs( eesin(q) ) ); P->Reset(x, y, 0.f, 0.f, 0.f, -(eeRandf() * 0.2f)); P->SetColor( eeColorAf(1.f, 0.5f, 0.2f, 0.6f + 0.2f * eeRandf()), 0.01f + eeRandf() * 0.08f ); break; case BlueExplosion: if ( P->Id() == 0 ) mProgression+=10; radio = atan( static_cast( P->Id() % 12 ) ); - x = mX + (radio * cos( (eeFloat)P->Id() / mProgression ) * 30); - y = mY + (radio * sin( (eeFloat)P->Id() / mProgression ) * 30); + x = mX + (radio * eecos( (eeFloat)P->Id() / mProgression ) * 30); + y = mY + (radio * eesin( (eeFloat)P->Id() / mProgression ) * 30); - P->Reset(x, y, cos( (eeFloat)P->Id() ), sin( (eeFloat)P->Id() ), 0, 0 ); + P->Reset(x, y, eecos( (eeFloat)P->Id() ), eesin( (eeFloat)P->Id() ), 0, 0 ); P->SetColor( eeColorAf(0.3f, 0.6f, 1.f, 1.f), 0.03f ); break; case GP: - radio = 50 + eeRandf() * 15 * cos( (eeFloat)P->Id() * 3.5f ); - x = mX + ( radio * cos( (eeFloat)P->Id() * (eeFloat)0.01428571428 ) ); - y = mY + ( radio * sin( (eeFloat)P->Id() * (eeFloat)0.01428571428 ) ); + radio = 50 + eeRandf() * 15 * eecos( (eeFloat)P->Id() * 3.5f ); + x = mX + ( radio * eecos( (eeFloat)P->Id() * (eeFloat)0.01428571428 ) ); + y = mY + ( radio * eesin( (eeFloat)P->Id() * (eeFloat)0.01428571428 ) ); P->Reset(x, y, 0, 0, 0, 0); P->SetColor( eeColorAf(0.2f, 0.8f, 0.4f, 0.5f) , eeRandf() * 0.3f ); @@ -227,8 +227,8 @@ void cParticleSystem::Reset(cParticle* P) { if (mProgression > 50) mDirection =-1; if (mProgression < -50) mDirection = 1; q = P->Id() * 0.01f + mProgression; - x = mX + w * sin((eeFloat)q * 2); - y = mY - w * cos((eeFloat)q * 2); + x = mX + w * eesin((eeFloat)q * 2); + y = mY - w * eecos((eeFloat)q * 2); P->Reset(x, y, 1, 1, 0, 0); P->SetColor( eeColorAf(0.25f, 0.25f, 1.f, 1.f), 0.1f + eeRandf() * 0.3f + eeRandf() * 0.3f ); @@ -239,16 +239,16 @@ void cParticleSystem::Reset(cParticle* P) { if (mProgression > 50) mDirection =-1; if (mProgression < -50) mDirection = 1; q = P->Id() * 0.01f + mProgression; - x = mX + w * sin((eeFloat)q * 2); - y = mY - w * cos((eeFloat)q * 2); + x = mX + w * eesin((eeFloat)q * 2); + y = mY - w * eecos((eeFloat)q * 2); P->Reset(x, y, -10, -1 * eeRandf(), 0, eeRandf()); P->SetColor( eeColorAf(0.25f, 0.25f, 1.f, 1.f), 0.1f + eeRandf() * 0.1f + eeRandf() * 0.3f ); break; case Atomic: - radio = 10 + sin( 2 * ( (eeFloat)P->Id() * 0.1f ) ) * 50; - x = mX + radio * cos( (eeFloat)P->Id() * (eeFloat)0.033333 ); - y = mY + radio * sin( (eeFloat)P->Id() * (eeFloat)0.033333 ); + radio = 10 + eesin( 2 * ( (eeFloat)P->Id() * 0.1f ) ) * 50; + x = mX + radio * eecos( (eeFloat)P->Id() * (eeFloat)0.033333 ); + y = mY + radio * eesin( (eeFloat)P->Id() * (eeFloat)0.033333 ); P->Reset(x, y, 1, 1, 0, 0); P->SetColor( eeColorAf(0.4f, 0.25f, 1.f, 1.f), 0.3f + eeRandf() * 0.2f + eeRandf() * 0.3f ); break; @@ -265,17 +265,11 @@ void cParticleSystem::Draw() { if ( mPointsSup ) { if ( GLi->Version() == GLv_3 ) { - GLi->GetRendererGL3()->SetShader( EEGL_SHADER_POINT_SPRITE ); - #ifndef EE_GLES2 GLi->Enable( GL_VERTEX_PROGRAM_POINT_SIZE ); - #endif } - #ifndef EE_GLES2 GLi->Enable( GL_POINT_SPRITE ); GLi->PointSize( mSize ); - glTexEnvf( GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE ); - #endif Uint32 alloc = mPCount * sizeof(cParticle); @@ -284,12 +278,10 @@ void cParticleSystem::Draw() { GLi->DrawArrays( GL_POINTS, 0, (GLsizei)mPCount ); - #ifndef EE_GLES2 GLi->Disable( GL_POINT_SPRITE ); - #endif if ( GLi->Version() == GLv_3 ) { - GLi->GetRendererGL3()->SetShader( EEGL_SHADER_BASE_TEX ); + GLi->Disable( GL_VERTEX_PROGRAM_POINT_SIZE ); } } else { cTexture * Tex = TF->GetTexture( mTexId ); diff --git a/src/graphics/csprite.hpp b/src/graphics/csprite.hpp index 56dce5d58..c4eb22dbd 100755 --- a/src/graphics/csprite.hpp +++ b/src/graphics/csprite.hpp @@ -331,7 +331,7 @@ class EE_API cSprite { /** Removes the current callback */ void ClearCallback(); - /** Creates a copy of the current sprite and returned it */ + /** Creates a copy of the current sprite and return it */ cSprite * Copy(); protected: enum SpriteFlags { diff --git a/src/graphics/ctexture.cpp b/src/graphics/ctexture.cpp index 16aec57e7..8fad081ac 100755 --- a/src/graphics/ctexture.cpp +++ b/src/graphics/ctexture.cpp @@ -649,14 +649,14 @@ void cTexture::DrawQuadEx( const eeQuad2f& Q, const eeFloat &offsetx, const eeFl if ( Scale != 1.0f ) { for (Uint8 i = 0; i < 4; i++ ) { if ( mQ.V[i].x < QCenter.x ) - mQ.V[i].x = QCenter.x - fabs(QCenter.x - mQ.V[i].x) * Scale; + mQ.V[i].x = QCenter.x - eeabs(QCenter.x - mQ.V[i].x) * Scale; else - mQ.V[i].x = QCenter.x + fabs(QCenter.x - mQ.V[i].x) * Scale; + mQ.V[i].x = QCenter.x + eeabs(QCenter.x - mQ.V[i].x) * Scale; if ( mQ.V[i].y < QCenter.y ) - mQ.V[i].y = QCenter.y - fabs(QCenter.y - mQ.V[i].y) * Scale; + mQ.V[i].y = QCenter.y - eeabs(QCenter.y - mQ.V[i].y) * Scale; else - mQ.V[i].y = QCenter.y + fabs(QCenter.y - mQ.V[i].y) * Scale; + mQ.V[i].y = QCenter.y + eeabs(QCenter.y - mQ.V[i].y) * Scale; } } diff --git a/src/graphics/ctexturefactory.cpp b/src/graphics/ctexturefactory.cpp index 9ccf8f13f..2b148c6f9 100755 --- a/src/graphics/ctexturefactory.cpp +++ b/src/graphics/ctexturefactory.cpp @@ -256,30 +256,20 @@ void cTextureFactory::SetActiveTextureUnit( const Uint32& Unit ) { GLi->ActiveTexture( GL_TEXTURE0 + Unit ); } -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 ) ); -} - -void cTextureFactory::SetTextureConstantColor( const eeColorAf& Color ) { - #ifndef EE_GLES2 - glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const GLfloat*)(&Color.Red) ); - #endif -} - void cTextureFactory::SetTextureEnv( const EE_TEXTURE_PARAM& Param, const Int32& Val ) { #ifndef EE_GLES2 GLenum lParam = (GLenum)GLi->GetTextureParamEnum( Param ); - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); + GLi->TexEnvi( 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, GLi->GetTextureFuncEnum( (EE_TEXTURE_FUNC)Val ) ); + GLi->TexEnvi( GL_TEXTURE_ENV, lParam, GLi->GetTextureFuncEnum( (EE_TEXTURE_FUNC)Val ) ); } else if( Param >= TEX_PARAM_COLOR_SOURCE_0 && Param <= TEX_PARAM_ALPHA_SOURCE_2 ) { - glTexEnvi( GL_TEXTURE_ENV, lParam, GLi->GetTextureSourceEnum( (EE_TEXTURE_SOURCE)Val ) ); + GLi->TexEnvi( GL_TEXTURE_ENV, lParam, GLi->GetTextureSourceEnum( (EE_TEXTURE_SOURCE)Val ) ); } else if( Param >= TEX_PARAM_COLOR_OP_0 && Param <= TEX_PARAM_ALPHA_OP_2 ) { - glTexEnvi( GL_TEXTURE_ENV, lParam, GLi->GetTextureOpEnum( (EE_TEXTURE_OP)Val ) ); + GLi->TexEnvi( GL_TEXTURE_ENV, lParam, GLi->GetTextureOpEnum( (EE_TEXTURE_OP)Val ) ); } else { - glTexEnvi( GL_TEXTURE_ENV, lParam, Val ); + GLi->TexEnvi( GL_TEXTURE_ENV, lParam, Val ); } #endif } diff --git a/src/graphics/ctexturefactory.hpp b/src/graphics/ctexturefactory.hpp index 4fcf3c5c8..1e20ec340 100755 --- a/src/graphics/ctexturefactory.hpp +++ b/src/graphics/ctexturefactory.hpp @@ -140,12 +140,6 @@ class EE_API cTextureFactory: public tSingleton, protected cMut /** 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 * @return A valid texture size for the video card (checks if support non power of two textures) diff --git a/src/graphics/renderer/cgl.cpp b/src/graphics/renderer/cgl.cpp index 791bfe468..c61bdf4af 100644 --- a/src/graphics/renderer/cgl.cpp +++ b/src/graphics/renderer/cgl.cpp @@ -265,12 +265,6 @@ void cGL::PolygonMode( GLenum face, GLenum mode ) { #endif } -void cGL::PointSize( GLfloat size ) { - #ifndef EE_GLES2 - glPointSize( size ); - #endif -} - void cGL::DrawArrays (GLenum mode, GLint first, GLsizei count) { glDrawArrays( mode, first, count ); } diff --git a/src/graphics/renderer/cgl.hpp b/src/graphics/renderer/cgl.hpp index 2048dd3c4..6c2b79673 100644 --- a/src/graphics/renderer/cgl.hpp +++ b/src/graphics/renderer/cgl.hpp @@ -32,9 +32,7 @@ enum EEGL_ARRAY_STATES { }; enum EEGL_SHADERS { - EEGL_SHADER_BASE_TEX, - EEGL_SHADER_POINT_SPRITE, - EEGL_SHADER_CLIP, + EEGL_SHADER_BASE, EEGL_SHADERS_COUNT }; @@ -96,8 +94,6 @@ class cGL { char * GetString( GLenum name ); - void PointSize( GLfloat size ); - void DrawArrays (GLenum mode, GLint first, GLsizei count); void DrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); @@ -110,6 +106,10 @@ class cGL { void Viewport ( GLint x, GLint y, GLsizei width, GLsizei height ); + virtual void PointSize( GLfloat size ) = 0; + + virtual GLfloat PointSize() = 0; + virtual void ClientActiveTexture( GLenum texture ) = 0; virtual void Disable ( GLenum cap ); @@ -150,12 +150,16 @@ class cGL { virtual void SetShader( cShaderProgram * Shader ); - virtual void ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) = 0; + virtual void Clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) = 0; - virtual void ClipPlaneDisable() = 0; + virtual void Clip2DPlaneDisable() = 0; virtual void MultMatrixf ( const GLfloat *m ) = 0; + virtual void ClipPlane( GLenum plane, const GLdouble *equation ) = 0; + + virtual void TexEnvi( GLenum target, GLenum pname, GLint param ) = 0; + cRendererGL * GetRendererGL(); cRendererGL3 * GetRendererGL3(); diff --git a/src/graphics/renderer/crenderergl.cpp b/src/graphics/renderer/crenderergl.cpp index 4879efbd7..341a5d4a3 100644 --- a/src/graphics/renderer/crenderergl.cpp +++ b/src/graphics/renderer/crenderergl.cpp @@ -78,7 +78,11 @@ void cRendererGL::ClientActiveTexture( GLenum texture ) { glClientActiveTexture( texture ); } -void cRendererGL::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) { +void cRendererGL::PointSize( GLfloat size ) { + glPointSize( size ); +} + +void cRendererGL::Clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) { GLdouble tX = (GLdouble)x; GLdouble tY = (GLdouble)y; GLdouble tW = (GLdouble)Width; @@ -94,23 +98,39 @@ void cRendererGL::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& GLi->Enable(GL_CLIP_PLANE2); GLi->Enable(GL_CLIP_PLANE3); - glClipPlane(GL_CLIP_PLANE0, clip_left); - glClipPlane(GL_CLIP_PLANE1, clip_right); - glClipPlane(GL_CLIP_PLANE2, clip_top); - glClipPlane(GL_CLIP_PLANE3, clip_bottom); + ClipPlane(GL_CLIP_PLANE0, clip_left); + ClipPlane(GL_CLIP_PLANE1, clip_right); + ClipPlane(GL_CLIP_PLANE2, clip_top); + ClipPlane(GL_CLIP_PLANE3, clip_bottom); } -void cRendererGL::ClipPlaneDisable() { +void cRendererGL::Clip2DPlaneDisable() { GLi->Disable(GL_CLIP_PLANE0); GLi->Disable(GL_CLIP_PLANE1); GLi->Disable(GL_CLIP_PLANE2); GLi->Disable(GL_CLIP_PLANE3); } +void cRendererGL::ClipPlane( GLenum plane, const GLdouble *equation ) { + glClipPlane( plane, equation ); +} + void cRendererGL::MultMatrixf ( const GLfloat *m ) { glMultMatrixf( m ); } +void cRendererGL::TexEnvi( GLenum target, GLenum pname, GLint param ) { + glTexEnvi( target, pname, param ); +} + +GLfloat cRendererGL::PointSize() { + float ps = 1; + + glGetFloatv( GL_POINT_SIZE, &ps ); + + return ps; +} + #endif }} diff --git a/src/graphics/renderer/crenderergl.hpp b/src/graphics/renderer/crenderergl.hpp index dd33f982f..6c2698649 100644 --- a/src/graphics/renderer/crenderergl.hpp +++ b/src/graphics/renderer/crenderergl.hpp @@ -18,6 +18,10 @@ class cRendererGL : public cGL { void ClientActiveTexture( GLenum texture ); + void PointSize( GLfloat size ); + + GLfloat PointSize(); + void PushMatrix(); void PopMatrix(); @@ -48,9 +52,13 @@ class cRendererGL : public cGL { void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); - void ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ); + void ClipPlane( GLenum plane, const GLdouble *equation ); - void ClipPlaneDisable(); + void Clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ); + + void Clip2DPlaneDisable(); + + void TexEnvi( GLenum target, GLenum pname, GLint param ); void MultMatrixf ( const GLfloat *m ); protected: diff --git a/src/graphics/renderer/crenderergl3.cpp b/src/graphics/renderer/crenderergl3.cpp index bcd95f2d2..dd25af3bc 100644 --- a/src/graphics/renderer/crenderergl3.cpp +++ b/src/graphics/renderer/crenderergl3.cpp @@ -13,11 +13,36 @@ const char * EEGL_STATES_NAME[] = { "dgl_EdgeFlag" }; -const GLchar * EEGL_SHADER_BASE_TEX_VS[] = { +const char * EEGL_PLANES_ENABLED_NAME[] = { + "dgl_ClipEnabled[0]", + "dgl_ClipEnabled[1]", + "dgl_ClipEnabled[2]", + "dgl_ClipEnabled[3]", + "dgl_ClipEnabled[4]", + "dgl_ClipEnabled[5]" +}; + +const char * EEGL_PLANES_NAME[] = { + "dgl_ClipPlane[0]", + "dgl_ClipPlane[1]", + "dgl_ClipPlane[2]", + "dgl_ClipPlane[3]", + "dgl_ClipPlane[4]", + "dgl_ClipPlane[5]" +}; + +const GLchar * EEGL_SHADER_BASE_VS[] = { "#version 150\n", "#extension GL_ARB_explicit_attrib_location : enable\n", + "#define MAX_CLIP_PLANES 6\n", "uniform mat4 dgl_ProjectionMatrix;\n", // replaces deprecated gl_ProjectionMatrix "uniform mat4 dgl_ModelViewMatrix;\n", // replaces deprecated gl_ModelViewMatrix + "uniform int dgl_ClippingEnabled = 0;\n", + "uniform int dgl_ClipEnabled[ MAX_CLIP_PLANES ] = { 0, 0, 0, 0, 0, 0 };\n", + "uniform vec4 dgl_ClipPlane[ MAX_CLIP_PLANES ];\n", + #ifdef EE_GLES2 + "uniform float dgl_PointSize = 1;\n", + #endif "layout(location = 0) in vec2 dgl_Vertex;\n", // replaces deprecated gl_Vertex "layout(location = 2) in vec4 dgl_Color;\n", // replaces deprecated gl_Color "layout(location = 4) in vec2 dgl_TexCoord;\n", // replaces deprecated gl_TexCoord @@ -25,97 +50,40 @@ const GLchar * EEGL_SHADER_BASE_TEX_VS[] = { "invariant out vec2 TexCoord;\n", // to fragment shader "void main(void)\n", "{\n", - " Color = dgl_Color;\n", - " TexCoord = dgl_TexCoord;\n", - " vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n", - " gl_Position = dgl_ProjectionMatrix * dgl_ModelViewMatrix * v4;\n", - "}\n" -}; - -const GLchar * EEGL_SHADER_BASE_TEX_FS[] = { - "#version 150\n", - "uniform sampler2D textureUnit0;\n", - "uniform int TexActive = 1;\n", - "invariant in vec4 Color;\n", - "invariant in vec2 TexCoord;\n", - "out vec4 dgl_FragColor;\n", - "void main(void)\n", - "{\n", - " if ( 1 == TexActive )\n", - " dgl_FragColor = Color * texture2D( textureUnit0, TexCoord );\n", - " else\n", - " dgl_FragColor = Color;\n", - "}\n" -}; - -const GLchar * EEGL_SHADER_POINT_SPRITE_VS[] = { - "#version 150\n", - "#extension GL_ARB_explicit_attrib_location : enable\n", - "uniform mat4 dgl_ProjectionMatrix;\n", - "uniform mat4 dgl_ModelViewMatrix;\n", - "layout(location = 0) in vec2 dgl_Vertex;\n", - "layout(location = 2) in vec4 dgl_Color;\n", - "invariant out vec4 Color;\n", - "void main(void)\n", - "{\n", - " Color = dgl_Color;\n", - " vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n", - " gl_Position = dgl_ProjectionMatrix * dgl_ModelViewMatrix * v4;\n", - "}\n" -}; - -const GLchar * EEGL_SHADER_POINT_SPRITE_FS[] = { - "#version 150\n", - "invariant in vec4 Color;\n", - "out vec4 dgl_FragColor;\n", - "uniform sampler2D textureUnit0;\n", - "void main(void)\n", - "{\n", - " dgl_FragColor = Color * texture2D( textureUnit0, gl_PointCoord );\n", - "}\n" -}; - -const GLchar * EEGL_SHADER_CLIP_VS[] = { - "#version 150\n", - "#extension GL_ARB_explicit_attrib_location : enable\n", - "uniform mat4 dgl_ProjectionMatrix;\n", - "uniform mat4 dgl_ModelViewMatrix;\n", - "uniform int ClipEnabled = 0;\n" - "uniform vec4 dgl_ClipPlane[ 4 ];\n", - "layout(location = 0) in vec2 dgl_Vertex;\n", - "layout(location = 2) in vec4 dgl_Color;\n", - "layout(location = 4) in vec2 dgl_TexCoord;\n", - "invariant out vec4 Color;\n", - "invariant out vec2 TexCoord;\n", - "void main(void)\n", - "{\n", + #ifdef EE_GLES2 + " gl_PointSize = dgl_PointSize;\n", + #endif " Color = dgl_Color;\n", " TexCoord = dgl_TexCoord;\n", " vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n", " vec4 vEye = dgl_ModelViewMatrix * v4;\n", " gl_Position = dgl_ProjectionMatrix * vEye;\n", - " if ( 1 == ClipEnabled ) {\n", - " gl_ClipDistance[0] = dot( vEye, dgl_ClipPlane[0] );", - " gl_ClipDistance[1] = dot( vEye, dgl_ClipPlane[1] );", - " gl_ClipDistance[2] = dot( vEye, dgl_ClipPlane[2] );", - " gl_ClipDistance[3] = dot( vEye, dgl_ClipPlane[3] );", + " if ( 1 == dgl_ClippingEnabled ) {\n", + " for ( int i = 0; i < MAX_CLIP_PLANES; i++ ) {\n", + " if ( 1 == dgl_ClipEnabled[i] )\n", + " gl_ClipDistance[i] = dot( vEye, dgl_ClipPlane[i] );\n", + " }\n", " }\n", "}\n" }; -const GLchar * EEGL_SHADER_CLIP_FS[] = { +const GLchar * EEGL_SHADER_BASE_FS[] = { "#version 150\n", - "uniform int TexActive = 1;\n", + "uniform sampler2D textureUnit0;\n", + "uniform int dgl_TexActive = 1;\n", + "uniform int dgl_PointSpriteActive = 0;\n", "invariant in vec4 Color;\n", "invariant in vec2 TexCoord;\n", "out vec4 dgl_FragColor;\n", - "uniform sampler2D textureUnit0;\n", "void main(void)\n", "{\n", - " if ( 1 == TexActive )\n", - " dgl_FragColor = Color * texture2D( textureUnit0, TexCoord );\n", - " else\n", - " dgl_FragColor = Color;\n", + " if ( 0 == dgl_PointSpriteActive ) {\n", + " if ( 1 == dgl_TexActive )\n", + " dgl_FragColor = Color * texture2D( textureUnit0, TexCoord );\n", + " else\n", + " dgl_FragColor = Color;\n", + " } else\n", + " dgl_FragColor = Color * texture2D( textureUnit0, gl_PointCoord );\n", "}\n" }; @@ -125,7 +93,10 @@ cRendererGL3::cRendererGL3() : mCurrentMode(0), mCurShader(NULL), mShaderPrev(NULL), - mTexActive(1) + mTexActive(1), + mTexActiveLoc(-1), + mPointSpriteLoc(-1), + mPointSize(1.f) { mProjectionMatrix.push ( glm::mat4( 1.0f ) ); // identity matrix mModelViewMatrix.push ( glm::mat4( 1.0f ) ); // identity matrix @@ -157,26 +128,29 @@ void cRendererGL3::SetShader( const EEGL_SHADERS& Shader ) { void cRendererGL3::SetShader( cShaderProgram * Shader ) { if ( NULL == Shader ) { - Shader = mShaders[ EEGL_SHADER_BASE_TEX ]; + Shader = mShaders[ EEGL_SHADER_BASE ]; } if ( mCurShader == Shader ) { return; } - if ( mShaders[ EEGL_SHADER_CLIP ] != mCurShader ) { - mShaderPrev = mCurShader; - } - + mShaderPrev = mCurShader; mCurShader = Shader; mProjectionMatrix_id = mCurShader->UniformLocation( "dgl_ProjectionMatrix" ); mModelViewMatrix_id = mCurShader->UniformLocation( "dgl_ModelViewMatrix" ); + mTexActiveLoc = mCurShader->UniformLocation( "dgl_TexActive" ); + mPointSpriteLoc = mCurShader->UniformLocation( "dgl_PointSpriteActive" ); - for ( Uint32 i = 0; i < EEGL_ARRAY_STATES_COUNT; i++ ) { + Uint32 i; + + for ( i = 0; i < EEGL_ARRAY_STATES_COUNT; i++ ) { mStates[ i ] = mCurShader->AttributeLocation( EEGL_STATES_NAME[ i ] ); } - mTexActiveLoc = mCurShader->UniformLocation( "TexActive" ); + for ( i = 0; i < EE_MAX_PLANES; i++ ) { + mPlanes[ i ] = mCurShader->UniformLocation( EEGL_PLANES_NAME[ i ] ); + } glUseProgram( mCurShader->Handler() ); @@ -190,13 +164,42 @@ void cRendererGL3::SetShader( cShaderProgram * Shader ) { } void cRendererGL3::Disable ( GLenum cap ) { - if ( GL_TEXTURE_2D == cap ) { - if ( glIsEnabled( cap ) ) { - mTexActive = 0; - mCurShader->SetUniform( mTexActiveLoc, mTexActive ); + switch ( cap ) { + case GL_TEXTURE_2D: + { + if ( glIsEnabled( cap ) ) { + mTexActive = 0; + mCurShader->SetUniform( mTexActiveLoc, mTexActive ); - /// Reset the vertex attrib to zero to avoid crashes on draw calls - TexCoordPointer( 2, GL_FLOAT, 0, (const GLvoid*)NULL, 0 ); + /// Reset the vertex attrib to zero to avoid crashes on draw calls + TexCoordPointer( 2, GL_FLOAT, 0, (const GLvoid*)NULL, 0 ); + } + + break; + } + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + { + GLint plane = cap - GL_CLIP_PLANE0; + + mPlanesStates[ plane ] = 0; + PlaneStateCheck( false ); + mCurShader->SetUniform( EEGL_PLANES_ENABLED_NAME[ plane ], 0 ); + + break; + } + case GL_POINT_SPRITE: + { + mCurShader->SetUniform( mPointSpriteLoc, 0 ); + break; + } + case GL_VERTEX_PROGRAM_POINT_SIZE: + { /// Point Sprite flag for the shader? + break; } } @@ -204,24 +207,72 @@ void cRendererGL3::Disable ( GLenum cap ) { } void cRendererGL3::Enable( GLenum cap ) { - if ( GL_TEXTURE_2D == cap ) { - if ( !glIsEnabled( cap ) ) { - mTexActive = 1; - mCurShader->SetUniform( mTexActiveLoc, mTexActive ); + switch ( cap ) { + case GL_TEXTURE_2D: + { + if ( !glIsEnabled( cap ) ) { + mTexActive = 1; + mCurShader->SetUniform( mTexActiveLoc, mTexActive ); + } + + break; + } + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + { + GLint plane = cap - GL_CLIP_PLANE0; + + mPlanesStates[ plane ] = 1; + PlaneStateCheck( true ); + mCurShader->SetUniform( EEGL_PLANES_ENABLED_NAME[ plane ], 1 ); + + break; + } + case GL_POINT_SPRITE: + { + mCurShader->SetUniform( mPointSpriteLoc, 1 ); + break; + } + case GL_VERTEX_PROGRAM_POINT_SIZE: + { + break; } } cGL::Enable( cap ); } +void cRendererGL3::PlaneStateCheck( bool tryEnable ) { + GLint i; + + if ( tryEnable ) { + for ( i = 0; i < EE_MAX_PLANES; i++ ) { + if ( 0 != mPlanesStates[ i ] ) { + mCurShader->SetUniform( "dgl_ClippingEnabled", 1 ); + return; + } + } + } else { + for ( i = 0; i < EE_MAX_PLANES; i++) { + if ( 0 != mPlanesStates[ i ] ) { + return; + } + } + + mCurShader->SetUniform( "dgl_ClippingEnabled", 0 ); + } +} + void cRendererGL3::Init() { cGL::Init(); - mShaders[ EEGL_SHADER_BASE_TEX ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_BASE_TEX_VS, sizeof(EEGL_SHADER_BASE_TEX_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_BASE_TEX_FS, sizeof(EEGL_SHADER_BASE_TEX_FS)/sizeof(const GLchar*), "EEGL_SHADER_BASE_TEX" ) ); - mShaders[ EEGL_SHADER_POINT_SPRITE ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_POINT_SPRITE_VS, sizeof(EEGL_SHADER_POINT_SPRITE_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_POINT_SPRITE_FS, sizeof(EEGL_SHADER_POINT_SPRITE_FS)/sizeof(const GLchar*), "EEGL_SHADER_POINT_SPRITE" ) ); - mShaders[ EEGL_SHADER_CLIP ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_CLIP_VS, sizeof(EEGL_SHADER_CLIP_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_CLIP_FS, sizeof(EEGL_SHADER_CLIP_FS)/sizeof(const GLchar*), "EEGL_SHADER_CLIP" ) ); + mShaders[ EEGL_SHADER_BASE ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_BASE_VS, sizeof(EEGL_SHADER_BASE_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_BASE_FS, sizeof(EEGL_SHADER_BASE_FS)/sizeof(const GLchar*), "EEGL_SHADER_BASE_TEX" ) ); - SetShader( mShaders[ EEGL_SHADER_BASE_TEX ] ); + SetShader( mShaders[ EEGL_SHADER_BASE ] ); #ifndef EE_GLES2 glGenVertexArrays( 1, &mVAO ); @@ -230,6 +281,9 @@ void cRendererGL3::Init() { memset( mVBO, 0, eeARRAY_SIZE( mVBO ) ); + memset( mPlanes, -1, EE_MAX_PLANES ); + memset( mPlanesStates, 0, EE_MAX_PLANES ); + glGenBuffers( EEGL_ARRAY_STATES_COUNT, &mVBO[0] ); //"in vec2 dgl_Vertex;", @@ -398,53 +452,85 @@ GLint cRendererGL3::GetStateIndex( const Uint32& State ) { return mStates[ State ]; } -void cRendererGL3::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) { +void cRendererGL3::Clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) { GLfloat tX = (GLfloat)x; GLfloat tY = (GLfloat)y; GLfloat tW = (GLfloat)Width; GLfloat tH = (GLfloat)Height; - GLfloat clip_left[] = { 1.0 , 0.0 , 0.0 , -tX }; - GLfloat clip_right[] = { -1.0 , 0.0 , 0.0 , tX + tW }; - GLfloat clip_top[] = { 0.0 , 1.0 , 0.0 , -tY }; - GLfloat clip_bottom[] = { 0.0 , -1.0 , 0.0 , tY + tH }; - - #ifndef EE_GLES2 + glm::vec4 vclip_left ( 1.0 , 0.0 , 0.0 , -tX ); + glm::vec4 vclip_right ( -1.0 , 0.0 , 0.0 , tX + tW ); + glm::vec4 vclip_top ( 0.0 , 1.0 , 0.0 , -tY ); + glm::vec4 vclip_bottom ( 0.0 , -1.0 , 0.0 , tY + tH ); + + glm::mat4 invMV = glm::inverse( mModelViewMatrix.top() ); + + vclip_left = vclip_left * invMV; + vclip_right = vclip_right * invMV; + vclip_top = vclip_top * invMV; + vclip_bottom = vclip_bottom * invMV; + GLi->Enable(GL_CLIP_PLANE0); GLi->Enable(GL_CLIP_PLANE1); GLi->Enable(GL_CLIP_PLANE2); GLi->Enable(GL_CLIP_PLANE3); - #endif - - SetShader( EEGL_SHADER_CLIP ); - mCurShader->SetUniform( mTexActiveLoc, mTexActive ); - - mCurShader->SetUniform( "ClipEnabled", (Int32)1 ); - glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[0]" ), 1, clip_left ); - glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[1]" ), 1, clip_right ); - glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[2]" ), 1, clip_top ); - glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[3]" ), 1, clip_bottom ); + glUniform4fv( mPlanes[0], 1, static_cast( &vclip_left[0] ) ); + glUniform4fv( mPlanes[1], 1, static_cast( &vclip_right[0] ) ); + glUniform4fv( mPlanes[2], 1, static_cast( &vclip_top[0] ) ); + glUniform4fv( mPlanes[3], 1, static_cast( &vclip_bottom[0] ) ); } -void cRendererGL3::ClipPlaneDisable() { - #ifndef EE_GLES2 +void cRendererGL3::Clip2DPlaneDisable() { GLi->Disable(GL_CLIP_PLANE0); GLi->Disable(GL_CLIP_PLANE1); GLi->Disable(GL_CLIP_PLANE2); GLi->Disable(GL_CLIP_PLANE3); +} + +void cRendererGL3::PointSize( GLfloat size ) { + #ifndef EE_GLES2 + glPointSize( size ); + #else + mCurShader->SetUniform( "dgl_PointSize", size ); #endif - mCurShader->SetUniform( "ClipEnabled", (Int32)0 ); - - SetShader( mShaderPrev ); + + mPointSize = size; +} + +void cRendererGL3::ClipPlane( GLenum plane, const GLdouble * equation ) { + Int32 nplane = plane - GL_CLIP_PLANE0; + Int32 location; + + if ( nplane < EE_MAX_PLANES ) { + location = mPlanes[ nplane ]; + } else { + std::string planeNum( "dgl_ClipPlane[" + toStr( nplane ) + "]" ); + + location = glGetUniformLocation( mCurShader->Handler(), (GLchar*)&planeNum[0] ); + } + + glm::vec4 teq( equation[0], equation[1], equation[2], equation[3] ); + + teq = teq * glm::inverse( mModelViewMatrix.top() ); /// Apply the inverse of the model view matrix to the equation + + glUniform4f( nplane, (GLfloat)teq[0], (GLfloat)teq[1], (GLfloat)teq[2], (GLfloat)teq[3] ); } void cRendererGL3::MultMatrixf ( const GLfloat * m ) { mCurMatrix->top() *= glm::mat4( *m ); } +GLfloat cRendererGL3::PointSize() { + return mPointSize; +} + void cRendererGL3::ClientActiveTexture( GLenum texture ) { - //! TODO: Implement multitexturing in GL3 renderer + /// TODO: Implement multitexturing in GL3 renderer +} + +void cRendererGL3::TexEnvi( GLenum target, GLenum pname, GLint param ) { + /// TODO: Implement TexEnvi } }} diff --git a/src/graphics/renderer/crenderergl3.hpp b/src/graphics/renderer/crenderergl3.hpp index a52af1965..d9e9c3f7a 100644 --- a/src/graphics/renderer/crenderergl3.hpp +++ b/src/graphics/renderer/crenderergl3.hpp @@ -18,6 +18,8 @@ #include #include +#define EE_MAX_PLANES 6 + namespace EE { namespace Graphics { class cRendererGL3 : public cGL { @@ -30,6 +32,10 @@ class cRendererGL3 : public cGL { void Init(); + void PointSize( GLfloat size ); + + GLfloat PointSize(); + void PushMatrix(); void PopMatrix(); @@ -74,11 +80,15 @@ class cRendererGL3 : public cGL { GLint GetStateIndex( const Uint32& State ); - void ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ); + void Clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ); - void ClipPlaneDisable(); + void Clip2DPlaneDisable(); void MultMatrixf ( const GLfloat *m ); + + void ClipPlane( GLenum plane, const GLdouble *equation ); + + void TexEnvi( GLenum target, GLenum pname, GLint param ); protected: std::stack mProjectionMatrix; // cpu-side GLint mProjectionMatrix_id; // cpu-side hook to shader uniform @@ -91,11 +101,17 @@ class cRendererGL3 : public cGL { GLuint mVAO; GLuint mVBO[ EEGL_ARRAY_STATES_COUNT ]; GLint mStates[ EEGL_ARRAY_STATES_COUNT ]; + GLint mPlanes[ EE_MAX_PLANES ]; + GLint mPlanesStates[ EE_MAX_PLANES ]; cShaderProgram * mShaderPrev; Int32 mTexActive; GLint mTexActiveLoc; + GLint mPointSpriteLoc; + GLfloat mPointSize; void UpdateMatrix(); + + void PlaneStateCheck( bool tryEnable ); }; }} diff --git a/src/math/math.cpp b/src/math/math.cpp index 30f7d87ef..7655dcb9a 100755 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -17,11 +17,11 @@ eeInt eeRandi( const eeInt& fMin, const eeInt& fMax ) { } eeFloat cosAng( const eeFloat& Ang ) { - return cos(Ang * PId180); + return eecos(Ang * PId180); } eeFloat sinAng( const eeFloat& Ang ) { - return sin(Ang * PId180); + return eesin(Ang * PId180); } eeFloat tanAng( const eeFloat& Ang ) { @@ -100,14 +100,14 @@ eeQuad2f ScaleQuadCentered( const eeQuad2f& Quad, const eeFloat& Scale, const ee for (Uint8 i = 0; i < 4; i++ ) { if ( mQ.V[i].x < QCenter.x ) - mQ.V[i].x = QCenter.x - fabs(QCenter.x - mQ.V[i].x) * Scale; + mQ.V[i].x = QCenter.x - eeabs(QCenter.x - mQ.V[i].x) * Scale; else - mQ.V[i].x = QCenter.x + fabs(QCenter.x - mQ.V[i].x) * Scale; + mQ.V[i].x = QCenter.x + eeabs(QCenter.x - mQ.V[i].x) * Scale; if ( mQ.V[i].y < QCenter.y ) - mQ.V[i].y = QCenter.y - fabs(QCenter.y - mQ.V[i].y) * Scale; + mQ.V[i].y = QCenter.y - eeabs(QCenter.y - mQ.V[i].y) * Scale; else - mQ.V[i].y = QCenter.y + fabs(QCenter.y - mQ.V[i].y) * Scale; + mQ.V[i].y = QCenter.y + eeabs(QCenter.y - mQ.V[i].y) * Scale; } return mQ; diff --git a/src/math/math.hpp b/src/math/math.hpp index 3b38a0347..e47f635a6 100755 --- a/src/math/math.hpp +++ b/src/math/math.hpp @@ -54,7 +54,7 @@ T IsPow2( T v ) { template T LineAngle( const T& X1, const T& Y1, const T& X2, const T& Y2 ) { - return atan2( (eeFloat)(Y2 - Y1), (eeFloat)(X2 - X1) ) * d180PI; + return eeatan2( (eeFloat)(Y2 - Y1), (eeFloat)(X2 - X1) ) * d180PI; } eeFloat EE_API LineAngle( const eeVector2f& p1, const eeVector2f& p2 ); @@ -82,7 +82,7 @@ void EE_API RotateVectorCentered( eeVector2f* p, const eeFloat& Angle, const eeV template T Distance( T x1, T y1, T x2, T y2 ) { - return sqrt( (eeFloat)( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) ) ); + return eesqrt( (eeFloat)( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) ) ); } eeFloat EE_API Distance( const eeVector2f& p1, const eeVector2f& p2); @@ -166,7 +166,7 @@ bool IntersectLines( T Ax, T Ay, T Bx, T By, T Cx, T Cy, T Dx, T Dy, T* X, T* Y Cx-=Ax; Cy-=Ay; Dx-=Ax; Dy-=Ay; - distAB=sqrt(Bx*Bx+By*By); + distAB=eesqrt(Bx*Bx+By*By); theCos=Bx/distAB; theSin=By/distAB; diff --git a/src/physics/cshapesegment.cpp b/src/physics/cshapesegment.cpp index 368448ac4..a0d6c7444 100644 --- a/src/physics/cshapesegment.cpp +++ b/src/physics/cshapesegment.cpp @@ -77,6 +77,7 @@ void cShapeSegment::Draw( cSpace * space ) { if( !seg->CP_PRIVATE(shape).sensor ){ eeColorA C = ColorForShape( mShape, space->Space() ); + /// TODO: Implement this fine #ifndef EE_GLES2 glColor3ub( C.R(), C.B(), C.B() ); #endif diff --git a/src/physics/cspace.cpp b/src/physics/cspace.cpp index 0941b7220..06d550db9 100644 --- a/src/physics/cspace.cpp +++ b/src/physics/cspace.cpp @@ -262,8 +262,8 @@ void cSpace::Draw() { BR->SetLineWidth( lw ); if( options->DrawBBs ){ - cpSpatialIndexEach(mSpace->CP_PRIVATE(activeShapes), (cpSpatialIndexIterator)drawBB, NULL); - cpSpatialIndexEach(mSpace->CP_PRIVATE(staticShapes), (cpSpatialIndexIterator)drawBB, NULL); + cpSpatialIndexEach( mSpace->CP_PRIVATE(activeShapes), (cpSpatialIndexIterator)drawBB, NULL ); + cpSpatialIndexEach( mSpace->CP_PRIVATE(staticShapes), (cpSpatialIndexIterator)drawBB, NULL ); } cpArray * constraints = mSpace->CP_PRIVATE(constraints); diff --git a/src/test/ee.cpp b/src/test/ee.cpp index d027469d8..d7ee03813 100644 --- a/src/test/ee.cpp +++ b/src/test/ee.cpp @@ -435,6 +435,8 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) { eeASSERT( TTF != NULL ); eeASSERT( TTFB != NULL ); + Map.Font( FF ); + Con.Create( FF, true ); Con.IgnoreCharOnPrompt( 186 ); // L'ยบ' @@ -461,7 +463,11 @@ void cEETest::CreateShaders() { if ( mUseShaders ) { mBlurFactor = 0.01f; - mShaderProgram = eeNew( cShaderProgram, ( MyPath + "data/shader/blur.vert", MyPath + "data/shader/blur.frag" ) ); + + if ( GLv_3 == GLi->Version() || GLv_ES2 == GLi->Version() ) + mShaderProgram = eeNew( cShaderProgram, ( MyPath + "data/shader/gl3_blur.vert", MyPath + "data/shader/gl3_blur.frag" ) ); + else + mShaderProgram = eeNew( cShaderProgram, ( MyPath + "data/shader/blur.vert", MyPath + "data/shader/blur.frag" ) ); } } @@ -1029,8 +1035,6 @@ void cEETest::LoadTextures() { mBlindy.AddFramesByPattern( "rn" ); mBlindy.Position( 320.f, 0.f ); - Map.myFont = reinterpret_cast ( &FF ); - Map.Create( 100, 100, 2, 128, 64, eeColor(175,175,175) ); RandomizeHeights(); @@ -1577,10 +1581,10 @@ void cEETest::Input() { Map.Move( 0, -EE->Elapsed() * 0.2f ); if ( KM->IsKeyDown(KEY_KP_MINUS) ) - Map.Light.Radio( Map.Light.Radio() - EE->Elapsed() * 0.2f ); + Map.BaseLight().Radius( Map.BaseLight().Radius() - EE->Elapsed() * 0.2f ); if ( KM->IsKeyDown(KEY_KP_PLUS) ) - Map.Light.Radio( Map.Light.Radio() + EE->Elapsed() * 0.2f ); + Map.BaseLight().Radius( Map.BaseLight().Radius() + EE->Elapsed() * 0.2f ); if ( KM->IsKeyUp(KEY_F6) ) { Wireframe = !Wireframe; @@ -1589,7 +1593,7 @@ void cEETest::Input() { } if ( KM->IsKeyUp(KEY_F7) ) - Map.DrawFont = !Map.DrawFont; + Map.DrawFont( !Map.DrawFont() ); if ( KM->IsKeyUp(KEY_F8) ) Map.Reset(); @@ -1894,7 +1898,8 @@ void cEETest::PhysicsCreate() { DSO->DrawHash = false; DSO->DrawBBs = false; DSO->DrawShapes = true; - DSO->BodyPointSize = 4; + DSO->CollisionPointSize = 0; + DSO->BodyPointSize = 0; DSO->LineThickness = 1; mDemo.clear(); @@ -1950,7 +1955,7 @@ void cEETest::PhysicsDestroy() { cPhysicsManager::DestroySingleton(); } /* -void defineVertexArrayObject(GLuint vaoId, size_t NbytesV, size_t NbytesC, GLint size, GLenum type, GLfloat *vertices, GLfloat *colors, GLfloat * texCoords, GLuint shader_id ) { +static void defineVertexArrayObject(GLuint vaoId, size_t NbytesV, size_t NbytesC, GLint size, GLenum type, GLfloat *vertices, GLfloat *colors, GLfloat * texCoords, GLuint shader_id ) { //enable vertex array object to be defined glBindVertexArray(vaoId); diff --git a/src/utils/cinterpolation.cpp b/src/utils/cinterpolation.cpp index 83a5f8a55..2060f8b60 100644 --- a/src/utils/cinterpolation.cpp +++ b/src/utils/cinterpolation.cpp @@ -65,24 +65,24 @@ void cInterpolation::AddWaypoint( const eeFloat Pos, const eeFloat Time ) { mPoints.push_back( cPoint1df( Pos, Time ) ); if ( mPoints.size() >= 2 ) - mTotDist += fabs( mPoints[ mPoints.size() - 1 ].p - mPoints[ mPoints.size() - 2 ].p ); + mTotDist += eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[ mPoints.size() - 2 ].p ); } bool cInterpolation::EditWaypoint( const eeUint PointNum, const eeFloat NewPos, const eeFloat NewTime ) { if ( PointNum < mPoints.size() ) { if ( 0 == PointNum ) - mTotDist -= fabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); + mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); else - mTotDist -= fabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); + mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); mPoints[ PointNum ] = cPoint1df( NewPos, NewTime ); if ( 0 == PointNum ) { if ( PointNum + (eeUint)1 < mPoints.size() ) - mTotDist += std::abs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); + mTotDist += eeabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); } else - mTotDist += std::abs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); + mTotDist += eeabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); return true; } @@ -92,9 +92,9 @@ bool cInterpolation::EditWaypoint( const eeUint PointNum, const eeFloat NewPos, bool cInterpolation::EraseWaypoint( const eeUint PointNum ) { if ( PointNum < mPoints.size() && !mEnable ) { if ( 0 == PointNum ) - mTotDist -= fabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); + mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); else - mTotDist -= fabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); + mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); mPoints.erase( mPoints.begin() + PointNum ); @@ -169,12 +169,12 @@ void cInterpolation::SetTotalTime( const eeFloat TotTime ) { } if ( mLoop ) { - tdist += fabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); - mPoints[ mPoints.size() - 1 ].t = std::abs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime / tdist; + tdist += eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); + mPoints[ mPoints.size() - 1 ].t = eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime / tdist; } for ( eeUint i = 0; i < mPoints.size() - 1; i++) { - eeFloat CurDist = fabs( mPoints[i].p - mPoints[i + 1].p ); + eeFloat CurDist = eeabs( mPoints[i].p - mPoints[i + 1].p ); mPoints[i].t = CurDist * TotTime / tdist; } } @@ -191,13 +191,13 @@ void cInterpolation::Speed( const eeFloat speed ) { eeFloat TotTime = tdist * mSpeed; if ( mLoop ) { - tdist += fabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); - mPoints[ mPoints.size() - 1 ].t = fabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime / tdist; + tdist += eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); + mPoints[ mPoints.size() - 1 ].t = eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime / tdist; TotTime = tdist * mSpeed; } for ( eeUint i = 0; i < mPoints.size() - 1; i++) { - eeFloat CurDist = fabs( mPoints[i].p - mPoints[i + 1].p ); + eeFloat CurDist = eeabs( mPoints[i].p - mPoints[i + 1].p ); mPoints[i].t = CurDist * TotTime / tdist; } } diff --git a/src/utils/cperlinnoise.cpp b/src/utils/cperlinnoise.cpp index a312b29bc..b4ea84d20 100755 --- a/src/utils/cperlinnoise.cpp +++ b/src/utils/cperlinnoise.cpp @@ -54,8 +54,8 @@ eeFloat cPerlinNoise::SmoothedNoise2D(eeFloat x, eeFloat y) { } eeFloat cPerlinNoise::Interpolate(eeFloat a, eeFloat b, eeFloat x) { - eeFloat fac1 = 3*pow(1-x, 2) - 2*pow(1-x,3); - eeFloat fac2 = 3*pow(x, 2) - 2*pow(x, 3); + eeFloat fac1 = 3*eepow(1-x, 2) - 2*eepow(1-x,3); + eeFloat fac2 = 3*eepow(x, 2) - 2*eepow(x, 3); return a*fac1 + b*fac2; //add the weighted factors diff --git a/src/utils/easing.cpp b/src/utils/easing.cpp index fa54eb9a4..439c07acf 100644 --- a/src/utils/easing.cpp +++ b/src/utils/easing.cpp @@ -64,23 +64,23 @@ eeFloat QuadraticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { } eeFloat SineIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - return -c * cos( t / d * ( PI / 2 ) ) + c + b; + return -c * eecos( t / d * ( PI / 2 ) ) + c + b; } eeFloat SineOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - return c * sin( t / d * ( PI / 2 ) ) + b; + return c * eesin( t / d * ( PI / 2 ) ) + b; } eeFloat SineInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - return -c / 2 * ( cos( PI * t / d ) - 1 ) + b; + return -c / 2 * ( eecos( PI * t / d ) - 1 ) + b; } eeFloat ExponentialIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - return t == 0 ? b : c * pow( 2, 10 * ( t / d - 1 ) ) + b; + return t == 0 ? b : c * eepow( 2, 10 * ( t / d - 1 ) ) + b; } eeFloat ExponentialOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { - return t == d ? b + c : c * ( -pow( 2, -10 * t / d ) + 1 ) + b; + return t == d ? b + c : c * ( -eepow( 2, -10 * t / d ) + 1 ) + b; } eeFloat ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { @@ -91,9 +91,9 @@ eeFloat ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { return b + c; if ( ( t /= d / 2 ) < 1 ) - return c / 2 * pow( 2, 10 * (t - 1) ) + b; + return c / 2 * eepow( 2, 10 * (t - 1) ) + b; - return c / 2 * ( -pow( 2, -10 * --t ) + 2 ) + b; + return c / 2 * ( -eepow( 2, -10 * --t ) + 2 ) + b; } eeFloat QuarticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { @@ -145,24 +145,24 @@ eeFloat QuinticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { eeFloat CircularIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { t /= d; - return -c * ( sqrt( 1 - t * t ) - 1) + b; + return -c * ( eesqrt( 1 - t * t ) - 1) + b; } eeFloat CircularOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { t = t / d - 1; - return c * sqrt( 1 - t * t ) + b; + return c * eesqrt( 1 - t * t ) + b; } eeFloat CircularInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { t /= d / 2; if ( t < 1 ) - return -c / 2 * ( sqrt( 1 - t * t ) - 1 ) + b; + return -c / 2 * ( eesqrt( 1 - t * t ) - 1 ) + b; t -= 2; - return c / 2 * ( sqrt( 1 - t * t ) + 1) + b; + return c / 2 * ( eesqrt( 1 - t * t ) + 1) + b; } eeFloat CubicIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { @@ -264,7 +264,7 @@ eeFloat ElasticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { t -= 1.f; - return -( a * pow( 2.f , 10.f * t ) * sin( ( t * d - s ) * ( 2.f * PI ) / p ) ) + b; + return -( a * eepow( 2.f , 10.f * t ) * eesin( ( t * d - s ) * ( 2.f * PI ) / p ) ) + b; } eeFloat ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { @@ -280,7 +280,7 @@ eeFloat ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { eeFloat s = p / 4.f; eeFloat a = c; - return ( a * pow( 2.f, -10.f * t ) * sin( ( t * d - s ) * ( 2.f * PI ) / p ) + c + b ); + return ( a * eepow( 2.f, -10.f * t ) * eesin( ( t * d - s ) * ( 2.f * PI ) / p ) + c + b ); } eeFloat ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { @@ -299,12 +299,12 @@ eeFloat ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) { if ( t < 1 ) { t -= 1.f; - return -0.5f * ( a * pow( 2.f, 10.f * t ) * sin( ( t * d - s ) * ( 2.f * PI ) / p ) ) + b; + return -0.5f * ( a * eepow( 2.f, 10.f * t ) * eesin( ( t * d - s ) * ( 2.f * PI ) / p ) ) + b; } t -= 1.f; - return a * pow( 2.f, -10.f * t ) * sin( ( t * d - s ) * ( 2.f * PI ) / p ) * 0.5f + c + b; + return a * eepow( 2.f, -10.f * t ) * eesin( ( t * d - s ) * ( 2.f * PI ) / p ) * 0.5f + c + b; } }}} diff --git a/src/utils/polygon2.hpp b/src/utils/polygon2.hpp index 013ca4120..56de755ac 100755 --- a/src/utils/polygon2.hpp +++ b/src/utils/polygon2.hpp @@ -122,14 +122,14 @@ void Polygon2::Scale( const T& scale, const Vector2& Center ) { for ( Uint32 i = 0; i < Vector.size(); i++ ) { if ( Vector[i].x < Center.x ) - Vector[i].x = Center.x - fabs( Center.x - Vector[i].x ) * scale; + Vector[i].x = Center.x - eeabs( Center.x - Vector[i].x ) * scale; else - Vector[i].x = Center.x + fabs( Center.x - Vector[i].x ) * scale; + Vector[i].x = Center.x + eeabs( Center.x - Vector[i].x ) * scale; if ( Vector[i].y < Center.y ) - Vector[i].y = Center.y - fabs( Center.y - Vector[i].y ) * scale; + Vector[i].y = Center.y - eeabs( Center.y - Vector[i].y ) * scale; else - Vector[i].y = Center.y + fabs( Center.y - Vector[i].y ) * scale; + Vector[i].y = Center.y + eeabs( Center.y - Vector[i].y ) * scale; } } diff --git a/src/utils/quad2.hpp b/src/utils/quad2.hpp index 23d0214f7..161f7bba8 100644 --- a/src/utils/quad2.hpp +++ b/src/utils/quad2.hpp @@ -49,14 +49,14 @@ void Quad2::Scale( const T& scale, const Vector2& Center ) { for ( Uint32 i = 0; i < 4; i++ ) { if ( V[i].x < Center.x ) - V[i].x = Center.x - fabs( Center.x - V[i].x ) * scale; + V[i].x = Center.x - eeabs( Center.x - V[i].x ) * scale; else - V[i].x = Center.x + fabs( Center.x - V[i].x ) * scale; + V[i].x = Center.x + eeabs( Center.x - V[i].x ) * scale; if ( V[i].y < Center.y ) - V[i].y = Center.y - fabs( Center.y - V[i].y ) * scale; + V[i].y = Center.y - eeabs( Center.y - V[i].y ) * scale; else - V[i].y = Center.y + fabs( Center.y - V[i].y ) * scale; + V[i].y = Center.y + eeabs( Center.y - V[i].y ) * scale; } } @@ -105,4 +105,4 @@ typedef Quad2 eeQuad2f; }} -#endif +#endif diff --git a/src/window/cengine.cpp b/src/window/cengine.cpp index 5d15e875c..e9f5c4961 100755 --- a/src/window/cengine.cpp +++ b/src/window/cengine.cpp @@ -280,9 +280,9 @@ void cEngine::Setup2D( const bool& KeepView ) { cTextureFactory::instance()->SetPreBlendFunc( ALPHA_NORMAL ); if ( GLv_3 != GLi->Version() ) { - #ifndef EE_GLES2 - glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - glShadeModel( GL_SMOOTH ); + #ifndef EE_GLES + GLi->TexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + GLi->TexEnvi( GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE ); #endif } @@ -1085,13 +1085,13 @@ void cEngine::SetDefaultContext() { void cEngine::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) { cGlobalBatchRenderer::instance()->Draw(); - GLi->ClipPlaneEnable( x, y, Width, Height ); + GLi->Clip2DPlaneEnable( x, y, Width, Height ); } void cEngine::ClipPlaneDisable() { cGlobalBatchRenderer::instance()->Draw(); - GLi->ClipPlaneDisable(); + GLi->Clip2DPlaneDisable(); } }}