当前位置: 首页>>代码示例>>C++>>正文


C++ RenderText函数代码示例

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


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

示例1: SDL_RenderClear

// ============================================================================================
// ================================= Renderering ==============================================
// ============================================================================================
void Renderer::Render( )
{
	SDL_RenderClear( renderer );

	switch ( gameState )
	{
		case GameState::MainMenu:
		case GameState::Options:
		case GameState::Lobby:
			RenderMenu();
			break;

		case GameState::InGame:
			RenderGameObjects();
		FALLTHROUGH
		case GameState::InGameWait:
			RenderText();
			break;

		case GameState::Paused:
			RenderPause();
		FALLTHROUGH
		case GameState::GameOver:
			RenderText();
			break;
		default:
			break;
	}

	SDL_RenderPresent( renderer );
}
开发者ID:olevegard,项目名称:DXBall,代码行数:34,代码来源:Renderer.cpp

示例2: SDL_SetRenderDrawColor

void GameTable::RenderUserInterface(SDL_Renderer* renderer)
{
    // Game timer drawing
    // Full background timer rectangle
    SDL_SetRenderDrawColor(renderer, timerBGColor.r, timerBGColor.g, timerBGColor.b, timerBGColor.a);
    SDL_RenderFillRect(renderer, &timerRect);

    // Amount of filled rect to render
    SDL_SetRenderDrawColor(renderer, timerFillColor.r, timerFillColor.g, timerFillColor.b, timerFillColor.a);
    auto amount = timer->getTicks() / timeToNextCol;
    auto fillRect = SDL_Rect{ timerRect.x, timerRect.y, static_cast<Uint32>(timerRect.w * amount), timerRect.h };
    SDL_RenderFillRect(renderer, &fillRect);

    // Score drawing
    RenderText(scoreText + std::to_string(score), scoreColor, scoreULPos);

    // Level drawing
    RenderText(levelText + std::to_string(level), scoreColor, levelULPos);

    // Experience drawing
    RenderText(expText, scoreColor, expULPos);

    // Full background Experience rectangle
    SDL_SetRenderDrawColor(renderer, timerBGColor.r, timerBGColor.g, timerBGColor.b, timerBGColor.a);
    SDL_RenderFillRect(renderer, &expRect);

    // Amount of filled rect to render - Experience
    SDL_SetRenderDrawColor(renderer, timerFillColor.r, timerFillColor.g, timerFillColor.b, timerFillColor.a);
    amount = static_cast<float>(experience) / static_cast<float>(expToLevelUp);
    fillRect = SDL_Rect{ expRect.x, expRect.y, static_cast<Uint32>(expRect.w * amount), expRect.h };
    SDL_RenderFillRect(renderer, &fillRect);

    btnAddColumn->Render();
    btnPauseGame->Render();
}
开发者ID:Farious,项目名称:GemBreaker,代码行数:35,代码来源:GameTable.cpp

示例3: RenderTime

/* Function that renders the current time of the game
    param: actual time of the game
    param: the renderer to handle all the rendering in the window
    param: font for the time rendering
*/
void RenderTime(time_t actualtime, SDL_Renderer *renderer, TTF_Font *font)
{
    int secs = 0;
    int mins = 0;
    char str[TIMERSIZE] = {0};
    SDL_Color white = {255, 255, 255};

    secs = actualtime%SIZEOFMIN;
    mins = actualtime/SIZEOFMIN;
    if(mins < PROBSIZES)
    {
        str[0] = '0';
        str[1] = '0' + mins;
    }
    else
    {
        str[0] = '0' + mins/PROBSIZES;
        str[1] = '0' + mins%PROBSIZES;
    }
    str[2] = ':';
    if(secs < PROBSIZES)
    {
        str[3] = '0';
        str[4] = '0' + secs;
    }
    else
    {
        str[3] = '0' + secs/PROBSIZES;
        str[4] = '0' + secs%PROBSIZES;
    }
    RenderText(XTIMER, YTIMER - TITLEVAR, "Timer", font, &white, renderer);
    RenderText(XTIMER, YTIMER, str, font, &white, renderer);
}
开发者ID:gmestre98,项目名称:Mastermind,代码行数:38,代码来源:Grafica.c

示例4: Redraw

