77
88namespace EE { namespace Graphics {
99
10- static GlobalBatchRenderer* sBR = NULL ;
11-
1210Primitives::Primitives () :
1311 mFillMode ( DRAW_FILL ),
1412 mBlendMode ( BlendMode::Alpha() ),
1513 mLineWidth ( 1 .f ),
1614 mForceDraw ( true ) {
17- if ( NULL == sBR ) {
18- sBR = GlobalBatchRenderer::instance ();
19- }
2015}
2116
2217Primitives::~Primitives () {}
2318
2419void Primitives::drawPoint ( const Vector2f& p, const Float& pointSize ) {
20+ auto sBR = GlobalBatchRenderer::instance ();
2521 sBR ->setPointSize ( pointSize );
2622
2723 sBR ->setTexture ( NULL );
@@ -34,6 +30,7 @@ void Primitives::drawPoint( const Vector2f& p, const Float& pointSize ) {
3430}
3531
3632void Primitives::drawLine ( const Line2f& line ) {
33+ auto sBR = GlobalBatchRenderer::instance ();
3734 sBR ->setLineWidth ( mLineWidth );
3835
3936 sBR ->setTexture ( NULL );
@@ -47,6 +44,7 @@ void Primitives::drawLine( const Line2f& line ) {
4744
4845void Primitives::drawTriangle ( const Triangle2f& t, const Color& Color1, const Color& Color2,
4946 const Color& Color3 ) {
47+ auto sBR = GlobalBatchRenderer::instance ();
5048 sBR ->setTexture ( NULL );
5149 sBR ->setBlendMode ( mBlendMode );
5250
@@ -141,6 +139,7 @@ void Primitives::drawArc( const Vector2f& p, const Float& radius, Uint32 segment
141139
142140 Float angleShift = 360 / static_cast <Float>( segmentsCount );
143141 Float arcAngleA = arcAngle > 360 ? arcAngle - 360 * std::floor ( arcAngle / 360 ) : arcAngle;
142+ auto sBR = GlobalBatchRenderer::instance ();
144143
145144 sBR ->setTexture ( NULL );
146145
@@ -197,6 +196,7 @@ void Primitives::drawArc( const Vector2f& p, const Float& radius, Uint32 segment
197196void Primitives::drawRectangle ( const Rectf& R, const Color& TopLeft, const Color& BottomLeft,
198197 const Color& BottomRight, const Color& TopRight, const Float& Angle,
199198 const Vector2f& Scale ) {
199+ auto sBR = GlobalBatchRenderer::instance ();
200200 sBR ->setTexture ( NULL );
201201 sBR ->setBlendMode ( mBlendMode );
202202
@@ -242,6 +242,7 @@ void Primitives::drawRectangle( const Rectf& R, const Float& Angle, const Vector
242242}
243243
244244void Primitives::drawRectangle ( const Rectf& R ) {
245+ auto sBR = GlobalBatchRenderer::instance ();
245246 sBR ->setTexture ( NULL );
246247 sBR ->setBlendMode ( mBlendMode );
247248
@@ -269,6 +270,7 @@ void Primitives::drawRoundedRectangle( const Rectf& R, const Color& TopLeft,
269270 const Color& BottomLeft, const Color& BottomRight,
270271 const Color& TopRight, const Float& Angle,
271272 const Vector2f& Scale, const unsigned int & Corners ) {
273+ auto sBR = GlobalBatchRenderer::instance ();
272274 sBR ->setTexture ( NULL );
273275 sBR ->setBlendMode ( mBlendMode );
274276
@@ -356,6 +358,7 @@ void Primitives::drawRoundedRectangle( const Rectf& R, const Float& Angle, const
356358void Primitives::drawQuad ( const Quad2f& q, const Color& Color1, const Color& Color2,
357359 const Color& Color3, const Color& Color4, const Float& OffsetX,
358360 const Float& OffsetY ) {
361+ auto sBR = GlobalBatchRenderer::instance ();
359362 sBR ->setTexture ( NULL );
360363 sBR ->setBlendMode ( mBlendMode );
361364
@@ -390,6 +393,7 @@ void Primitives::drawQuad( const Quad2f& q, const Float& OffsetX, const Float& O
390393}
391394
392395void Primitives::drawPolygon ( const Polygon2f& p ) {
396+ auto sBR = GlobalBatchRenderer::instance ();
393397 sBR ->setTexture ( NULL );
394398 sBR ->setBlendMode ( mBlendMode );
395399
@@ -416,6 +420,7 @@ void Primitives::drawPolygon( const Polygon2f& p ) {
416420}
417421
418422void Primitives::drawBatch () {
423+ auto sBR = GlobalBatchRenderer::instance ();
419424 if ( mForceDraw )
420425 sBR ->draw ();
421426 else
0 commit comments