Fixed nested clippning.

Fixes in tRECT.
OutlineSize is taken in dp.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-03-03 05:27:11 -03:00
parent cab961cbcb
commit 3cd48da1ca
10 changed files with 92 additions and 61 deletions

View File

@@ -25,7 +25,9 @@ class tRECT {
bool contains( const Vector2<T>& Vect );
void merge( const tRECT<T>& Rect );
void expand( const tRECT<T>& Rect );
void shrink( const tRECT<T>& Rect );
void expand( const Vector2<T>& Vect );
@@ -214,19 +216,27 @@ T tRECT<T>::getHeight() {
}
template <typename T>
void tRECT<T>::merge( const tRECT<T>& Rect ) {
void tRECT<T>::expand( const tRECT<T>& Rect ) {
Left = eemin( Left , Rect.Left );
Bottom = eemin( Bottom , Rect.Bottom );
Bottom = eemax( Bottom , Rect.Bottom );
Right = eemax( Right , Rect.Right );
Top = eemin( Top , Rect.Top );
}
template <typename T>
void tRECT<T>::shrink( const tRECT<T>& Rect ) {
Left = eemax( Left , Rect.Left );
Bottom = eemin( Bottom , Rect.Bottom );
Right = eemin( Right , Rect.Right );
Top = eemax( Top , Rect.Top );
}
template <typename T>
void tRECT<T>::expand( const Vector2<T>& Vect ) {
Left = eemin( Left , Vect.x );
Bottom = eemin( Bottom , Vect.y );
Bottom = eemax( Bottom , Vect.y );
Right = eemax( Right , Vect.x );
Top = eemax( Top , Vect.y );
Top = eemin( Top , Vect.y );
}
template <typename T>

View File

@@ -4,22 +4,22 @@
#include <eepp/config.hpp>
#include <string>
#define EEPP_MAJOR_VERSION 1
#define EEPP_MAJOR_VERSION 2
#define EEPP_MINOR_VERSION 0
#define EEPP_PATCHLEVEL 0
#define EEPP_CODENAME "Bodhisattva"
#define EEPP_PATCH_LEVEL 0
#define EEPP_CODENAME "Lokuttara"
/** The compiled version of the library */
#define EEPP_VERSION(x) \
{ \
(x)->major = EEPP_MAJOR_VERSION; \
(x)->minor = EEPP_MINOR_VERSION; \
(x)->patch = EEPP_PATCHLEVEL; \
(x)->patch = EEPP_PATCH_LEVEL; \
}
#define EEPP_VERSIONNUM(X, Y, Z) ((X)*1000 + (Y)*100 + (Z))
#define EEPP_COMPILEDVERSION EEPP_VERSIONNUM(EEPP_MAJOR_VERSION, EEPP_MINOR_VERSION, EEPP_PATCHLEVEL)
#define EEPP_COMPILEDVERSION EEPP_VERSIONNUM(EEPP_MAJOR_VERSION, EEPP_MINOR_VERSION, EEPP_PATCH_LEVEL)
#define EEPP_VERSION_ATLEAST(X, Y, Z) (EEPP_COMPILEDVERSION >= EEPP_VERSIONNUM(X, Y, Z))

View File

@@ -229,15 +229,17 @@ void RendererGL::pointSize( float size ) {
}
void RendererGL::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
double tX = (double)x;
double tY = (double)y;
double tW = (double)Width;
double tH = (double)Height;
Rectf r( x, y, x + Width, y + Height );
double clip_left[] = { 1.0 , 0.0 , 0.0, -tX };
double clip_right[] = { -1.0, 0.0 , 0.0, tX + tW };
double clip_top[] = { 0.0 , 1.0 , 0.0, -tY };
double clip_bottom[] = { 0.0 , -1.0 , 0.0, tY + tH };
if ( !mPlanesClipped.empty() ) {
Rectf r2 = mPlanesClipped.back();
r.shrink( r2 );
}
double clip_left[] = { 1.0 , 0.0 , 0.0, -r.Left };
double clip_right[] = { -1.0, 0.0 , 0.0, r.Right };
double clip_top[] = { 0.0 , 1.0 , 0.0, -r.Top };
double clip_bottom[] = { 0.0 , -1.0 , 0.0, r.Bottom };
GLi->enable(GL_CLIP_PLANE0);
GLi->enable(GL_CLIP_PLANE1);
@@ -250,7 +252,7 @@ void RendererGL::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32&
clipPlane(GL_CLIP_PLANE3, clip_bottom);
if ( mPushClip ) {
mPlanesClipped.push_back( Rectf( x, y, Width, Height ) );
mPlanesClipped.push_back( r );
}
}
@@ -267,7 +269,7 @@ void RendererGL::clip2DPlaneDisable() {
} else {
Rectf R( mPlanesClipped.back() );
mPushClip = false;
clip2DPlaneEnable( R.Left, R.Top, R.Right, R.Bottom );
clip2DPlaneEnable( R.Left, R.Top, R.getWidth(), R.getHeight() );
mPushClip = true;
}
}

