Пример #1
0
void Slice::drawPolygon(Polygons &pgs, int layer){

    glColor4f(0.0f, 1.0f, 0.0f, 0.25f);
    GLUtesselator* tess = gluNewTess();
    gluTessCallback(tess, GLU_TESS_BEGIN, (GLvoid (__stdcall *) ())&BeginCallback);
    gluTessCallback(tess, GLU_TESS_VERTEX, (GLvoid (__stdcall *) ())&VertexCallback);
    gluTessCallback(tess, GLU_TESS_END, (GLvoid (__stdcall *) ())&EndCallback);
    gluTessCallback(tess, GLU_TESS_COMBINE, (GLvoid (__stdcall *) ())&CombineCallback);
    gluTessCallback(tess, GLU_TESS_ERROR, (GLvoid (__stdcall *) ())&ErrorCallback);
    gluTessNormal(tess, 0.0, 0.0, 1.0);
    gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
    gluTessProperty(tess, GLU_TESS_BOUNDARY_ONLY, GL_FALSE); //GL_FALSE
    gluTessBeginPolygon(tess, NULL);
    glPushMatrix();
    glTranslated(0.0,0.0,this->layerHeight*layer);
    for (Polygons::size_type i = 0; i < pgs.size(); ++i)
    {
        gluTessBeginContour(tess);
        for (ClipperLib::Polygon::size_type j = 0; j < pgs[i].size(); ++j)
        {
            GLdouble *vert =
                    NewVector((GLdouble)pgs[i][j].X/1000, (GLdouble)pgs[i][j].Y/1000);
            gluTessVertex(tess, vert, vert);
        }
        gluTessEndContour(tess);
    }
    gluTessEndPolygon(tess);
    ClearVectors();

    glColor4f(0.0f, 0.6f, 1.0f, 0.5f);
    glLineWidth(1.8f);

    gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
    gluTessProperty(tess, GLU_TESS_BOUNDARY_ONLY, GL_TRUE);
    for (Polygons::size_type i = 0; i < pgs.size(); ++i)
    {
        gluTessBeginPolygon(tess, NULL);
        gluTessBeginContour(tess);
        for (ClipperLib::Polygon::size_type j = 0; j < pgs[i].size(); ++j)
        {
            GLdouble *vert =
                    NewVector((GLdouble)pgs[i][j].X/1000, (GLdouble)pgs[i][j].Y/1000);
            gluTessVertex(tess, vert, vert);
        }

        glColor4f(0.0f, 0.0f, 0.8f, 0.5f);

        gluTessEndContour(tess);
        gluTessEndPolygon(tess);
    }

    //final cleanup ...
    gluDeleteTess(tess);
    ClearVectors();
    glPopMatrix();
}
//updates the vectors to hold infomation on current time
void FontGenerator::Update()
{
	ClearVectors();

	//getting the time using CTime
	time_t time;
	std::time(&time);
	struct tm* time_info = std::localtime(&time);

	//Strings hold the characters we would like in our vectors
	std::string* hour_binary = DecToBin(time_info->tm_hour % 12);
	std::string* minute_binary = DecToBin(time_info->tm_min);
	std::string* second_binary = DecToBin(time_info->tm_sec);

	//pushes the character specific matricies into the appropriate vector
	for (int i = 0; i < (int) hour_binary->size(); i++)
	{
		hour_font_vector_->push_back(new PixelMatrix(FONT_HEIGHT, FONT_WIDTH));
		SetMatrixToCharacter(hour_font_vector_->at(i), hour_binary->at(i));
	}
	for (int i = 0; i < (int) minute_binary->size(); i++)
	{
		minute_font_vector_->push_back(new PixelMatrix(FONT_HEIGHT, FONT_WIDTH));
		SetMatrixToCharacter(minute_font_vector_->at(i), minute_binary->at(i));
	}
	for (int i = 0; i < (int) second_binary->size(); i++)
	{
		second_font_vector_->push_back(new PixelMatrix(FONT_HEIGHT, FONT_WIDTH));
		SetMatrixToCharacter(second_font_vector_->at(i), second_binary->at(i));
	}

	//clean up
	delete hour_binary;
	delete minute_binary;
	delete second_binary;

	update_count_++;

	return;
}