Renamed cImage::Size() to cImage::MemSize(), since it was confusing.

cImage::Size() now returns the image dimensions.
Changed how cUIControl::SetSkin works, it was confusing, now just spects a Skin const reference and make a copy from it.
Fixed DoAfterSetTheme to be virtual, now SetSkin works for all the controls.
Restructured cPrimitives.
Removed some Draw* calls, since it was a little bit bloated, sometimes less is more.
Also added fill mode, blend mode and line width as members of the instance of the primitives class, this way i reduced the number of parameters in almost all the functions, and, it's cleaner.
This commit is contained in:
Martín Lucas Golini
2013-01-03 02:24:28 -03:00
parent bf81f1d6d5
commit 9fdffcabea
30 changed files with 513 additions and 569 deletions

View File

@@ -110,9 +110,9 @@ void cGameObjectVirtual::Draw() {
if ( NULL != mLayer ) {
eeSize ts = mLayer->Map()->TileSize();
P.DrawRectangle( mPos.x, mPos.y, ts.x ,ts.y, 0, 1 );
P.DrawRectangle( eeRectf( eeVector2f( mPos.x, mPos.y ), eeSizef( ts.x ,ts.y ) ), 0, 1 );
} else {
P.DrawRectangle( mPos.x, mPos.y, 32 ,32, 0, 1 );
P.DrawRectangle( eeRectf( eeVector2f( mPos.x, mPos.y ), eeSizef( 32 ,32 ) ), 0, 1 );
}
}
}

View File