void Redraw()
{
    int w = 0, h = textRect.h;
    SDL_Rect cursorRect, underlineRect;

    SDL_FillRect(screen, &textRect, backColor);

#ifdef HAVE_SDL_TTF
    if (strlen(text))
    {
        RenderText(screen, font, text, textRect.x, textRect.y, textColor);
        TTF_SizeUTF8(font, text, &w, &h);
    }
#endif

    markedRect.x = textRect.x + w;
    markedRect.w = textRect.w - w;
    if (markedRect.w < 0)
    {
        SDL_Flip(screen);
        // Stop text input because we cannot hold any more characters
        SDL_StopTextInput();
        return;
    }
    else
    {
        SDL_StartTextInput();
    }

    cursorRect = markedRect;
    cursorRect.w = 2;
    cursorRect.h = h;

    SDL_FillRect(screen, &markedRect, backColor);
    if (markedText)
    {
#ifdef HAVE_SDL_TTF
        RenderText(screen, font, markedText, markedRect.x, markedRect.y, textColor);
        TTF_SizeUTF8(font, markedText, &w, &h);
#endif

        underlineRect = markedRect;
        underlineRect.y += (h - 2);
        underlineRect.h = 2;
        underlineRect.w = w;

        cursorRect.x += w + 1;

        SDL_FillRect(screen, &underlineRect, lineColor);
    }

    SDL_FillRect(screen, &cursorRect, lineColor);

    SDL_Flip(screen);

    SDL_SetTextInputRect(&markedRect);
}
开发者ID:albertz,项目名称:sdl,代码行数:57,代码来源:testime.c

示例5: RenderMenu

/* Function to render the menus line in the bottom of the window
    param: the renderer to handle all the rendering in the window
    param: font for the names of each option
*/
void RenderMenu(SDL_Renderer *renderer, TTF_Font *Queen)
{
    SDL_Color white = {255, 255, 255};

    RenderImage(renderer, "Home.bmp", XHOME, YHOME);
    RenderImage(renderer, "New_Game.bmp", XNEWGAME, YNEWGAME);
    RenderImage(renderer, "Statistics.bmp", XSTATISTICS, YSTATISTICS);
    RenderText(XHOMETXT, YHOMETXT, "Home", Queen, &white, renderer);
    RenderText(XNGTXT, YNGTXT, "New Game", Queen, &white, renderer);
    RenderText(XSTATS, YSTATS, "Statistics", Queen, &white, renderer);
}
开发者ID:gmestre98,项目名称:Mastermind,代码行数:15,代码来源:Grafica.c

示例6: RenderTable

/**
 * RenderTable: Draws the table where the game will be played, namely:
 * -  some texture for the background
 * -  the right part with the IST logo and the student name and number
 * -  squares to define the playing positions of each player
 * -  names and the available money for each player
 * \param _money amount of money of each player
 * \param _img surfaces where the table background and IST logo were loaded
 * \param _renderer renderer to handle all rendering in a window
 */
void RenderTable(List *players, TTF_Font *_font, SDL_Surface *_img[], SDL_Renderer *_renderer)
{
    SDL_Color black = {0, 0, 0, 255}; // black
    SDL_Texture *table_texture;
    SDL_Rect tableSrc, tableDest;
    int height;
    char money_str[STRING_SIZE];

    // set color of renderer to white
    SDL_SetRenderDrawColor(_renderer, 255, 255, 255, 255);

    // clear the window
    SDL_RenderClear(_renderer);

    tableDest.x = tableSrc.x = 0;
    tableDest.y = tableSrc.y = 0;
    tableSrc.w = _img[0]->w;
    tableSrc.h = _img[0]->h;

    tableDest.w = SEP;
    tableDest.h = HEIGHT_WINDOW;

    table_texture = SDL_CreateTextureFromSurface(_renderer, _img[0]);
    SDL_RenderCopy(_renderer, table_texture, &tableSrc, &tableDest);

    // render the IST Logo
    height = RenderLogo(SEP, 0, _img[1], _renderer);

    // render the student name
    height += RenderText(SEP+3*MARGIN, height, myName1, _font, &black, _renderer);

    // this renders the student number
    height += RenderText(SEP+3*MARGIN, height, myName2, _font, &black, _renderer);

    // 2xnewline
    height += 2*RenderText(SEP+3*MARGIN, height, " ", _font, &black, _renderer);

	List *aux = players->next;
	Player *cur_player = NULL;
	while (aux) {
		cur_player = (Player *) aux->payload;
		if (cur_player->ingame) {
			sprintf(money_str, "%s (%s): %d euros",
					cur_player->name, cur_player->type == HU ? "HU" : "EA", cur_player->money);
			height += RenderText(SEP+3*MARGIN, height, money_str, _font, &black, _renderer);
		}
		aux = aux->next;
	}

	RenderPlayerArea(players, _renderer, _font);

    // destroy everything
    SDL_DestroyTexture(table_texture);
}
开发者ID:joajfreitas,项目名称:blackjack,代码行数:64,代码来源:sdl.c