View File

@@ -541,15 +541,17 @@ void RendererGL3::matrixMode(unsigned int mode) {
}
void RendererGL3::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
float tX = (float)x;
float tY = (float)y;
float tW = (float)Width;
float tH = (float)Height;
Rectf r( x, y, x + Width, y + Height );
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 );
if ( !mPlanesClipped.empty() ) {
Rectf r2 = mPlanesClipped.back();
r.shrink( r2 );
}
glm::vec4 vclip_left ( 1.0 , 0.0 , 0.0 , -r.Left );
glm::vec4 vclip_right ( -1.0 , 0.0 , 0.0 , r.Right );
glm::vec4 vclip_top ( 0.0 , 1.0 , 0.0 , -r.Top );
glm::vec4 vclip_bottom ( 0.0 , -1.0 , 0.0 , r.Bottom );
glm::mat4 invMV = glm::inverse( mStack->mModelViewMatrix.top() );
@@ -569,7 +571,7 @@ void RendererGL3::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32
glUniform4fv( mPlanes[3], 1, static_cast<const float*>( &vclip_bottom[0] ) );
if ( mPushClip ) {
mPlanesClipped.push_back( Rectf( x, y, Width, Height ) );
mPlanesClipped.push_back( r );
}
}
@@ -586,7 +588,7 @@ void RendererGL3::clip2DPlaneDisable() {
} else {
Rectf R( mPlanesClipped.back() );
mPushClip = false;
clip2DPlaneEnable( R.Left, R.Top, R.Right, R.Bottom );
clip2DPlaneEnable( R.Left, R.Top, R.getWidth(), R.getHeight() );
mPushClip = true;
}
}

View File

@@ -614,15 +614,17 @@ void RendererGL3CP::matrixMode(unsigned int mode) {
}
void RendererGL3CP::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
float tX = (float)x;
float tY = (float)y;
float tW = (float)Width;
float tH = (float)Height;
Rectf r( x, y, x + Width, y + Height );
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 );
if ( !mPlanesClipped.empty() ) {
Rectf r2 = mPlanesClipped.back();
r.shrink( r2 );
}
glm::vec4 vclip_left ( 1.0 , 0.0 , 0.0 , -r.Left );
glm::vec4 vclip_right ( -1.0 , 0.0 , 0.0 , r.Right );
glm::vec4 vclip_top ( 0.0 , 1.0 , 0.0 , -r.Top );
glm::vec4 vclip_bottom ( 0.0 , -1.0 , 0.0 , r.Bottom );
glm::mat4 invMV = glm::inverse( mStack->mModelViewMatrix.top() );
@@ -642,7 +644,7 @@ void RendererGL3CP::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int
glUniform4fv( mPlanes[3], 1, static_cast<const float*>( &vclip_bottom[0] ) );
if ( mPushClip ) {
mPlanesClipped.push_back( Rectf( x, y, Width, Height ) );
mPlanesClipped.push_back( r );
}
}
@@ -659,7 +661,7 @@ void RendererGL3CP::clip2DPlaneDisable() {
} else {
Rectf R( mPlanesClipped.back() );
mPushClip = false;
clip2DPlaneEnable( R.Left, R.Top, R.Right, R.Bottom );
clip2DPlaneEnable( R.Left, R.Top, R.getWidth(), R.getHeight() );
mPushClip = true;
}
}