@@ -1,5 +1,6 @@
#include <eepp/gaming/cisomap.hpp>
#include <eepp/graphics/renderer/cgl.hpp>
#include <eepp/graphics/cglobalbatchrenderer.hpp>
namespace EE { namespace Gaming {

View File

@@ -12,6 +12,7 @@
#include <eepp/graphics/cprimitives.hpp>
#include <eepp/graphics/ctextureatlasmanager.hpp>
#include <eepp/graphics/ctextureatlasloader.hpp>
#include <eepp/graphics/cglobalbatchrenderer.hpp>
using namespace EE::Graphics;
#include <eepp/ui/cuithememanager.hpp>
@@ -205,7 +206,7 @@ void cMap::Draw() {
Uint8 Alpha = static_cast<Uint8>( (eeFloat)mBackColor.A() * ( (eeFloat)mBackAlpha / 255.f ) );
P.SetColor( eeColorA( mBackColor.R(), mBackColor.G(), mBackColor.B(), Alpha ) );
P.DrawRectangle( mScreenPos.x, mScreenPos.y, mViewSize.x, mViewSize.y, 0.f, 1.f );
P.DrawRectangle( eeRectf( eeVector2f( mScreenPos.x, mScreenPos.y ), eeSizef( mViewSize.x, mViewSize.y ) ), 0.f, 1.f );
P.SetColor( eeColorA( 255, 255, 255, 255 ) );
}

View File

@@ -163,9 +163,9 @@ void cUIMap::MapDraw() {
eeVector2f Pos( mSelLight->GetAABB().Left, mSelLight->GetAABB().Top );
eeAABB AB( mSelLight->GetAABB() );
eeSizef Size( AB.Size() );
P.DrawRectangle( Pos.x, Pos.y, Size.Width(), Size.Height(), 0, 1, EE_DRAW_LINE );
P.FillMode( EE_DRAW_LINE );
P.DrawRectangle( eeRectf( Pos, AB.Size() ) );
}
}

View File

@@ -122,7 +122,7 @@ void cConsole::Draw() {
if ( mY > 0.0f ) {
if ( mTexId == 0 ) {
mPri.SetColor( eeColorA( mConColor.R(), mConColor.G(), mConColor.B(), static_cast<Uint8>(mA) ) );
mPri.DrawRectangle( 0.0f, 0.0f, mWidth, mY );
mPri.DrawRectangle( eeRectf( eeVector2f( 0.0f, 0.0f ), eeSizef( mWidth, mY ) ) );
} else {
eeColorA C( mConColor.R(), mConColor.G(), mConColor.B(), static_cast<Uint8>(mA) );
@@ -132,7 +132,7 @@ void cConsole::Draw() {
Tex->DrawEx( 0.0f, 0.0f, mWidth, mY, 0.0f, 1.0f, C, C, C, C );
}
mPri.SetColor( eeColorA( mConLineColor.R(), mConLineColor.G(), mConLineColor.B(), static_cast<Uint8>(mA) ) );
mPri.DrawRectangle( 0.0f, mY, mWidth, 4.0f );
mPri.DrawRectangle( eeRectf( eeVector2f( 0.0f, mY ), eeSizef( mWidth, 4.0f ) ) );
Int16 LinesInScreen = (Int16) ( (mCurHeight / mFontSize) - 1 );

View File

@@ -13,7 +13,7 @@ Uint32 cImage::JpegQuality() {
}
void cImage::JpegQuality( Uint32 level ) {
level = eemin( level, (Uint32)100 );
level = eemin<Uint32>( level, 100 );
sJpegQuality = level;
}
@@ -250,10 +250,14 @@ void cImage::Allocate( const Uint32& size, eeColorA DefaultColor ) {
mSize = size;
}
eeUint cImage::Size() const {
eeUint cImage::MemSize() const {
return mSize;
}
eeSize cImage::Size() {
return eeSize( mWidth, mHeight );
}
void cImage::ClearCache() {
if ( mLoadedFromStbi ) {
free( mPixels );

View File

@@ -1,349 +1,315 @@
#include <eepp/graphics/cprimitives.hpp>
#include <eepp/math/polygon2.hpp>
#include <eepp/graphics/cbatchrenderer.hpp>
#include <eepp/graphics/cglobalbatchrenderer.hpp>
namespace EE { namespace Graphics {
static cGlobalBatchRenderer * sBR = NULL;
cPrimitives::cPrimitives() :
mBR( cGlobalBatchRenderer::instance() ),
mFillMode( EE_DRAW_FILL ),
mBlendMode( ALPHA_NORMAL ),
mLineWidth( 1.f ),
mForceDraw( true )
{
if ( NULL == sBR ) {
sBR = cGlobalBatchRenderer::instance();
}
}
cPrimitives::~cPrimitives() {
}
void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) {
mBR->SetTexture( NULL );
mBR->SetBlendMode( blend );
void cPrimitives::DrawPoint( const eeVector2f& p, const eeFloat& pointSize ) {
sBR->SetPointSize( pointSize );
sBR->SetTexture( NULL );
sBR->PointsBegin();
sBR->PointSetColor( mColor );
sBR->BatchPoint( p.x, p.y );
DrawBatch();
}
void cPrimitives::DrawLine( const eeLine2f& line ) {
sBR->SetLineWidth( mLineWidth );
sBR->SetTexture( NULL );
sBR->LinesBegin();
sBR->LinesSetColor( mColor );
sBR->BatchLine( line.V[0].x, line.V[0].y, line.V[1].x, line.V[1].y );
DrawBatch();
}
void cPrimitives::DrawTriangle( const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3 ) {
sBR->SetTexture( NULL );
sBR->SetBlendMode( mBlendMode );
switch( mFillMode ) {
case EE_DRAW_LINE:
{
sBR->SetLineWidth( mLineWidth );
sBR->LineLoopBegin();
sBR->LineLoopSetColorFree( Color1, Color2 );
sBR->BatchLineLoop( t.V[0].x, t.V[0].y, t.V[1].x, t.V[1].y );
sBR->LineLoopSetColorFree( Color2, Color3 );
sBR->BatchLineLoop( t.V[1].x, t.V[1].y, t.V[2].x, t.V[2].y );
break;
}
default:
case EE_DRAW_FILL:
{
sBR->TrianglesBegin();
sBR->TrianglesSetColorFree( Color1, Color2, Color3 );
sBR->BatchTriangle( t.V[0].x, t.V[0].y, t.V[1].x, t.V[1].y, t.V[2].x, t.V[2].y );
break;
}
}
DrawBatch();
}
void cPrimitives::DrawTriangle( const eeTriangle2f& t ) {
DrawTriangle( t, mColor, mColor, mColor );
}
void cPrimitives::DrawCircle( const eeVector2f& p, const eeFloat& radius, Uint32 points ) {
if(points < 6) points = 6;
eeFloat angle_shift = 360 / static_cast<eeFloat>(points);
sBR->SetTexture( NULL );
switch( mFillMode ) {
case EE_DRAW_LINE:
{
sBR->SetLineWidth( mLineWidth );
sBR->LineLoopBegin();
sBR->LineLoopSetColor( mColor );
for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift ) )
sBR->BatchLineLoop( p.x + radius * Math::sinAng(i), p.y + radius * Math::cosAng(i), p.x + radius * Math::sinAng( i + angle_shift ), p.y + radius * Math::cosAng( i + angle_shift ) );
break;
}
case EE_DRAW_FILL:
{
sBR->TriangleFanBegin();
sBR->TriangleFanSetColor( mColor );
for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift + angle_shift ) )
sBR->BatchTriangleFan( p.x + radius * Math::sinAng(i), p.y + radius * Math::cosAng(i), p.x + radius * Math::sinAng( i + angle_shift ), p.y + radius * Math::cosAng( i + angle_shift ), p.x + radius * Math::sinAng( i + angle_shift + angle_shift ), p.y + radius * Math::cosAng( i + angle_shift + angle_shift ) );
break;
}
}
DrawBatch();
}
void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale ) {
sBR->SetTexture( NULL );
sBR->SetBlendMode( mBlendMode );
switch( mFillMode ) {
case EE_DRAW_FILL:
{
sBR->QuadsBegin();
sBR->QuadsSetColorFree( TopLeft, BottomLeft, BottomRight, TopRight );
eeSizef size = const_cast<eeRectf*>(&R)->Size();
sBR->BatchQuadEx( R.Left, R.Top, size.Width(), size.Height(), Angle, Scale );
break;
}
case EE_DRAW_LINE:
{
sBR->SetLineWidth( mLineWidth );
sBR->LineLoopBegin();
sBR->LineLoopSetColorFree( TopLeft, BottomLeft );
if ( Scale != 1.0f || Angle != 0.0f ) {
eeQuad2f Q( R );
Q.Scale( Scale );
Q.Rotate( Angle, Q.GetCenter() );
sBR->BatchLineLoop( Q[0].x, Q[0].y, Q[1].x, Q[1].y );
sBR->LineLoopSetColorFree( BottomRight, TopRight );
sBR->BatchLineLoop( Q[2].x, Q[2].y, Q[3].x, Q[3].y );
} else {
sBR->BatchLineLoop( R.Left, R.Top, R.Left, R.Bottom );
sBR->LineLoopSetColorFree( BottomRight, TopRight );
sBR->BatchLineLoop( R.Right, R.Bottom, R.Right, R.Top );
}
break;
}
}
DrawBatch();
}
void cPrimitives::DrawRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale ) {
DrawRectangle( R, mColor, mColor, mColor, mColor, Angle, Scale );
}
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 eeUint& Corners ) {
sBR->SetTexture( NULL );
sBR->SetBlendMode( mBlendMode );
eeUint i;
eeFloat xscalediff = width * Scale - width;
eeFloat yscalediff = height * Scale - height;
eeSizef size = const_cast<eeRectf*>( &R )->Size();
eeFloat xscalediff = size.Width() * Scale - size.Width();
eeFloat yscalediff = size.Height() * Scale - size.Height();
eeVector2f Center( R.Left + size.Width() * 0.5f + xscalediff, R.Top + size.Height() * 0.5f + yscalediff );
eePolygon2f Poly = eePolygon2f::CreateRoundedPolygon( R.Left - xscalediff, R.Top - yscalediff, size.Width() + xscalediff, size.Height() + yscalediff, Corners );
eeVector2f poly;
eeVector2f Center( x + width * 0.5f + xscalediff, y + height * 0.5f + yscalediff );
eePolygon2f Poly = eePolygon2f::CreateRoundedPolygon( x - xscalediff, y - yscalediff, width + xscalediff, height + yscalediff, Corners );
Poly.Rotate( Angle, Center );
switch(fillmode) {
case EE_DRAW_FILL: {
switch( mFillMode ) {
case EE_DRAW_FILL:
{
if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) {
mBR->PolygonSetColor( TopLeft );
sBR->PolygonSetColor( TopLeft );
mBR->BatchPolygon( Poly );
sBR->BatchPolygon( Poly );
} else {
for ( i = 0; i < Poly.Size(); i++ ) {
poly = Poly[i];
if ( poly.x <= Center.x && poly.y <= Center.y )
mBR->PolygonSetColor( TopLeft );
sBR->PolygonSetColor( TopLeft );
else if ( poly.x <= Center.x && poly.y >= Center.y )
mBR->PolygonSetColor( BottomLeft );
sBR->PolygonSetColor( BottomLeft );
else if ( poly.x > Center.x && poly.y > Center.y )
mBR->PolygonSetColor( BottomRight );
sBR->PolygonSetColor( BottomRight );
else if ( poly.x > Center.x && poly.y < Center.y )
mBR->PolygonSetColor( TopRight );
sBR->PolygonSetColor( TopRight );
else
mBR->PolygonSetColor( TopLeft );
sBR->PolygonSetColor( TopLeft );
mBR->BatchPolygonByPoint( Poly[i] );
sBR->BatchPolygonByPoint( Poly[i] );
}
}
break;
}
case EE_DRAW_LINE:
mBR->SetLineWidth( lineWidth );
{
sBR->SetLineWidth( mLineWidth );
mBR->LineLoopBegin();
mBR->LineLoopSetColor( TopLeft );
sBR->LineLoopBegin();
sBR->LineLoopSetColor( TopLeft );
if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) {
for ( i = 0; i < Poly.Size(); i+=2 )
mBR->BatchLineLoop( Poly[i], Poly[i+1] );
for ( i = 0; i < Poly.Size(); i+=2 ) {
sBR->BatchLineLoop( Poly[i], Poly[i+1] );
}
} else {
for ( eeUint i = 0; i < Poly.Size(); i++ ) {
poly = Poly[i];
if ( poly.x <= Center.x && poly.y <= Center.y )
mBR->LineLoopSetColor( TopLeft );
sBR->LineLoopSetColor( TopLeft );
else if ( poly.x < Center.x && poly.y > Center.y )
mBR->LineLoopSetColor( BottomLeft );
sBR->LineLoopSetColor( BottomLeft );
else if ( poly.x > Center.x && poly.y > Center.y )
mBR->LineLoopSetColor( BottomRight );
sBR->LineLoopSetColor( BottomRight );
else if ( poly.x > Center.x && poly.y < Center.y )
mBR->LineLoopSetColor( TopRight );
sBR->LineLoopSetColor( TopRight );
else
mBR->LineLoopSetColor( TopLeft );
sBR->LineLoopSetColor( TopLeft );
mBR->BatchLineLoop( Poly[i] );
sBR->BatchLineLoop( Poly[i] );
}
}
break;
}
}
DrawBatch();
}
void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) {
if ( 0 != Corners ) {
DrawRoundedRectangle( x, y, width, height, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners );
return;
}
void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const eeUint& Corners ) {
DrawRoundedRectangle( R, mColor, mColor, mColor, mColor, Angle, Scale, Corners );
}
mBR->SetTexture( NULL );
mBR->SetBlendMode( blend );
void cPrimitives::DrawQuad( const eeQuad2f& q, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
sBR->SetTexture( NULL );
sBR->SetBlendMode( mBlendMode );
switch(fillmode) {
case EE_DRAW_FILL: {
mBR->QuadsBegin();
mBR->QuadsSetColorFree( TopLeft, BottomLeft, BottomRight, TopRight );
mBR->BatchQuadEx( x, y, width, height, Angle, Scale );
switch( mFillMode ) {
case EE_DRAW_LINE:
{
sBR->SetLineWidth( mLineWidth );
sBR->LineLoopBegin();
sBR->LineLoopSetColorFree( Color1, Color2 );
sBR->BatchLineLoop( OffsetX + q[0].x, OffsetY + q[0].y, OffsetX + q[1].x, OffsetY + q[1].y );
sBR->LineLoopSetColorFree( Color2, Color3 );
sBR->BatchLineLoop( OffsetX + q[2].x, OffsetY + q[2].y, OffsetX + q[3].x, OffsetY + q[3].y );
break;
}
case EE_DRAW_LINE:
mBR->SetLineWidth( lineWidth );
mBR->LineLoopBegin();
mBR->LineLoopSetColorFree( TopLeft, BottomLeft );
if ( Scale != 1.0f || Angle != 0.0f ) {
eeQuad2f Q;
Q.V[0].x = x; Q.V[0].y = y;
Q.V[1].x = x, Q.V[1].y = y + height;
Q.V[2].x = x + width; Q.V[2].y = y + height;
Q.V[3].x = x + width; Q.V[3].y = y;
Q.Scale( Scale );
Q.Rotate( Angle, eeVector2f( x + width * 0.5f, y + height * 0.5f ) );
mBR->BatchLineLoop( Q[0].x, Q[0].y, Q[1].x, Q[1].y );
mBR->LineLoopSetColorFree( BottomRight, TopRight );
mBR->BatchLineLoop( Q[2].x, Q[2].y, Q[3].x, Q[3].y );
} else {
mBR->BatchLineLoop( x, y, x, y + height );
mBR->LineLoopSetColorFree( BottomRight, TopRight );
mBR->BatchLineLoop( x + width, y + height, x + width, y );
}
break;
}
DrawBatch();
}
void cPrimitives::DrawLine(const eeFloat& x, const eeFloat& y, const eeFloat& x2, const eeFloat& y2, const eeFloat& lineWidth) {
mBR->SetLineWidth( lineWidth );
mBR->SetTexture( NULL );
mBR->LinesBegin();
mBR->LinesSetColor( mColor );
mBR->BatchLine( x, y, x2, y2 );
DrawBatch();
}
void cPrimitives::DrawPoint( const eeFloat& x, const eeFloat& y, const eeFloat& pointSize ) {
mBR->SetPointSize( pointSize );
mBR->SetTexture( NULL );
mBR->PointsBegin();
mBR->PointSetColor( mColor );
mBR->BatchPoint( x, y );
DrawBatch();
}
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<eeFloat>(points);
mBR->SetTexture( NULL );
switch( fillmode ) {
case EE_DRAW_LINE:
mBR->SetLineWidth( lineWidth );
mBR->LineLoopBegin();
mBR->LineLoopSetColor( mColor );
for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift ) )
mBR->BatchLineLoop( x + radius * Math::sinAng(i), y + radius * Math::cosAng(i), x + radius * Math::sinAng( i + angle_shift ), y + radius * Math::cosAng( i + angle_shift ) );
break;
case EE_DRAW_FILL:
mBR->TriangleFanBegin();
mBR->TriangleFanSetColor( mColor );
for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift + angle_shift ) )
mBR->BatchTriangleFan( x + radius * Math::sinAng(i), y + radius * Math::cosAng(i), x + radius * Math::sinAng( i + angle_shift ), y + radius * Math::cosAng( i + angle_shift ), x + radius * Math::sinAng( i + angle_shift + angle_shift ), y + radius * Math::cosAng( i + angle_shift + angle_shift ) );
{
sBR->QuadsBegin();
sBR->QuadsSetColorFree( Color1, Color2, Color3, Color4 );
sBR->BatchQuadFree( OffsetX + q[0].x, OffsetY + q[0].y, OffsetX + q[1].x, OffsetY + q[1].y, OffsetX + q[2].x, OffsetY + q[2].y, OffsetX + q[3].x, OffsetY + q[3].y );
break;
}
}
DrawBatch();
}
void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
mBR->SetTexture( NULL );
mBR->SetBlendMode( blend );
switch(fillmode) {
case EE_DRAW_LINE:
mBR->SetLineWidth( lineWidth );
mBR->LineLoopBegin();
mBR->LineLoopSetColorFree( Color1, Color2 );
mBR->BatchLineLoop( x1, y1, x2, y2 );
mBR->LineLoopSetColorFree( Color2, Color3 );
mBR->BatchLineLoop( x2, y2, x3, y3 );
break;
default:
case EE_DRAW_FILL:
mBR->TrianglesBegin();
mBR->TrianglesSetColorFree( Color1, Color2, Color3 );
mBR->BatchTriangle( x1, y1, x2, y2, x3, y3 );
break;
}
DrawBatch();
void cPrimitives::DrawQuad( const eeQuad2f& q, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
DrawQuad( q, mColor, mColor, mColor, mColor, OffsetX, OffsetY );
}
void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
mBR->SetTexture( NULL );
mBR->SetBlendMode( blend );
void cPrimitives::DrawPolygon( const eePolygon2f& p ) {
sBR->SetTexture( NULL );
sBR->SetBlendMode( mBlendMode );
switch(fillmode) {
switch( mFillMode ) {
case EE_DRAW_LINE:
mBR->SetLineWidth( lineWidth );
{
sBR->SetLineWidth( mLineWidth );
mBR->LineLoopBegin();
mBR->LineLoopSetColorFree( Color1, Color2 );
mBR->BatchLineLoop( OffsetX + x1, OffsetY + y1, OffsetX + x2, OffsetY + y2 );
mBR->LineLoopSetColorFree( Color2, Color3 );
mBR->BatchLineLoop( OffsetX + x3, OffsetY + y3, OffsetX + x4, OffsetY + y4 );
break;
case EE_DRAW_FILL:
mBR->QuadsBegin();
mBR->QuadsSetColorFree( Color1, Color2, Color3, Color4 );
mBR->BatchQuadFree( OffsetX + x1, OffsetY + y1, OffsetX + x2, OffsetY + y2, OffsetX + x3, OffsetY + y3, OffsetX + x4, OffsetY + y4 );
break;
}
DrawBatch();
}
void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
mBR->SetTexture( NULL );
mBR->SetBlendMode( blend );
switch(fillmode) {
case EE_DRAW_LINE:
mBR->SetLineWidth( lineWidth );
mBR->LineLoopBegin();
mBR->LineLoopSetColor( mColor );
sBR->LineLoopBegin();
sBR->LineLoopSetColor( mColor );
for ( Uint32 i = 0; i < p.Size(); i += 2 )
mBR->BatchLineLoop( p[i].x, p[i].y, p[i+1].x, p[i+1].y );
sBR->BatchLineLoop( p[i].x, p[i].y, p[i+1].x, p[i+1].y );
break;
}
case EE_DRAW_FILL:
mBR->PolygonSetColor( mColor );
mBR->BatchPolygon( p );
{
sBR->PolygonSetColor( mColor );
sBR->BatchPolygon( p );
break;
}
}
DrawBatch();
}
void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) {
DrawRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners);
}
void cPrimitives::DrawRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) {
DrawRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners);
}
void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) {
DrawRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners);
}
void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) {
DrawRoundedRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners);
}
void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) {
DrawRoundedRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners);
}
void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) {
DrawRoundedRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners);
}
void cPrimitives::DrawLine(const eeVector2f& p1, const eeVector2f& p2, const eeFloat& lineWidth) {
DrawLine(p1.x, p1.y, p2.x, p2.y, lineWidth);
}
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_FILL_MODE& fillmode, const eeFloat& lineWidth) {
DrawCircle(p.x, p.y, radius, points, fillmode, lineWidth);
}
void cPrimitives::SetColor( const eeColorA& Color ) {
mColor = Color;
}
void cPrimitives::DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
DrawTriangle( t.V[0], t.V[1], t.V[2], mColor, mColor, mColor, fillmode, blend, lineWidth );
}
void cPrimitives::DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
DrawTriangle( t.V[0], t.V[1], t.V[2], Color1, Color2, Color3, fillmode, blend, lineWidth );
}
void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
DrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, Color1, Color2, Color3, fillmode, blend, lineWidth);
}
void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
DrawTriangle(x1, y1, x2, y2, x3, y3, mColor, mColor, mColor, fillmode, blend, lineWidth);
}
void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) {
DrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, mColor, mColor, mColor, fillmode, blend, lineWidth);
}
void cPrimitives::DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
DrawQuad(x1, y1, x2, y2, x3, y3, x4, y4, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY);
}
void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
DrawQuad(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, Color1, Color2, Color3, Color4, fillmode, blend, lineWidth, OffsetX, OffsetY);
}
void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
DrawQuad(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY);
}
void cPrimitives::DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) {
DrawQuad(q.V[0].x, q.V[0].y, q.V[1].x, q.V[1].y, q.V[2].x, q.V[2].y, q.V[3].x, q.V[3].y, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY);
}
void cPrimitives::DrawBatch() {
if ( mForceDraw )
mBR->Draw();
sBR->Draw();
else
mBR->DrawOpt();
sBR->DrawOpt();
}
void cPrimitives::ForceDraw( const bool& force ) {
@@ -357,4 +323,32 @@ const bool& cPrimitives::ForceDraw() const {
return mForceDraw;
}
void cPrimitives::SetColor( const eeColorA& Color ) {
mColor = Color;
}
void cPrimitives::FillMode( const EE_FILL_MODE& Mode ) {
mFillMode = Mode;
}
const EE_FILL_MODE& cPrimitives::FillMode() const {
return mFillMode;
}
void cPrimitives::BlendMode( const EE_BLEND_MODE& Mode ) {
mBlendMode = Mode;
}
const EE_BLEND_MODE& cPrimitives::BlendMode() const {
return mBlendMode;
}
void cPrimitives::LineWidth( const eeFloat& width ) {
mLineWidth = width;
}
const eeFloat& cPrimitives::LineWidth() const {
return mLineWidth;
}
}}