示例7: PrintDebugStats

	void PrintDebugStats(const Application &app, LockBufferInfo &frame_info)
	{
		// unsafe
		static char buffer[1024];
		U32 line = 0;

		sprintf_s(buffer, sizeof buffer, "FPS: %.2f (%.2fms)", 1.0f / app.frame_delta, app.frame_delta * 1000.0f);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));

		sprintf_s(buffer, sizeof buffer, "RenderScene: %.3fms", (float(app.render_scene_time) / float(U64(1) << U64(32))) * 1000.0f);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));

		sprintf_s(buffer, sizeof buffer, "Position: [%.2f, %.2f, %.2f]", app.camera.pos.x, app.camera.pos.y, app.camera.pos.z);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));
		sprintf_s(buffer, sizeof buffer, "Yaw: %.2f", app.player_yaw / Pi * 180.0f);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));
		sprintf_s(buffer, sizeof buffer, "Pitch: %.2f", app.player_pitch / Pi * 180.0f);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));

		sprintf_s(buffer, sizeof buffer, "Axis X: [%.2f, %.2f, %.2f]", app.camera.axis[0].x, app.camera.axis[0].y, app.camera.axis[0].z);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));
		sprintf_s(buffer, sizeof buffer, "Axis Y: [%.2f, %.2f, %.2f]", app.camera.axis[1].x, app.camera.axis[1].y, app.camera.axis[1].z);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));
		sprintf_s(buffer, sizeof buffer, "Axis Z: [%.2f, %.2f, %.2f]", app.camera.axis[2].x, app.camera.axis[2].y, app.camera.axis[2].z);
		RenderText(app.font, frame_info, 0, 18 * line++, buffer, float4(1.0f, 0.0f, 0.0f, 0.0f));
	}
开发者ID:Venomic,项目名称:CPURasterizer,代码行数:26,代码来源:Main.cpp

示例8: RenderHome

/* Function to render the home menu
    param: the renderer to handle all the rendering in the window
    param: font for the names of each option
    param: font for the game name in the top
*/
void RenderHome(SDL_Renderer *renderer, TTF_Font *Queen, TTF_Font *QueenBig)
{
    SDL_Color white = {255, 255, 255};

    RenderImage(renderer, "Fundo.bmp", BACKGROUNDX, BACKGROUNDY);
    RenderImage(renderer, "TextBox.bmp", XTEXTBOX, YTEXTBOX);
    RenderImage(renderer, "TextBox.bmp", XTEXTBOX, YTEXTBOX + BOXHEIGHT);
    RenderImage(renderer, "TextBox.bmp", XTEXTBOX, YTEXTBOX + 2*BOXHEIGHT);
    RenderText(XCGAME, YOPTION, "Current Game", Queen, &white, renderer);
    RenderText(XNGAME, YOPTION + BOXHEIGHT, "New Game", Queen, &white, renderer);
    RenderText(XHOMESTATS, YOPTION + 2*BOXHEIGHT, "Statistics", Queen, &white, renderer);
    RenderImage(renderer, "ScreenshotJogo.bmp", XSCREENSHOT, YSCREENSHOT);
    RenderText(XTITLE, YTITLE, "Mastermind", QueenBig, &white, renderer);
}
开发者ID:gmestre98,项目名称:Mastermind,代码行数:19,代码来源:Grafica.c

示例9: render_status

