Пример #1
0
void C2DRenderUtils::DrawText(
    const float fX, const float fY,
    const float fSizeX, const float fSizeY,
    const char *strText,
    const ColorF& color,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontal        /* = UIDRAWHORIZONTAL_LEFT*/,  // Checked
    const EUIDRAWVERTICAL		eUIDrawVertical          /* = UIDRAWVERTICAL_TOP*/,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontalDocking /* = UIDRAWHORIZONTAL_LEFT*/,
    const EUIDRAWVERTICAL		eUIDrawVerticalDocking   /* = UIDRAWVERTICAL_TOP */)
{
    float drawX = fX;
    float drawY = fY;
    float sizeX = (fSizeX<=0.0f) ? 15.0f : fSizeX;
    float sizeY = (fSizeY<=0.0f) ? 15.0f : fSizeY;

    InitFont( m_pFont, sizeX, sizeY, color );

    float w=0.0f, h=0.0f;
    InternalGetTextDim( m_pFont, &w, &h, 0.0f, strText );
    const float wcpy=w, hcpy=h;
    m_pLayoutManager->AdjustToSafeArea( &drawX, &drawY, &w, &h, eUIDrawHorizontal, eUIDrawVertical, eUIDrawHorizontalDocking, eUIDrawVerticalDocking );
    // Scale the font
    sizeX *= w/wcpy;
    sizeY *= h/hcpy;
    InitFont( m_pFont, sizeX, sizeY, color );
    //InternalDrawRect( drawX, drawY, w, h, ColorF(0.0f,0,1.0f,0.1f));
    InternalDrawText( drawX, drawY, strText );
}
Пример #2
0
void CFontMgr::Init()
{
    m_pStorage = Kernel()->RequestInterface<IStorageTW>();
    m_FontFiles.clear();
    m_FontFiles.hint_size(10);

    ReloadFontlist();

    if(g_Config.m_FtPreloadFonts)
        for(int i = 0; i < m_FontFiles.size(); i++)
            InitFont(&m_FontFiles[i]);

    // load default font
    char aFontFile[256];
    str_format(aFontFile, sizeof(aFontFile), "%s", g_Config.m_FtFont);
    if(str_comp(g_Config.m_FtFont, "fonts/DejaVuSansCJKName.ttf") == 0)
        if (str_find(g_Config.m_ClLanguagefile, "chinese") != NULL || str_find(g_Config.m_ClLanguagefile, "japanese") != NULL ||
                str_find(g_Config.m_ClLanguagefile, "korean") != NULL)
            str_format(aFontFile, sizeof(aFontFile), "fonts/DejavuWenQuanYiMicroHei.ttf");


    for(int i = 0; i < m_FontFiles.size(); i++)
    {
        if(str_comp(m_FontFiles[i].m_Path.c_str(), aFontFile) == 0)
            ActivateFont(i);
    }
}
Пример #3
0
void drawSaveMenu(SaveMenu* sm){
	Font* font = InitFont();
	drawBitmap(sm->Exit, Exit3X, Exit3Y, ALIGN_LEFT, 0);
	if (sm->exit == 1) {
		drawBitmap(sm->Highlight, Exit3X, Exit3Y, ALIGN_LEFT, 0);
	} else if (sm->flag1 == 1) {
		drawBitmap(sm->Highlight2, 500, 235, ALIGN_LEFT, 0);
	} else if (sm->flag2 == 1) {
		drawBitmap(sm->Highlight2, 550, 235, ALIGN_LEFT, 0);
	} else if (sm->flag3 == 1) {
		drawBitmap(sm->Highlight2, 600, 235, ALIGN_LEFT, 0);
	}
	drawChar(font, sm->Letter1, 500, 200);
	drawChar(font, sm->Letter3, 600, 200);
	drawChar(font, sm->Letter2, 550, 200);
	char str[15];
	sprintf(str, "%d", sm->score);
	char score[] = "SCORE";
	char name[] = "NAME";
	drawText(font, name, 300, 200);
	drawText(font, score, 270, 400);
	drawText(font, str, 500, 400);
	deleteFont(font);

}
Пример #4
0
/**
 * InitEverything: Initializes the SDL2 library and all graphical components: font, window, renderer
 * \param width width in px of the window
 * \param height height in px of the window
 * \param _img surface to be created with the table background and IST logo
 * \param _window represents the window of the application
 * \param _renderer renderer to handle all rendering in a window
 */