View File

@@ -288,8 +288,8 @@ eeUint cTextureFactory::GetTexMemSize( const eeUint& TexId ) {
eeUint h = Tex->Height();
eeUint c = Tex->Channels();
if ( 0 != Tex->Size() )
Size = Tex->Size();
if ( 0 != Tex->MemSize() )
Size = Tex->MemSize();
else
Size = ( w * h * c );
@@ -301,7 +301,7 @@ eeUint cTextureFactory::GetTexMemSize( const eeUint& TexId ) {
}
}
} else {
Size = Tex->Size();
Size = Tex->MemSize();
}
}

View File

@@ -171,10 +171,10 @@ void cShape::DrawBB() {
cPrimitives P;
P.SetColor( eeColorA( 76, 128, 76, 255 ) );
P.ForceDraw( false );
P.DrawLine( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.t ) );
P.DrawLine( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.l, mShape->bb.b ) );
P.DrawLine( eeVector2f( mShape->bb.l, mShape->bb.b ), eeVector2f( mShape->bb.r, mShape->bb.b ) );
P.DrawLine( eeVector2f( mShape->bb.r, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.b ) );
P.DrawLine( eeLine2f( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.t ) ) );
P.DrawLine( eeLine2f( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.l, mShape->bb.b ) ) );
P.DrawLine( eeLine2f( eeVector2f( mShape->bb.l, mShape->bb.b ), eeVector2f( mShape->bb.r, mShape->bb.b ) ) );
P.DrawLine( eeLine2f( eeVector2f( mShape->bb.r, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.b ) ) );
#endif
}