// Desenhar o estado do jogador
// Blackjack, Bust e Surrender
void render_status(List *players, TTF_Font *_font, SDL_Renderer *renderer)
{
    SDL_Rect rect;

    char bust[] = "BUST";
    char blackjack[] = "BLACKJACK";
	char surrender[] = "SURRENDER";

    List *aux = players->next;
    Player *cur_player = NULL;
    SDL_Color white = { 255, 255, 255, 255};
    for (int i=0; aux; i++) {
        cur_player = (Player *) aux->payload;
        rect.y = 380;
        rect.h = 30;
        if (cur_player->ingame) {
			if (cur_player->status == BJ) {
				rect.x = 55 + 208*i;
				rect.w = 115;
				SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255 );
				SDL_RenderFillRect(renderer, &rect);
				SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255 );
				SDL_RenderDrawRect(renderer, &rect);
				RenderText(64+208*i, 382, blackjack, _font, &white, renderer);
			}
			else if (cur_player->status == BU) {
				rect.x = 80 + 208*i;
				rect.w = 70;
				SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255 );
				SDL_RenderFillRect(renderer, &rect);
				SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255 );
				SDL_RenderDrawRect(renderer, &rect);
				RenderText(94+(208*i), 382, bust, _font, &white, renderer);
			}
			else if (cur_player->status == SU) {
				rect.x = 55 + 208*i;
				rect.w = 115;
				SDL_SetRenderDrawColor(renderer, 255, 200, 0, 255 );
				SDL_RenderFillRect(renderer, &rect);
				SDL_SetRenderDrawColor(renderer, 255, 200, 0, 255 );
				SDL_RenderDrawRect(renderer, &rect);
				RenderText(64+208*i, 382, surrender, _font, &white, renderer);
			}

		}
        aux = aux->next;
    }
}
开发者ID:joajfreitas,项目名称:blackjack,代码行数:50,代码来源:sdl.c

示例10: assert

void
Canvas::DrawTransparentText(int x, int y, const TCHAR *text)
{
  assert(text != nullptr);
#ifndef UNICODE
  assert(ValidateUTF8(text));
#endif

#ifdef ENABLE_OPENGL
  /*
   * RenderText return buffer owned by TextCache, this can be delete by GUI Thread
   *  lock is need for avoid to used alredy deleted buffer.
   */
  TextCache::Lock();
#endif
  
  auto s = RenderText(font, text);
  if (s.data != nullptr) {

    SDLRasterCanvas canvas(buffer);
    ColoredAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
      transparent(canvas.Import(text_color));
    canvas.CopyRectangle<decltype(transparent), GreyscalePixelTraits>
      (x, y, s.width, s.height,
       GreyscalePixelTraits::const_pointer_type(s.data),
       s.pitch, transparent);
  }
  
#ifdef ENABLE_OPENGL  
  TextCache::Unlock();
#endif  
}
开发者ID:jaaaaf,项目名称:LK8000,代码行数:32,代码来源:Canvas.cpp

示例11: RenderText

/* Draw each part of the text */
bool Font::PartText(const std::string &message, int x, int y, SDL_Color color)
{
	int corx;
	int cory;

	/* TTF gestion */
	tex = RenderText(message.c_str(), color, size, ren);
	if (tex == NULL){
		return false;
	}

	//Get the texture w/h so we can center it in the screen
	if (isCenter)
	{
		int iW, iH;
		SDL_QueryTexture(tex, NULL, NULL, &iW, &iH);
		corx = x - iW / 2;
		cory = y - iH / 2;
	}
	else
	{
		corx = x;
		cory = y;
	}

	/* Dessiner le texte */
	RenderTexture(tex, ren, corx, cory);

	SDL_DestroyTexture(tex);

	return true;
}
开发者ID:gdraynz,项目名称:super-bernard-land,代码行数:33,代码来源:Font.cpp

示例12: RenderHUD

