Пример #1
0
void cFontManager::DrawText(std::string font, std::string text, int x, int y, 
		float r, float g, float b, float scale, float rotation){
	if(fonts.count(font) == 0){
		return;
	}
	sFont *tmpF = &fonts[font];
	int firstX = x;
	for(int i = 0; i < (int)text.size(); i++){
		std::string tmpG = "";
		if(IsUtf8(text, i)){
			tmpG = text.substr(i, 2);
			i += 1;
		}else{
			tmpG += text.at(i);
		}
		if(tmpG == " "){	//Handle space
			x += (tmpF->spacing * 4);
			continue;
		}else if(tmpG == "\n"){	//Handle new line
			y += tmpF->newLine;
			x = firstX;
			continue;
		}
		if(tmpF->glyphs.count(tmpG) > 0){
			DrawSection(tmpF->glyphs[tmpG], x, y, scale, rotation, r, g, b);
			x += tManager->GetSection(tmpF->glyphs[tmpG])->width + tmpF->spacing;
		}
	}
}
Пример #2
0
eU32 eMesh::_findDrawSectionIdx(const eMaterial *mat, DrawSection::Type dsType)
{
    for (eU32 i=0; i<m_drawSections.size(); i++)
    {
        DrawSection &ds = m_drawSections[i];

        if (ds.material == mat && ds.type == dsType)
        {
            return i;
        }
    }

    m_drawSections.append(DrawSection());
    DrawSection &ds = m_drawSections[m_drawSections.size()-1];
    ds.type = dsType;
    ds.material = mat;
    ds.geometry = eNULL;

    return m_drawSections.size() - 1;
}
Пример #3
0
void kGUIText::Draw(int x,int y,int w,int h,kGUIColor color)
{
	/* this is the only draw call that looks at the valign and halign */
	kGUIInputLineInfo *lbptr;
	int i;
	FT_HALIGN halign=GetHAlign();
	int cx=0;
	int cy;
	int lineheight=GetLineHeight()+2;
	int numl;

	if(m_llnum<2)
		numl=1;
	else
		numl=m_llnum;

	cy=y;
	switch(GetVAlign())
	{
	case FT_TOP:
	break;
	case FT_MIDDLE:
		cy+=(h-((lineheight*numl)-2))/2;
	break;
	case FT_BOTTOM:
		cy+=h-((lineheight*numl)-2);
	break;
	}

	if(m_llnum<2)
	{
		switch(halign)
		{
		case FT_LEFT:
			cx=x;
		break;
		case FT_CENTER:
			cx=x+((w-(int)GetWidth())/2);
		break;
		case FT_RIGHT:
			cx=x+(w-(int)GetWidth());
		break;
		}

		DrawSection(0,GetLen(),x,cx,cy,GetLineHeight(),color);
	}
	else
	{
		for(i=0;i<m_llnum;++i)
		{
			lbptr=m_linelist.GetEntry(i);
			switch(halign)
			{
			case FT_LEFT:
				cx=x;
			break;
			case FT_CENTER:
				cx=x+((w-lbptr->pixwidth)/2);
			break;
			case FT_RIGHT:
				cx=x+(w-lbptr->pixwidth);
			break;
			}
			DrawSection(lbptr->startindex,lbptr->endindex-lbptr->startindex,x,cx,cy,lbptr->pixheight,color);
			cy+=lineheight;
		}
	}
}
void FusionForeverWidget::paintGL()
{
	if(icon_render_mode) 
	{ //On first pass render all sections to an icon
		glClearColor(1.0f,1.0f,1.0f,0.0f);
		std::vector<std::string> section_types = SectionTypes::GetSectionNames();
		std::vector<std::string> core_types = SectionTypes::GetCoreNames();
		std::vector<std::pair<std::string, QPixmap*> > section_icons;
		std::vector<std::pair<std::string, QPixmap*> > core_icons;

		for(std::vector<std::string>::iterator it = section_types.begin(); it != section_types.end(); ++it)
		{
			Section_ptr section = SectionTypes::GetSection(*it);
			DrawSection(section, *it, section_icons);
		}
		for(std::vector<std::string>::iterator it = core_types.begin(); it != core_types.end(); ++it)
		{
			Section_ptr section = XMLCore::CreateXMLCore(*it);
			DrawSection(section, *it, core_icons);
		}

		core_ = XMLCore::CreateXMLCore("SquareCore");
		SetSelection(core_);
		icon_render_mode = false;

		emit initialisedSections(section_icons, core_icons);
		glClearColor(0.0f,0.0f,0.0f,0.0f);
	}
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	Camera::Instance().SetupCamera();
	glMatrixMode(GL_MODELVIEW);

	if(selection_)
	{
		glColor3ub(50, 50, 50);
		Matrix4f transform;
		if(!selection_->IsCore())
			transform = selection_->GetParent()->GetTransform();
		glLoadMatrixf(&transform.data[0]);
		//Draw grid
		glBegin(GL_LINES);
		float worst_width = sqrt(Camera::Instance().GetWidth() * Camera::Instance().GetWidth() +
								 Camera::Instance().GetHeight() * Camera::Instance().GetHeight());
		
		//Calculate grid size to ensure 5px minimum size
		float drawn_grid_size = grid_snap_;
		const float min_screen_size = 5;
		while(drawn_grid_size < min_screen_size * Camera::Instance().GetWidth() / Camera::Instance().GetWindowWidth())
		{
			drawn_grid_size *= 2.0f;
		}	

		for(float x = 0; x < worst_width; x+=drawn_grid_size)
		{
			glVertex3f(x, -10000, 0);
			glVertex3f(x, 10000, 0);
			glVertex3f(-x, -10000, 0);
			glVertex3f(-x, 10000, 0);
			
			glVertex3f(-10000, x, 0);
			glVertex3f(10000, x, 0);
			glVertex3f(-10000, -x, 0);
			glVertex3f(10000, -x, 0);
		}
		glEnd();
	}

	glLoadIdentity();
	core_->DrawSelf();

	//Calculate world space length so that constant 5px screenspace is achieved.
	Vector3f scaled_line = Camera::Instance().ScreenDeltaToWorldDelta(Vector3f(5,0,0));
	core_->DrawEditorSupport(scaled_line.x, selection_);
	glFlush();

}