View File

@@ -41,7 +41,7 @@ void cShapeCircle::Draw( cSpace * space ) {
cpCircleShape * cs = (cpCircleShape*)mShape;
p.SetColor( ColorForShape( mShape, space->Space() ) );
p.DrawCircle( cs->CP_PRIVATE(tc).x, cs->CP_PRIVATE(tc).y, cs->CP_PRIVATE(r) );
p.DrawCircle( eeVector2f( cs->CP_PRIVATE(tc).x, cs->CP_PRIVATE(tc).y ), cs->CP_PRIVATE(r) );
#endif
}

View File

@@ -105,7 +105,7 @@ void cShapeSegment::Draw( cSpace * space ) {
GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY );
} else {
cPrimitives p;
p.DrawLine( eeVector2f( a.x, a.y ), eeVector2f( b.x, b.y ) );
p.DrawLine( eeLine2f( eeVector2f( a.x, a.y ), eeVector2f( b.x, b.y ) ) );
}
#endif
}

View File

@@ -497,25 +497,54 @@ void cUIControl::OnSizeChange() {
SendCommonEvent( cUIEvent::EventOnSizeChange );
}
eeRectf cUIControl::GetRectf() {
return eeRectf( eeVector2f( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y ), eeSizef( (eeFloat)mSize.Width(), (eeFloat)mSize.Height() ) );
}
void cUIControl::BackgroundDraw() {
cPrimitives P;
eeRectf R = GetRectf();
P.BlendMode( mBackground->Blend() );
P.SetColor( mBackground->Color() );
if ( 4 == mBackground->Colors().size() ) {
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.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() );
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( R, mBackground->Colors()[0], mBackground->Colors()[1], mBackground->Colors()[2], mBackground->Colors()[3], mBackground->Corners() );
} else {
P.DrawRectangle( R, mBackground->Colors()[0], mBackground->Colors()[1], mBackground->Colors()[2], mBackground->Colors()[3] );
}
} else {
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_FILL, mBackground->Blend(), 1.0f, mBackground->Corners() );
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( R, 0.f, 1.f, mBackground->Corners() );
} else {
P.DrawRectangle( R );
}
}
}
void cUIControl::BorderDraw() {
cPrimitives P;
P.FillMode( EE_DRAW_LINE );
P.BlendMode( Blend() );
P.LineWidth( (eeFloat)mBorder->Width() );
P.SetColor( mBorder->Color() );
if ( mFlags & UI_CLIP_ENABLE )
P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() );
else
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() );
//! @TODO: Check why was this +0.1f -0.1f?
if ( mFlags & UI_CLIP_ENABLE ) {
eeRectf R( eeVector2f( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f ), eeSizef( (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f ) );
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() );
} else {
P.DrawRectangle( R );
}
} else {
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() );
} else {
P.DrawRectangle( GetRectf() );
}
}
}
const Uint32& cUIControl::ControlFlags() const {
@@ -908,14 +937,16 @@ void cUIControl::SetSkinFromTheme( cUITheme * Theme, const std::string& ControlN
SetThemeControl( Theme, ControlName );
}
void cUIControl::SetSkin( cUISkin * Skin ) {
if ( NULL != Skin ) {
SafeDeleteSkinState();
void cUIControl::SetSkin( const cUISkin& Skin ) {
SafeDeleteSkinState();
WriteCtrlFlag( UI_CTRL_FLAG_SKIN_OWNER, 1 );
WriteCtrlFlag( UI_CTRL_FLAG_SKIN_OWNER, 1 );
mSkinState = eeNew( cUISkinState, ( Skin ) );
}
cUISkin * SkinCopy = const_cast<cUISkin*>( &Skin )->Copy();
mSkinState = eeNew( cUISkinState, ( SkinCopy ) );
DoAfterSetTheme();
}
void cUIControl::OnStateChange() {
@@ -1145,4 +1176,7 @@ cUIControl * cUIControl::NextComplexControl() {
return cUIManager::instance()->MainControl();
}
void cUIControl::DoAfterSetTheme() {
}
}}

View File

@@ -1,6 +1,7 @@
#include <eepp/ui/cuicontrolanim.hpp>
#include <eepp/ui/cuimanager.hpp>
#include <eepp/graphics/renderer/cgl.hpp>
#include <eepp/graphics/cglobalbatchrenderer.hpp>
namespace EE { namespace UI {
@@ -45,8 +46,10 @@ void cUIControlAnim::Draw() {
if ( cUIManager::instance()->HighlightFocus() && cUIManager::instance()->FocusControl() == this ) {
cPrimitives P;
P.FillMode( EE_DRAW_LINE );
P.BlendMode( Blend() );
P.SetColor( cUIManager::instance()->HighlightColor() );
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), 1, 0 );
P.DrawRectangle( GetRectf() );
}
}
}
@@ -262,23 +265,48 @@ void cUIControlAnim::DisableFadeOut( const eeFloat& Time, const bool& AlphaChild
void cUIControlAnim::BackgroundDraw() {
cPrimitives P;
eeRectf R = GetRectf();
P.BlendMode( mBackground->Blend() );
P.SetColor( GetColor( mBackground->Color() ) );
if ( 4 == mBackground->Colors().size() ) {
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.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() );
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( R, GetColor( mBackground->Colors()[0] ), GetColor( mBackground->Colors()[1] ), GetColor( mBackground->Colors()[2] ), GetColor( mBackground->Colors()[3] ), mBackground->Corners() );
} else {
P.DrawRectangle( R, GetColor( mBackground->Colors()[0] ), GetColor( mBackground->Colors()[1] ), GetColor( mBackground->Colors()[2] ), GetColor( mBackground->Colors()[3] ) );
}
} else {
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_FILL, mBackground->Blend(), 1.0f, mBackground->Corners() );
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( R, 0.f, 1.f, mBackground->Corners() );
} else {
P.DrawRectangle( R );
}
}
}
void cUIControlAnim::BorderDraw() {
cPrimitives P;
P.FillMode( EE_DRAW_LINE );
P.BlendMode( Blend() );
P.LineWidth( (eeFloat)mBorder->Width() );
P.SetColor( GetColor( mBorder->Color() ) );
if ( mFlags & UI_CLIP_ENABLE )
P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() );
else
P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() );
//! @TODO: Check why was this +0.1f -0.1f?
if ( mFlags & UI_CLIP_ENABLE ) {
eeRectf R( eeVector2f( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f ), eeSizef( (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f ) );
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() );
} else {
P.DrawRectangle( R );
}
} else {
if ( mBackground->Corners() ) {
P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() );
} else {
P.DrawRectangle( GetRectf() );
}
}
}
eeColorA cUIControlAnim::GetColor( const eeColorA& Col ) {

View File

@@ -1,5 +1,6 @@
#include <eepp/ui/cuimanager.hpp>
#include <eepp/window/cengine.hpp>
#include <eepp/graphics/cglobalbatchrenderer.hpp>
#include <algorithm>
namespace EE { namespace UI {

View File

@@ -127,12 +127,6 @@ void cUIPushButton::SetTheme( cUITheme * Theme ) {
DoAfterSetTheme();
}
void cUIPushButton::SetSkin( cUISkin * Skin ) {
cUIControl::SetSkin( Skin );
DoAfterSetTheme();
}
void cUIPushButton::DoAfterSetTheme() {
if ( NULL != mTextBox && NULL == mTextBox->Font() && NULL != mSkinState && NULL != mSkinState->GetSkin() && NULL != mSkinState->GetSkin()->Theme() && NULL != mSkinState->GetSkin()->Theme()->Font() )
mTextBox->Font( mSkinState->GetSkin()->Theme()->Font() );

View File

@@ -84,7 +84,7 @@ void cUITextInput::Draw() {
if ( CurPosX > (eeFloat)mScreenPos.x + (eeFloat)mSize.x )
CurPosX = (eeFloat)mScreenPos.x + (eeFloat)mSize.x;
P.DrawLine( CurPosX, CurPosY, CurPosX, CurPosY + mTextCache->Font()->GetFontHeight(), 1.f );
P.DrawLine( eeLine2f( eeVector2f( CurPosX, CurPosY ), eeVector2f( CurPosX, CurPosY + mTextCache->Font()->GetFontHeight() ) ) );
if ( disableSmooth )
GLi->LineSmooth( true );

View File

@@ -582,15 +582,15 @@ void cUIWindow::Draw() {
eeVector2i ShadowPos = mScreenPos + eeVector2i( 0, 16 );
P.DrawRectangle( ShadowPos.x, ShadowPos.y, mSize.Width(), mSize.Height(), BeginC, BeginC, BeginC, BeginC );
P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y ), eeSizef( mSize.Width(), mSize.Height() ) ), BeginC, BeginC, BeginC, BeginC );
P.DrawRectangle( ShadowPos.x, ShadowPos.y - SSize, mSize.Width(), SSize, EndC, BeginC, BeginC, EndC );
P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y - SSize ), eeSizef( mSize.Width(), SSize ) ), EndC, BeginC, BeginC, EndC );
P.DrawRectangle( ShadowPos.x - SSize, ShadowPos.y, SSize, mSize.Height(), EndC, EndC, BeginC, BeginC );
P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x - SSize, ShadowPos.y ), eeSizef( SSize, mSize.Height() ) ), EndC, EndC, BeginC, BeginC );
P.DrawRectangle( ShadowPos.x + mSize.Width(), ShadowPos.y, SSize, mSize.Height(), BeginC, BeginC, EndC, EndC );
P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y ), eeSizef( SSize, mSize.Height() ) ), BeginC, BeginC, EndC, EndC );
P.DrawRectangle( ShadowPos.x, ShadowPos.y + mSize.Height(), mSize.Width(), SSize, BeginC, EndC, EndC, BeginC );
P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() ), eeSizef( mSize.Width(), SSize ) ), BeginC, EndC, EndC, BeginC );
P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y ), eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y - SSize ), eeVector2f( ShadowPos.x + mSize.Width() + SSize, ShadowPos.y ) ), BeginC, EndC, EndC );