VOID RenderHUD( ID3D11DeviceContext* pd3dImmediateContext, FLOAT fElapsedTime )
{
    DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
    g_HUD.OnRender( fElapsedTime );
    g_SampleUI.OnRender( fElapsedTime );

    static FLOAT InspectionYOffset = 0;
    if( g_pInspectionTexture != NULL )
    {
        const INT ViewportHeight = (INT)g_HalfClientHeightPixels * 2;
        INT TotalHeight = 0;
        INT SliceHeight = 0;
        g_PageDebugRender.Render( pd3dImmediateContext, g_pTitleResidencyManager, g_pInspectionTexture, 10, ViewportHeight - (INT)InspectionYOffset, &TotalHeight, &SliceHeight );

        FLOAT fLerp = min( 1.0f, fElapsedTime * 8.0f );
        FLOAT TargetOffset = (FLOAT)( SliceHeight * ( g_InspectionSliceIndex + 1 ) );
        if( fabsf( TargetOffset - InspectionYOffset ) < 2.0f )
        {
            InspectionYOffset = TargetOffset;
        }
        else
        {
            InspectionYOffset = ( TargetOffset * fLerp + (FLOAT)InspectionYOffset * ( 1.0f - fLerp ) );
        }
    }
    else
    {
        InspectionYOffset = 0;
        g_InspectionSliceIndex = 0;
    }

    if( g_bDrawResidencySampleViews )
    {
        ID3D11ShaderResourceView* pSRViewUVGradientID = NULL;
        ID3D11ShaderResourceView* pSRViewExtendedUVSlice = NULL;

        g_pTitleResidencyManager->GetViewShaderResources( g_LastResidencySampleViewID, &pSRViewUVGradientID, &pSRViewExtendedUVSlice );

        if( pSRViewExtendedUVSlice != NULL && pSRViewUVGradientID != NULL )
        {
            RECT ClientRect;
            GetClientRect( DXUTGetHWND(), &ClientRect );

            UINT Width = 256;
            UINT Height = 144;
            UINT Margin = 10;
            UINT BottomMargin = 60 + Margin;

            RECT Rect2 = { ClientRect.right - ( Width + Margin ), ClientRect.bottom - ( Height + BottomMargin ), ClientRect.right - Margin, ClientRect.bottom - BottomMargin };
            RECT Rect1 = { Rect2.left, Rect2.top - ( Height + Margin ), Rect2.right, Rect2.top - Margin };

            g_PageDebugRender.RenderTexture( pd3dImmediateContext, pSRViewUVGradientID, Rect1 );
            g_PageDebugRender.RenderTexture( pd3dImmediateContext, pSRViewExtendedUVSlice, Rect2 );
        }
    }

    RenderText();

    DXUT_EndPerfEvent();
}
开发者ID:kingofthebongo2008,项目名称:examples,代码行数:60,代码来源:TiledResources11.cpp

示例13: sizeof

//-------------------------------------------------------------
// Name: Render()
// Desc: ȭ�� ����
//-------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
    // ȭ�� Ŭ����
    m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
                         0x000000ff, 1.0f, 0L );

    //---------------------------------------------------------
    // ����
    //---------------------------------------------------------
    if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
    {
		// �� �ȼ����̴� ����
		m_pd3dDevice->SetPixelShader( m_pPixelShader );

        // ������� ����
        m_pd3dDevice->SetVertexDeclaration(m_pVertexDeclaration);
        m_pd3dDevice->SetVertexShader( m_pVertexShader );
		
        // ������ ����
        m_pd3dDevice->SetStreamSource( 0, m_pVB, 0,
                                       sizeof(CUSTOMVERTEX) );
        m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );

        RenderText();    // ȭ����¿� ���� ���

        // ��������
        m_pd3dDevice->EndScene();
    }

    return S_OK;
}
开发者ID:jjuiddong,项目名称:Dx9-Shader,代码行数:35,代码来源:main.cpp

示例14: GetClientRect

void CodePreview::Show(HWND bar, IVsTextView* view, IVsTextLines* buffer, const wchar_t* text, int numLines)
{
	RECT r;
	GetClientRect(bar, &r);
	
	POINT p;
	p.x = r.left;
	p.y = r.top;
	ClientToScreen(bar, &p);
	m_rightEdge = p.x;
	m_parentYMin = p.y;

	p.x = r.left;
	p.y = r.bottom;
	ClientToScreen(bar, &p);
	m_parentYMax = p.y;

	if(!m_paintDC)
	{
		HDC wndDC = GetDC(m_hwnd);
		m_paintDC = CreateCompatibleDC(wndDC);
		m_codeBmp = CreateCompatibleBitmap(wndDC, m_wndWidth, m_wndHeight);
		SelectObject(m_paintDC, m_codeBmp);
		ReleaseDC(m_hwnd, wndDC);
	}

	int charsPerLine = (m_wndWidth - HORIZ_MARGIN*2) / s_charWidth;
	PreviewRenderOp renderOp(m_text, charsPerLine);
	m_imgNumLines = RenderText(renderOp, view, buffer, text, numLines);

	ShowWindow(m_hwnd, SW_SHOW);
}
开发者ID:Blacktempel,项目名称:metalscroll,代码行数:32,代码来源:CodePreview.cpp

示例15: RenderText

void HUD::RenderRoundTripTime()
{
	float rttMS = NetworkManagerClient::sInstance->GetAvgRoundTripTime().GetValue() * 1000.f;

	string roundTripTime = StringUtils::Sprintf( "RTT %d ms", ( int ) rttMS  );
	RenderText( roundTripTime, mRoundTripTimeOrigin, Colors::White );
}
开发者ID:Resinderate,项目名称:ShadowMultiplayer,代码行数:7,代码来源:HUD.cpp


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