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( mFillMode ) { case 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 DRAW_FILL: { 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 DrawRect(float x, float y, float w, float h, color c, GLuint texture) { float scale = gameState.scale; x = x * scale / gameState.screenWidth * 2.0f - 1.0f; y = y * scale / gameState.screenHeight * 2.0f - 1.0f; w = w * scale / gameState.screenWidth * 2.0f; h = h * scale / gameState.screenHeight * 2.0f; float vVertices[] = { x, y, 0.0f, x, y + h, 0.0f, x + w, y, 0.0f, x + w, y + h, 0.0f, x, y + h, 0.0f, x + w, y, 0.0f }; float vColors[] = { c.r, c.g, c.b, c.a, c.r, c.g, c.b, c.a, c.r, c.g, c.b, c.a, c.r, c.g, c.b, c.a, c.r, c.g, c.b, c.a, c.r, c.g, c.b, c.a }; float vTexCoords[] = { 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f }; DrawBatch(vVertices, vColors, vTexCoords, 6, texture); }
void cPrimitives::DrawPolygon( const eePolygon2f& p ) { sBR->SetTexture( NULL ); sBR->SetBlendMode( mBlendMode ); switch( mFillMode ) { case DRAW_LINE: { sBR->SetLineWidth( mLineWidth ); sBR->LineLoopBegin(); sBR->LineLoopSetColor( mColor ); for ( Uint32 i = 0; i < p.Size(); i += 2 ) sBR->BatchLineLoop( p.X() + p[i].x, p.Y() + p[i].y, p.X() + p[i+1].x, p.Y() + p[i+1].y ); break; } case DRAW_FILL: { sBR->PolygonSetColor( mColor ); sBR->BatchPolygon( p ); break; } } 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 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 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 OpenGL::UpdateScissorState(bool enabled) { DrawBatch(); _enableScissoring = enabled; _rasterizerDesc.ScissorEnable = _enableScissoring; ID3D11RasterizerState* rasterizerState; _device->CreateRasterizerState(&_rasterizerDesc, &rasterizerState); _context->RSSetState(rasterizerState); }
void CRenderer::End() { DrawBatch(); IwGxFlush(); IwGxSwapBuffers(); ClearMtlCache(); }
void DX11SpriteBatch::EndBatch(ID3D11DeviceContext* dc) { assert(mInitialized); u32 viewportCount = 1; D3D11_VIEWPORT vp; dc->RSGetViewports(&viewportCount, &vp); mScreenWidth = vp.Width; mScreenHeight = vp.Height; u32 stride = sizeof(MeshData::SpriteVertex); u32 offset = 0; dc->IASetInputLayout(mInputLayout); dc->IASetIndexBuffer(mIndexBuffer, DXGI_FORMAT_R16_UINT, 0); dc->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &offset); dc->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); DX11Effects::SpriteFX->SetSpriteMap(mBatchTexSRV); ID3DX11EffectPass* pass = DX11Effects::SpriteFX->SpriteTech->GetPassByIndex(0); pass->Apply(0, dc); u32 spritesToDraw = (u32)mSpriteList.size(); u32 startIndex = 0; while( spritesToDraw > 0 ) { if( spritesToDraw <= BatchSize ) { DrawBatch(dc, startIndex, spritesToDraw); spritesToDraw = 0; } else { DrawBatch(dc, startIndex, BatchSize); startIndex += BatchSize; spritesToDraw -= BatchSize; } } RJE_SAFE_RELEASE(mBatchTexSRV); }
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::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 DxSprite::EndBatch( ) { assert( Initialized ); GetDX11Context()->VSSetShader(VS, 0, 0); GetDX11Context()->PSSetShader(PS, 0, 0); UINT stride = sizeof(SpriteVertex); UINT offset = 0; GetDX11Context()->IASetInputLayout(InputLayout ); GetDX11Context()->IASetIndexBuffer(IB, DXGI_FORMAT_R16_UINT, 0); GetDX11Context()->IASetVertexBuffers(0, 1, &VB, &stride, &offset); GetDX11Context()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); GetDX11Context()->PSSetShaderResources(0, 1, &BatchTexSRV); UINT spritesToDraw = SpriteList.size(); UINT startIndex = 0; while(spritesToDraw > 0) { if(spritesToDraw <= 512) { DrawBatch(startIndex, spritesToDraw); spritesToDraw = 0; } else { DrawBatch(startIndex, 512); startIndex += 512; spritesToDraw -= 512; } } BatchTexSRV->Release(); }
void CRenderer::Draw( IwGxPrimType type, const CIwSVec2 * vertex, const CIwSVec2 * uv, const uint16* indexStream, const CIwColour * colour, int32 vertexCount, CIwMaterial * mat ) { if ( mat == NULL ) { mat = mDefaultMaterial; } if (( GetVBSize() + vertexCount >= RENDER_MAX_BUFF_SIZE || (mat != mCurrMtl) || (GetBufferType() != type) || (uv == NULL && GetUVBSize() != 0) || (indexStream == NULL && GetIBSize() != 0) || (colour == NULL && GetCBSize() != 0) )) { DrawBatch(); } if ( (uint32)vertexCount >= RENDER_MAX_BUFF_SIZE ) { CIwSVec2 * _v = IW_GX_ALLOC(CIwSVec2, vertexCount); CIwSVec2 * _uv = IW_GX_ALLOC(CIwSVec2, vertexCount); CIwColour * _c = IW_GX_ALLOC(CIwColour, vertexCount); uint16 * _is = NULL; if (indexStream != NULL ) { _is = IW_GX_ALLOC(uint16, vertexCount); memcpy(_is, indexStream, vertexCount*sizeof(uint16)); } memcpy(&_v[0], &vertex[0], vertexCount*sizeof(CIwSVec2)); memcpy(&_uv[0], &uv[0], vertexCount*sizeof(CIwSVec2)); memcpy(&_c[0], &colour[0], vertexCount*sizeof(CIwColour)); CameraTransform( &_v[0], vertexCount); DrawDirect(type, _v, _uv, _is, _c, vertexCount, mat); } else { mCurrMtl = mat; SetBufferType(type); AddBuffer(type, vertex, uv, indexStream, colour, vertexCount); CameraTransform( &mVB[GetVBSize() - vertexCount], vertexCount); } }
void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeVector2f& Scale ) { sBR->SetTexture( NULL ); sBR->SetBlendMode( mBlendMode ); switch( mFillMode ) { case 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 DRAW_LINE: { sBR->SetLineWidth( mLineWidth ); sBR->LineLoopBegin(); sBR->LineLoopSetColorFree( TopLeft, BottomLeft ); if ( Scale != 1.0f || Angle != 0.0f ) { eeQuad2f Q( R ); eeSizef size = const_cast<eeRectf*>(&R)->Size(); Q.Scale( Scale ); Q.Rotate( Angle, eeVector2f( R.Left + size.Width() * 0.5f, R.Top + size.Height() * 0.5f ) ); 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::DrawCircle( const eeVector2f& p, const eeFloat& radius, Uint32 points ) { if ( 0 == points ) { // Optimized circle rendering static const GLfloat circleVAR[] = { 0.0000f, 1.0000f, 0.2588f, 0.9659f, 0.5000f, 0.8660f, 0.7071f, 0.7071f, 0.8660f, 0.5000f, 0.9659f, 0.2588f, 1.0000f, 0.0000f, 0.9659f, -0.2588f, 0.8660f, -0.5000f, 0.7071f, -0.7071f, 0.5000f, -0.8660f, 0.2588f, -0.9659f, 0.0000f, -1.0000f, -0.2588f, -0.9659f, -0.5000f, -0.8660f, -0.7071f, -0.7071f, -0.8660f, -0.5000f, -0.9659f, -0.2588f, -1.0000f, -0.0000f, -0.9659f, 0.2588f, -0.8660f, 0.5000f, -0.7071f, 0.7071f, -0.5000f, 0.8660f, -0.2588f, 0.9659f, 0.0000f, 1.0000f, 0.0f, 0.0f, // For an extra line to see the rotation. }; static const int circleVAR_count = sizeof(circleVAR)/sizeof(GLfloat)/2; GLi->Disable( GL_TEXTURE_2D ); GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); GLi->PushMatrix(); GLi->Translatef( p.x, p.y, 0.0f ); GLi->Scalef( radius, radius, 1.0f); GLi->VertexPointer( 2, GL_FLOAT, 0, circleVAR, circleVAR_count * sizeof(float) * 2 ); std::vector<eeColorA> colors( circleVAR_count - 1 ,mColor ); GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, &colors[0], circleVAR_count * 4 ); switch( mFillMode ) { case DRAW_LINE: { GLi->DrawArrays( GL_LINE_LOOP, 0, circleVAR_count - 1 ); break; } case DRAW_FILL: { GLi->DrawArrays( GL_TRIANGLE_FAN, 0, circleVAR_count - 1 ); break; } } GLi->PopMatrix(); GLi->Enable( GL_TEXTURE_2D ); GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY ); return; } if(points < 6) points = 6; eeFloat angle_shift = 360 / static_cast<eeFloat>(points); sBR->SetTexture( NULL ); switch( mFillMode ) { case 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 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 OpenGL::Draw(const std::vector<OpenGLVertex>& vertices) { if (_loadingComplete == false) { return; } if (_vertexBuffer == NULL) { D3D11_BUFFER_DESC bd; ZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_DYNAMIC; bd.ByteWidth = _maxVertices * sizeof(OpenGLVertex); bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; bd.CPUAccessFlags = D3D11_CPU_ACCESS_FLAG::D3D11_CPU_ACCESS_WRITE; bd.MiscFlags = 0; bd.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA initData; ZeroMemory(&initData, sizeof(initData)); auto hr = _device->CreateBuffer(&bd, NULL, &_vertexBuffer); } if (_firstDrawInFrame) { _context->IASetInputLayout(_inputLayout); _context->VSSetShader(_vertexShader, nullptr, 0); _context->VSSetConstantBuffers(0, 1, &_constantBuffer); _firstDrawInFrame = false; _context->UpdateSubresource(_constantBuffer, 0, NULL, &_constantBufferData, 0, 0); UINT stride = sizeof(OpenGLVertex); UINT offset = 0; _context->IASetVertexBuffers(0, 1, &_vertexBuffer, &stride, &offset); _context->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); } // Check if a texture state has changed if (_currentTextureId != _batchCurrentTextureId || _enableTexture2D != _batchEnableTexture2D) { DrawBatch(); _batchCurrentTextureId = _currentTextureId; _batchEnableTexture2D = _enableTexture2D; } auto matrix4x4 = _matrices.top(); auto viewMatrix = DirectX::XMLoadFloat4x4(matrix4x4); int count = vertices.size(); for (int i = 0; i < count; i++) { OpenGLVertex vertex = vertices[i]; DirectX::XMVECTOR v = DirectX::XMVectorSet(vertex.x, vertex.y, vertex.z, 1.f); DirectX::XMVECTOR tv = DirectX::XMVector4Transform(v, viewMatrix); vertex.x = DirectX::XMVectorGetX( tv ); vertex.y = DirectX::XMVectorGetY( tv ); vertex.z = DirectX::XMVectorGetZ( tv ); _batchVertices[_currentBatchVertex++] = vertex; } }
void cPrimitives::ForceDraw( const bool& force ) { mForceDraw = force; if ( force ) DrawBatch(); }
//////////////////////////////////////////////////////////////// // // CMaterialLine3DBatcher::Flush // // Draw all pending lines // //////////////////////////////////////////////////////////////// void CMaterialLine3DBatcher::Flush(void) { if (m_LineList.empty()) return; // Get scene matrices D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); const D3DXMATRIX& matView = g_pDeviceState->TransformState.VIEW; const D3DXMATRIX& matProjection = g_pDeviceState->TransformState.PROJECTION; // Pre-calc camera position D3DXMATRIX matViewInv; D3DXMatrixInverse(&matViewInv, NULL, &matView); const CVector vecCameraPos(matViewInv._41, matViewInv._42, matViewInv._43); // Set transforms m_pDevice->SetTransform(D3DTS_WORLD, &matWorld); m_pDevice->SetTransform(D3DTS_VIEW, &matView); m_pDevice->SetTransform(D3DTS_PROJECTION, &matProjection); // Set render states if (g_pDeviceState->AdapterState.bRequiresClipping) m_pDevice->SetRenderState(D3DRS_CLIPPING, TRUE); m_pDevice->SetRenderState(D3DRS_ZENABLE, m_bPreGUI ? D3DZB_TRUE : D3DZB_FALSE); m_pDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); m_pDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); m_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); m_pDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); m_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); m_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); m_pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); m_pDevice->SetRenderState(D3DRS_ALPHAREF, 0x01); m_pDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); m_pDevice->SetRenderState(D3DRS_LIGHTING, FALSE); m_pDevice->SetRenderState(D3DRS_FOGENABLE, TRUE); m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); m_CurrentTextureAddress = (ETextureAddress)0; // // Sort by distance // const float fMaxDrawDistance = CCore::GetSingleton().GetMultiplayer()->GetFarClipDistance(); const float fSmallLineTolerance = 20; const float fMaxDrawDistanceIncTol = fMaxDrawDistance + fSmallLineTolerance; const float fMaxDrawDistanceSq = fMaxDrawDistance * fMaxDrawDistance; const float fMaxDrawDistanceIncTolSq = fMaxDrawDistanceIncTol * fMaxDrawDistanceIncTol; const float fSmallLineToleranceSq = fSmallLineTolerance * fSmallLineTolerance; const uint uiNumLines = m_LineList.size(); std::vector<uint> indexList; indexList.resize(uiNumLines); uint* pIndices = &indexList[0]; uint uiNumIndicies = 0; // Calculate distances for (uint i = 0; i < uiNumLines; i++) { SMaterialLine3DItem& item = m_LineList[i]; item.fDistSq = (item.vecAvgPosition - vecCameraPos).LengthSquared(); if (item.fDistSq > fMaxDrawDistanceIncTolSq) { // Check if line bounding sphere is visible float fRadiusSq = (item.vecTo - item.vecFrom).LengthSquared(); if (fRadiusSq < fSmallLineToleranceSq) continue; float fSphereDist = std::max(0.f, (item.vecAvgPosition - vecCameraPos).Length() - sqrt(fRadiusSq)); float fSphereDistSq = fSphereDist * fSphereDist; if (fSphereDistSq > fMaxDrawDistanceSq) continue; } // Add the index for this line to the draw list pIndices[uiNumIndicies++] = i; } if (uiNumIndicies > 0) { indexList.resize(uiNumIndicies); // Sort index list by distance ms_pLines = &m_LineList[0]; std::sort(indexList.begin(), indexList.end(), [](const uint a, const uint b) { return ms_pLines[a].fDistSq > ms_pLines[b].fDistSq; }); pIndices = &indexList[0]; // Draw index list, batching by material uint uiBatchFirstIndex = 0; for (uint i = 0; i < uiNumIndicies; i++) { const SMaterialLine3DItem& item = ms_pLines[pIndices[i]]; // Flush batch if this is the last index, or the next one uses a different material if ((i == uiNumIndicies - 1) || item.pMaterial != ms_pLines[pIndices[i + 1]].pMaterial) { uint* pBatchIndices = &pIndices[uiBatchFirstIndex]; uint uiNumBatchLines = i - uiBatchFirstIndex + 1; DrawBatch(vecCameraPos, pBatchIndices, uiNumBatchLines, item.pMaterial); uiBatchFirstIndex = i + 1; } } } // Clean up for (uint i = 0; i < uiNumLines; i++) m_LineList[i].pMaterial->Release(); ListClearAndReserve(m_LineList); if (g_pDeviceState->AdapterState.bRequiresClipping) m_pDevice->SetRenderState(D3DRS_CLIPPING, FALSE); }
void CRenderer::Flush() { DrawBatch(); }
void OpenGL::EndFrame() { // Ensure that everything has been drawn before ending the frame. DrawBatch(); }
void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeVector2f& Scale, const eeUint& Corners ) { sBR->SetTexture( NULL ); sBR->SetBlendMode( mBlendMode ); eeUint i; eeSizef size = const_cast<eeRectf*>( &R )->Size(); eeFloat xscalediff = size.Width() * Scale.x - size.Width(); eeFloat yscalediff = size.Height() * Scale.y - size.Height(); eeVector2f Center( R.Left + size.Width() * 0.5f + xscalediff, R.Top + size.Height() * 0.5f + yscalediff ); eePolygon2f Poly = eePolygon2f::CreateRoundedRectangle( R.Left - xscalediff, R.Top - yscalediff, size.Width() + xscalediff, size.Height() + yscalediff, Corners ); eeVector2f poly; Poly.Rotate( Angle, Center ); switch( mFillMode ) { case DRAW_FILL: { if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) { sBR->PolygonSetColor( TopLeft ); sBR->BatchPolygon( Poly ); } else { for ( i = 0; i < Poly.Size(); i++ ) { poly = Poly[i]; if ( poly.x <= Center.x && poly.y <= Center.y ) sBR->PolygonSetColor( TopLeft ); else if ( poly.x <= Center.x && poly.y >= Center.y ) sBR->PolygonSetColor( BottomLeft ); else if ( poly.x > Center.x && poly.y > Center.y ) sBR->PolygonSetColor( BottomRight ); else if ( poly.x > Center.x && poly.y < Center.y ) sBR->PolygonSetColor( TopRight ); else sBR->PolygonSetColor( TopLeft ); sBR->BatchPolygonByPoint( Poly[i] ); } } break; } case DRAW_LINE: { sBR->SetLineWidth( mLineWidth ); sBR->LineLoopBegin(); sBR->LineLoopSetColor( TopLeft ); if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) { 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 ) sBR->LineLoopSetColor( TopLeft ); else if ( poly.x < Center.x && poly.y > Center.y ) sBR->LineLoopSetColor( BottomLeft ); else if ( poly.x > Center.x && poly.y > Center.y ) sBR->LineLoopSetColor( BottomRight ); else if ( poly.x > Center.x && poly.y < Center.y ) sBR->LineLoopSetColor( TopRight ); else sBR->LineLoopSetColor( TopLeft ); sBR->BatchLineLoop( Poly[i] ); } } break; } } DrawBatch(); }