Replaced eeTexCoord to Vector2f in BatchRenderer class.

Added BatchRenderer::batchPointList.

--HG--
branch : dev
This commit is contained in:
Martín Lucas Golini
2018-12-29 14:09:42 -03:00
parent b3e681a0c1
commit f2c45e3f39
2 changed files with 32 additions and 24 deletions

View File

@@ -14,14 +14,9 @@ using namespace EE::System;
namespace EE { namespace Graphics {
struct eeTexCoord {
Float u;
Float v;
};
struct eeVertex {
Vector2f pos;
eeTexCoord tex;
Vector2f tex;
Color color;
};
@@ -123,9 +118,12 @@ class EE_API BatchRenderer {
/** 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 ) */
/** Adds to the batch a point */
void batchPoint( const Float& x, const Float& y, const PrimitiveType& primitiveType = PRIMITIVE_POINTS );
/** Adds to the batch a point list */
void batchPointList( const std::vector<eeVertex>& points, const PrimitiveType& primitiveType = PRIMITIVE_POINTS );
/** This will set as the default batch rendering to PRIMITIVE_LINES. And will reset the line color to ColorA(255,255,255,255). */
void linesBegin();
@@ -251,7 +249,7 @@ class EE_API BatchRenderer {
const Texture * mTexture;
BlendMode mBlend;
eeTexCoord mTexCoord[4];
Vector2f mTexCoord[4];
Color mVerColor[4];
PrimitiveType mCurrentMode;

View File

@@ -155,7 +155,7 @@ void BatchRenderer::flush() {
}
GLi->vertexPointer ( 2, GL_FP , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) , alloc );
GLi->colorPointer ( 4, GL_UNSIGNED_BYTE , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) + sizeof(Vector2f) + sizeof(eeTexCoord) , alloc );
GLi->colorPointer ( 4, GL_UNSIGNED_BYTE , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) + sizeof(Vector2f) + sizeof(Vector2f) , alloc );
if ( !GLi->quadsSupported() ) {
if ( PRIMITIVE_QUADS == mCurrentMode ) {
@@ -457,18 +457,18 @@ void BatchRenderer::quadsSetColorFree( const Color& Color0, const Color& Color1,
}
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;
mTexCoord[0].x = tl_u; mTexCoord[1].x = tl_u;
mTexCoord[0].y = tl_v; mTexCoord[1].y = br_v;
mTexCoord[2].u = br_u; mTexCoord[3].u = br_u;
mTexCoord[2].v = br_v; mTexCoord[3].v = tl_v;
mTexCoord[2].x = br_u; mTexCoord[3].x = br_u;
mTexCoord[2].y = br_v; mTexCoord[3].y = tl_v;
}
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;
mTexCoord[3].u = x3; mTexCoord[3].v = y3;
mTexCoord[0].x = x0; mTexCoord[0].y = y0;
mTexCoord[1].x = x1; mTexCoord[1].y = y1;
mTexCoord[2].x = x2; mTexCoord[2].y = y2;
mTexCoord[3].x = x3; mTexCoord[3].y = y3;
}
void BatchRenderer::rotate( const Vector2f& center, Vector2f* point, const Float& angle ) {
@@ -491,7 +491,7 @@ void BatchRenderer::pointSetColor( const Color& color ) {
}
void BatchRenderer::pointSetTexCoord( const Float& x, const Float& y ) {
mTexCoord[0].u = x; mTexCoord[0].v = y;
mTexCoord[0].x = x; mTexCoord[0].y = y;
}
void BatchRenderer::batchPoint( const Float& x, const Float& y , const PrimitiveType & primitiveType ) {
@@ -509,6 +509,16 @@ void BatchRenderer::batchPoint( const Float& x, const Float& y , const Primitive
addVertexs(1);
}
void BatchRenderer::batchPointList( const std::vector<eeVertex> & points, const PrimitiveType & primitiveType ) {
setDrawMode( primitiveType, mForceBlendMode );
unsigned int curNumVertex = mNumVertex;
addVertexs(points.size());
memcpy( (void*)&mVertex[ curNumVertex ], (void*)&points[0], sizeof(eeVertex) * points.size() );
}
void BatchRenderer::linesBegin() {
setDrawMode( PRIMITIVE_LINES, true );
quadsSetTexCoord( 0, 0, 1, 1 );
@@ -675,9 +685,9 @@ void BatchRenderer::triangleFanSetColorFree( const Color& Color0, const Color& C
}
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;
mTexCoord[0].x = x0; mTexCoord[0].y = y0;
mTexCoord[1].x = x1; mTexCoord[1].y = y1;
mTexCoord[2].x = x2; mTexCoord[2].y = y2;
}
void BatchRenderer::batchTriangleFan( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ) {
@@ -738,9 +748,9 @@ void BatchRenderer::trianglesSetColorFree( const Color& Color0, const Color& Col
}
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;
mTexCoord[0].x = x0; mTexCoord[0].y = y0;
mTexCoord[1].x = x1; mTexCoord[1].y = y1;
mTexCoord[2].x = x2; mTexCoord[2].y = y2;
}
void BatchRenderer::batchTriangle( const Float& x0, const Float& y0, const Float& x1, const Float& y1, const Float& x2, const Float& y2 ) {