View File

@@ -617,15 +617,17 @@ void RendererGLES2::matrixMode(unsigned int mode) {
}
void RendererGLES2::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
float tX = (float)x;
float tY = (float)y;
float tW = (float)Width;
float tH = (float)Height;
Rectf r( x, y, x + Width, y + Height );
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 );
if ( !mPlanesClipped.empty() ) {
Rectf r2 = mPlanesClipped.back();
r.shrink( r2 );
}
glm::vec4 vclip_left ( 1.0 , 0.0 , 0.0 , -r.Left );
glm::vec4 vclip_right ( -1.0 , 0.0 , 0.0 , r.Right );
glm::vec4 vclip_top ( 0.0 , 1.0 , 0.0 , -r.Top );
glm::vec4 vclip_bottom ( 0.0 , -1.0 , 0.0 , r.Bottom );
glm::mat4 invMV = glm::inverse( mStack->mModelViewMatrix.top() );
@@ -645,7 +647,7 @@ void RendererGLES2::clip2DPlaneEnable( const Int32& x, const Int32& y, const Int
glUniform4fv( mPlanes[3], 1, static_cast<const float*>( &vclip_bottom[0] ) );
if ( mPushClip ) {
mPlanesClipped.push_back( Rectf( x, y, Width, Height ) );
mPlanesClipped.push_back( r );
}
}
@@ -662,7 +664,7 @@ void RendererGLES2::clip2DPlaneDisable() {
} else {
Rectf R( mPlanesClipped.back() );
mPushClip = false;
clip2DPlaneEnable( R.Left, R.Top, R.Right, R.Bottom );
clip2DPlaneEnable( R.Left, R.Top, R.getWidth(), R.getHeight() );
mPushClip = true;
}
}

View File