View File

@@ -35,8 +35,8 @@ cTextureAtlasSubTextureEditor::~cTextureAtlasSubTextureEditor() {
void cTextureAtlasSubTextureEditor::Draw() {
cPrimitives P;
P.SetColor( eeColorA( 255, 0, 0, mAlpha ) );
P.DrawLine( mScreenPos.x, mScreenPos.y + mUICenter.y, mScreenPos.x + mSize.Width(), mScreenPos.y + mUICenter.y );
P.DrawLine( mScreenPos.x + mUICenter.x, mScreenPos.y, mScreenPos.x + mUICenter.x, mScreenPos.y + mSize.Height() );
P.DrawLine( eeLine2f( eeVector2f( mScreenPos.x, mScreenPos.y + mUICenter.y ), eeVector2f( mScreenPos.x + mSize.Width(), mScreenPos.y + mUICenter.y ) ) );
P.DrawLine( eeLine2f( eeVector2f( mScreenPos.x + mUICenter.x, mScreenPos.y ), eeVector2f( mScreenPos.x + mUICenter.x, mScreenPos.y + mSize.Height() ) ) );
cUIComplexControl::Draw();
}

View File

@@ -25,7 +25,7 @@ cCursor::cCursor( cImage * img, const eeVector2i& hotspot, const std::string& na
mHotSpot( hotspot ),
mWindow( window )
{
if ( img->Size() ) {
if ( img->MemSize() ) {
mImage = eeNew( cImage, ( img->GetPixelsPtr(), img->Width(), img->Height(), img->Channels() ) );
} else {
cLog::instance()->Write( "cCursor::cCursor: Error creating cursor from cImage." );

View File

@@ -126,7 +126,7 @@ static void local_draw_to_hdc( HDC dc, cImage * bitmap, int x, int y ) {
}
void cCursorWin::Create() {
if ( NULL == mImage && mImage->Size() )
if ( NULL == mImage && mImage->MemSize() )
return;
int x, y;

View File

@@ -41,7 +41,7 @@ cCursorX11::~cCursorX11() {
}
void cCursorX11::Create() {
if ( NULL == mImage && mImage->Size() )
if ( NULL == mImage && mImage->MemSize() )
return;
XcursorImage * image;

View File

@@ -32,7 +32,7 @@ EE_MAIN_FUNC int main (int argc, char * argv [])
}
// Draw a circle
p.DrawCircle( win->GetWidth() / 2, win->GetHeight() / 2, 200 );
p.DrawCircle( eeVector2f( win->GetWidth() * 0.5f, win->GetHeight() * 0.5f ), 200 );
// Draw frame
win->Display();

View File

@@ -562,18 +562,20 @@ void cEETest::CreateUI() {
#ifdef EE_PLATFORM_TOUCH
cTextureAtlas * SG = cGlobalTextureAtlas::instance();
SG->Add( TF->Load( MyPath + "extra/button-te_normal.png" ), "button-te_normal" );
cTexture * butTex = TF->GetTexture( TF->Load( MyPath + "extra/button-te_normal.png" ) );
SG->Add( butTex->Id(), "button-te_normal" );
SG->Add( TF->Load( MyPath + "extra/button-te_mdown.png" ), "button-te_mdown" );
cUISkinSimple * nSkin = eeNew( cUISkinSimple, ( "button-te" ) );
cUISkinSimple nSkin( "button-te" );
mShowMenu = mTheme->CreatePushButton( NULL, eeSize( 128, 64 ), eeVector2i( mWindow->GetWidth() - 158, mWindow->GetHeight() - 74 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
mShowMenu = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mWindow->GetWidth() - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
mShowMenu->SetSkin( nSkin );
mShowMenu->Text( "Show Menu" );
mShowMenu->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnShowMenu ) );
mTerrainBut = mTheme->CreatePushButton( NULL, eeSize( 128, 64 ), eeVector2i( mShowMenu->Pos().x - 128 - 20, mWindow->GetHeight() - 74 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
mTerrainBut->SetSkin( nSkin->Copy() );
mTerrainBut = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mShowMenu->Pos().x - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
mTerrainBut->SetSkin( nSkin );
mTerrainBut->Text( "Terrain Up" );
mTerrainBut->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnTerrainMouse ) );
mTerrainBut->Visible( 1 == Screen );
@@ -1105,9 +1107,10 @@ void cEETest::Screen2() {
CL1.Draw();
CL2.Draw();
PR.DrawRectangle( CL1.GetAABB(), 0.0f, 1.0f, EE_DRAW_LINE );
PR.FillMode( EE_DRAW_LINE );
PR.DrawRectangle( CL1.GetAABB() );
PR.DrawQuad( CL1.GetQuad(), EE_DRAW_LINE );
PR.DrawQuad( CL1.GetQuad() );
#endif
Ang = Ang + mWindow->Elapsed() * 0.1f;
@@ -1140,15 +1143,16 @@ void cEETest::Screen2() {
else if (iL2)
PR.SetColor( eeColorA(255, 255, 0, 255) );
PR.DrawCircle(Mousef.x, Mousef.y, 80.f, (Uint32)(Ang/3), EE_DRAW_LINE);
PR.FillMode( EE_DRAW_LINE );
PR.DrawCircle( eeVector2f( Mousef.x, Mousef.y ), 80.f, (Uint32)(Ang/3) );
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)mWindow->GetWidth(), 0.f), eeVector2f( 0.f, (eeFloat)mWindow->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, EE_DRAW_LINE);
PR.DrawLine( eeVector2f(0.f, 0.f), eeVector2f( (eeFloat)mWindow->GetWidth(), (eeFloat)mWindow->GetHeight() ) );
PR.DrawTriangle( eeTriangle2f( 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 ) ) );
PR.DrawLine( eeLine2f( eeVector2f(Mousef.x - 80.f, Mousef.y - 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y + 80.f) ) );
PR.DrawLine( eeLine2f( eeVector2f(Mousef.x - 80.f, Mousef.y + 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y - 80.f) ) );
PR.DrawLine( eeLine2f( eeVector2f((eeFloat)mWindow->GetWidth(), 0.f), eeVector2f( 0.f, (eeFloat)mWindow->GetHeight() ) ) );
PR.DrawQuad( eeQuad2f( 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( eeRectf( eeVector2f( Mousef.x - 80.f, Mousef.y - 80.f ), eeSizef( 160.f, 160.f ) ), 45.f );
PR.DrawLine( eeLine2f( eeVector2f(0.f, 0.f), eeVector2f( (eeFloat)mWindow->GetWidth(), (eeFloat)mWindow->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) );
@@ -1262,13 +1266,19 @@ void cEETest::Render() {
eeColorA ColRR3( 100, 100, 100, 220 );
PR.SetColor( eeColorA(150, 150, 150, 220) );
PR.FillMode( EE_DRAW_FILL );
PR.DrawRectangle(
0.f,
(eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight(),
mEEText.GetTextWidth(),
mEEText.GetTextHeight(),
ColRR1, ColRR2, ColRR3, ColRR4
eeRectf(
eeVector2f(
0.f,
(eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight()
),
eeVector2f(
mEEText.GetTextWidth(),
mEEText.GetTextHeight()
)
),
ColRR1, ColRR2, ColRR3, ColRR4
);
mEEText.Draw( 0.f, (eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight(), FONT_DRAW_CENTER );