void InitEverything(int width, int height, TTF_Font **_font, SDL_Surface *_img[], SDL_Window** _window, SDL_Renderer** _renderer)
{
    InitSDL();
    InitFont();
    *_window = CreateWindow(width, height);
    *_renderer = CreateRenderer(width, height, *_window);

    // load the table texture
    _img[0] = IMG_Load("assets//table_texture.png");
    if (_img[0] == NULL) {
        fprintf(stderr, "Unable to load image: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
    }

    // load IST logo
    _img[1] = SDL_LoadBMP("assets//ist_logo.bmp");
    if (_img[1] == NULL) {
        fprintf(stderr, "Unable to load bitmap: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
    }

    // this opens (loads) a font file and sets a size
    *_font = TTF_OpenFont("assets//FreeSerif.ttf", 16);
    if(*_font == NULL) {
        fprintf(stderr, "TTF_OpenFont: %s\n", TTF_GetError());
        exit(EXIT_FAILURE);
    }
}
Пример #5
0
void CDX10Core::OnResize(int width, int height)
{		
	SAFE_DX_RELEASE( m_pRenderTargetView);
	SAFE_DX_RELEASE( m_pDepthStencilView);	
	
	// Resize the swap chain and recreate the render target view.

	HR(m_pSwapChain->ResizeBuffers(1, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, 0));
		
	InitRenderAndDepthStencilTargets( width, height );

	// Set the viewport transform.
	D3D10_VIEWPORT vp;
	vp.TopLeftX = 0;
	vp.TopLeftY = 0;
	vp.Width    = width;
	vp.Height   = height;
	vp.MinDepth = 0.0f;
	vp.MaxDepth = 1.0f;

	m_pDevice->RSSetViewports( 1, &vp );

	InitMatrices(vp.Width, vp.Height);
	
	InitDepthStencilState();

	InitFont();

}
/*
================
CSyntaxRichEditCtrl::Init
================
*/
void CSyntaxRichEditCtrl::Init(void)
{

	// get the Rich Edit ITextDocument to use the wonky TOM interface
	IRichEditOle *ire = GetIRichEditOle();
	IUnknown *iu = (IUnknown *)ire;

	if (iu == NULL || iu->QueryInterface(tom::IID_ITextDocument, (void **) &m_TextDoc) != S_OK) {
		m_TextDoc = NULL;
	}

	InitFont();

	InitSyntaxHighlighting();

	SetEventMask(GetEventMask() | ENM_CHANGE | ENM_KEYEVENTS | ENM_MOUSEEVENTS | ENM_PROTECTED);	// ENM_SCROLLEVENTS

	EnableToolTips(TRUE);

	// create auto complete list box
	CRect rect(0, 0, AUTOCOMPLETE_WIDTH, AUTOCOMPLETE_HEIGHT);
	autoCompleteListBox.Create(WS_DLGFRAME | WS_VISIBLE | WS_VSCROLL | LBS_SORT | LBS_NOTIFY, rect, this, IDC_LISTBOX_AUTOCOMPLETE);
	autoCompleteListBox.SetFont(GetParent()->GetFont());
	autoCompleteListBox.ShowWindow(FALSE);

	// create function parameter tool tip
	funcParmToolTip.Create(WS_VISIBLE | WS_BORDER, rect, this, IDC_EDITBOX_FUNCPARMS);
	funcParmToolTip.SetFont(GetParent()->GetFont());
	funcParmToolTip.ShowWindow(FALSE);
}
Пример #7
0
BOOL CPropShowTime::OnInitDialog()
{
	CPropertyPage::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CTime currentTime;
	currentTime = CTime::GetCurrentTime();
	CString time;
	time.Format(_T("%d年%d月%d日 %d时%d分%d秒"),
		currentTime.GetYear(),currentTime.GetMonth(),currentTime.GetDay(),
		currentTime.GetHour(),currentTime.GetMinute(),currentTime.GetSecond());
	m_com_timeStyle.AddString(time);
	time = currentTime.Format(_T("%Y-%m-%d"));
	m_com_timeStyle.AddString(time);
	time = currentTime.Format(_T("%H:%M:%S"));
	m_com_timeStyle.AddString(time);
	time = currentTime.Format(_T("%Y-%m-%d %H:%M:%S"));
	m_com_timeStyle.AddString(time);
	//初始化
	InitFont();

	SetTimer(ShowTime,1000,NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Пример #8
0
CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles)
    :
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
      m_bUseLogFontStyle(FALSE),
      m_dwLogFontStyle(0),
#endif
      m_pFont(nullptr),
      m_pFontMgr(src.m_pFontMgr),
      m_iRefCount(1),
      m_bExtFont(FALSE),
      m_pStream(nullptr),
      m_pFileRead(nullptr),
      m_pFontEncoding(nullptr),
      m_pCharWidthMap(nullptr),
      m_pRectArray(nullptr),
      m_pBBoxMap(nullptr),
      m_pProvider(nullptr) {
  ASSERT(src.m_pFont);
  m_pFont = new CFX_Font;
  m_pFont->LoadClone(src.m_pFont);
  CFX_SubstFont* pSubst = m_pFont->GetSubstFont();
  if (!pSubst) {
    pSubst = new CFX_SubstFont;
    m_pFont->SetSubstFont(pSubst);
  }
  pSubst->m_Weight =
      (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
  if (dwFontStyles & FX_FONTSTYLE_Italic) {
    pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC;
  }
  InitFont();
}
void C2DRenderUtils::DrawTextW(
															 const float fX,
															 const float fY,
															 const float fSizeX,
															 const float fSizeY,
															 const wchar_t *strText,
															 const ColorF& cfColor,
															 const EUIDRAWHORIZONTAL	eUIDrawHorizontal        /*= UIDRAWHORIZONTAL_LEFT*/,  // checked
															 const EUIDRAWVERTICAL		eUIDrawVertical          /*= UIDRAWVERTICAL_TOP*/,
															 const EUIDRAWHORIZONTAL	eUIDrawHorizontalDocking /*= UIDRAWHORIZONTAL_LEFT*/,
															 const EUIDRAWVERTICAL		eUIDrawVerticalDocking   /*= UIDRAWVERTICAL_TOP*/ )
{
	float drawX = fX;
	float drawY = fY;
	float sizeX = (fSizeX<=0.0f) ? 15.0f : fSizeX;
	float sizeY = (fSizeY<=0.0f) ? 15.0f : fSizeY;

	InitFont( m_pFont, sizeX, sizeY, cfColor );

	float w=0.0f, h=0.0f;
	GetTextDimW( m_pFont, &w, &h, sizeX, sizeY, strText );
	const float wcpy=w, hcpy=h;
	m_pLayoutManager->AdjustToSafeArea( &drawX, &drawY, &w, &h, eUIDrawHorizontal, eUIDrawVertical, eUIDrawHorizontalDocking, eUIDrawVerticalDocking );

	// scale font size appropriately
	sizeX *= w/wcpy; 
	sizeY *= h/hcpy;

	InternalDrawTextW( drawX, drawY, 0.0f, strText );
}
Пример #10
0
BOOL RenderLaser::Init(UINT width, UINT height, HWND hwnd, BOOL windowed, D3DDEVTYPE devType) {
    HRESULT hr = Render::Init(width, height, hwnd, windowed, devType);
    SGL_FAILED_DO(hr, MYTRACE_DX("Render::Init", hr); return FALSE);

    // seed random number generator
    srand((unsigned) time(NULL));

    // Create Laser
    m_Gun.reset(new SGL::ParticleGun(&m_Camera));
    if (!m_Gun->Init(m_D3DDev, TextureFile))
        return FALSE;

    // Setup a basic scene.
    m_BasicScene.reset(new BasicScene(m_D3DDev));
    if (!m_BasicScene->Init())
        return FALSE;

    // Set projection matrix.
    D3DXMATRIX proj;
    D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4.0f, (float) width / (float) height, 1.0f, 5000.0f);
    m_D3DDev->SetTransform(D3DTS_PROJECTION, &proj);

    if (!InitFont())
        return FALSE;

    return TRUE;
}
Пример #11
0
struct SDL_Font *SDL_InitFont(const char *src) {
	FILE *fptr = fopen(src, "rb");
	int q = 0,mx = 0,my = 0;
	struct SDL_Font *fnt;
	int i,z,p;
	if(!fptr) return 0;

	fnt = (struct SDL_Font*)malloc(sizeof(struct SDL_Font));

	fread((char*)&q, sizeof(int), 1, fptr);
	if(q == -100) {
		fread((char*)&mx, sizeof(int), 1, fptr);
		fread((char*)&my, sizeof(int), 1, fptr);
		fread((char*)&fnt->tcolor, sizeof(int), 1, fptr);
		if(mx < 0 || mx < 0 || mx > 250 || my > 250) {
			// invalid font file
			fprintf(stderr, "Error invalid font file format!\n");
			free(fnt);
			return 0;
		}
		InitFont(fnt, mx, my, fnt->tcolor);
		for(p = 0; p <= 127; p++)
		for(i = 0; i < fnt->mx; i++) {
			for(z = 0; z < fnt->my; z++) {
				fread((char*)&fnt->letters[p].fnt_ptr[i][z], sizeof(int), 1, fptr);
			}
		}
	}
	fclose(fptr);
	return fnt;
}
Пример #12
0
void InitResource()
{
    InitPack("data.dat");
    /*---------------------------------------------*/
    ReadTextureObject("img\\font.txt");
    res.font_stage = GetTextrueObject("font_stage");
    res.font_score = GetTextrueObject("font_score");
    /*---------------------------------------------*/
    ReadTextureObject("img\\chare.txt");
    res.player_right = GetTextrueObject("player_right");
    res.player_left  = GetTextrueObject("player_left");
    res.enemy_bird   = GetTextrueObject("bird");
    res.block_block1 = GetTextrueObject("map_green");
    res.item_apple   = GetTextrueObject("apple");
    res.enemy_dog    = GetTextrueObject("dog");
    /*---------------------------------------------*/
    ReadTextureObject("img\\effect1.txt");
    res.effect1_0 = GetTextrueObject("effect1_1");
    res.effect1_1 = GetTextrueObject("effect1_2");
    res.effect1_2 = GetTextrueObject("effect1_3");
    res.effect1_3 = GetTextrueObject("effect1_4");
    res.effect1_4 = GetTextrueObject("effect1_5");
    res.effect1_5 = GetTextrueObject("effect1_6");
    res.effect1_6 = GetTextrueObject("effect1_7");
    res.effect1_7 = GetTextrueObject("effect1_8");
    res.effect1_8 = GetTextrueObject("effect1_9");
    res.effect1_9 = GetTextrueObject("effect1_10");
    /*---------------------------------------------*/
    res.sound_jump  = LoadSound("sound\\jump.wav");
    res.sound_die   = LoadSound("sound\\die.wav");
    InitFont();
    /*---------------------------------------------*/
    SwitchObject = DrawObject;
    SwitchBlock  = DrawBlock;
}    
Пример #13
0
void RetrieveResources( void )
{
	                            OpeningProgress( 0, 10 );
	InitSound( );				OpeningProgress( 1, 10 );

	InitBackdrop( );			OpeningProgress( 2, 10 );

	GetBlobGraphics( );			OpeningProgress( 3, 10 );
	
	InitNext( );				OpeningProgress( 4, 10 );
	
	InitScore( );				OpeningProgress( 5, 10 );

	InitGrayMonitors( );		OpeningProgress( 6, 10 );
	
	InitOpponent( );			OpeningProgress( 7, 10 );

	InitStage( );   // must run after backdrop window is open
	InitGameTickCount( );

	InitPlayers( ); // must run after backdrop window is open
	InitFont( ); 
	InitZapStyle( );// must run after fonts are inited
					            OpeningProgress( 8, 10 );
	
	InitBlitter( ); // must run after player windows are open
	InitPlayerWorlds( );  		OpeningProgress( 9, 10 );
	
	InitVictory( );	// must run after fonts are inited			
	InitTweak( );				OpeningProgress( 10, 10 );
}
Пример #14
0
void CDebug::Initialize()
{
	m_pDevice = _SINGLE(CDevice)->GetDevice();
	if(!m_pDevice)
		return;
	_SINGLE(CTimeManager)->Init();
	//CreateVertexBuffer();

	//memset(&m_tGridMaterial, 0, sizeof(D3DMATERIAL9));
	//m_tGridMaterial.Diffuse.a = 1.f;
	//m_tGridMaterial.Diffuse.r = 1.f;
	//m_tGridMaterial.Diffuse.g = 0.8f;
	//m_tGridMaterial.Diffuse.b = 1.f;
	//m_tGridMaterial.Power = 0.2f;
	//m_tGridMaterial.Specular = m_tGridMaterial.Diffuse;
	//m_tGridMaterial.Ambient = m_tGridMaterial.Diffuse;

	//m_pTerrain = new CTerrainMesh;

	//m_pTerrain->Initialize();

	InitFont();
	InitLog();
	InitLine();

	//AddText3D( D3DXVECTOR3(10, 3, 10), _T("3D텍스트다!") );

}
Пример #15
0
void InitAll(void)
{
	int i;
	for (i = 0; devs[i]; i++) devs[i]->Init();

	InitDevMaps();

	for (i = 0; i < 0x10; i++) colors[i] = colors_base[i];

	InitSurfaces();
	InitFont();
	FileDialogInit();
	C_Tape::Init();

	for (i = 0; i < 0x10000; i++) breakpoints[i] = false;

	cpu = z80ex_create(
		ReadByte, NULL,
		WriteByte, NULL,
		InputByte, NULL,
		OutputByte, NULL,
		ReadIntVec, NULL
	);

#if defined(__APPLE__)
	updateScreenThreadSem = SDL_CreateSemaphore(0);
	upadteScreenThread = SDL_CreateThread(UpdateScreenThreadFunc, NULL);
#endif
}
Пример #16
0
TkFont *
TkpGetNativeFont(
    Tk_Window tkwin,		/* For display where font will be used. */
    CONST char *name)		/* Platform-specific font name. */
{
    UnixFtFont *fontPtr;
    FcPattern *pattern;
#if DEBUG_FONTSEL
    printf("TkpGetNativeFont %s\n", name);
#endif /* DEBUG_FONTSEL */

    pattern = XftXlfdParse(name, FcFalse, FcFalse);
    if (!pattern) {
	return NULL;
    }

    /*
     * Should also try: pattern = FcNameParse(name); but generic/tkFont.c
     * expects TkpGetNativeFont() to only work on XLFD names under Unix.
     */

    fontPtr = InitFont(tkwin, pattern, NULL);
    if (!fontPtr) {
	return NULL;
    }
    return &fontPtr->font;
}
Пример #17
0
void Test22()
{
	int curgrp = 0; char tb[512];

	printf("Use LTTT? ");
	int uselt = atoi(fgets(tb, 511, stdin));

	LoadBCP("data.bcp");
	InitWindow();
	InitFont();

	if(uselt) LoadLTTT("Maps\\Map_Textures\\128_4Peaks.lttt");
	LoadMapTextures();

	//MessageBox(hWindow, "Terrain textures loaded.", appName, 64);
	printf("%u groups:\n", maptexgroup.len);
	for(int i = 0; i < maptexgroup.len; i++)
	{
		MapTextureGroup *g = maptexgroup.getpnt(i);
		printf(" * %s\n", g->name);
		printf("   %u textures:\n", g->tex->len);
		for(int j = 0; j < g->tex->len; j++)
			printf("    - %u\n", g->tex->getpnt(j)->id);
	}
	//texture t = GetTexture("Warrior Kings Game Set\\Textures\\Tavern.pcx");
	while(!appexit)
	{
		BeginDrawing();
		InitRectDrawing();

		//SetTexture(0, maptexgroup.getpnt(0)->tex->getpnt(0)->t);
		//SetTexture(0, t);
		//DrawRect(0, 0, 256, 256, -1);

		MapTextureGroup *g = maptexgroup.getpnt(curgrp);
		sprintf(tb, "%s (%u/%u)", g->name, curgrp, maptexgroup.len);
		DrawFont(0, 0, tb);
		for(int i = 0; i < g->tex->len; i++)
		{
			MapTexture *t = g->tex->getpnt(i);
			SetTexture(0, t->t);
			DrawRect(i * 65, 32, 64, 64, -1, t->x / 256.f, t->y / 256.f, t->w / 256.f, t->h / 256.f);
			sprintf(tb, "%u", t->id);
			DrawFont(i * 65, 96, tb);
		}

		if(keypressed[VK_LEFT])
		{
			if(curgrp > 0) curgrp--;
		}
		if(keypressed[VK_RIGHT])
		{
			if(curgrp < maptexgroup.len-1) curgrp++;
		}

		EndDrawing();
		HandleWindow();
	}
}
Пример #18
0
FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExtFont) {
  if (m_pFont || !pExtFont) {
    return FALSE;
  }
  m_pFont = pExtFont;
  m_bExtFont = TRUE;
  return InitFont();
}
Пример #19
0
bool CDX10Core::Init( HWND hWnd, const DXInitDesc &initDesc )
{
	m_bInitialized = false;
	// Save new window handle for future use
	m_hWnd = hWnd;

	// Save new init description for future use
	m_initDesc = initDesc;

	// Use init description in building specific init description
	DXGI_SWAP_CHAIN_DESC sd;
	ZeroMemory( &sd, sizeof( sd ) );
	sd.BufferCount = initDesc.bufferCount;
	sd.BufferDesc.Width = initDesc.bufferDesc.width;
	sd.BufferDesc.Height = initDesc.bufferDesc.height;
	sd.BufferDesc.Format = ( DXGI_FORMAT )initDesc.bufferDesc.format;
	sd.BufferDesc.RefreshRate.Numerator = initDesc.bufferDesc.refreshRate.numerator;
	sd.BufferDesc.RefreshRate.Denominator = initDesc.bufferDesc.refreshRate.denominator;
	sd.BufferUsage = initDesc.bufferUsage;
	sd.OutputWindow = initDesc.hOutputWindow;
	sd.SampleDesc.Count = initDesc.sampleDesc.count;
	sd.SampleDesc.Quality = initDesc.sampleDesc.quality;
	sd.Windowed = initDesc.bWindowed;

	// Create d3d device, swap chain
	
	HR( D3D10CreateDeviceAndSwapChain1( NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0,
		D3D10_FEATURE_LEVEL_10_1, D3D10_1_SDK_VERSION, &sd, &m_pSwapChain, &m_pDevice ) );
	
	InitRenderAndDepthStencilTargets( sd.BufferDesc.Width, sd.BufferDesc.Height );

	// Set the viewport transform.
	D3D10_VIEWPORT vp;
	vp.TopLeftX = 0;
	vp.TopLeftY = 0;
	vp.Width    = sd.BufferDesc.Width;
	vp.Height   = sd.BufferDesc.Height;
	vp.MinDepth = 0.0f;
	vp.MaxDepth = 1.0f;

	m_pDevice->RSSetViewports( 1, &vp );

	InitMatrices(vp.Width, vp.Height);

	InitRasterizerState();

	InitDepthStencilState();

	InitBasicEffects();

	InitializeBuffers();

	InitFont();

	m_bInitialized = true;
	return true;
}
Пример #20
0
FX_BOOL CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
  if (m_pFont)
    return FALSE;

  m_pFont = new CFX_Font;
  if (!m_pFont->LoadEmbedded(pBuffer, length))
    return FALSE;
  return InitFont();
}
Пример #21
0
void InformationState::Init(sf::RenderWindow* screen)
{

	LoadResources(screen);

	InitFont();
	InitText();

}
Пример #22
0
BOOL RenderPick::Init(UINT width, UINT height, HWND hwnd, BOOL windowed, D3DDEVTYPE devType) {
    HRESULT hr = Render::Init(width, height, hwnd, windowed, devType);
    SGL_FAILED_DO(hr, MYTRACE_DX("Render::Init", hr); return FALSE);

    // Create the teapot.
    ID3DXMesh* teapot;
    D3DXCreateTeapot(m_D3DDev, &teapot, NULL);
    m_Teapot.Attach(teapot);

    // Compute the bounding sphere.
    BYTE* v = 0;
    teapot->LockVertexBuffer(0, (void**) &v);

    D3DXComputeBoundingSphere((D3DXVECTOR3*) v, teapot->GetNumVertices(), D3DXGetFVFVertexSize(teapot->GetFVF()), &m_BSphere.center, &m_BSphere.radius);
    teapot->UnlockVertexBuffer();

    // Build a sphere mesh that describes the teapot's bounding sphere.
    ID3DXMesh* sphere;
    D3DXCreateSphere(m_D3DDev, m_BSphere.radius, 20, 20, &sphere, NULL);
    m_Sphere.Attach(sphere);

    // Set light.
    D3DXVECTOR3 dir(0.707f, -0.0f, 0.707f);
    D3DXCOLOR clr(1.0f, 1.0f, 1.0f, 1.0f);
    D3DLIGHT9 light;
    SGL::InitDirLight(&light, dir, clr);

    m_D3DDev->SetLight(0, &light);
    m_D3DDev->LightEnable(0, TRUE);
    m_D3DDev->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
    m_D3DDev->SetRenderState(D3DRS_SPECULARENABLE, FALSE);

    // Set view matrix.
    D3DXVECTOR3 pos(0.0f, 0.0f, -10.0f);
    D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
    D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);

    D3DXMATRIX V;
    D3DXMatrixLookAtLH(&V, &pos, &target, &up);
    m_D3DDev->SetTransform(D3DTS_VIEW, &V);

    // Set projection matrix.
    D3DXMATRIX proj;
    D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI * 0.25f, (float) width / (float) height, 1.0f, 1000.0f);
    m_D3DDev->SetTransform(D3DTS_PROJECTION, &proj);

    // Setup a basic scene.
    m_BasicScene.reset(new BasicScene(m_D3DDev));
    if (!m_BasicScene->Init())
        return FALSE;

    if (!InitFont())
        return FALSE;

    return TRUE;
}
Пример #23
0
FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
                             FX_DWORD dwFontStyles,
                             FX_WORD wCodePage) {
  if (m_pFont) {
    return FALSE;
  }
  Lock();
  CFX_ByteString csFontFamily;
  if (pszFontFamily != NULL) {
    csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily);
  }
  FX_DWORD dwFlags = 0;
  if (dwFontStyles & FX_FONTSTYLE_FixedPitch) {
    dwFlags |= FXFONT_FIXED_PITCH;
  }
  if (dwFontStyles & FX_FONTSTYLE_Serif) {
    dwFlags |= FXFONT_SERIF;
  }
  if (dwFontStyles & FX_FONTSTYLE_Symbolic) {
    dwFlags |= FXFONT_SYMBOLIC;
  }
  if (dwFontStyles & FX_FONTSTYLE_Script) {
    dwFlags |= FXFONT_SCRIPT;
  }
  if (dwFontStyles & FX_FONTSTYLE_Italic) {
    dwFlags |= FXFONT_ITALIC;
  }
  if (dwFontStyles & FX_FONTSTYLE_Bold) {
    dwFlags |= FXFONT_BOLD;
  }
  if (dwFontStyles & FX_FONTSTYLE_ExactMatch) {
    dwFlags |= FXFONT_EXACTMATCH;
  }
  int32_t iWeight =
      (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
  FX_WORD wCharSet = FX_GetCharsetFromCodePage(wCodePage);
  if (wCharSet == 0xFFFF) {
    wCharSet = FXSYS_GetACP();
  }
  m_wCharSet = wCharSet;
  m_pFont = new CFX_Font;
  if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) {
    csFontFamily += ",BoldItalic";
  } else if (dwFlags & FXFONT_BOLD) {
    csFontFamily += ",Bold";
  } else if (dwFlags & FXFONT_ITALIC) {
    csFontFamily += ",Italic";
  }
  m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage);
  FX_BOOL bRet = m_pFont->GetFace() != nullptr;
  if (bRet) {
    bRet = InitFont();
  }
  Unlock();
  return bRet;
}
Пример #24
0
void C2DRenderUtils::GetTextDimW(IFFont *pFont,
																 float *fWidth,
																 float *fHeight,
																 const float fSizeX,
																 const float fSizeY,
																 const wchar_t *strText)
{
	InitFont( pFont, fSizeX, fSizeY );
	InternalGetTextDimW(pFont, fWidth, fHeight, 0.0f, strText);
}
Пример #25
0
Font::Font( std::string name, int point_size )
{
	Initialized = false;
	TTFont = NULL;
	
	Name = name;
	PointSize = point_size;
	
	InitFont();
}
Пример #26
0
void Init_All()
{
	
	done = 0;
	nexttimer = -1;
	Init_Graphics();
	InitFont();
	InitMenu();
	InitMouse();
	atexit(CleanUpAll);
}
Пример #27
0
void m1_init_machine(void)
{
    #ifdef ENABLE_FONT_RESOURCE
	InitFont();
	#endif
    #ifdef CONFIG_AML_I2C
	sys_test_i2c_init(&aml_i2c_info, ARRAY_SIZE(aml_i2c_info));
	#endif
	adc_init(&adc_info, ARRAY_SIZE(adc_info));
	power_on_backlight();
}
Пример #28
0
//-----------------------------------------------------------------------------------------------------
void C2DRenderUtils::DrawWrappedText(
    const float fX,
    const float fY,
    const float fMaxWidth,
    const float fSizeX,
    const float fSizeY,
    const char *strText,
    const ColorF& cfColor,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontal /*= UIDRAWHORIZONTAL_LEFT*/, // Checked
    const EUIDRAWVERTICAL		eUIDrawVertical /*= UIDRAWVERTICAL_TOP*/,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontalDocking /*= UIDRAWHORIZONTAL_LEFT*/,
    const EUIDRAWVERTICAL		eUIDrawVerticalDocking /*= UIDRAWVERTICAL_TOP*/
)
{
    float drawX = fX;
    float drawY = fY;
    float sizeX = (fSizeX<=0.0f) ? 15.0f : fSizeX;
    float sizeY = (fSizeY<=0.0f) ? 15.0f : fSizeY;

    InitFont( m_pFont, fSizeX, fSizeY, cfColor );

    string wrappedStr;
    const bool bWrapText = fMaxWidth > 0.0f;
    if (bWrapText)
    {
        m_pFont->WrapText(wrappedStr, fMaxWidth, strText, m_ctx);
        strText = wrappedStr.c_str();
    }
    Vec2 vDim = m_pFont->GetTextSize(strText, true, m_ctx);

    const float wcpy=vDim.x, hcpy=vDim.y;
    m_pLayoutManager->AdjustToSafeArea( &drawX, &drawY, &vDim.x, &vDim.y, eUIDrawHorizontal, eUIDrawVertical, eUIDrawHorizontalDocking, eUIDrawVerticalDocking );

    // scale font size appropriately
    sizeX *= vDim.x/wcpy;
    sizeY *= vDim.y/hcpy;
    InitFont( m_pFont, sizeX, sizeY, cfColor );
    //InternalDrawRect( drawX, drawY, vDim.x, vDim.y, ColorF(0.0f,1.0f,0.0f,0.1f));
    InternalDrawText( drawX, drawY, strText );
}
Пример #29
0
int main(int argc, char* args[]) {

//====== Инициализация ==============================================================
	SDL_Surface *screen = NULL;
	TTF_Font	*font	= NULL;		// Шрифт
	// SDL_Surface буквально есть поверхность окна,
	// на ней мы проделываем все действия по отрисовке,
	// а затем ф-ией SDL_Flip(...) показываем нужную
	// поверхность в окне. (см. реализацию в SDLVisualSort.h)


	screen = InitSDL(); // Инициализация основного окна
	InitFont();			// ... шрифта
//====================================================================================

	// Пример Гномьей сортировки
	const unsigned size = 36;
	float arr[size] =	{10, 15, 0, -5, 20, 12, 50, 3, -34, 21, 33, 1, 2, 3,5, 9, 8, 7,
						-20, -15, 0, -5, 2, 12, 45, 23, -8, -24, 32, 7, 41,33, 1,50, 3, -34};
	float temp;
	int i = 1;
    int j = 2;
	while (i < size) {
		// DrawSort (см.выше)
		DrawSort(arr, size, screen, i);
	
		SDL_Delay(50); //пауза (чтобы замедлить процесс отображения сортировки)
		if (arr[i - 1] <= arr[i]) {
            i = j;
            j = j + 1;
		}
		else {
            //swap a[i - 1] and a[i]
			temp = arr[i-1];
			arr[i-1] = arr[i];
			arr[i] = temp;

            i = i - 1;
			if (i == 0) {
                i = j;
                j = j + 1;
			}
		}
	}
/*
	Если массив сильно большой и отображается так мелко, что не видно цифр,
	можно увеличить размеры окна: WIDTH(ширина) и HEIGHT(высота) в самом
	верху SDLVisualSort.h
*/	
	system ("pause");
	return 0;
}
Пример #30
0
//-----------------------------------------------------------------------------------------------------
// TODO :
//	* Fix/Check rendering location/scaling.
void C2DRenderUtils::GetWrappedTextDim(IFFont *pFont,
                                       float *fWidth,
                                       float *fHeight,
                                       const float fMaxWidth,
                                       const float fSizeX,
                                       const float fSizeY,
                                       const char *strText)
{
    float sizeX = (fSizeX<=0.0f) ? 15.0f : fSizeX;
    float sizeY = (fSizeY<=0.0f) ? 15.0f : fSizeY;

    InitFont( pFont, sizeX, sizeY );
    InternalGetTextDim(pFont, fWidth, fHeight, fMaxWidth, strText);
}