PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Trying to draw a polygon

Hello all!,

It's the first time that I test pocketfrog and I have problems trying to draw a polygon. There are some instructions to use FillPoly?

I have taken the "Rotate" example as is and changed the GameLoop function to draw a polygon:

Code:
void RotateSample::GameLoop()
{
const float PI = 3.1415926535897932384626433832795f;

Display* display = GetDisplay();

display->Clear( Color(255,255,255) );

/*
display->BlitRotated( display->GetWidth() - m_image->GetWidth()/2, m_image->GetHeight()/2, m_angle, m_image );
display->BlitRotated( display->GetWidth()/2, display->GetHeight()/2, m_angle, m_image );
display->BlitRotated( m_image->GetWidth()/2, display->GetHeight() - m_image->GetHeight()/2, m_angle, m_image );


// Update angle
m_angle += 0.03f;
if (m_angle > 2.0f * PI)
m_angle -= 2.0f * PI;
*/

Point test[6];
test[0].Set(155,125);
test[1].Set(120,90);
test[2].Set(120,160);
test[3].Set(190,160);
test[4].Set(225,125);
test[5].Set(190,90);

display->FillPoly(test, 6, Color(200, 200, 100));

// Update FPS
m_FPSTicks[ m_FPSCounter & 15 ] = PocketPC::GetTickCount();
if (m_FPSCounter > 15)
{
uint32_t totalTime = m_FPSTicks[ m_FPSCounter & 15 ] - m_FPSTicks[ (m_FPSCounter+1) & 15 ];
if (totalTime == 0) totalTime = 1;
uint32_t fps = 16000 / totalTime;
uint32_t n100 = fps / 100; fps -= n100 * 100;
uint32_t n10 = fps / 10; fps -= n10 * 10;
uint32_t n1 = fps;

if (n100 > 9) { n100 = 9; n10 = 9; n1 = 9; }

// Display fps
display->Blit( 0, 0, m_numbers, &Rect;( n100 * 8, 0, (n100+1)*8, 11 ) );
display->Blit( 8, 0, m_numbers, &Rect;( n10 * 8, 0, (n10+1)*8, 11 ) );
display->Blit( 16, 0, m_numbers, &Rect;( n1 * 8, 0, (n1+1)*8, 11 ) );
}
++m_FPSCounter;


// Update screen
display->Update();
}


I have a unexpected result (see pictures labeled with bad and ok tags)

Image
Image

What I'm doing wrong?

Regards,
JAL
The FillPolygon() routin will only draw convex polygons. Your's isn't.