@@ -52,10 +52,10 @@ bool TTFFont::loadFromMemory( Uint8* TTFData, const unsigned int& TTFDataSize, c
if ( OutlineSize && OutlineFreetype == OutlineMethod ) {
mFontOutline = hkFontManager::instance()->OpenFromMemory( reinterpret_cast<Uint8*>(&TTFData[0]), TTFDataSize, rSize, 0, NumCharsToGen );
mFontOutline->Outline( OutlineSize );
mFontOutline->Outline( OutlineSize * PixelDensity::getPixelDensity() );
}
return iLoad( rSize, Style, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator );
return iLoad( rSize, Style, NumCharsToGen, FontColor, OutlineSize * PixelDensity::getPixelDensity(), OutlineColor, AddPixelSeparator );
}
bool TTFFont::load( const std::string& Filepath, const unsigned int& Size, EE_TTF_FONT_STYLE Style, const Uint16& NumCharsToGen, const RGB& FontColor, const Uint8& OutlineSize, const RGB& OutlineColor, const bool& AddPixelSeparator ) {
@@ -70,10 +70,10 @@ bool TTFFont::load( const std::string& Filepath, const unsigned int& Size, EE_TT
if ( OutlineSize && OutlineFreetype == OutlineMethod ) {
mFontOutline = hkFontManager::instance()->OpenFromFile( Filepath.c_str(), rSize, 0, NumCharsToGen );
mFontOutline->Outline( OutlineSize );
mFontOutline->Outline( OutlineSize * PixelDensity::getPixelDensity() );
}
return iLoad( rSize, Style, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator );
return iLoad( rSize, Style, NumCharsToGen, FontColor, OutlineSize * PixelDensity::getPixelDensity(), OutlineColor, AddPixelSeparator );
} else if ( PackManager::instance()->isFallbackToPacksActive() ) {
Pack * tPack = PackManager::instance()->exists( mFilepath );

View File

@@ -329,11 +329,19 @@ void Window::display( bool clear ) {
void Window::clipEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ) {
GlobalBatchRenderer::instance()->draw();
GLi->scissor( x, getHeight() - ( y + Height ), Width, Height );
Rectf r( x, y, x + Width, y + Height );
if ( !mScissorsClipped.empty() ) {
Rectf r2 = mScissorsClipped.back();
r.shrink( r2 );
}
GLi->scissor( r.Left, getHeight() - r.Bottom, r.getWidth(), r.getHeight() );
GLi->enable( GL_SCISSOR_TEST );
if ( mPushScissorClip ) {
mScissorsClipped.push_back( Rectf( x, y, Width, Height ) );
mScissorsClipped.push_back( r );
}
}
@@ -349,7 +357,7 @@ void Window::clipDisable() {
} else {
Rectf R( mScissorsClipped.back() );
mPushScissorClip = false;
clipEnable( R.Left, R.Top, R.Right, R.Bottom );
clipEnable( R.Left, R.Top, R.getWidth(), R.getHeight() );
mPushScissorClip = true;
}
}

View File

@@ -179,6 +179,7 @@ void EETest::loadFonts() {
mFontLoader.add( eeNew( TextureFontLoader, ( "ProggySquareSZ", eeNew( TextureLoader, ( MyPath + "fonts/ProggySquareSZ.png" ) ), MyPath + "fonts/ProggySquareSZ.dat" ) ) );
mFontLoader.add( eeNew( TTFFontLoader, ( "arial", MyPath + "fonts/arial.ttf", 12, TTF_STYLE_NORMAL, 256, RGB(255,255,255) ) ) );
mFontLoader.add( eeNew( TTFFontLoader, ( "arialb", MyPath + "fonts/arial.ttf", 12, TTF_STYLE_NORMAL, 256, RGB(255,255,255), 1, RGB(0,0,0), true ) ) );
mFontLoader.add( eeNew( TTFFontLoader, ( "DejaVuSansMono", MyPath + "fonts/DejaVuSansMono.ttf", 12, TTF_STYLE_NORMAL, 256, RGB(255,255,255), 1 ) ) );
mFontLoader.load( cb::Make1( this, &EETest::onFontLoaded ) );
}
@@ -188,13 +189,14 @@ void EETest::onFontLoaded( ResourceLoader * ObjLoaded ) {
FF2 = FontManager::instance()->getByName( "ProggySquareSZ" );
TTF = FontManager::instance()->getByName( "arial" );
TTFB = FontManager::instance()->getByName( "arialb" );
DBSM = FontManager::instance()->getByName( "DejaVuSansMono" );
eePRINTL( "Fonts loading time: %4.3f ms.", mFTE.getElapsed().asMilliseconds() );
eeASSERT( TTF != NULL );
eeASSERT( TTFB != NULL );
Con.create( FF, true );
Con.create( DBSM, true );
Con.ignoreCharOnPrompt( 186 ); // 'º'
mBuda = String::fromUtf8( "El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde." );
@@ -441,6 +443,7 @@ void EETest::createUI() {
TextEdit->setText( mBuda );
UIGenericGrid * genGrid = UIGenericGrid::New();
genGrid->setSmoothScroll( true );
genGrid->setParent( C )->setPosition( 325, 245 )->setSize( 200, 130 );
genGrid->setCollumnsCount( 3 )->setRowHeight( 24 );
@@ -575,6 +578,7 @@ void EETest::createNewUI() {
spinBox->setPosition( 350, 210 )->setSize( 200, 0 );
UIGenericGrid * genGrid = UIGenericGrid::New();
genGrid->setSmoothScroll( true );
genGrid->setPosition( 350, 250 )->setSize( 200, 130 );
genGrid->setCollumnsCount( 3 )->setRowHeight( 24 );
genGrid->setCollumnWidth( 0, 50 );
@@ -1293,11 +1297,11 @@ void EETest::render() {
);
#else
mInfo = String::strFormated( "EE - FPS: %d Elapsed Time: %4.2f\nMouse X: %d Mouse Y: %d\nTexture Memory Usage: %s",
mWindow->FPS(),
et.AsMilliseconds(),
mWindow->getFPS(),
et.asMilliseconds(),
(Int32)Mouse.x,
(Int32)Mouse.y,
FileSystem::sizeToString( TF->MemorySize() ).c_str()
FileSystem::sizeToString( TF->getTextureMemorySize() ).c_str()
);
#endif

View File

@@ -66,6 +66,7 @@ class EETest : private Thread {
Font * FF2;
Font * TTF;
Font * TTFB;
Font * DBSM;
Primitives PR;
bool iL1, iL2;