void SG_EXPORT sgTrailDraw(SGTrail* trail) { if(trail == NULL) return; if((trail->numpoints != 0) && ((trail->xpoints[0] != trail->xpoints[0]) || (trail->ypoints[0] != trail->ypoints[0]))) sgTrailPopPoint(trail); if(trail->numpoints == 0) return; SGuint i; float sumlen = 0.0; float curlen = 0.0; float px = trail->xpoints[0]; float py = trail->ypoints[0]; float x; float y; for(i = 0; i < trail->numpoints; i++) { x = trail->xpoints[i]; y = trail->ypoints[i]; if((x != x) || (y != y)) continue; sumlen += sqrt((px - x) * (px - x) + (py - y) * (py - y)); px = x; py = y; } sgDrawBegin(SG_LINE_STRIP); px = trail->xpoints[0]; py = trail->ypoints[0]; for(i = 0; i < trail->numpoints; i++) { x = trail->xpoints[i]; y = trail->ypoints[i]; if((x != x) || (y != y)) { sgDrawEnd(); sgDrawBegin(SG_LINE_STRIP); continue; } sgDrawColor2f(1.0, i / (float)(trail->numpoints - 1)); sgDrawVertex2f(x, y); curlen += sqrt((px - x) * (px - x) + (py - y) * (py - y)); px = x; py = y; } sgDrawEnd(); }
void SG_CALL sgAtlasAreaDrawRads3f2f2f1f(SGAtlas* atlas, SGAtlasArea* area, float x, float y, float z, float xscale, float yscale, float xoffset, float yoffset, float angle) { float s0, t0, s1, t1; sgAtlasGetTexCoordsA(atlas, area, &s0, &t0, &s1, &t1); // offset -> scale -> rotate -> translate SGVec2 pos = sgVec2f(x, y); SGVec2 p0, p1, p2, p3; p0 = sgVec2f(-xoffset , -yoffset ); p1 = sgVec2f(-xoffset , -yoffset + area->h * yscale); p2 = sgVec2f(-xoffset + area->w * xscale, -yoffset + area->h * yscale); p3 = sgVec2f(-xoffset + area->w * xscale, -yoffset ); p0 = sgVec2RotateRads(p0, sgVec2AngleRads(p0) + angle); p1 = sgVec2RotateRads(p1, sgVec2AngleRads(p1) + angle); p2 = sgVec2RotateRads(p2, sgVec2AngleRads(p2) + angle); p3 = sgVec2RotateRads(p3, sgVec2AngleRads(p3) + angle); p0 = sgVec2Add(p0, pos); p1 = sgVec2Add(p1, pos); p2 = sgVec2Add(p2, pos); p3 = sgVec2Add(p3, pos); sgDrawBeginT(SG_QUADS, sgAtlasGetTextureA(atlas, area)); sgDrawTexCoord2f(s0, t0); sgDrawVertex3f(p0.x, p0.y, z); sgDrawTexCoord2f(s0, t1); sgDrawVertex3f(p1.x, p1.y, z); sgDrawTexCoord2f(s1, t1); sgDrawVertex3f(p2.x, p3.y, z); sgDrawTexCoord2f(s1, t0); sgDrawVertex3f(p2.x, p3.y, z); sgDrawEnd(); }
void SG_EXPORT sgMaskDrawDBG(SGMask* mask, SGint x, SGint y, SGbool transparent) { if(mask == NULL) return; SGuint i, j; sgDrawBegin(SG_POINTS); for(i = 0; i < mask->width; i++) { for(j = 0; j < mask->height; j++) { if(!transparent) sgDrawColor1f(mask->field[i][j] ? 1.0 : 0.0); if(mask->field[i][j] || !transparent) sgDrawVertex2f(x - mask->xoffset + i, y - mask->yoffset + j); } } sgDrawEnd(); }
void drawPath(SGList* path, SGColor color, SGbool lines, SGbool fill) { if(!path) return; SGListNode* node; SGNavGridData* data; if(lines) sgDrawBegin(SG_LINE_STRIP); sgDrawColor4fv(&color.r); for(node = path->head; node; node = node->next) { data = node->item; if(lines) sgDrawVertex2f(data->x * cellw + cellw/2, data->y * cellh + cellh/2); else sgDrawRectangleWH(data->x * cellw, data->y * cellh, cellw, cellh, fill); } if(lines) sgDrawEnd(); }