// Run Different Kind of Tests
//
hTgt = oapiCreateSurfaceEx(768, 512, OAPISURFACE_RENDERTARGET);
if (!hTgt) return;
gcCore *pCore = gcGetCoreInterface();
if (!pCore) return;
float a = 0.0f;
float s = float(PI2 / 6.0);
gcCore::TriangleVtx Vtx[8];
oapi::FVECTOR2 Pol[6];
for (int i = 0; i < 6; i++) {
Pol[i].x = cos(a);
Pol[i].y = sin(a);
Vtx[i + 1].pos.x = Pol[i].x;
Vtx[i + 1].pos.y = Pol[i].y;
a += s;
}
// AABBGGRR
Vtx[1].color = 0xFFFF0000;
Vtx[2].color = 0xFFFFFF00;
Vtx[3].color = 0xFF00FF00;
Vtx[4].color = 0xFF00FFFF;
Vtx[5].color = 0xFF0000FF;
Vtx[6].color = 0xFFFF00FF;
// Center vertex
Vtx[0].pos.x = 0.0f;
Vtx[0].pos.y = 0.0f;
Vtx[0].color = 0xFFFFFFFF; // White
Vtx[7] = Vtx[1];
HPOLY hColors = pCore->CreateTriangles(NULL, Vtx, 8, PF_FAN);
HPOLY hOutline = pCore->CreatePoly(NULL, Pol, 6, PF_CONNECT);
HPOLY hOutline2 = pCore->CreatePoly(NULL, Pol, 6);
Vtx[0].color = 0xFFFF0000;
Vtx[1].color = 0xFFFFFF00;
Vtx[2].color = 0xFFF0FF00;
Vtx[3].color = 0xFF00FFFF;
Vtx[4].color = 0xFF0000FF;
Vtx[5].color = 0xFFFF00FF;
Vtx[0].pos = FVECTOR2(-1, 0);
Vtx[1].pos = FVECTOR2(-1, 1);
Vtx[2].pos = FVECTOR2(0, 0);
Vtx[3].pos = FVECTOR2(0, 1);
Vtx[4].pos = FVECTOR2(1, 0);
Vtx[5].pos = FVECTOR2(1, 1);
HPOLY hStrip = pCore->CreateTriangles(NULL, Vtx, 6, PF_STRIP);
Vtx[0].color = 0xFF00FF00; // Green
Vtx[1].color = 0xFF00FF00; // Green
Vtx[2].color = 0xFFFF00FF; // Mangenta
Vtx[3].color = 0xFFFF00FF; // Mangenta
Vtx[4].color = 0xFF0000FF; // Blue
Vtx[5].color = 0xFF0000FF; // Blue
Vtx[0].pos = FVECTOR2(-1, 1);
Vtx[1].pos = FVECTOR2(-1, 0);
Vtx[2].pos = FVECTOR2(0, 1);
Vtx[3].pos = FVECTOR2(0, 0);
Vtx[4].pos = FVECTOR2(1, 1);
Vtx[5].pos = FVECTOR2(1, 0);
HPOLY hStrip2 = pCore->CreateTriangles(NULL, Vtx, 6, PF_STRIP);
IVECTOR2 pos0 = { 128, 128 };
IVECTOR2 pos1 = { 128, 384 };
IVECTOR2 pos2 = { 384, 128 };
IVECTOR2 pos3 = { 640, 128 };
IVECTOR2 pos4 = { 384, 384 };
pSkp = static_cast<Sketchpad3 *>(oapiGetSketchpad(hTgt));
pSkp->ColorFill(FVECTOR4((DWORD)0xFFFFFFFF), NULL);
pSkp->QuickBrush(0xA0000088);
pSkp->QuickPen(0xA0000000, 3.0f);
pSkp->PushWorldTransform();
pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos0);
pSkp->DrawPoly(hColors);
pSkp->DrawPoly(hOutline);
pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos1);
pSkp->DrawPoly(hOutline2);
pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos2);
pSkp->DrawPoly(hStrip);
pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos3);
pSkp->DrawPoly(hStrip2);
pSkp->SetWorldScaleTransform2D(&FVECTOR2(100.0f, 100.0f), &pos4);
pSkp->QuickPen(0xFF000000, 25.0f);
pSkp->DrawPoly(hOutline);
pSkp->PopWorldTransform();
oapiReleaseSketchpad(pSkp);
pCore->DeletePoly(hColors); // Must release Sketchpad before releasing any sketchpad resources
pCore->DeletePoly(hOutline);
pCore->DeletePoly(hOutline2);
pCore->DeletePoly(hStrip);
pCore->DeletePoly(hStrip2);
clbkSaveSurfaceToImage(hTgt, "SketchpadOutput2", ImageFileFormat::IMAGE_PNG);