Ejemplo n.º 1
0
void Grid::UpdateTris() {
	int        i, j;
	Polygon*   poly;
	Triangle*  tri;

	for( i = 0; i < nPolys; i++ ) {
		poly = polys[i];
		for( j = 0; j < poly->n; j++ ) {
			tri = poly->tris[j];
			tri->a[0] = poly->verts[j][0];
			tri->a[1] = poly->verts[j][1];
			tri->b[0] = poly->verts[(j+1)%poly->n][0];
			tri->b[1] = poly->verts[(j+1)%poly->n][1];
			tri->c[0] = poly->origin[0];
			tri->c[1] = poly->origin[1];
			tri->Init();
			/* update the triangle edges */
			tri->ab->v1[0] = tri->a[0];
			tri->ab->v1[1] = tri->a[1];
			tri->ab->v2[0] = tri->b[0];
			tri->ab->v2[1] = tri->b[1];
			tri->ab->Init();

			tri->bc->v1[0] = tri->b[0];
			tri->bc->v1[1] = tri->b[1];
			tri->bc->v2[0] = tri->c[0];
			tri->bc->v2[1] = tri->c[1];
			tri->bc->Init();

			tri->ca->v1[0] = tri->c[0];
			tri->ca->v1[1] = tri->c[1];
			tri->ca->v2[0] = tri->a[0];
			tri->ca->v2[1] = tri->a[1];
			tri->ca->Init();
		}
	}
}
Ejemplo n.º 2
0
void Init() {
    // sets background color
    glClearColor(0.937, 0.937, 0.937 /*gray*/, 1.0 /*solid*/);

    triangle.Init();
}