您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Graphics函数代码示例

51自学网 2021-06-01 21:19:34
  C++
这篇教程C++ Graphics函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Graphics函数的典型用法代码示例。如果您正苦于以下问题:C++ Graphics函数的具体用法?C++ Graphics怎么用?C++ Graphics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Graphics函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Graphics

void CScoreboard::OnRender(){	if(!Active())		return;	// if the score board is active, then we should clear the motd message aswell	if(m_pClient->m_pMotd->IsActive())		m_pClient->m_pMotd->Clear();	float Width = 400*3.0f*Graphics()->ScreenAspect();	float Height = 400*3.0f;	Graphics()->MapScreen(0, 0, Width, Height);	m_pClient->m_pLua->m_pEventListener->OnEvent("OnScoreboardRender");	if (m_pClient->m_pLua->m_pEventListener->m_Returns.m_aVars[0].GetInteger() == 1)        return;	float w = 700.0f;	if(m_pClient->m_Snap.m_pGameInfoObj)	{		if(!(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS))			RenderScoreboard(Width/2-w/2, 150.0f, w, 0, 0);		else		{			const char *pRedClanName = GetClanName(TEAM_RED);			const char *pBlueClanName = GetClanName(TEAM_BLUE);			if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER && m_pClient->m_Snap.m_pGameDataObj)			{				char aText[256];				str_copy(aText, Localize("Draw!"), sizeof(aText));				if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue)				{					if(pRedClanName)						str_format(aText, sizeof(aText), Localize("%s wins!"), pRedClanName);					else						str_copy(aText, Localize("Red team wins!"), sizeof(aText));				}				else if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed)				{					if(pBlueClanName)						str_format(aText, sizeof(aText), Localize("%s wins!"), pBlueClanName);					else						str_copy(aText, Localize("Blue team wins!"), sizeof(aText));				}				float w = TextRender()->TextWidth(0, 86.0f, aText, -1);				TextRender()->Text(0, Width/2-w/2, 39, 86.0f, aText, -1);			}			RenderScoreboard(Width/2-w-5.0f, 150.0f, w, TEAM_RED, pRedClanName ? pRedClanName : Localize("Red team"));			RenderScoreboard(Width/2+5.0f, 150.0f, w, TEAM_BLUE, pBlueClanName ? pBlueClanName : Localize("Blue team"));		}	}	RenderGoals(Width/2-w/2, 150+760+10, w);	RenderSpectators(Width/2-w/2, 150+760+10+50+10, w);	RenderRecordingNotification((Width/7)*4);}
开发者ID:Parhamic,项目名称:teeworlds,代码行数:62,


示例2: str_format

void CHud::RenderScoreHud(){	// render small score hud	if(!(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&(GAMESTATEFLAG_ROUNDOVER|GAMESTATEFLAG_GAMEOVER)))	{		int GameFlags = m_pClient->m_GameInfo.m_GameFlags;		float Whole = 300*Graphics()->ScreenAspect();		float StartY = 229.0f;		if(GameFlags&GAMEFLAG_TEAMS && m_pClient->m_Snap.m_pGameDataTeam)		{			char aScoreTeam[2][32];			str_format(aScoreTeam[TEAM_RED], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreRed);			str_format(aScoreTeam[TEAM_BLUE], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreBlue);			float aScoreTeamWidth[2] = { TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_RED], -1), TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_BLUE], -1) };			float ScoreWidthMax = max(max(aScoreTeamWidth[TEAM_RED], aScoreTeamWidth[TEAM_BLUE]), TextRender()->TextWidth(0, 14.0f, "100", -1));			float Split = 3.0f;			float ImageSize = GameFlags&GAMEFLAG_FLAGS ? 16.0f : Split;			for(int t = 0; t < NUM_TEAMS; t++)			{				// draw box				CUIRect Rect = {Whole-ScoreWidthMax-ImageSize-2*Split, StartY+t*20, ScoreWidthMax+ImageSize+2*Split, 18.0f};				Graphics()->BlendNormal();				RenderTools()->DrawUIRect(&Rect, t == 0 ? vec4(1.0f, 0.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 1.0f, 0.25f), CUI::CORNER_L, 5.0f);				// draw score				TextRender()->Text(0, Whole-ScoreWidthMax+(ScoreWidthMax-aScoreTeamWidth[t])/2-Split, StartY+t*20, 14.0f, aScoreTeam[t], -1);				if(GameFlags&GAMEFLAG_SURVIVAL)				{					// draw number of alive players					char aBuf[32];					str_format(aBuf, sizeof(aBuf), m_pClient->m_Snap.m_AliveCount[t]==1 ? Localize("%d player left") : Localize("%d players left"),								m_pClient->m_Snap.m_AliveCount[t]);					float w = TextRender()->TextWidth(0, 8.0f, aBuf, -1);					TextRender()->Text(0, min(Whole-w-1.0f, Whole-ScoreWidthMax-ImageSize-2*Split), StartY+(t+1)*20.0f-3.0f, 8.0f, aBuf, -1);				}				StartY += 8.0f;			}			if(GameFlags&GAMEFLAG_FLAGS && m_pClient->m_Snap.m_pGameDataFlag)			{				int FlagCarrier[2] = { m_pClient->m_Snap.m_pGameDataFlag->m_FlagCarrierRed, m_pClient->m_Snap.m_pGameDataFlag->m_FlagCarrierBlue };				int FlagDropTick[2] = { m_pClient->m_Snap.m_pGameDataFlag->m_FlagDropTickRed, m_pClient->m_Snap.m_pGameDataFlag->m_FlagDropTickBlue };				StartY = 229.0f;				for(int t = 0; t < 2; t++)				{					int BlinkTimer = (FlagDropTick[t] != 0 && (Client()->GameTick()-FlagDropTick[t])/Client()->GameTickSpeed() >= 25) ? 10 : 20;					if(FlagCarrier[t] == FLAG_ATSTAND || (FlagCarrier[t] == FLAG_TAKEN && ((Client()->GameTick()/BlinkTimer)&1)))					{						// draw flag						Graphics()->BlendNormal();						Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);						Graphics()->QuadsBegin();						RenderTools()->SelectSprite(t==0?SPRITE_FLAG_RED:SPRITE_FLAG_BLUE);						IGraphics::CQuadItem QuadItem(Whole-ScoreWidthMax-ImageSize, StartY+1.0f+t*20, ImageSize/2, ImageSize);						Graphics()->QuadsDrawTL(&QuadItem, 1);						Graphics()->QuadsEnd();					}					else if(FlagCarrier[t] >= 0)					{						// draw name of the flag holder						int ID = FlagCarrier[t]%MAX_CLIENTS;						char aName[64];						str_format(aName, sizeof(aName), "%2d: %s", ID, g_Config.m_ClShowsocial ? m_pClient->m_aClients[ID].m_aName : "");						float w = TextRender()->TextWidth(0, 8.0f, aName, -1);						TextRender()->Text(0, min(Whole-w-1.0f, Whole-ScoreWidthMax-ImageSize-2*Split), StartY+(t+1)*20.0f-3.0f, 8.0f, aName, -1);						// draw tee of the flag holder						CTeeRenderInfo Info = m_pClient->m_aClients[ID].m_RenderInfo;						Info.m_Size = 18.0f;						RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1,0),							vec2(Whole-ScoreWidthMax-Info.m_Size/2-Split, StartY+1.0f+Info.m_Size/2+t*20));					}					StartY += 8.0f;				}			}		}		else		{			int Local = -1;			int aPos[2] = { 1, 2 };			CGameClient::CPlayerInfoItem aPlayerInfo[2] = {{0}};			int i = 0;			for(int t = 0; t < 2 && i < MAX_CLIENTS && m_pClient->m_Snap.m_aInfoByScore[i].m_pPlayerInfo; ++i)			{				if(m_pClient->m_aClients[m_pClient->m_Snap.m_aInfoByScore[i].m_ClientID].m_Team != TEAM_SPECTATORS)				{					aPlayerInfo[t] = m_pClient->m_Snap.m_aInfoByScore[i];					if(aPlayerInfo[t].m_ClientID == m_pClient->m_LocalClientID)						Local = t;					++t;				}			}			// search local player info if not a spectator, nor within top2 scores			if(Local == -1 && m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team != TEAM_SPECTATORS)			{				for(; i < MAX_CLIENTS && m_pClient->m_Snap.m_aInfoByScore[i].m_pPlayerInfo; ++i)//.........这里部分代码省略.........
开发者ID:Mailaender,项目名称:teeworlds,代码行数:101,


示例3: Graphics

void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 Color, int RenderFlags){	//Graphics()->TextureSet(img_get(tmap->image));	float ScreenX0, ScreenY0, ScreenX1, ScreenY1;	Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);	//Graphics()->MapScreen(screen_x0-50, screen_y0-50, screen_x1+50, screen_y1+50);	// calculate the final pixelsize for the tiles	float TilePixelSize = 1024/32.0f;	float FinalTileSize = Scale/(ScreenX1-ScreenX0) * Graphics()->ScreenWidth();	float FinalTilesetScale = FinalTileSize/TilePixelSize;	Graphics()->QuadsBegin();	Graphics()->SetColor(Color.r, Color.g, Color.b, Color.a);	int StartY = (int)(ScreenY0/Scale)-1;	int StartX = (int)(ScreenX0/Scale)-1;	int EndY = (int)(ScreenY1/Scale)+1;	int EndX = (int)(ScreenX1/Scale)+1;	// adjust the texture shift according to mipmap level	float TexSize = 1024.0f;	float Frac = (1.25f/TexSize) * (1/FinalTilesetScale);	float Nudge = (0.5f/TexSize) * (1/FinalTilesetScale);	for(int y = StartY; y < EndY; y++)		for(int x = StartX; x < EndX; x++)		{			int mx = x;			int my = y;			if(RenderFlags&TILERENDERFLAG_EXTEND)			{				if(mx<0)					mx = 0;				if(mx>=w)					mx = w-1;				if(my<0)					my = 0;				if(my>=h)					my = h-1;			}			else			{				if(mx<0)					continue; // mx = 0;				if(mx>=w)					continue; // mx = w-1;				if(my<0)					continue; // my = 0;				if(my>=h)					continue; // my = h-1;			}			int c = mx + my*w;			unsigned char Index = pTiles[c].m_Index;			if(Index)			{				unsigned char Flags = pTiles[c].m_Flags;				bool Render = false;				if(Flags&TILEFLAG_OPAQUE)				{					if(RenderFlags&LAYERRENDERFLAG_OPAQUE)						Render = true;				}				else				{					if(RenderFlags&LAYERRENDERFLAG_TRANSPARENT)						Render = true;				}				if(Render)				{					int tx = Index%16;					int ty = Index/16;					int Px0 = tx*(1024/16);					int Py0 = ty*(1024/16);					int Px1 = Px0+(1024/16)-1;					int Py1 = Py0+(1024/16)-1;					float x0 = Nudge + Px0/TexSize+Frac;					float y0 = Nudge + Py0/TexSize+Frac;					float x1 = Nudge + Px1/TexSize-Frac;					float y1 = Nudge + Py0/TexSize+Frac;					float x2 = Nudge + Px1/TexSize-Frac;					float y2 = Nudge + Py1/TexSize-Frac;					float x3 = Nudge + Px0/TexSize+Frac;					float y3 = Nudge + Py1/TexSize-Frac;					if(Flags&TILEFLAG_VFLIP)					{						x0 = x2;						x1 = x3;						x2 = x3;						x3 = x0;					}//.........这里部分代码省略.........
开发者ID:Fear-cool,项目名称:DDRace,代码行数:101,


示例4: Graphics

void CKillMessages::OnRender(){	float Width = 400*3.0f*Graphics()->ScreenAspect();	float Height = 400*3.0f;	Graphics()->MapScreen(0, 0, Width*1.5f, Height*1.5f);	float StartX = Width*1.5f-10.0f;	float y = 20.0f;	for(int i = 0; i < MAX_KILLMSGS; i++)	{		int r = (m_KillmsgCurrent+i+1)%MAX_KILLMSGS;		if(Client()->GameTick() > m_aKillmsgs[r].m_Tick+50*10)			continue;		float FontSize = 36.0f;		float KillerNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aKillerName, -1);		float VictimNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aVictimName, -1);		float x = StartX;		// render victim name		x -= VictimNameW;		TextRender()->Text(0, x, y, FontSize, m_aKillmsgs[r].m_aVictimName, -1);		// render victim tee		x -= 24.0f;				if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_FLAGS)		{			if(m_aKillmsgs[r].m_ModeSpecial&1)			{				Graphics()->BlendNormal();				Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);				Graphics()->QuadsBegin();				if(m_aKillmsgs[r].m_VictimTeam == 0)					RenderTools()->SelectSprite(SPRITE_FLAG_BLUE);				else					RenderTools()->SelectSprite(SPRITE_FLAG_RED);								float Size = 56.0f;				IGraphics::CQuadItem QuadItem(x, y-16, Size/2, Size);				Graphics()->QuadsDrawTL(&QuadItem, 1);				Graphics()->QuadsEnd();								}		}				RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_VictimRenderInfo, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28));		x -= 32.0f;				// render weapon		x -= 44.0f;		if (m_aKillmsgs[r].m_Weapon >= 0)		{			Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);			Graphics()->QuadsBegin();			RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[m_aKillmsgs[r].m_Weapon].m_pSpriteBody);			RenderTools()->DrawSprite(x, y+28, 96);			Graphics()->QuadsEnd();		}		x -= 52.0f;		if(m_aKillmsgs[r].m_VictimID != m_aKillmsgs[r].m_KillerID)		{			if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_FLAGS)			{				if(m_aKillmsgs[r].m_ModeSpecial&2)				{					Graphics()->BlendNormal();					Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);					Graphics()->QuadsBegin();					if(m_aKillmsgs[r].m_KillerTeam == 0)						RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);					else						RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);										float Size = 56.0f;					IGraphics::CQuadItem QuadItem(x-56, y-16, Size/2, Size);					Graphics()->QuadsDrawTL(&QuadItem, 1);					Graphics()->QuadsEnd();								}			}										// render killer tee			x -= 24.0f;			RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_KillerRenderInfo, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28));			x -= 32.0f;			// render killer name			x -= KillerNameW;			TextRender()->Text(0, x, y, FontSize, m_aKillmsgs[r].m_aKillerName, -1);		}		y += 44;	}}
开发者ID:wthnonck,项目名称:tdtw,代码行数:99,


示例5: CALLSTACK_ADD

// stolen from H-Client :3void CMenus::RenderIRC(CUIRect MainView){    CALLSTACK_ADD();    static float YOffset = -500.0f; // dunno if a constant is optimal...    if(!m_IRCActive)    {        YOffset = -500.0f;        return;    }    smooth_set(&YOffset, 50.0f, 35.0f, Client()->RenderFrameTime());    // small0r    MainView.x = 50;    MainView.y = YOffset;    MainView.w -= 100;    MainView.h -= 100;    CUIRect Screen = *UI()->Screen();    Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);    Graphics()->BlendNormal();    RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActiveIngame-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 5.0f);    MainView.HSplitTop(15.0f, 0, &MainView);    MainView.VSplitLeft(15.0f, 0, &MainView);    MainView.Margin(5.0f, &MainView);    RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActiveIngame-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 5.0f);    CUIRect MainIRC, EntryBox, Button;    MainView.Margin(10.0f, &MainIRC);    /*if (m_GamePagePanel != PANEL_CHAT && UI()->MouseInside(&MainView) && Input()->KeyPressed(KEY_MOUSE_1))     {     m_GamePagePanel = PANEL_CHAT;     }*/    if(m_pClient->IRC()->GetState() == IIRC::STATE_DISCONNECTED)    {        EntryBox.x = MainIRC.x + (MainIRC.w / 2.0f - 300.0f / 2.0f);        EntryBox.w = 300.0f;        EntryBox.y = MainIRC.y + (MainIRC.h / 2.0f - 55.0f / 2.0f);        EntryBox.h = 55.0f;        RenderTools()->DrawUIRect(&EntryBox, ms_ColorTabbarActive-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 10.0f);        EntryBox.Margin(5.0f, &EntryBox);        EntryBox.HSplitTop(18.0f, &Button, &EntryBox);        CUIRect Label;        Button.VSplitLeft(40.0f, &Label, &Button);        UI()->DoLabelScaled(&Label, Localize("Nick:"), 14.0f, -1);        static float OffsetNick;        if(g_Config.m_ClIRCNick[0] == 0)        {            str_copy(g_Config.m_ClIRCNick, g_Config.m_PlayerName, sizeof(g_Config.m_ClIRCNick));            str_irc_sanitize(g_Config.m_ClIRCNick);        } //TODO_ here?        static CButtonContainer s_EditboxIRCNick;        DoEditBox(&s_EditboxIRCNick, &Button, g_Config.m_ClIRCNick, sizeof(g_Config.m_ClIRCNick), 12.0f, &OffsetNick,                  false, CUI::CORNER_ALL);        EntryBox.HSplitTop(5.0f, 0x0, &EntryBox);        EntryBox.HSplitTop(20.0f, &Button, &EntryBox);        static CButtonContainer s_ButtonConnect;        if(DoButton_Menu(&s_ButtonConnect, Localize("Connect"), 0, &Button))            m_pClient->m_pIRCBind->Connect();    }    else if(m_pClient->IRC()->GetState() == IIRC::STATE_CONNECTING)    {        EntryBox.x = MainIRC.x + (MainIRC.w / 2.0f - 300.0f / 2.0f);        EntryBox.w = 300.0f;        EntryBox.y = MainIRC.y + (MainIRC.h / 2.0f - 25.0f / 2.0f);        EntryBox.h = 25.0f;        RenderTools()->DrawUIRect(&EntryBox, ms_ColorTabbarActive-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 10.0f);        EntryBox.Margin(5.0f, &EntryBox);        UI()->DoLabelScaled(&EntryBox, Localize("Connecting, please wait..."), 14.0f, -1);    }    else if(m_pClient->IRC()->GetState() == IIRC::STATE_CONNECTED)    {        CUIRect ButtonBox, InputBox;        // channel list        MainIRC.HSplitTop(20.0f, &ButtonBox, &EntryBox);        ButtonBox.VSplitRight(80.0f, &ButtonBox, &Button);        static CButtonContainer s_ButtonDisc;        if(DoButton_Menu(&s_ButtonDisc, g_Config.m_ClIRCAutoconnect ? Localize("Reconnect") : Localize("Disconnect"), 0, &Button))            m_pClient->m_pIRCBind->Disconnect(g_Config.m_ClIRCLeaveMsg);        // scroll through the tabs        if(UI()->MouseInside(&ButtonBox) && m_pClient->m_pGameConsole->IsClosed())        {            if(m_pClient->Input()->KeyPress(KEY_MOUSE_WHEEL_UP))                m_pClient->IRC()->NextRoom();            else if(m_pClient->Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN))                m_pClient->IRC()->PrevRoom();//.........这里部分代码省略.........
开发者ID:AllTheHaxx,项目名称:AllTheHaxx,代码行数:101,


示例6: Layers

void CMapLayers::OnRender(){	if((Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK && !m_pMenuMap))		return;	CLayers *pLayers = 0;	if(Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK)		pLayers = Layers();	else if(m_pMenuMap->IsLoaded())		pLayers = m_pMenuLayers;	if(!pLayers)		return;	CUIRect Screen;	Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);	vec2 Center = m_pClient->m_pCamera->m_Center;	//float center_x = gameclient.camera->center.x;	//float center_y = gameclient.camera->center.y;	bool PassedGameLayer = false;	for(int g = 0; g < pLayers->NumGroups(); g++)	{		CMapItemGroup *pGroup = pLayers->GetGroup(g);		if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)		{			// set clipping			float Points[4];			MapScreenToGroup(Center.x, Center.y, pLayers->GameGroup());			Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);			float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);			float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);			float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);			float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);			Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));		}		MapScreenToGroup(Center.x, Center.y, pGroup);		for(int l = 0; l < pGroup->m_NumLayers; l++)		{			CMapItemLayer *pLayer = pLayers->GetLayer(pGroup->m_StartLayer+l);			bool Render = false;			bool IsGameLayer = false;			if(pLayer == (CMapItemLayer*)pLayers->GameLayer())			{				IsGameLayer = true;				PassedGameLayer = 1;			}			// skip rendering if detail layers if not wanted			if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))				continue;			if(m_Type == -1)				Render = true;			else if(m_Type == 0)			{				if(PassedGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))					return;				Render = true;			}			else			{				if(PassedGameLayer && !IsGameLayer)					Render = true;			}			if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))			{				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;				CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTMap->m_Data);				CServerInfo CurrentServerInfo;				Client()->GetServerInfo(&CurrentServerInfo);				char aFilename[256];				str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);				IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);				if(File)				{					for(int y = 0; y < pTMap->m_Height; y++)					{						for(int x = 0; x < pTMap->m_Width; x++)							io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));						io_write_newline(File);					}					io_close(File);				}			}			if(Render && !IsGameLayer)			{				//layershot_begin();				if(pLayer->m_Type == LAYERTYPE_TILES)//.........这里部分代码省略.........
开发者ID:4a4ik,项目名称:teeworlds,代码行数:101,


示例7: PROFILE_FUNCTION

void TSRAlphaPass::SubmitRendering( vector< TSRSceneEntity* >& _renderables ){    PROFILE_FUNCTION( "Alpha Pass" );    Graphics()->SetDepthStencilState( Graphics()->m_DepthTestEnabledWriteDisabled );    Graphics()->CopyBackBufferToTexture( *m_pBackBufferTarget );     // now the screen texture is the back buffer copy    TSRGlobalConstants.m_BackBuferTexture.Set( *m_pBackBufferTarget );    Graphics()->SetCurrentPass( TWISTER_PASS_ALPHA );  //  LightsManager()->GenerateLightingContexts();    LightsManager()->SetShaderConstants();//	if ( KEYUP( 'P' ) )	{		m_pWorld->RenderObjectsAlpha( m_pWorld->GetMainCamera() );	}//#define LINES_TEST#ifdef LINES_TEST	Graphics()->SetBlendState( Graphics()->m_BlendAdditiveSrcAlphaInvSrcAlpha );	TSRMaterial whiteMaterial;	TSRGlobalConstants.SetMaterial( whiteMaterial );	float fStartX = -400.0f;	float fStartY = -400.0f;	float fEndX = 400.0f;	float fEndY = 400.0f;	unsigned int iNumGridLinesX = 20;	unsigned int iNumGridLinesY = 20;	float fStepX = (fEndX - fStartX) / iNumGridLinesX;	float fStepY = (fEndY - fStartY) / iNumGridLinesY;	bool bRealLines = false;//	Graphics()->SetRasterizerState( Graphics()->m_FillDoubleSidedState );	//Graphics()->SetDepthStencilState( Graphics()->m_DefaultDepthStencilState );	if ( bRealLines )	{		TSRImmediateDraw::Begin( TWISTER_RENDERMODE_LINELIST );		TSRImmediateDraw::Color4f( 1.0f, 1.0f, 1.0f, 1.0f );		for (unsigned int i = 0; i < iNumGridLinesX; i++)		{			TSRImmediateDraw::Vertex3f( fStartX + (i)* fStepX, fStartY, 0.0f );			TSRImmediateDraw::Vertex3f( fStartX + (i)* fStepX, fEndY, 0.0f );		}		for (unsigned int i = 0; i < iNumGridLinesY; i++)		{			TSRImmediateDraw::Vertex3f( fStartX, fStartY + i * fStepY, 0.0f );			TSRImmediateDraw::Vertex3f( fEndX, fStartY + i * fStepY, 0.0f );		}		TSRImmediateDraw::End();//( Graphics()->m_pVertexColorShader );	}	else	{		static float fLineWidth = 1.0f;		TSRImmediateDraw::BeginLines( fLineWidth + 3.0f );		TSRImmediateDraw::LineColor4f( 1.0f, 1.0f, 1.0f, 1.0f );		for (unsigned int i = 0; i < iNumGridLinesX; i++)		{			TSRImmediateDraw::LineVertex3f( fStartX + (i)* fStepX, fStartY, 0.0f );			TSRImmediateDraw::LineVertex3f( fStartX + (i)* fStepX, fEndY, 0.0f );		}		for (unsigned int i = 0; i < iNumGridLinesY; i++)		{			TSRImmediateDraw::LineVertex3f( fStartX, fStartY + i * fStepY, 0.0f );			TSRImmediateDraw::LineVertex3f( fEndX, fStartY + i * fStepY, 0.0f );		}		TSRImmediateDraw::EndLines();//( Graphics()->m_pVertexColorShader );	}#endif    if ( Graphics()->GetCurrentPass() == TWISTER_PASS_ALPHA && m_pBackBufferTarget )    {        // now the screen texture is the back buffer copy        Graphics()->CopyBackBufferToTexture( *m_pBackBufferTarget );        TSRGlobalConstants.m_BackBuferTexture.Set( *m_pBackBufferTarget );    }}
开发者ID:ShadyEM,项目名称:Twister3D,代码行数:85,


示例8: vec4

void CPlayers::RenderHook(	const CNetObj_Character *pPrevChar,	const CNetObj_Character *pPlayerChar,	const CNetObj_PlayerInfo *pPrevInfo,	const CNetObj_PlayerInfo *pPlayerInfo	){	CNetObj_Character Prev;	CNetObj_Character Player;	Prev = *pPrevChar;	Player = *pPlayerChar;	CNetObj_PlayerInfo pInfo = *pPlayerInfo;	CTeeRenderInfo RenderInfo = m_pClient->m_aClients[pInfo.m_ClientId].m_RenderInfo;	// check for teamplay modes	bool IsTeamplay = false;	if(m_pClient->m_Snap.m_pGameobj)		IsTeamplay = (m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS) != 0;	// check for ninja		if (Player.m_Weapon == WEAPON_NINJA)	{		// change the skin for the player to the ninja		int Skin = m_pClient->m_pSkins->Find("x_ninja");		if(Skin != -1)		{			if(IsTeamplay)				RenderInfo.m_Texture = m_pClient->m_pSkins->Get(Skin)->m_ColorTexture;			else			{				RenderInfo.m_Texture = m_pClient->m_pSkins->Get(Skin)->m_OrgTexture;				RenderInfo.m_ColorBody = vec4(1,1,1,1);				RenderInfo.m_ColorFeet = vec4(1,1,1,1);			}		}		}	float IntraTick = Client()->IntraGameTick();	if(Player.m_Health < 0) // dont render dead players		return;	// set size	RenderInfo.m_Size = 64.0f;		// use preditect players if needed	if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)	{		if(!m_pClient->m_Snap.m_pLocalCharacter || (m_pClient->m_Snap.m_pLocalCharacter->m_Health < 0) || (m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver))		{		}		else		{			// apply predicted results			m_pClient->m_PredictedChar.Write(&Player);			m_pClient->m_PredictedPrevChar.Write(&Prev);			IntraTick = Client()->PredIntraGameTick();		}	}	vec2 Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);	if(Prev.m_Health < 0) // Don't flicker from previous position		Position = vec2(Player.m_X, Player.m_Y);	// draw hook	if (Prev.m_HookState>0 && Player.m_HookState>0)	{		Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);		Graphics()->QuadsBegin();		//Graphics()->QuadsBegin();		vec2 Pos = Position;		vec2 HookPos;				if(pPlayerChar->m_HookedPlayer != -1)		{			if(m_pClient->m_Snap.m_pLocalInfo && pPlayerChar->m_HookedPlayer == m_pClient->m_Snap.m_pLocalInfo->m_ClientId)			{				if(Client()->State() == IClient::STATE_DEMOPLAYBACK) // only use prediction if needed					HookPos = vec2(m_pClient->m_LocalCharacterPos.x, m_pClient->m_LocalCharacterPos.y);				else					HookPos = mix(vec2(m_pClient->m_PredictedPrevChar.m_Pos.x, m_pClient->m_PredictedPrevChar.m_Pos.y),						vec2(m_pClient->m_PredictedChar.m_Pos.x, m_pClient->m_PredictedChar.m_Pos.y), Client()->PredIntraGameTick());			}			else				HookPos = mix(vec2(pPrevChar->m_HookX, pPrevChar->m_HookY), vec2(pPlayerChar->m_HookX, pPlayerChar->m_HookY), Client()->IntraGameTick());		}		else			HookPos = mix(vec2(Prev.m_HookX, Prev.m_HookY), vec2(Player.m_HookX, Player.m_HookY), IntraTick);		float d = distance(Pos, HookPos);		vec2 Dir = normalize(Pos-HookPos);		Graphics()->QuadsSetRotation(GetAngle(Dir)+pi);		// render head		RenderTools()->SelectSprite(SPRITE_HOOK_HEAD);//.........这里部分代码省略.........
开发者ID:wthnonck,项目名称:tdtw,代码行数:101,


示例9: Graphics

void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos, bool Alpha){    vec2 Direction = Dir;    vec2 Position = Pos;    //Graphics()->TextureSet(data->images[IMAGE_CHAR_DEFAULT].id);    Graphics()->TextureSet(pInfo->m_Texture);    // TODO: FIX ME    Graphics()->QuadsBegin();    //Graphics()->QuadsDraw(pos.x, pos.y-128, 128, 128);    // first pass we draw the outline    // second pass we draw the filling    for(int p = 0; p < 2; p++)    {        int OutLine = p==0 ? 1 : 0;        for(int f = 0; f < 2; f++)        {            float AnimScale = pInfo->m_Size * 1.0f/64.0f;            float BaseSize = pInfo->m_Size;            if(f == 1)            {                Graphics()->QuadsSetRotation(pAnim->GetBody()->m_Angle*pi*2);                // draw body                if(Alpha)                    Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, pInfo->m_ColorBody.a);                else                    Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, 1.0f);                vec2 BodyPos = Position + vec2(pAnim->GetBody()->m_X, pAnim->GetBody()->m_Y)*AnimScale;                SelectSprite(OutLine?SPRITE_TEE_BODY_OUTLINE:SPRITE_TEE_BODY, 0, 0, 0);                IGraphics::CQuadItem QuadItem(BodyPos.x, BodyPos.y, BaseSize, BaseSize);                Graphics()->QuadsDraw(&QuadItem, 1);                // draw eyes                if(p == 1)                {                    switch (Emote)                    {                    case EMOTE_PAIN:                        SelectSprite(SPRITE_TEE_EYE_PAIN, 0, 0, 0);                        break;                    case EMOTE_HAPPY:                        SelectSprite(SPRITE_TEE_EYE_HAPPY, 0, 0, 0);                        break;                    case EMOTE_SURPRISE:                        SelectSprite(SPRITE_TEE_EYE_SURPRISE, 0, 0, 0);                        break;                    case EMOTE_ANGRY:                        SelectSprite(SPRITE_TEE_EYE_ANGRY, 0, 0, 0);                        break;                    default:                        SelectSprite(SPRITE_TEE_EYE_NORMAL, 0, 0, 0);                        break;                    }                    float EyeScale = BaseSize*0.40f;                    float h = Emote == EMOTE_BLINK ? BaseSize*0.15f : EyeScale;                    float EyeSeparation = (0.075f - 0.010f*absolute(Direction.x))*BaseSize;                    vec2 Offset = vec2(Direction.x*0.125f, -0.05f+Direction.y*0.10f)*BaseSize;                    IGraphics::CQuadItem Array[2] = {                        IGraphics::CQuadItem(BodyPos.x-EyeSeparation+Offset.x, BodyPos.y+Offset.y, EyeScale, h),                        IGraphics::CQuadItem(BodyPos.x+EyeSeparation+Offset.x, BodyPos.y+Offset.y, -EyeScale, h)                    };                    Graphics()->QuadsDraw(Array, 2);                }            }            // draw feet            CAnimKeyframe *pFoot = f ? pAnim->GetFrontFoot() : pAnim->GetBackFoot();            float w = BaseSize;            float h = BaseSize/2;            Graphics()->QuadsSetRotation(pFoot->m_Angle*pi*2);            bool Indicate = !pInfo->m_GotAirJump && g_Config.m_ClAirjumpindicator;            float cs = 1.0f; // color scale            if(OutLine)                SelectSprite(SPRITE_TEE_FOOT_OUTLINE, 0, 0, 0);            else            {                SelectSprite(SPRITE_TEE_FOOT, 0, 0, 0);                if(Indicate)                    cs = 0.5f;            }            if(Alpha)                Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, pInfo->m_ColorFeet.a*cs);            else                Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, 1.0f);            IGraphics::CQuadItem QuadItem(Position.x+pFoot->m_X*AnimScale, Position.y+pFoot->m_Y*AnimScale, w, h);            Graphics()->QuadsDraw(&QuadItem, 1);        }    }//.........这里部分代码省略.........
开发者ID:Ameb,项目名称:ddnet,代码行数:101,


示例10: if

void CMapLayers::OnRender(){	if (Client()->State() != IClient::STATE_OFFLINE && Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)		return;    else if (Client()->State() == IClient::STATE_OFFLINE && !Client()->BackgroundLoaded())        return;	CUIRect Screen;	Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);	vec2 Center = m_pClient->m_pCamera->m_Center;	//float center_x = gameclient.camera->center.x;	//float center_y = gameclient.camera->center.y;    CMapItemLayerTilemap *pGTMap = m_pLayers->GameLayer();    CTile *pGameTiles = (CTile *)m_pLayers->Map()->GetData(pGTMap->m_Data);	bool PassedGameLayer = false;	for(int g = 0; g < m_pLayers->NumGroups(); g++)	{		CMapItemGroup *pGroup = m_pLayers->GetGroup(g);		if (!pGroup)            continue;		if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)		{			// set clipping			float Points[4];			MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup());			Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);			float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);			float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);			float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);			float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);			Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));		}		MapScreenToGroup(Center.x, Center.y, pGroup, g==0);		for(int l = 0; l < pGroup->m_NumLayers; l++)		{			CMapItemLayer *pLayer = m_pLayers->GetLayer(pGroup->m_StartLayer+l);			bool Render = false;			bool IsGameLayer = false;			if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer())			{				IsGameLayer = true;				PassedGameLayer = 1;			}			// skip rendering if detail layers if not wanted			if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer)				continue;			if(m_Type == -1)				Render = true;			else if(m_Type == 0)			{				if(PassedGameLayer)					return;				Render = true;			}			else			{				if(PassedGameLayer && !IsGameLayer)					Render = true;			}			if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))			{				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;				CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);				CServerInfo CurrentServerInfo;				Client()->GetServerInfo(&CurrentServerInfo);				char aFilename[256];				str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);				IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorageTW::TYPE_SAVE);				if(File)				{					#if defined(CONF_FAMILY_WINDOWS)						static const char Newline[] = "/r/n";					#else						static const char Newline[] = "/n";					#endif					for(int y = 0; y < pTMap->m_Height; y++)					{						for(int x = 0; x < pTMap->m_Width; x++)							io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));						io_write(File, Newline, sizeof(Newline)-1);					}					io_close(File);				}			}			if(Render && !IsGameLayer)			{				//layershot_begin();//.........这里部分代码省略.........
开发者ID:def-,项目名称:HClient,代码行数:101,


示例11: Say

void CChat::OnRender(){	if (!g_Config.m_ClShowChat)		return;	// send pending chat messages	if(m_PendingChatCounter > 0 && m_LastChatSend+time_freq() < time_get())	{		CHistoryEntry *pEntry = m_History.Last();		for(int i = m_PendingChatCounter-1; pEntry; --i, pEntry = m_History.Prev(pEntry))		{			if(i == 0)			{				Say(pEntry->m_Team, pEntry->m_aText);				break;			}		}		--m_PendingChatCounter;	}	float Width = 300.0f*Graphics()->ScreenAspect();	Graphics()->MapScreen(0.0f, 0.0f, Width, 300.0f);	float x = 5.0f;	float y = 300.0f-20.0f;	if(m_Mode != MODE_NONE)	{		// render chat input		CTextCursor Cursor;		TextRender()->SetCursor(&Cursor, x, y, 8.0f, TEXTFLAG_RENDER);		Cursor.m_LineWidth = Width-190.0f;		Cursor.m_MaxLines = 2;		if(m_Mode == MODE_ALL)			TextRender()->TextEx(&Cursor, Localize("All"), -1);		else if(m_Mode == MODE_TEAM)			TextRender()->TextEx(&Cursor, Localize("Team"), -1);		else			TextRender()->TextEx(&Cursor, Localize("Chat"), -1);		TextRender()->TextEx(&Cursor, ": ", -1);		// check if the visible text has to be moved		if(m_InputUpdate)		{			if(m_ChatStringOffset > 0 && m_Input.GetLength() < m_OldChatStringLength)				m_ChatStringOffset = max(0, m_ChatStringOffset-(m_OldChatStringLength-m_Input.GetLength()));			if(m_ChatStringOffset > m_Input.GetCursorOffset())				m_ChatStringOffset -= m_ChatStringOffset-m_Input.GetCursorOffset();			else			{				CTextCursor Temp = Cursor;				Temp.m_Flags = 0;				TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset);				TextRender()->TextEx(&Temp, "|", -1);				while(Temp.m_LineCount > 2)				{					++m_ChatStringOffset;					Temp = Cursor;					Temp.m_Flags = 0;					TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset);					TextRender()->TextEx(&Temp, "|", -1);				}			}			m_InputUpdate = false;		}		TextRender()->TextEx(&Cursor, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset);		static float MarkerOffset = TextRender()->TextWidth(0, 8.0f, "|", -1)/3;		CTextCursor Marker = Cursor;		Marker.m_X -= MarkerOffset;		TextRender()->TextEx(&Marker, "|", -1);		TextRender()->TextEx(&Cursor, m_Input.GetString()+m_Input.GetCursorOffset(), -1);	}	y -= 8.0f;#if defined(__ANDROID__)	x += 120.0f;#endif	int64 Now = time_get();	float LineWidth = m_pClient->m_pScoreboard->Active() ? 90.0f : 200.0f;	float HeightLimit = m_pClient->m_pScoreboard->Active() ? 230.0f : m_Show ? 50.0f : 200.0f;	float Begin = x;#if defined(__ANDROID__)	float FontSize = 10.0f;#else	float FontSize = 6.0f;#endif	CTextCursor Cursor;	int OffsetType = m_pClient->m_pScoreboard->Active() ? 1 : 0;	for(int i = 0; i < MAX_LINES; i++)	{		int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES;		if(Now > m_aLines[r].m_Time+16*time_freq() && !m_Show)			break;		// get the y offset (calculate it if we haven't done that yet)		if(m_aLines[r].m_YOffset[OffsetType] < 0.0f)		{//.........这里部分代码省略.........
开发者ID:hamidkag,项目名称:TBlock,代码行数:101,


示例12: while

//.........这里部分代码省略.........			// on demo playback use local id from snap directly,			// since m_LocalIDs isn't valid there			if (LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName))				Highlighted = true;		}		m_aLines[m_CurrentLine].m_Highlighted = Highlighted;		if(ClientID == -1) // server message		{			str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName));			str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine);		}		else		{			if(m_pClient->m_aClients[ClientID].m_Team == TEAM_SPECTATORS)				m_aLines[m_CurrentLine].m_NameColor = TEAM_SPECTATORS;			if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS)			{				if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED)					m_aLines[m_CurrentLine].m_NameColor = TEAM_RED;				else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE)					m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE;			}			if (Team == 2) // whisper send			{				str_format(m_aLines[m_CurrentLine].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName), "→ %s", m_pClient->m_aClients[ClientID].m_aName);				m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE;				m_aLines[m_CurrentLine].m_Highlighted = false;				m_aLines[m_CurrentLine].m_Team = 0;				Highlighted = false;			}			else if (Team == 3) // whisper recv			{				str_format(m_aLines[m_CurrentLine].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName), "← %s", m_pClient->m_aClients[ClientID].m_aName);				m_aLines[m_CurrentLine].m_NameColor = TEAM_RED;				m_aLines[m_CurrentLine].m_Highlighted = true;				m_aLines[m_CurrentLine].m_Team = 0;				Highlighted = true;			}			else			{				str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientID].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName));			}			str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine);		}		char aBuf[1024];		str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);		Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, Team >= 2?"whisper":(m_aLines[m_CurrentLine].m_Team?"teamchat":"chat"), aBuf, Highlighted);	}	// play sound	int64 Now = time_get();	if(ClientID == -1)	{		if(Now-m_aLastSoundPlayed[CHAT_SERVER] >= time_freq()*3/10)		{			if(g_Config.m_SndServerMessage)			{				m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0);				m_aLastSoundPlayed[CHAT_SERVER] = Now;			}		}	}	else if(Highlighted)	{		if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10)		{#ifdef CONF_PLATFORM_MACOSX			char aBuf[1024];			str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);			CNotification::notify("DDNet-Chat", aBuf);#else			Graphics()->NotifyWindow();#endif			if(g_Config.m_SndHighlight)			{				m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0);				m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;			}		}	}	else if(Team != 2)	{		if(Now-m_aLastSoundPlayed[CHAT_CLIENT] >= time_freq()*3/10)		{			if ((g_Config.m_SndTeamChat || !m_aLines[m_CurrentLine].m_Team)				&& (g_Config.m_SndChat || m_aLines[m_CurrentLine].m_Team))			{				m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0);				m_aLastSoundPlayed[CHAT_CLIENT] = Now;			}		}	}}
开发者ID:hamidkag,项目名称:TBlock,代码行数:101,


示例13: Say

void CChat::OnRender(){	// send pending chat messages	if(m_PendingChatCounter > 0 && m_LastChatSend+time_freq() < time_get())	{		CHistoryEntry *pEntry = m_History.Last();		for(int i = m_PendingChatCounter-1; pEntry; --i, pEntry = m_History.Prev(pEntry))		{			if(i == 0)			{				Say(pEntry->m_Team, pEntry->m_aText);				break;			}		}		--m_PendingChatCounter;	}	// dont render chat if the menu is active	if(m_pClient->m_pMenus->IsActive())		return;	float Width = 300.0f*Graphics()->ScreenAspect();	Graphics()->MapScreen(0.0f, 0.0f, Width, 300.0f);	float x = 5.0f;	float y = 300.0f-20.0f;	if(m_Mode != MODE_NONE)	{		// render chat input		CTextCursor Cursor;		TextRender()->SetCursor(&Cursor, x, y, 8.0f, TEXTFLAG_RENDER);		Cursor.m_LineWidth = Width-190.0f;		Cursor.m_MaxLines = 2;		if(m_Mode == MODE_ALL)			TextRender()->TextEx(&Cursor, Localize("All"), -1);		else if(m_Mode == MODE_TEAM)			TextRender()->TextEx(&Cursor, Localize("Team"), -1);		else			TextRender()->TextEx(&Cursor, Localize("Chat"), -1);		TextRender()->TextEx(&Cursor, ": ", -1);		// check if the visible text has to be moved		if(m_InputUpdate)		{			if(m_ChatStringOffset > 0 && m_Input.GetLength() < m_OldChatStringLength)				m_ChatStringOffset = max(0, m_ChatStringOffset-(m_OldChatStringLength-m_Input.GetLength()));			if(m_ChatStringOffset > m_Input.GetCursorOffset())				m_ChatStringOffset -= m_ChatStringOffset-m_Input.GetCursorOffset();			else			{				CTextCursor Temp = Cursor;				Temp.m_Flags = 0;				TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset);				TextRender()->TextEx(&Temp, "|", -1);				while(Temp.m_LineCount > 2)				{					++m_ChatStringOffset;					Temp = Cursor;					Temp.m_Flags = 0;					TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset);					TextRender()->TextEx(&Temp, "|", -1);				}			}			m_InputUpdate = false;		}		TextRender()->TextEx(&Cursor, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset);		static float MarkerOffset = TextRender()->TextWidth(0, 8.0f, "|", -1)/3;		CTextCursor Marker = Cursor;		Marker.m_X -= MarkerOffset;		TextRender()->TextEx(&Marker, "|", -1);		TextRender()->TextEx(&Cursor, m_Input.GetString()+m_Input.GetCursorOffset(), -1);	}	y -= 8.0f;	int64 Now = time_get();	float LineWidth = m_pClient->m_pScoreboard->Active() ? 90.0f : 200.0f;	float HeightLimit = m_pClient->m_pScoreboard->Active() ? 230.0f : m_Show ? 50.0f : 200.0f;	float Begin = x;	float FontSize = 6.0f;	CTextCursor Cursor;	int OffsetType = m_pClient->m_pScoreboard->Active() ? 1 : 0;	for(int i = 0; i < MAX_LINES; i++)	{		int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES;		if(Now > m_aLines[r].m_Time+16*time_freq() && !m_Show)			break;		// get the y offset (calculate it if we haven't done that yet)		if(m_aLines[r].m_YOffset[OffsetType] < 0.0f)		{			TextRender()->SetCursor(&Cursor, Begin, 0.0f, FontSize, 0);			Cursor.m_LineWidth = LineWidth;			TextRender()->TextEx(&Cursor, m_aLines[r].m_aName, -1);			TextRender()->TextEx(&Cursor, m_aLines[r].m_aText, -1);			m_aLines[r].m_YOffset[OffsetType] = Cursor.m_Y + Cursor.m_FontSize;		}//.........这里部分代码省略.........
开发者ID:Mailaender,项目名称:teeworlds,代码行数:101,


示例14: str_format

//.........这里部分代码省略.........                UI()->DoLabelScaled(&Text, paParts[i], 14.0f, -1);                int PrevColor = *paColors[i];                int Color = 0;                for(int s = 0; s < 3; s++)                {                    CUIRect Text;                    RightView.HSplitTop(19.0f, &Button, &RightView);                    Button.VSplitLeft(30.0f, 0, &Button);                    Button.VSplitLeft(70.0f, &Text, &Button);                    Button.VSplitRight(5.0f, &Button, 0);                    Button.HSplitTop(4.0f, 0, &Button);                    float k = ((PrevColor>>((2-s)*8))&0xff)  / 255.0f;                    k = DoScrollbarH(&s_aColorSlider[i][s], &Button, k);                    Color <<= 8;                    Color += clamp((int)(k*255), 0, 255);                    UI()->DoLabelScaled(&Text, paLabels[s], 15.0f, -1);                }                if(*paColors[i] != Color)                    m_NeedSendinfo = true;                *paColors[i] = Color;                RightView.HSplitTop(5.0f, 0, &RightView);            }        }        MainView.HSplitTop(MainView.h/2, 0, &MainView);        // render skinselector        static bool s_InitSkinlist = true;        static sorted_array<const CSkins::CSkin *> s_paSkinList;        static float s_ScrollValue = 0;        if(s_InitSkinlist)        {            s_paSkinList.clear();            for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i)            {                const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);                // no special skins                if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')                    continue;                s_paSkinList.add(s);            }            s_InitSkinlist = false;        }        int OldSelected = -1;        UiDoListboxStart(&s_InitSkinlist, &MainView, 50.0f, Localize("Skins"), "", s_paSkinList.size(), 4, OldSelected, s_ScrollValue);        for(int i = 0; i < s_paSkinList.size(); ++i)        {            const CSkins::CSkin *s = s_paSkinList[i];            if(s == 0)                continue;            if(str_comp(s->m_aName, g_Config.m_PlayerSkin) == 0)                OldSelected = i;            CListboxItem Item = UiDoListboxNextItem(&s_paSkinList[i], OldSelected == i);            if(Item.m_Visible)            {                CTeeRenderInfo Info;                Info.m_Texture = s->m_OrgTexture;                Info.m_ColorBody = vec4(1, 1, 1, 1);                Info.m_ColorFeet = vec4(1, 1, 1, 1);                if(g_Config.m_PlayerUseCustomColor)                {                    Info.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody);                    Info.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet);                    Info.m_Texture = s->m_ColorTexture;                }                Info.m_Size = UI()->Scale()*50.0f;                Item.m_Rect.HSplitTop(5.0f, 0, &Item.m_Rect); // some margin from the top                RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, 0, vec2(1, 0), vec2(Item.m_Rect.x+Item.m_Rect.w/2, Item.m_Rect.y+Item.m_Rect.h/2));                if(g_Config.m_Debug)                {                    vec3 BloodColor = g_Config.m_PlayerUseCustomColor ? m_pClient->m_pSkins->GetColorV3(g_Config.m_PlayerColorBody) : s->m_BloodColor;                    Graphics()->TextureSet(-1);                    Graphics()->QuadsBegin();                    Graphics()->SetColor(BloodColor.r, BloodColor.g, BloodColor.b, 1.0f);                    IGraphics::CQuadItem QuadItem(Item.m_Rect.x, Item.m_Rect.y, 12, 12);                    Graphics()->QuadsDrawTL(&QuadItem, 1);                    Graphics()->QuadsEnd();                }            }        }        const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);        if(OldSelected != NewSelected)        {            mem_copy(g_Config.m_PlayerSkin, s_paSkinList[NewSelected]->m_aName, sizeof(g_Config.m_PlayerSkin));            m_NeedSendinfo = true;        }    }
开发者ID:ReDFoX43rus,项目名称:AiP-DDRace,代码行数:101,


示例15: QuadItem

void CRenderTools::DrawSprite(float x, float y, float Size){    IGraphics::CQuadItem QuadItem(x, y, Size*gs_SpriteWScale, Size*gs_SpriteHScale);    Graphics()->QuadsDraw(&QuadItem, 1);}
开发者ID:Ameb,项目名称:ddnet,代码行数:5,


示例16: str_format

void CHud::RenderScoreHud(){	// render small score hud	if(!(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))	{		int GameFlags = m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags;		float Whole = 300*Graphics()->ScreenAspect();		float StartY = 229.0f;		if(GameFlags&GAMEFLAG_TEAMS && m_pClient->m_Snap.m_pGameDataObj)		{			char aScoreTeam[2][32];			str_format(aScoreTeam[TEAM_RED], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed);			str_format(aScoreTeam[TEAM_BLUE], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue);			float aScoreTeamWidth[2] = { TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_RED], -1), TextRender()->TextWidth(0, 14.0f, aScoreTeam[TEAM_BLUE], -1) };			int FlagCarrier[2] = { m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierRed, m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue };			float ScoreWidthMax = max(max(aScoreTeamWidth[TEAM_RED], aScoreTeamWidth[TEAM_BLUE]), TextRender()->TextWidth(0, 14.0f, "100", -1));			float Split = 3.0f;			float ImageSize = GameFlags&GAMEFLAG_FLAGS ? 16.0f : Split;			for(int t = 0; t < 2; t++)			{				// draw box				Graphics()->BlendNormal();				Graphics()->TextureSet(-1);				Graphics()->QuadsBegin();				if(t == 0)					Graphics()->SetColor(1.0f, 0.0f, 0.0f, 0.25f);				else					Graphics()->SetColor(0.0f, 0.0f, 1.0f, 0.25f);				RenderTools()->DrawRoundRectExt(Whole-ScoreWidthMax-ImageSize-2*Split, StartY+t*20, ScoreWidthMax+ImageSize+2*Split, 18.0f, 5.0f, CUI::CORNER_L);				Graphics()->QuadsEnd();				// draw score				TextRender()->Text(0, Whole-ScoreWidthMax+(ScoreWidthMax-aScoreTeamWidth[t])/2-Split, StartY+t*20, 14.0f, aScoreTeam[t], -1);				if(GameFlags&GAMEFLAG_FLAGS)				{					int BlinkTimer = (m_pClient->m_FlagDropTick[t] != 0 &&										(Client()->GameTick()-m_pClient->m_FlagDropTick[t])/Client()->GameTickSpeed() >= 25) ? 10 : 20;					if(FlagCarrier[t] == FLAG_ATSTAND || (FlagCarrier[t] == FLAG_TAKEN && ((Client()->GameTick()/BlinkTimer)&1)))					{						// draw flag						Graphics()->BlendNormal();						Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);						Graphics()->QuadsBegin();						RenderTools()->SelectSprite(t==0?SPRITE_FLAG_RED:SPRITE_FLAG_BLUE);						IGraphics::CQuadItem QuadItem(Whole-ScoreWidthMax-ImageSize, StartY+1.0f+t*20, ImageSize/2, ImageSize);						Graphics()->QuadsDrawTL(&QuadItem, 1);						Graphics()->QuadsEnd();					}					else if(FlagCarrier[t] >= 0)					{						// draw name of the flag holder						int ID = FlagCarrier[t]%MAX_CLIENTS;						const char *pName = m_pClient->m_aClients[ID].m_aName;						float w = TextRender()->TextWidth(0, 8.0f, pName, -1);						TextRender()->Text(0, min(Whole-w-1.0f, Whole-ScoreWidthMax-ImageSize-2*Split), StartY+(t+1)*20.0f-3.0f, 8.0f, pName, -1);						// draw tee of the flag holder						CTeeRenderInfo Info = m_pClient->m_aClients[ID].m_RenderInfo;						Info.m_Size = 18.0f;						RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1,0),							vec2(Whole-ScoreWidthMax-Info.m_Size/2-Split, StartY+1.0f+Info.m_Size/2+t*20));					}				}				StartY += 8.0f;			}		}		else		{			int Local = -1;			int aPos[2] = { 1, 2 };			const CNetObj_PlayerInfo *apPlayerInfo[2] = { 0, 0 };			int i = 0;			for(int t = 0; t < 2 && i < MAX_CLIENTS && m_pClient->m_Snap.m_paInfoByScore[i]; ++i)			{				if(m_pClient->m_Snap.m_paInfoByScore[i]->m_Team != TEAM_SPECTATORS)				{					apPlayerInfo[t] = m_pClient->m_Snap.m_paInfoByScore[i];					if(apPlayerInfo[t]->m_ClientID == m_pClient->m_Snap.m_LocalClientID)						Local = t;					++t;				}			}			// search local player info if not a spectator, nor within top2 scores			if(Local == -1 && m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS)			{				for(; i < MAX_CLIENTS && m_pClient->m_Snap.m_paInfoByScore[i]; ++i)				{					if(m_pClient->m_Snap.m_paInfoByScore[i]->m_Team != TEAM_SPECTATORS)						++aPos[1];					if(m_pClient->m_Snap.m_paInfoByScore[i]->m_ClientID == m_pClient->m_Snap.m_LocalClientID)					{						apPlayerInfo[1] = m_pClient->m_Snap.m_paInfoByScore[i];						Local = 1;						break;					}				}			}//.........这里部分代码省略.........
开发者ID:paaszczak,项目名称:teeworlds-neural-network,代码行数:101,


示例17: cosf

void CRenderTools::DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners){    IGraphics::CFreeformItem ArrayF[32];    int NumItems = 0;    int Num = 8;    for(int i = 0; i < Num; i+=2)    {        float a1 = i/(float)Num * pi/2;        float a2 = (i+1)/(float)Num * pi/2;        float a3 = (i+2)/(float)Num * pi/2;        float Ca1 = cosf(a1);        float Ca2 = cosf(a2);        float Ca3 = cosf(a3);        float Sa1 = sinf(a1);        float Sa2 = sinf(a2);        float Sa3 = sinf(a3);        if(Corners&1) // TL            ArrayF[NumItems++] = IGraphics::CFreeformItem(                                     x+r, y+r,                                     x+(1-Ca1)*r, y+(1-Sa1)*r,                                     x+(1-Ca3)*r, y+(1-Sa3)*r,                                     x+(1-Ca2)*r, y+(1-Sa2)*r);        if(Corners&2) // TR            ArrayF[NumItems++] = IGraphics::CFreeformItem(                                     x+w-r, y+r,                                     x+w-r+Ca1*r, y+(1-Sa1)*r,                                     x+w-r+Ca3*r, y+(1-Sa3)*r,                                     x+w-r+Ca2*r, y+(1-Sa2)*r);        if(Corners&4) // BL            ArrayF[NumItems++] = IGraphics::CFreeformItem(                                     x+r, y+h-r,                                     x+(1-Ca1)*r, y+h-r+Sa1*r,                                     x+(1-Ca3)*r, y+h-r+Sa3*r,                                     x+(1-Ca2)*r, y+h-r+Sa2*r);        if(Corners&8) // BR            ArrayF[NumItems++] = IGraphics::CFreeformItem(                                     x+w-r, y+h-r,                                     x+w-r+Ca1*r, y+h-r+Sa1*r,                                     x+w-r+Ca3*r, y+h-r+Sa3*r,                                     x+w-r+Ca2*r, y+h-r+Sa2*r);    }    Graphics()->QuadsDrawFreeform(ArrayF, NumItems);    IGraphics::CQuadItem ArrayQ[9];    NumItems = 0;    ArrayQ[NumItems++] = IGraphics::CQuadItem(x+r, y+r, w-r*2, h-r*2); // center    ArrayQ[NumItems++] = IGraphics::CQuadItem(x+r, y, w-r*2, r); // top    ArrayQ[NumItems++] = IGraphics::CQuadItem(x+r, y+h-r, w-r*2, r); // bottom    ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y+r, r, h-r*2); // left    ArrayQ[NumItems++] = IGraphics::CQuadItem(x+w-r, y+r, r, h-r*2); // right    if(!(Corners&1)) ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y, r, r); // TL    if(!(Corners&2)) ArrayQ[NumItems++] = IGraphics::CQuadItem(x+w, y, -r, r); // TR    if(!(Corners&4)) ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y+h, r, -r); // BL    if(!(Corners&8)) ArrayQ[NumItems++] = IGraphics::CQuadItem(x+w, y+h, -r, -r); // BR    Graphics()->QuadsDrawTL(ArrayQ, NumItems);}
开发者ID:Ameb,项目名称:ddnet,代码行数:62,


示例18: Kernel

void CGameClient::OnConsoleInit(){	m_pEngine = Kernel()->RequestInterface<IEngine>();	m_pClient = Kernel()->RequestInterface<IClient>();	m_pGraphics = Kernel()->RequestInterface<IGraphics>();	m_pTextRender = Kernel()->RequestInterface<ITextRender>();	m_pSound = Kernel()->RequestInterface<ISound>();	m_pInput = Kernel()->RequestInterface<IInput>();	m_pConsole = Kernel()->RequestInterface<IConsole>();	m_pStorage = Kernel()->RequestInterface<IStorage>();	m_pDemoPlayer = Kernel()->RequestInterface<IDemoPlayer>();	m_pDemoRecorder = Kernel()->RequestInterface<IDemoRecorder>();	m_pServerBrowser = Kernel()->RequestInterface<IServerBrowser>();	m_pEditor = Kernel()->RequestInterface<IEditor>();	m_pFriends = Kernel()->RequestInterface<IFriends>();	// setup pointers	m_pBinds = &::gs_Binds;	m_pGameConsole = &::gs_GameConsole;	m_pParticles = &::gs_Particles;	m_pMenus = &::gs_Menus;	m_pSkins = &::gs_Skins;	m_pCountryFlags = &::gs_CountryFlags;	m_pChat = &::gs_Chat;	m_pFlow = &::gs_Flow;	m_pCamera = &::gs_Camera;	m_pControls = &::gs_Controls;	m_pEffects = &::gs_Effects;	m_pSounds = &::gs_Sounds;	m_pMotd = &::gs_Motd;	m_pDamageind = &::gsDamageInd;	m_pMapimages = &::gs_MapImages;	m_pVoting = &::gs_Voting;	m_pScoreboard = &::gs_Scoreboard;	m_pItems = &::gs_Items;	// make a list of all the systems, make sure to add them in the corrent render order	m_All.Add(m_pSkins);	m_All.Add(m_pCountryFlags);	m_All.Add(m_pMapimages);	m_All.Add(m_pEffects); // doesn't render anything, just updates effects	m_All.Add(m_pParticles);	m_All.Add(m_pBinds);	m_All.Add(m_pControls);	m_All.Add(m_pCamera);	m_All.Add(m_pSounds);	m_All.Add(m_pVoting);	m_All.Add(m_pParticles); // doesn't render anything, just updates all the particles	m_All.Add(&gs_MapLayersBackGround); // first to render	m_All.Add(&m_pParticles->m_RenderTrail);	m_All.Add(m_pItems);	m_All.Add(&gs_Players);	m_All.Add(&gs_MapLayersForeGround);	m_All.Add(&m_pParticles->m_RenderExplosions);	m_All.Add(&gs_NamePlates);	m_All.Add(&m_pParticles->m_RenderGeneral);	m_All.Add(m_pDamageind);	m_All.Add(&gs_Hud);	m_All.Add(&gs_Spectator);	m_All.Add(&gs_Emoticon);	m_All.Add(&gs_KillMessages);	m_All.Add(m_pChat);	m_All.Add(&gs_Broadcast);	m_All.Add(&gs_DebugHud);	m_All.Add(&gs_Scoreboard);	m_All.Add(m_pMotd);	m_All.Add(m_pMenus);	m_All.Add(m_pGameConsole);	// build the input stack	m_Input.Add(&m_pMenus->m_Binder); // this will take over all input when we want to bind a key	m_Input.Add(&m_pBinds->m_SpecialBinds);	m_Input.Add(m_pGameConsole);	m_Input.Add(m_pChat); // chat has higher prio due to tha you can quit it by pressing esc	m_Input.Add(m_pMotd); // for pressing esc to remove it	m_Input.Add(m_pMenus);	m_Input.Add(&gs_Spectator);	m_Input.Add(&gs_Emoticon);	m_Input.Add(m_pControls);	m_Input.Add(m_pBinds);	// add the some console commands	Console()->Register("team", "i", CFGFLAG_CLIENT, ConTeam, this, "Switch team");	Console()->Register("kill", "", CFGFLAG_CLIENT, ConKill, this, "Kill yourself");	// register server dummy commands for tab completion	Console()->Register("tune", "si", CFGFLAG_SERVER, 0, 0, "Tune variable to value");	Console()->Register("tune_reset", "", CFGFLAG_SERVER, 0, 0, "Reset tuning");	Console()->Register("tune_dump", "", CFGFLAG_SERVER, 0, 0, "Dump tuning");	Console()->Register("change_map", "?r", CFGFLAG_SERVER, 0, 0, "Change map");	Console()->Register("restart", "?i", CFGFLAG_SERVER, 0, 0, "Restart in x seconds");	Console()->Register("broadcast", "r", CFGFLAG_SERVER, 0, 0, "Broadcast message");	Console()->Register("say", "r", CFGFLAG_SERVER, 0, 0, "Say in chat");	Console()->Register("set_team", "ii?i", CFGFLAG_SERVER, 0, 0, "Set team of player to team");	Console()->Register("set_team_all", "i", CFGFLAG_SERVER, 0, 0, "Set team of all players to team");	Console()->Register("add_vote", "sr", CFGFLAG_SERVER, 0, 0, "Add a voting option");	Console()->Register("remove_vote", "s", CFGFLAG_SERVER, 0, 0, "remove a voting option");	Console()->Register("force_vote", "ss?r", CFGFLAG_SERVER, 0, 0, "Force a voting option");	Console()->Register("clear_votes", "", CFGFLAG_SERVER, 0, 0, "Clears the voting options");//.........这里部分代码省略.........
开发者ID:Milkax3,项目名称:TRP--TeeRolePlay-,代码行数:101,


示例19: render_background

void CMenus::OnRender(){	/*	// text rendering test stuff	render_background();	CTextCursor cursor;	TextRender()->SetCursor(&cursor, 10, 10, 20, TEXTFLAG_RENDER);	TextRender()->TextEx(&cursor, "ようこそ - ガイド", -1);	TextRender()->SetCursor(&cursor, 10, 30, 15, TEXTFLAG_RENDER);	TextRender()->TextEx(&cursor, "ようこそ - ガイド", -1);		//Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();	Graphics()->QuadsDrawTL(60, 60, 5000, 5000);	Graphics()->QuadsEnd();	return;*/		if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)		SetActive(true);	if(Client()->State() == IClient::STATE_DEMOPLAYBACK)	{		CUIRect Screen = *UI()->Screen();		Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);		RenderDemoPlayer(Screen);	}		if(Client()->State() == IClient::STATE_ONLINE && m_pClient->m_ServerMode == m_pClient->SERVERMODE_PUREMOD)	{		Client()->Disconnect();		SetActive(true);		m_Popup = POPUP_PURE;	}		if(!IsActive())	{		m_EscapePressed = false;		m_EnterPressed = false;		m_DeletePressed = false;		m_NumInputEvents = 0;		return;	}		// update colors	vec3 Rgb = HslToRgb(vec3(g_Config.m_UiColorHue/255.0f, g_Config.m_UiColorSat/255.0f, g_Config.m_UiColorLht/255.0f));	ms_GuiColor = vec4(Rgb.r, Rgb.g, Rgb.b, g_Config.m_UiColorAlpha/255.0f);	ms_ColorTabbarInactiveOutgame = vec4(0,0,0,0.25f);	ms_ColorTabbarActiveOutgame = vec4(0,0,0,0.5f);	float ColorIngameScaleI = 0.5f;	float ColorIngameAcaleA = 0.2f;	ms_ColorTabbarInactiveIngame = vec4(		ms_GuiColor.r*ColorIngameScaleI,		ms_GuiColor.g*ColorIngameScaleI,		ms_GuiColor.b*ColorIngameScaleI,		ms_GuiColor.a*0.8f);		ms_ColorTabbarActiveIngame = vec4(		ms_GuiColor.r*ColorIngameAcaleA,		ms_GuiColor.g*ColorIngameAcaleA,		ms_GuiColor.b*ColorIngameAcaleA,		ms_GuiColor.a);    	// update the ui	CUIRect *pScreen = UI()->Screen();	float mx = (m_MousePos.x/(float)Graphics()->ScreenWidth())*pScreen->w;	float my = (m_MousePos.y/(float)Graphics()->ScreenHeight())*pScreen->h;			int Buttons = 0;	if(m_UseMouseButtons)	{		if(Input()->KeyPressed(KEY_MOUSE_1)) Buttons |= 1;		if(Input()->KeyPressed(KEY_MOUSE_2)) Buttons |= 2;		if(Input()->KeyPressed(KEY_MOUSE_3)) Buttons |= 4;	}			UI()->Update(mx,my,mx*3.0f,my*3.0f,Buttons);    	// render	if(Client()->State() != IClient::STATE_DEMOPLAYBACK)		Render();	// render cursor	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CURSOR].m_Id);	Graphics()->QuadsBegin();	Graphics()->SetColor(1,1,1,1);	IGraphics::CQuadItem QuadItem(mx, my, 24, 24);	Graphics()->QuadsDrawTL(&QuadItem, 1);	Graphics()->QuadsEnd();	// render debug information	if(g_Config.m_Debug)	{		CUIRect Screen = *UI()->Screen();		Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);		char aBuf[512];//.........这里部分代码省略.........
开发者ID:DarkTwister,项目名称:TDTW-0.6-trunk,代码行数:101,


示例20: m_pWorld

TSRAlphaPass::TSRAlphaPass( TSRSceneWorldInterface* _pWorld ): m_pWorld( _pWorld ){    m_pBackBufferTarget = new TSRRenderTarget( Graphics()->m_uiWidth, Graphics()->m_uiHeight, TWISTER_TEXTUREFORMAT_A8R8G8B8 );}
开发者ID:ShadyEM,项目名称:Twister3D,代码行数:4,


示例21: Graphics

void CMenus::RenderBackground(){	//Graphics()->Clear(1,1,1);	//render_sunrays(0,0);	if(gs_TextureBlob == -1)		gs_TextureBlob = Graphics()->LoadTexture("blob.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);	float sw = 300*Graphics()->ScreenAspect();	float sh = 300;	Graphics()->MapScreen(0, 0, sw, sh);	// render background color	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();		//vec4 bottom(gui_color.r*0.3f, gui_color.g*0.3f, gui_color.b*0.3f, 1.0f);		//vec4 bottom(0, 0, 0, 1.0f);		vec4 Bottom(ms_GuiColor.r, ms_GuiColor.g, ms_GuiColor.b, 1.0f);		vec4 Top(ms_GuiColor.r, ms_GuiColor.g, ms_GuiColor.b, 1.0f);		IGraphics::CColorVertex Array[4] = {			IGraphics::CColorVertex(0, Top.r, Top.g, Top.b, Top.a),			IGraphics::CColorVertex(1, Top.r, Top.g, Top.b, Top.a),			IGraphics::CColorVertex(2, Bottom.r, Bottom.g, Bottom.b, Bottom.a),			IGraphics::CColorVertex(3, Bottom.r, Bottom.g, Bottom.b, Bottom.a)};		Graphics()->SetColorVertex(Array, 4);		IGraphics::CQuadItem QuadItem(0, 0, sw, sh);		Graphics()->QuadsDrawTL(&QuadItem, 1);	Graphics()->QuadsEnd();		// render the tiles	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();		float Size = 15.0f;		float OffsetTime = fmod(Client()->LocalTime()*0.15f, 2.0f);		for(int y = -2; y < (int)(sw/Size); y++)			for(int x = -2; x < (int)(sh/Size); x++)			{				Graphics()->SetColor(0,0,0,0.045f);				IGraphics::CQuadItem QuadItem((x-OffsetTime)*Size*2+(y&1)*Size, (y+OffsetTime)*Size, Size, Size);				Graphics()->QuadsDrawTL(&QuadItem, 1);			}	Graphics()->QuadsEnd();	// render border fade	Graphics()->TextureSet(gs_TextureBlob);	Graphics()->QuadsBegin();		Graphics()->SetColor(0,0,0,0.5f);		QuadItem = IGraphics::CQuadItem(-100, -100, sw+200, sh+200);		Graphics()->QuadsDrawTL(&QuadItem, 1);	Graphics()->QuadsEnd();	// restore screen	    {CUIRect Screen = *UI()->Screen();	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);}	}
开发者ID:DarkTwister,项目名称:TDTW-0.6-trunk,代码行数:55,


示例22: Graphics

void CMapLayers::OnRender(){	if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)		return;		CUIRect Screen;	Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);		vec2 Center = m_pClient->m_pCamera->m_Center;	//float center_x = gameclient.camera->center.x;	//float center_y = gameclient.camera->center.y;		bool PassedGameLayer = false;		for(int g = 0; g < m_pLayers->NumGroups(); g++)	{		CMapItemGroup *pGroup = m_pLayers->GetGroup(g);		if(!pGroup)		{			dbg_msg("MapLayers", "Error:Group was null, Group Number = %d, Total Groups = %d", g, m_pLayers->NumGroups());			dbg_msg("MapLayers", "This is here to prevent a crash but the source of this is unknown, please report this for it to get fixed");			dbg_msg("MapLayers", "we need mapname and crc and the map that caused this if possible, and anymore info you think is relevant");			continue;		}		if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)		{			// set clipping			float Points[4];			MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), m_pClient->m_pCamera->m_Zoom);			Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);			float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);			float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);			float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);			float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);						Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));		}						MapScreenToGroup(Center.x, Center.y, pGroup, m_pClient->m_pCamera->m_Zoom);				for(int l = 0; l < pGroup->m_NumLayers; l++)		{			CMapItemLayer *pLayer = m_pLayers->GetLayer(pGroup->m_StartLayer+l);			bool Render = false;			bool IsGameLayer = false;						if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer())			{				IsGameLayer = true;				PassedGameLayer = 1;			}						// skip rendering if detail layers if not wanted			if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer)				continue;							if(m_Type == -1)				Render = true;			else if(m_Type == 0)			{				if(PassedGameLayer)					return;				Render = true;			}			else			{				if(PassedGameLayer && !IsGameLayer)					Render = true;			}						if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))			{				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;				CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);				CServerInfo CurrentServerInfo;				Client()->GetServerInfo(&CurrentServerInfo);				char aFilename[256];				str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);				IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);				if(File)				{					#if defined(CONF_FAMILY_WINDOWS)						static const char Newline[] = "/r/n";					#else						static const char Newline[] = "/n";					#endif					for(int y = 0; y < pTMap->m_Height; y++)					{						for(int x = 0; x < pTMap->m_Width; x++)							io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));						io_write(File, Newline, sizeof(Newline)-1);					}					io_close(File);				}			}									if(Render && !IsGameLayer)//.........这里部分代码省略.........
开发者ID:EliteKuchen,项目名称:AiP-DDRace,代码行数:101,


示例23: time_get

void CMenus::RenderLoading(){	static int64 LastLoadRender = 0;	float Percent = m_LoadCurrent++/(float)m_LoadTotal;	// make sure that we don't render for each little thing we load	// because that will slow down loading if we have vsync	if(time_get()-LastLoadRender < time_freq()/60)		return;			LastLoadRender = time_get();		// need up date this here to get correct	vec3 Rgb = HslToRgb(vec3(g_Config.m_UiColorHue/255.0f, g_Config.m_UiColorSat/255.0f, g_Config.m_UiColorLht/255.0f));	ms_GuiColor = vec4(Rgb.r, Rgb.g, Rgb.b, g_Config.m_UiColorAlpha/255.0f);	    CUIRect Screen = *UI()->Screen();	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);	RenderBackground();	float tw;	float w = 700;	float h = 200;	float x = Screen.w/2-w/2;	float y = Screen.h/2-h/2;	Graphics()->BlendNormal();	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();	Graphics()->SetColor(0,0,0,0.50f);	RenderTools()->DrawRoundRect(x, y, w, h, 40.0f);	Graphics()->QuadsEnd();	const char *pCaption = Localize("Loading");	tw = TextRender()->TextWidth(0, 48.0f, pCaption, -1);	CUIRect r;	r.x = x;	r.y = y+20;	r.w = w;	r.h = h;	UI()->DoLabel(&r, pCaption, 48.0f, 0, -1);	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();	Graphics()->SetColor(1,1,1,0.75f);	RenderTools()->DrawRoundRect(x+40, y+h-75, (w-80)*Percent, 25, 5.0f);	Graphics()->QuadsEnd();	Graphics()->Swap();}
开发者ID:DarkTwister,项目名称:TDTW-0.6-trunk,代码行数:55,


示例24: Spectate

void CSpectator::OnRender(){	if(!m_Active)	{		if(m_WasActive)		{			if(m_SelectedSpectatorID != NO_SELECTION)				Spectate(m_SelectedSpectatorID);			m_WasActive = false;		}		return;	}	m_WasActive = true;	m_SelectedSpectatorID = NO_SELECTION;	// draw background	float Width = 400*3.0f*Graphics()->ScreenAspect();	float Height = 400*3.0f;	Graphics()->MapScreen(0, 0, Width, Height);	Graphics()->BlendNormal();	Graphics()->TextureSet(-1);	Graphics()->QuadsBegin();	Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f);	RenderTools()->DrawRoundRect(Width/2.0f-300.0f, Height/2.0f-300.0f, 600.0f, 600.0f, 20.0f);	Graphics()->QuadsEnd();	// clamp mouse position to selector area	m_SelectorMouse.x = clamp(m_SelectorMouse.x, -280.0f, 280.0f);	m_SelectorMouse.y = clamp(m_SelectorMouse.y, -280.0f, 280.0f);	// draw selections	float FontSize = 20.0f;	float StartY = -190.0f;	float LineHeight = 60.0f;	bool Selected = false;	if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)	{		Graphics()->TextureSet(-1);		Graphics()->QuadsBegin();		Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);		RenderTools()->DrawRoundRect(Width/2.0f-280.0f, Height/2.0f-280.0f, 270.0f, 60.0f, 20.0f);		Graphics()->QuadsEnd();	}	if(m_SelectorMouse.x >= -280.0f && m_SelectorMouse.x <= -10.0f &&		m_SelectorMouse.y >= -280.0f && m_SelectorMouse.y <= -220.0f)	{		m_SelectedSpectatorID = SPEC_FREEVIEW;		Selected = true;	}	TextRender()->TextColor(1.0f, 1.0f, 1.0f, Selected?1.0f:0.5f);	TextRender()->Text(0, Width/2.0f-240.0f, Height/2.0f-265.0f, FontSize, Localize("Free-View"), -1);	float x = -270.0f, y = StartY;	for(int i = 0, Count = 0; i < MAX_CLIENTS; ++i)	{		if(!m_pClient->m_Snap.m_paPlayerInfos[i] || m_pClient->m_Snap.m_paPlayerInfos[i]->m_Team == TEAM_SPECTATORS)			continue;		if(++Count%9 == 0)		{			x += 290.0f;			y = StartY;		}		if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == i)		{			Graphics()->TextureSet(-1);			Graphics()->QuadsBegin();			Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);			RenderTools()->DrawRoundRect(Width/2.0f+x-10.0f, Height/2.0f+y-10.0f, 270.0f, 60.0f, 20.0f);			Graphics()->QuadsEnd();		}		Selected = false;		if(m_SelectorMouse.x >= x-10.0f && m_SelectorMouse.x <= x+260.0f &&			m_SelectorMouse.y >= y-10.0f && m_SelectorMouse.y <= y+50.0f)		{			m_SelectedSpectatorID = i;			Selected = true;		}		TextRender()->TextColor(1.0f, 1.0f, 1.0f, Selected?1.0f:0.5f);		TextRender()->Text(0, Width/2.0f+x+50.0f, Height/2.0f+y+5.0f, FontSize, m_pClient->m_aClients[i].m_aName, 220.0f);		// flag		if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_FLAGS &&			m_pClient->m_Snap.m_pGameDataObj && (m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierRed == m_pClient->m_Snap.m_paPlayerInfos[i]->m_ClientID ||			m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue == m_pClient->m_Snap.m_paPlayerInfos[i]->m_ClientID))		{			Graphics()->BlendNormal();			Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);			Graphics()->QuadsBegin();			RenderTools()->SelectSprite(m_pClient->m_Snap.m_paPlayerInfos[i]->m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);			float Size = LineHeight;//.........这里部分代码省略.........
开发者ID:Berzzzebub,项目名称:teeworlds,代码行数:101,


示例25: RenderTools

void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter){	if(!pCharacter)		return;	float x = 5;	float y = 5;	int i;	IGraphics::CQuadItem Array[10];	// render ammo	if(pCharacter->m_Weapon == WEAPON_NINJA)	{		CUIRect Rect = {x, y+24.0f, 118.0f, 10.0f};		RenderTools()->DrawUIRect(&Rect, vec4(0.8f, 0.8f, 0.8f, 0.5f), 0, 0.0f);		int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000;		Rect.x = x+1.0f;		Rect.y = y+25.0f;		Rect.w = 116.0f * clamp(pCharacter->m_AmmoCount-Client()->GameTick(), 0, Max) / Max;		Rect.h = 8.0f;		RenderTools()->DrawUIRect(&Rect, vec4(0.9f, 0.2f, 0.2f, 0.85f), 0, 0.0f);		Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);		Graphics()->QuadsBegin();		Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);		RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[WEAPON_NINJA].m_pSpriteBody);		Array[0] = IGraphics::CQuadItem(x+40.0f,y+25, 32.0f, 8.0f);		Graphics()->QuadsDrawTL(Array, 1);	}	else	{		Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);		Graphics()->QuadsBegin();		RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[pCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteProj);		for(i = 0; i < min(pCharacter->m_AmmoCount, 10); i++)			Array[i] = IGraphics::CQuadItem(x+i*12,y+24,10,10);		Graphics()->QuadsDrawTL(Array, i);	}	int h = 0;	// render health	RenderTools()->SelectSprite(SPRITE_HEALTH_FULL);	for(; h < min(pCharacter->m_Health, 10); h++)		Array[h] = IGraphics::CQuadItem(x+h*12,y,10,10);	Graphics()->QuadsDrawTL(Array, h);	i = 0;	RenderTools()->SelectSprite(SPRITE_HEALTH_EMPTY);	for(; h < 10; h++)		Array[i++] = IGraphics::CQuadItem(x+h*12,y,10,10);	Graphics()->QuadsDrawTL(Array, i);	// render armor meter	h = 0;	RenderTools()->SelectSprite(SPRITE_ARMOR_FULL);	for(; h < min(pCharacter->m_Armor, 10); h++)		Array[h] = IGraphics::CQuadItem(x+h*12,y+12,10,10);	Graphics()->QuadsDrawTL(Array, h);	i = 0;	RenderTools()->SelectSprite(SPRITE_ARMOR_EMPTY);	for(; h < 10; h++)		Array[i++] = IGraphics::CQuadItem(x+h*12,y+12,10,10);	Graphics()->QuadsDrawTL(Array, i);	Graphics()->QuadsEnd();}
开发者ID:Mailaender,项目名称:teeworlds,代码行数:68,


示例26: Graphics

void CRenderTools::RenderQuads(CQuad *pQuads, int NumQuads, int RenderFlags, ENVELOPE_EVAL pfnEval, void *pUser){	Graphics()->QuadsBegin();	float Conv = 1/255.0f;	for(int i = 0; i < NumQuads; i++)	{		CQuad *q = &pQuads[i];		float r=1, g=1, b=1, a=1;		if(q->m_ColorEnv >= 0)		{			float aChannels[4];			pfnEval(q->m_ColorEnvOffset/1000.0f, q->m_ColorEnv, aChannels, pUser);			r = aChannels[0];			g = aChannels[1];			b = aChannels[2];			a = aChannels[3];		}		bool Opaque = false;		/* TODO: Analyze quadtexture		if(a < 0.01f || (q->m_aColors[0].a < 0.01f && q->m_aColors[1].a < 0.01f && q->m_aColors[2].a < 0.01f && q->m_aColors[3].a < 0.01f))			Opaque = true;		*/		if(Opaque && !(RenderFlags&LAYERRENDERFLAG_OPAQUE))			continue;		if(!Opaque && !(RenderFlags&LAYERRENDERFLAG_TRANSPARENT))			continue;		Graphics()->QuadsSetSubsetFree(			fx2f(q->m_aTexcoords[0].x), fx2f(q->m_aTexcoords[0].y),			fx2f(q->m_aTexcoords[1].x), fx2f(q->m_aTexcoords[1].y),			fx2f(q->m_aTexcoords[2].x), fx2f(q->m_aTexcoords[2].y),			fx2f(q->m_aTexcoords[3].x), fx2f(q->m_aTexcoords[3].y)		);		float OffsetX = 0;		float OffsetY = 0;		float Rot = 0;		// TODO: fix this		if(q->m_PosEnv >= 0)		{			float aChannels[4];			pfnEval(q->m_PosEnvOffset/1000.0f, q->m_PosEnv, aChannels, pUser);			OffsetX = aChannels[0];			OffsetY = aChannels[1];			Rot = aChannels[2]/360.0f*pi*2;		}		IGraphics::CColorVertex Array[4] = {			IGraphics::CColorVertex(0, q->m_aColors[0].r*Conv*r, q->m_aColors[0].g*Conv*g, q->m_aColors[0].b*Conv*b, q->m_aColors[0].a*Conv*a),			IGraphics::CColorVertex(1, q->m_aColors[1].r*Conv*r, q->m_aColors[1].g*Conv*g, q->m_aColors[1].b*Conv*b, q->m_aColors[1].a*Conv*a),			IGraphics::CColorVertex(2, q->m_aColors[2].r*Conv*r, q->m_aColors[2].g*Conv*g, q->m_aColors[2].b*Conv*b, q->m_aColors[2].a*Conv*a),			IGraphics::CColorVertex(3, q->m_aColors[3].r*Conv*r, q->m_aColors[3].g*Conv*g, q->m_aColors[3].b*Conv*b, q->m_aColors[3].a*Conv*a)};		Graphics()->SetColorVertex(Array, 4);		CPoint *pPoints = q->m_aPoints;		if(Rot != 0)		{			static CPoint aRotated[4];			aRotated[0] = q->m_aPoints[0];			aRotated[1] = q->m_aPoints[1];			aRotated[2] = q->m_aPoints[2];			aRotated[3] = q->m_aPoints[3];			pPoints = aRotated;			Rotate(&q->m_aPoints[4], &aRotated[0], Rot);			Rotate(&q->m_aPoints[4], &aRotated[1], Rot);			Rotate(&q->m_aPoints[4], &aRotated[2], Rot);			Rotate(&q->m_aPoints[4], &aRotated[3], Rot);		}		IGraphics::CFreeformItem Freeform(			fx2f(pPoints[0].x)+OffsetX, fx2f(pPoints[0].y)+OffsetY,			fx2f(pPoints[1].x)+OffsetX, fx2f(pPoints[1].y)+OffsetY,			fx2f(pPoints[2].x)+OffsetX, fx2f(pPoints[2].y)+OffsetY,			fx2f(pPoints[3].x)+OffsetX, fx2f(pPoints[3].y)+OffsetY);		Graphics()->QuadsDrawFreeform(&Freeform, 1);	}	Graphics()->QuadsEnd();}
开发者ID:4a4ik,项目名称:teeworlds,代码行数:84,



注:本文中的Graphics函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ Graphics_drawInnerBox函数代码示例
C++ Graph_IsValid函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。