コード例 #1
0
ファイル: Renderer.cpp プロジェクト: olevegard/DXBall
// ============================================================================================
// ================================= 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 );
}
コード例 #2
0
ファイル: GameTable.cpp プロジェクト: Farious/GemBreaker
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();
}
コード例 #3
0
ファイル: Grafica.c プロジェクト: gmestre98/Mastermind
/* 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);
}
コード例 #4
0
ファイル: testime.c プロジェクト: albertz/sdl
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);
}
コード例 #5
0
ファイル: Grafica.c プロジェクト: gmestre98/Mastermind
/* 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);
}
コード例 #6
0
ファイル: sdl.c プロジェクト: joajfreitas/blackjack
/**
 * 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);
}
コード例 #7
0
ファイル: Main.cpp プロジェクト: Venomic/CPURasterizer
	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));
	}
コード例 #8
0
ファイル: Grafica.c プロジェクト: gmestre98/Mastermind
/* 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);
}
コード例 #9
0
ファイル: sdl.c プロジェクト: joajfreitas/blackjack
// 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;
    }
}
コード例 #10
0
ファイル: Canvas.cpp プロジェクト: jaaaaf/LK8000
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  
}
コード例 #11
0
ファイル: Font.cpp プロジェクト: gdraynz/super-bernard-land
/* 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;
}
コード例 #12
0
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();
}
コード例 #13
0
ファイル: main.cpp プロジェクト: jjuiddong/Dx9-Shader
//-------------------------------------------------------------
// 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;
}
コード例 #14
0
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);
}
コード例 #15
0
ファイル: HUD.cpp プロジェクト: Resinderate/ShadowMultiplayer
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 );
}
コード例 #16
0
ファイル: HDimension.cpp プロジェクト: CarlosGS/heekscad
void HDimension::glCommands(bool select, bool marked, bool no_color)
{
	gp_Pnt b = GetB2();
	
	if(A->m_p.IsEqual(b, wxGetApp().m_geom_tol))return;

	if(!no_color)wxGetApp().glColorEnsuringContrast(m_color);

	gp_Dir xdir = gp_Dir(1, 0, 0).Transformed(m_trsf);
	gp_Dir ydir = gp_Dir(0, 1, 0).Transformed(m_trsf);
	gp_Dir zdir = gp_Dir(0, 0, 1).Transformed(m_trsf);
	if(m_mode == TwoPointsDimensionMode || m_mode == TwoPointsXYOnlyDimensionMode || m_mode == TwoPointsXOnlyDimensionMode)
	{
		xdir = make_vector(A->m_p, b);
		if(xdir.IsParallel(zdir,wxGetApp().m_geom_tol))
			zdir = xdir ^ ydir;
		else
			ydir = zdir ^ xdir;
	}

	wxString text = MakeText();

	float width, height;
	if(!wxGetApp().get_text_size(text, &width, &height))return;

	// draw arrow line
	draw_arrow_line(m_mode, A->m_p, b, GetC2(), xdir, ydir, width, m_scale);

	// draw text
	RenderText(text, GetC2(), xdir, ydir, m_scale);

	EndedObject::glCommands(select,marked,no_color);
}
コード例 #17
0
ファイル: Canvas.cpp プロジェクト: lniv/tophat
void
Canvas::DrawText(int x, int y, const TCHAR *text)
{
    assert(text != nullptr);
#ifndef UNICODE
    assert(ValidateUTF8(text));
#endif

    auto s = RenderText(font, text);
    if (s.data == nullptr)
        return;

    SDLRasterCanvas canvas(buffer);

    if (background_mode == OPAQUE) {
        OpaqueAlphaPixelOperations<SDLPixelTraits, GreyscalePixelTraits>
        opaque(canvas.Import(background_color), canvas.Import(text_color));
        canvas.CopyRectangle<decltype(opaque), GreyscalePixelTraits>
        (x, y, s.width, s.height,
         GreyscalePixelTraits::const_pointer_type(s.data),
         s.pitch, opaque);
    } else {
        ColoredAlphaPixelOperations<SDLPixelTraits, 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);
    }
}
コード例 #18
0
ファイル: Main.cpp プロジェクト: dj-foxxy/scalefreenetworks
void RenderGraph(Graph * graph)
{
  if(m_stepping)
    m_stepping = GraphLayout::step(graph, m_state,0.01f);
  
  for(int i = 0; i < graph->m_nodes.size(); i++)
  {
    RGB * color = NULL;
    for(int j = 0; j < m_current_color_states.size(); j++)
      if(m_current_color_states[j]->m_node == graph->m_nodes[i]->m_name)
	color = m_current_color_states[j]->m_node_color;
    
    if(color != NULL)
    {
      glColor3f((double)color->R / 255.0, (double)color->G / 255.0, (double)color->B /255.0);
    }
    else
      glColor3f(1.0,1.0,1.0);
    RenderNode(graph->m_nodes[i]);
  }
  
  std::stringstream oss;
  
  oss << "Time Step: "	    << m_state->m_time_step 	 << "\n"
      << "Damping:   " 	    << m_state->m_damping	 << "\n"
      << "Kinetic Energy: " << m_state->m_kinetic_energy << "\n"
      << "Converges At: "   << m_state->m_convergence    << "\n";
  
  RenderText(oss.str(), 10, 250);
//  RenderText("Hello2", 10, 280);
  
}
コード例 #19
0
ファイル: HUD.cpp プロジェクト: Resinderate/ShadowMultiplayer
void HUD::RenderBandWidth()
{
	string bandwidth = StringUtils::Sprintf( "In %d  Bps, Out %d Bps",
												static_cast< int >( NetworkManagerClient::sInstance->GetBytesReceivedPerSecond().GetValue() ),
												static_cast< int >( NetworkManagerClient::sInstance->GetBytesSentPerSecond().GetValue() ) );
	RenderText( bandwidth, mBandwidthOrigin, Colors::White );
}
コード例 #20
0
ファイル: CompiledEffect.cpp プロジェクト: KNeal/Oculus
//--------------------------------------------------------------------------------------
// Render the scene using the D3D9 device
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // If the settings dialog is being shown, then
    // render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    HRESULT hr;

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 45, 50, 70 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        UINT iPass, cPasses;
        V( g_pEffect->Begin( &cPasses, 0 ) );
        for( iPass = 0; iPass < cPasses; iPass++ )
        {
            V( g_pEffect->BeginPass( iPass ) );
            V( g_Mesh.Render( pd3dDevice ) );
            g_pEffect->EndPass();
        }
        g_pEffect->End();

        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );

        V( pd3dDevice->EndScene() );
    }
}
コード例 #21
0
ファイル: main.cpp プロジェクト: jjuiddong/Dx9-Shader
//-------------------------------------------------------------
// 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->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;
}
コード例 #22
0
ファイル: TerrainPaging.cpp プロジェクト: Samahu/GigaRender
//--------------------------------------------------------------------------------------
// Render the scene 
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    HRESULT hr;

	BaseCamera *pCamera = (g_SwitchCameras ? &g_Camera1 : &g_Camera2);

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
		D3DXMATRIX mat;
		D3DXMatrixIdentity(&mat);
		pd3dDevice->SetTransform(D3DTS_WORLD, &mat);
		pd3dDevice->SetTransform(D3DTS_VIEW, pCamera->GetViewMatrix());
        pd3dDevice->SetTransform(D3DTS_PROJECTION, pCamera->GetProjMatrix());

		g_pTerrain->Render();

		if (!g_SwitchCameras)	// only render the furstum if we are viewing it from the outside.
			g_Frustum.Render(*pd3dDevice);

		RenderText();

        V( pd3dDevice->EndScene() );
    }

	// Copy in-memory ready items to the video memory
	g_pTerrain->Process(fElapsedTime);
}
コード例 #23
0
ファイル: GraphicsEngine.cpp プロジェクト: Dopelust/SP4-10
void GraphicsEngine::Render2D(const char * shader, int x, int y, bool identity)
{
	screen_projection.SetToOrtho(0, x, 0, y, -10, 10);
	Quad.RenderInstances(shader, identity);

	RenderText();
}
コード例 #24
0
ファイル: vg_text.c プロジェクト: varialus/agar
static void
RenderTextPolled(VG_Text *vt, VG_View *vv)
{
	char val[64], s[VG_TEXT_MAX], *c;
	int argIdx = 0;

	s[0] = '\0';
	for (c = &vt->text[0]; *c != '\0'; ) {
		if (c[0] != '%') {
			val[0] = *c;
			val[1] = '\0';
			Strlcat(s, val, sizeof(s));
			c++;
			continue;
		}
		if (c[1] == '\0' || c[1] == '%') {
			val[0] = '%';
			val[1] = '\0';
			Strlcat(s, val, sizeof(s));
			c+=2;
			continue;
		}
		if ((argIdx+1) >= vt->args->n) {
			AG_FatalError("Argument inconsistency");
		}
		AG_PrintVariable(val, sizeof(val), &vt->args->v[argIdx]);
		Strlcat(s, val, sizeof(s));
		c += vt->argSizes[argIdx++];
	}
	RenderText(vt, s, vv);
}
コード例 #25
0
ファイル: TSRGuiContainer.cpp プロジェクト: ShadyEM/Twister3D
/********************************************************
*	class cContainer implementation						*
*	end of class cFrame implementation					*
********************************************************/
void TSRGuiContainer::Render()
{
    if ( !m_bVisible )
    {
        return;
    }
    TSRGlobalConstants.PushMatrix();
    TSRGlobalConstants.Translate( m_Position.x, m_Position.y, 0.0f );
    RenderBody();	
        
	if ( m_bBordered )
    {
        TSRMaterial material;
        material.m_vDiffuseColor.Assign( m_BorderColor.r, m_BorderColor.g, m_BorderColor.b, 1.0f );
        TSRGlobalConstants.SetMaterial( material );
        Graphics()->m_pSimpleShader->Activate();
        m_pBorderMesh->Render();
    }

    for ( unsigned int i = 0; i < m_Children.size(); i++ )
	{
        m_Children[ i ]->Render();
	}
    TSRGlobalConstants.PopMatrix();
    RenderText( m_Text.c_str() );								//	set rasterization position
}
コード例 #26
0
ファイル: MeshFromObj.cpp プロジェクト: KNeal/Oculus
//--------------------------------------------------------------------------------------
// This callback function will be called at the end of every frame to perform all the 
// rendering calls for the scene, and it will also be called if the window needs to be 
// repainted. After this function has returned, DXUT will call 
// IDirect3DDevice9::Present to display the contents of the next buffer in the swap chain
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // If the settings dialog is being shown, then
    // render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    HRESULT hr;
    D3DXMATRIXA16 mWorld;
    D3DXMATRIXA16 mView;
    D3DXMATRIXA16 mProj;
    D3DXMATRIXA16 mWorldViewProjection;


    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 141, 153, 191 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        // Get the projection & view matrix from the camera class
        mWorld = *g_Camera.GetWorldMatrix();
        mView = *g_Camera.GetViewMatrix();
        mProj = *g_Camera.GetProjMatrix();

        mWorldViewProjection = mWorld * mView * mProj;

        // Update the effect's variables. 
        V( g_pEffect->SetMatrix( g_hWorldViewProjection, &mWorldViewProjection ) );
        V( g_pEffect->SetMatrix( g_hWorld, &mWorld ) );
        V( g_pEffect->SetFloat( g_hTime, ( float )fTime ) );
        V( g_pEffect->SetValue( g_hCameraPosition, g_Camera.GetEyePt(), sizeof( D3DXVECTOR3 ) ) );

        UINT iCurSubset = ( UINT )( INT_PTR )g_SampleUI.GetComboBox( IDC_SUBSET )->GetSelectedData();

        // A subset of -1 was arbitrarily chosen to represent all subsets
        if( iCurSubset == -1 )
        {
            // Iterate through subsets, changing material properties for each
            for( UINT iSubset = 0; iSubset < g_MeshLoader.GetNumMaterials(); iSubset++ )
            {
                RenderSubset( iSubset );
            }
        }
        else
        {
            RenderSubset( iCurSubset );
        }

        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );
        V( g_SampleUI.OnRender( fElapsedTime ) );

        V( pd3dDevice->EndScene() );
    }
}
コード例 #27
0
ファイル: fde_render.cpp プロジェクト: andoma/pdfium
FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
  if (m_pRenderDevice == NULL) {
    return FDE_RENDERSTATUS_Failed;
  }
  if (m_pIterator == NULL) {
    return FDE_RENDERSTATUS_Failed;
  }
  Lock();
  FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused;
  CFX_Matrix rm;
  rm.SetReverse(m_Transform);
  CFX_RectF rtDocClip = m_pRenderDevice->GetClipRect();
  if (rtDocClip.IsEmpty()) {
    rtDocClip.left = rtDocClip.top = 0;
    rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth();
    rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight();
  }
  rm.TransformRect(rtDocClip);
  IFDE_VisualSet* pVisualSet;
  FDE_HVISUALOBJ hVisualObj;
  CFX_RectF rtObj;
  int32_t iCount = 0;
  while (TRUE) {
    hVisualObj = m_pIterator->GetNext(pVisualSet);
    if (hVisualObj == NULL || pVisualSet == NULL) {
      eStatus = FDE_RENDERSTATUS_Done;
      break;
    }
    rtObj.Empty();
    pVisualSet->GetRect(hVisualObj, rtObj);
    if (!rtDocClip.IntersectWith(rtObj)) {
      continue;
    }
    switch (pVisualSet->GetType()) {
      case FDE_VISUALOBJ_Text:
        RenderText((IFDE_TextSet*)pVisualSet, hVisualObj);
        iCount += 5;
        break;
      case FDE_VISUALOBJ_Path:
        RenderPath((IFDE_PathSet*)pVisualSet, hVisualObj);
        iCount += 20;
        break;
      case FDE_VISUALOBJ_Widget:
        iCount += 10;
        break;
      case FDE_VISUALOBJ_Canvas:
        FXSYS_assert(FALSE);
        break;
      default:
        break;
    }
    if (iCount >= 100 && pPause != NULL && pPause->NeedToPauseNow()) {
      eStatus = FDE_RENDERSTATUS_Paused;
      break;
    }
  }
  Unlock();
  return m_eStatus = eStatus;
}
コード例 #28
0
ファイル: UI.c プロジェクト: Tomius/LittleFighter
/** Benchmark módban kiírja az FPS-t, illetve hogy az egyes oldalaknak hány %-nyi élete van */
static void Draw_benchmark_UI(SDL_Surface *screen, struct character *chars, int enemies_killed) {
    // FPS kiírása
    char c[50];
    sprintf(c, "FPS: %d", fps);
    SDL_Color white = {255,255,255};
    SDL_Surface *text = RenderText(Cour45, c, white);
    SDL_Rect fpsRect = {kx/2 - text->w/2, ky - text->h/2 - 5*(ky-kyBottom)/12, 0, 0};
    BlitSurface(text, NULL, screen, &fpsRect);
    SDL_FreeSurface(text);

    // Bal oldali (LittleFighters' health) szöveg kiírása
    SDL_Color blue = {0, 0, 255};
    text = RenderText(Cour20B, "LittleFighters' health:", blue);
    SDL_Rect allytextRect = {15*scale , kyBottom + 15*scale, text->w, text->h};
    BlitSurface(text, NULL, screen, &allytextRect);
    SDL_FreeSurface(text);

    // Bal oldali (LittleFighters' health) számérték kiszámolása és kiírása
    long hp, maxhp;
    Total_hp(chars, friendly, &hp, &maxhp);
    int percent = hp * 100 / (maxhp * 30);
    sprintf(c, "%d%%", percent);
    text = RenderText(Cour35B, c, blue);
    SDL_Rect allyhpRect = {allytextRect.x + allytextRect.w/2 - text->w/2 , allytextRect.y + allytextRect.h + 10*scale, 0, 0};
    BlitSurface(text, NULL, screen, &allyhpRect);
    SDL_FreeSurface(text);

    // Jobb oldali (Bandits' health) szöveg kiírása
    SDL_Color red = {255, 0, 0};
    text = RenderText(Cour20B, "Bandits' health:", red);
    SDL_Rect enemytextRect = {kx - text->w - 15*scale , kyBottom + 15*scale, text->w, text->h};
    BlitSurface(text, NULL, screen, &enemytextRect);
    SDL_FreeSurface(text);

    // Jobb oldali (Bandits' health) számérték kiszámolása és kiírása
    Total_hp(chars, enemy, &hp, &maxhp);
    if(enemies_killed < 60)
        percent = (hp + (60 - enemies_killed) * maxhp) * 100 / (maxhp * 90);
    else
        percent = hp * 100 / (maxhp * 90);
    sprintf(c, "%d%%", percent);
    text = RenderText(Cour35B, c, red);
    SDL_Rect enemyhpRect = {enemytextRect.x + enemytextRect.w/2 - text->w/2 , enemytextRect.y + enemytextRect.h + 10*scale, 0, 0};
    BlitSurface(text, NULL, screen, &enemyhpRect);
    SDL_FreeSurface(text);
}
コード例 #29
0
ファイル: GUIButtonControl.cpp プロジェクト: MrMC/mrmc
void CGUIButtonControl::Render()
{
  m_imgFocus.Render();
  m_imgNoFocus.Render();

  RenderText();
  CGUIControl::Render();
}
コード例 #30
0
void CALLBACK OnD3D10FrameRender(ID3D10Device *pd3dDevice,double fTime,float fElapsedTime,void *pUserContext)
{
	if(SceneManager::mInited)
	{
		g_pSceneManager->onFrameRender(fTime,fElapsedTime);
		RenderText();
	}
}