From af3af9bef07f9bfe8d8a9e84df9714f71ab1ff42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 11 Jan 2018 22:56:58 -0300 Subject: [PATCH] Renamed all the functions with "*Subset*" to "*TexCoord". --HG-- branch : dev-2.1 --- include/eepp/graphics/batchrenderer.hpp | 13 +++++---- src/eepp/graphics/batchrenderer.cpp | 30 ++++++++++++--------- src/eepp/graphics/texture.cpp | 36 ++++++++++++------------- src/test/eetest.cpp | 2 +- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/include/eepp/graphics/batchrenderer.hpp b/include/eepp/graphics/batchrenderer.hpp index a28f3e99d..4151ffe2d 100755 --- a/include/eepp/graphics/batchrenderer.hpp +++ b/include/eepp/graphics/batchrenderer.hpp @@ -96,14 +96,14 @@ class EE_API BatchRenderer { /** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to PRIMITIVE_QUADS, so if you were using another one will Draw all the batched vertexs first ) */ void batchQuadFreeEx( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2, const Float& x3, const Float& y3, const Float& Angle = 0.0f, const Float& Scale = 1.0f ); - /** This will set as the default batch rendering to GL_QUADS. WIll reset the texture subset rendering to the whole texture. Will reset the default color rendering to ColorA(255,255,255,255). */ + /** This will set as the default batch rendering to GL_QUADS. WIll reset the texture TexCoord rendering to the whole texture. Will reset the default color rendering to ColorA(255,255,255,255). */ void quadsBegin(); /** Set the texture sector to be rendered */ - void quadsSetSubset( const Float& tl_u, const Float& tl_v, const Float& br_u, const Float& br_v ); + void quadsSetTexCoord( const Float& tl_u, const Float& tl_v, const Float& br_u, const Float& br_v ); /** Set the texture sector to be rendered but freely seted */ - void quadsSetSubsetFree( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2, const Float& x3, const Float& y3 ); + void quadsSetTexCoordFree( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2, const Float& x3, const Float& y3 ); /** Set the quad color */ void quadsSetColor( const Color& Color ); @@ -117,6 +117,9 @@ class EE_API BatchRenderer { /** Set the point color */ void pointSetColor( const Color& Color ); + /** Set the texture sector to be rendered */ + void pointSetTexCoord(const Float & x, const Float & y); + /** Add to the batch a point ( this will change your batch rendering method to PRIMITIVE_POINTS, so if you were using another one will Draw all the batched vertexs first ) */ void batchPoint( const Float& x, const Float& y ); @@ -184,7 +187,7 @@ class EE_API BatchRenderer { void triangleFanSetColorFree( const Color& Color0, const Color& Color1, const Color& Color2 ); /** Set the texture sector to be rendered but freely seted */ - void triangleFanSetSubset( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ); + void triangleFanSetTexCoord( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ); /** Add to the batch a triangle fan ( this will change your batch rendering method to PRIMITIVE_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first ) */ void batchTriangleFan( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ); @@ -202,7 +205,7 @@ class EE_API BatchRenderer { void trianglesSetColorFree( const Color& Color0, const Color& Color1, const Color& Color2 ); /** Set the texture sector to be rendered but freely seted */ - void trianglesSetSubset( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ); + void trianglesSetTexCoord( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ); /** Add to the batch a triangle ( this will change your batch rendering method to PRIMITIVE_TRIANGLES, so if you were using another one will Draw all the batched vertexs first ) */ void batchTriangle( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ); diff --git a/src/eepp/graphics/batchrenderer.cpp b/src/eepp/graphics/batchrenderer.cpp index 40fce7738..b87ecb856 100755 --- a/src/eepp/graphics/batchrenderer.cpp +++ b/src/eepp/graphics/batchrenderer.cpp @@ -425,7 +425,7 @@ void BatchRenderer::batchQuadFreeEx( const Float& x0, const Float& y0, const Flo void BatchRenderer::quadsBegin() { setDrawMode( PRIMITIVE_QUADS, true ); - quadsSetSubset( 0, 0, 1, 1 ); + quadsSetTexCoord( 0, 0, 1, 1 ); quadsSetColor( Color::White ); } @@ -440,7 +440,7 @@ void BatchRenderer::quadsSetColorFree( const Color& Color0, const Color& Color1, mVerColor[3] = Color3; } -void BatchRenderer::quadsSetSubset( const Float& tl_u, const Float& tl_v, const Float& br_u, const Float& br_v ) { +void BatchRenderer::quadsSetTexCoord( const Float& tl_u, const Float& tl_v, const Float& br_u, const Float& br_v ) { mTexCoord[0].u = tl_u; mTexCoord[1].u = tl_u; mTexCoord[0].v = tl_v; mTexCoord[1].v = br_v; @@ -448,7 +448,7 @@ void BatchRenderer::quadsSetSubset( const Float& tl_u, const Float& tl_v, const mTexCoord[2].v = br_v; mTexCoord[3].v = tl_v; } -void BatchRenderer::quadsSetSubsetFree( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2, const Float& x3, const Float& y3 ) { +void BatchRenderer::quadsSetTexCoordFree( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2, const Float& x3, const Float& y3 ) { mTexCoord[0].u = x0; mTexCoord[0].v = y0; mTexCoord[1].u = x1; mTexCoord[1].v = y1; mTexCoord[2].u = x2; mTexCoord[2].v = y2; @@ -466,12 +466,16 @@ void BatchRenderer::rotate( const Vector2f& center, Vector2f* point, const Float void BatchRenderer::pointsBegin() { setDrawMode( PRIMITIVE_POINTS, true ); - quadsSetSubset( 0, 0, 1, 1 ); + quadsSetTexCoord( 0, 0, 1, 1 ); pointSetColor( Color::White ); } -void BatchRenderer::pointSetColor( const Color& Color ) { - quadsSetColor( Color ); +void BatchRenderer::pointSetColor( const Color& color ) { + mVerColor[0] = color; +} + +void BatchRenderer::pointSetTexCoord( const Float& x, const Float& y ) { + mTexCoord[0].u = x; mTexCoord[0].v = y; } void BatchRenderer::batchPoint( const Float& x, const Float& y ) { @@ -491,7 +495,7 @@ void BatchRenderer::batchPoint( const Float& x, const Float& y ) { void BatchRenderer::linesBegin() { setDrawMode( PRIMITIVE_LINES, true ); - quadsSetSubset( 0, 0, 1, 1 ); + quadsSetTexCoord( 0, 0, 1, 1 ); pointSetColor( Color::White ); } @@ -526,7 +530,7 @@ void BatchRenderer::batchLine( const Float& x0, const Float& y0, const Float& x1 void BatchRenderer::lineLoopBegin() { setDrawMode( PRIMITIVE_LINE_LOOP, true ); - quadsSetSubset( 0, 0, 1, 1 ); + quadsSetTexCoord( 0, 0, 1, 1 ); pointSetColor( Color::White ); } @@ -584,7 +588,7 @@ void BatchRenderer::batchLineLoop( const Vector2f& vector1 ) { void BatchRenderer::lineStripBegin() { setDrawMode( PRIMITIVE_LINE_STRIP, true ); - quadsSetSubset( 0, 0, 1, 1 ); + quadsSetTexCoord( 0, 0, 1, 1 ); pointSetColor( Color::White ); } @@ -642,7 +646,7 @@ void BatchRenderer::batchLineStrip( const Vector2f& vector1 ) { void BatchRenderer::triangleFanBegin() { setDrawMode( PRIMITIVE_TRIANGLE_FAN, true ); - triangleFanSetSubset( 0, 0, 0, 1, 1, 1 ); + triangleFanSetTexCoord( 0, 0, 0, 1, 1, 1 ); triangleFanSetColor( Color::White ); } @@ -654,7 +658,7 @@ void BatchRenderer::triangleFanSetColorFree( const Color& Color0, const Color& C quadsSetColorFree( Color0, Color1, Color2, Color0 ); } -void BatchRenderer::triangleFanSetSubset( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ) { +void BatchRenderer::triangleFanSetTexCoord( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ) { mTexCoord[0].u = x0; mTexCoord[0].v = y0; mTexCoord[1].u = x1; mTexCoord[1].v = y1; mTexCoord[2].u = x2; mTexCoord[2].v = y2; @@ -705,7 +709,7 @@ void BatchRenderer::batchTriangleFan( const Float& x0, const Float& y0 ) { void BatchRenderer::trianglesBegin() { setDrawMode( PRIMITIVE_TRIANGLES, true ); - trianglesSetSubset( 0, 0, 0, 1, 1, 1 ); + trianglesSetTexCoord( 0, 0, 0, 1, 1, 1 ); trianglesSetColor( Color::White ); } @@ -717,7 +721,7 @@ void BatchRenderer::trianglesSetColorFree( const Color& Color0, const Color& Col quadsSetColorFree( Color0, Color1, Color2, Color0 ); } -void BatchRenderer::trianglesSetSubset( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ) { +void BatchRenderer::trianglesSetTexCoord( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ) { mTexCoord[0].u = x0; mTexCoord[0].v = y0; mTexCoord[1].u = x1; mTexCoord[1].v = y1; mTexCoord[2].u = x2; mTexCoord[2].v = y2; diff --git a/src/eepp/graphics/texture.cpp b/src/eepp/graphics/texture.cpp index e2fd48876..f8b053523 100755 --- a/src/eepp/graphics/texture.cpp +++ b/src/eepp/graphics/texture.cpp @@ -539,7 +539,7 @@ void Texture::drawFast( const Float& x, const Float& y, const Float& Angle, cons if ( getClampMode() == CLAMP_REPEAT ) { Float iw = (Float)getImageWidth(); Float ih = (Float)getImageHeight(); - sBR->quadsSetSubsetFree( 0, 0, 0, height / ih, width / iw, height / ih, width / iw, 0 ); + sBR->quadsSetTexCoordFree( 0, 0, 0, height / ih, width / iw, height / ih, width / iw, 0 ); } sBR->batchQuadEx( x, y, w, h, Angle, Scale ); @@ -577,7 +577,7 @@ void Texture::drawEx( Float x, Float y, Float width, Float height, const Float & if ( getClampMode() == CLAMP_REPEAT ) { if ( Effect == RENDER_NORMAL ) { if ( renderSector ) { - sBR->quadsSetSubsetFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h ); + sBR->quadsSetTexCoordFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h ); Float sw = (Float)( Sector.Right - Sector.Left ); Float sh = (Float)( Sector.Bottom - Sector.Top ); @@ -618,7 +618,7 @@ void Texture::drawEx( Float x, Float y, Float width, Float height, const Float & Float swn = ( Sector.Right - Sector.Left ) * ( tx - (Float)ttx ); Float tor = Sector.Left + swn ; - sBR->quadsSetSubsetFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, tor / w, Sector.Bottom / h, tor / w, Sector.Top / h ); + sBR->quadsSetTexCoordFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, tor / w, Sector.Bottom / h, tor / w, Sector.Top / h ); for ( Int32 tmpY = 0; tmpY < tty; tmpY++ ) { sBR->batchQuad( x + ttx * sw, y + tmpY * sh, swn, sh ); @@ -629,7 +629,7 @@ void Texture::drawEx( Float x, Float y, Float width, Float height, const Float & Float shn = ( Sector.Bottom - Sector.Top ) * ( ty - (Float)tty ); Float tob = Sector.Top + shn; - sBR->quadsSetSubsetFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, tob / h, Sector.Right / w, tob / h, Sector.Right / w, Sector.Top / h ); + sBR->quadsSetTexCoordFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, tob / h, Sector.Right / w, tob / h, Sector.Right / w, Sector.Top / h ); for ( Int32 tmpX = 0; tmpX < ttx; tmpX++ ) { sBR->batchQuad( x + tmpX * sw, y + tty * sh, sw, shn ); @@ -643,41 +643,41 @@ void Texture::drawEx( Float x, Float y, Float width, Float height, const Float & return; } else { - sBR->quadsSetSubsetFree( 0, 0, 0, height / h, width / w, height / h, width / w, 0 ); + sBR->quadsSetTexCoordFree( 0, 0, 0, height / h, width / w, height / h, width / w, 0 ); } } else if ( Effect == RENDER_MIRROR ) { - sBR->quadsSetSubsetFree( width / w, 0, width / w, height / h, 0, height / h, 0, 0 ); + sBR->quadsSetTexCoordFree( width / w, 0, width / w, height / h, 0, height / h, 0, 0 ); } else if ( Effect == RENDER_FLIPPED ) { - sBR->quadsSetSubsetFree( 0, height / h, 0, 0, width / w, 0, width / w, height / h ); + sBR->quadsSetTexCoordFree( 0, height / h, 0, 0, width / w, 0, width / w, height / h ); } else { - sBR->quadsSetSubsetFree( width / w, height / h, width / w, 0, 0, 0, 0, height / h ); + sBR->quadsSetTexCoordFree( width / w, height / h, width / w, 0, 0, 0, 0, height / h ); } } else { if ( Effect == RENDER_NORMAL ) { if ( renderSector ) - sBR->quadsSetSubsetFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h ); + sBR->quadsSetTexCoordFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h ); } else if ( Effect == RENDER_MIRROR ) { if ( renderSector ) - sBR->quadsSetSubsetFree( Sector.Right / w, Sector.Top / h, Sector.Right / w, Sector.Bottom / h, Sector.Left / w, Sector.Bottom / h, Sector.Left / w, Sector.Top / h ); + sBR->quadsSetTexCoordFree( Sector.Right / w, Sector.Top / h, Sector.Right / w, Sector.Bottom / h, Sector.Left / w, Sector.Bottom / h, Sector.Left / w, Sector.Top / h ); else - sBR->quadsSetSubsetFree( 1, 0, 1, 1, 0, 1, 0, 0 ); + sBR->quadsSetTexCoordFree( 1, 0, 1, 1, 0, 1, 0, 0 ); } else if ( Effect == RENDER_FLIPPED ) { if ( renderSector ) - sBR->quadsSetSubsetFree( Sector.Left / w, Sector.Bottom / h, Sector.Left / w, Sector.Top / h, Sector.Right / w, Sector.Top / h, Sector.Right / w, Sector.Bottom / h ); + sBR->quadsSetTexCoordFree( Sector.Left / w, Sector.Bottom / h, Sector.Left / w, Sector.Top / h, Sector.Right / w, Sector.Top / h, Sector.Right / w, Sector.Bottom / h ); else - sBR->quadsSetSubsetFree( 0, 1, 0, 0, 1, 0, 1, 1 ); + sBR->quadsSetTexCoordFree( 0, 1, 0, 0, 1, 0, 1, 1 ); } else if ( Effect == RENDER_FLIPPED_MIRRORED ) { if ( renderSector ) - sBR->quadsSetSubsetFree( Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h, Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h ); + sBR->quadsSetTexCoordFree( Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h, Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h ); else - sBR->quadsSetSubsetFree( 1, 1, 1, 0, 0, 0, 0, 1 ); + sBR->quadsSetTexCoordFree( 1, 1, 1, 0, 0, 0, 0, 1 ); } } sBR->batchQuadEx( x, y, width, height, Angle, Scale, Center ); } else { if ( renderSector ) - sBR->quadsSetSubsetFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h ); + sBR->quadsSetTexCoordFree( Sector.Left / w, Sector.Top / h, Sector.Left / w, Sector.Bottom / h, Sector.Right / w, Sector.Bottom / h, Sector.Right / w, Sector.Top / h ); Rectf TmpR( x, y, x + width, y + height ); Quad2f Q = Quad2f( Vector2f( TmpR.Left, TmpR.Top ), Vector2f( TmpR.Left, TmpR.Bottom ), Vector2f( TmpR.Right, TmpR.Bottom ), Vector2f( TmpR.Right, TmpR.Top ) ); @@ -745,9 +745,9 @@ void Texture::drawQuadEx( Quad2f Q, const Vector2f& Offset, const Float &Angle, } if ( getClampMode() == CLAMP_REPEAT ) { - sBR->quadsSetSubsetFree( 0, 0, 0, ( Q.V[0].y - Q.V[0].y ) / h, ( Q.V[0].x - Q.V[0].x ) / w, ( Q.V[0].y - Q.V[0].y ) / h, ( Q.V[0].x - Q.V[0].x ) / w, 0 ); + sBR->quadsSetTexCoordFree( 0, 0, 0, ( Q.V[0].y - Q.V[0].y ) / h, ( Q.V[0].x - Q.V[0].x ) / w, ( Q.V[0].y - Q.V[0].y ) / h, ( Q.V[0].x - Q.V[0].x ) / w, 0 ); } else if ( renderSector ) { - sBR->quadsSetSubsetFree( texSector.Left / w, texSector.Top / h, texSector.Left / w, texSector.Bottom / h, texSector.Right / w, texSector.Bottom / h, texSector.Right / w, texSector.Top / h ); + sBR->quadsSetTexCoordFree( texSector.Left / w, texSector.Top / h, texSector.Left / w, texSector.Bottom / h, texSector.Right / w, texSector.Bottom / h, texSector.Right / w, texSector.Top / h ); } Q.move( Offset ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 8860dfd2f..2e527abd2 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -1347,7 +1347,7 @@ void EETest::screen2() { Batch.setTexture( TNP[2] ); Batch.quadsBegin(); Batch.quadsSetColor( Color(150,150,150,100) ); - Batch.quadsSetSubset( 0.0f, 0.0f, 0.5f, 0.5f ); + Batch.quadsSetTexCoord( 0.0f, 0.0f, 0.5f, 0.5f ); Batch.setBatchRotation( ang ); Batch.setBatchScale( scale );