static int SetupText(PSEngine *psEngine) { int opq; int h= gistA.t.alignH, v= gistA.t.alignV; GtGetAlignment(&gistA.t, &h, &v); if (SetupColor(psEngine, gistA.t.color)) return 1; if (psEngine->curAlignH!=h || psEngine->curAlignV!=v) { sprintf(line, "%s %s JUS", psHCommands[h-1], psVCommands[v-1]); if (Append(psEngine, line)) return 1; psEngine->curAlignH= h; psEngine->curAlignV= v; } opq= gistA.t.opaque; /* if (gistA.t.orient!=TX_RIGHT) opq= 1; let this be X only limitation */ if (psEngine->curOpaque != (opq!=0)) { if (opq) Append(psEngine, "1 OPQ"); else if (Append(psEngine, "0 OPQ")) return 1; psEngine->curOpaque= (opq!=0); } if (psEngine->curFont!=gistA.t.font || psEngine->curHeight!=gistA.t.height) { if (SetupFont(psEngine, gistA.t.height)) return 1; } return 0; }
static int DrawMarkers(Engine *engine, long n, const GpReal *px, const GpReal *py) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &engine->map; long maxPoints= 4050, nPoints; int type, markEnd= 0; GpPoint *points; int size; char typeString[8]; if (n<1 || gistA.m.type<=0) return 0; if (CheckClip(psEngine)) return 1; if (SetupColor(psEngine, gistA.m.color) || SetupFont(psEngine, gistA.m.size*DEFAULT_MARKER_SIZE)) return 1; if (psEngine->curClip) size= 0; else size= (int)(psEngine->curHeight*NDC_TO_PS); if (gistA.m.type>32 && gistA.m.type<127) { char *now= typeString; *now++= '('; if (gistA.m.type=='(' || gistA.m.type==')' || gistA.m.type=='\\') *now++= '\\'; *now++= type= gistA.m.type; *now++= ')'; *now++= '\0'; } else { if (gistA.m.type<0 || gistA.m.type>M_CROSS) type= M_ASTERISK; else type= gistA.m.type; sprintf(typeString, "%d", type-1); } if (n>90) { long nLines= (n-1)/9 + 1; /* 9 points is 72 characters */ if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } if (Append(psEngine, typeString)) return 1; /* "(A)" or "1", e.g. */ sprintf(line, type<32? "%ld MS" : "%ld M", n); if (Append(psEngine, line) || PutLine(psEngine)) return 1; while ((nPoints= GpIntPoints(map, maxPoints, n, px, py, &points))) { if (PutPoints(psEngine, points, nPoints, size)) return 1; if (n==nPoints) break; n-= nPoints; px+= nPoints; py+= nPoints; } if (markEnd) { if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1; } return 0; }
HRESULT GameLoader::InitialiseD3D(HWND hWnd) { m_pD3D = Direct3DCreate9(D3D_SDK_VERSION); if(m_pD3D == NULL) { return E_FAIL; } D3DDISPLAYMODE d3ddm; if( FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) { return E_FAIL; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.BackBufferCount = 1; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.hDeviceWindow = hWnd; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; if(m_pD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32) == D3D_OK) { d3dpp.AutoDepthStencilFormat = D3DFMT_D32; d3dpp.EnableAutoDepthStencil = TRUE; } else if(m_pD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8) == D3D_OK) { d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8; d3dpp.EnableAutoDepthStencil = TRUE; } else if(m_pD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) == D3D_OK) { d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.EnableAutoDepthStencil = TRUE; } else { d3dpp.EnableAutoDepthStencil = FALSE; } if(FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &m_pD3DDevice))) { return E_FAIL; } m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); SetupPerspective(); SetupFont(); return S_OK; }
static BOOL doInit ( HINSTANCE hInstance, int nCmdShow ) { WNDCLASS wc; // Set up and register window class wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = ( WNDPROC ) WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof ( DWORD ); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor ( NULL, IDC_ARROW ); wc.hbrBackground = ( HBRUSH ) GetStockObject ( BLACK_BRUSH ); wc.lpszMenuName = NULL; wc.lpszClassName = "CSG"; if ( !RegisterClass ( &wc ) ) return FALSE; int ScreenWidth = GetSystemMetrics ( SM_CXSCREEN ); int ScreenHeight = GetSystemMetrics ( SM_CYSCREEN ); // Create a window and display HWND hWnd; hWnd = CreateWindow( "CSG", "DB Pro CSG", //WS_VISIBLE|WS_OVERLAPPED, WS_OVERLAPPED, 0, 0, 10, 10, NULL, NULL, hInstance, NULL ); if ( !hWnd ) return FALSE; //ShowWindow ( hWnd, nCmdShow ); UpdateWindow ( hWnd ); Init_DX ( hWnd ); hwnd = hWnd; SetupFont ( ); InitPolygons ( ); return TRUE; }
void PrintText(Vec2 pos, const char* text, Vec4& colour) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, fontTex); if (!fontInitialised) SetupFont(); while (*text) { glBegin(GL_QUADS); glTexCoord2f((*text) * offset, 0.0); glVertex2f(pos[0], pos[1]); glTexCoord2f((*text + 1) * offset, 0.0); glVertex2f(pos[0] + 8, pos[1]); glTexCoord2f((*text + 1) * offset, 1.0); glVertex2f(pos[0] + 8, pos[1] + 16); glTexCoord2f((*text) * offset, 1.0); glVertex2f(pos[0], pos[1] + 16); glEnd(); pos += Vec2(7, 0); ++text; } glDisable(GL_TEXTURE_2D); }
LTBOOL CInterfaceResMgr::InitFonts() { m_pSmallFont = debug_new(CLTGUIFont); m_pMediumFont = debug_new(CLTGUIFont); m_pLargeFont = debug_new(CLTGUIFont); m_pHelpFont = debug_new(CLTGUIFont); m_pTitleFont = debug_new(CLTGUIFont); m_pMsgForeFont = debug_new(CLTGUIFont); m_pHUDForeFont = debug_new(CLTGUIFont); m_pAirFont = debug_new(CLTGUIFont); m_pChooserFont = debug_new(CLTGUIFont); // Initialize the bitmap fonts if we are in english if (IsEnglish()) { // ************* help font g_pLayoutMgr->GetHelpFont(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pHelpFont)) { debug_delete(m_pHelpFont); m_pHelpFont=LTNULL; return LTFALSE; } // *********** small font g_pLayoutMgr->GetSmallFontBase(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pSmallFont)) { debug_delete(m_pSmallFont); m_pSmallFont=LTNULL; return LTFALSE; } // *********** medium font g_pLayoutMgr->GetMediumFontBase(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pMediumFont)) { debug_delete(m_pMediumFont); m_pMediumFont=LTNULL; return LTFALSE; } // *********** Large font g_pLayoutMgr->GetLargeFontBase(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pLargeFont)) { debug_delete(m_pLargeFont); m_pLargeFont=LTNULL; return LTFALSE; } // ************* Title font g_pLayoutMgr->GetTitleFont(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pTitleFont)) { if (!SetupFont(m_pTitleFont,LTFALSE)) { debug_delete(m_pTitleFont); m_pTitleFont=LTNULL; return LTFALSE; } } // ************* Foreground HUD (i.e. white) HUD font g_pLayoutMgr->GetMsgForeFont(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pMsgForeFont)) { debug_delete(m_pMsgForeFont); m_pMsgForeFont=LTNULL; return LTFALSE; } uint32 dwFlags = LTF_INCLUDE_SYMBOLS_1 | LTF_INCLUDE_NUMBERS | LTF_INCLUDE_SYMBOLS_2; // ************* Foreground HUD (i.e. white) HUD font g_pLayoutMgr->GetHUDForeFont(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pHUDForeFont,LTTRUE,dwFlags)) { debug_delete(m_pHUDForeFont); m_pHUDForeFont=LTNULL; return LTFALSE; } // ************* Air font g_pLayoutMgr->GetAirFont(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pAirFont,LTFALSE,dwFlags)) { debug_delete(m_pAirFont); m_pAirFont=LTNULL; return LTFALSE; } // ************* Weapon Chooser font g_pLayoutMgr->GetChooserFont(g_szFontName,sizeof(g_szFontName)); if (!SetupFont(m_pChooserFont,LTFALSE)) { debug_delete(m_pChooserFont); m_pChooserFont=LTNULL; return LTFALSE; } } else { // TODO: put these into string table for localization // Initialize the engine fonts for non-english resource files if (!InitEngineFont(m_pSmallFont, IDS_SMALL_FONT_NAME, IDS_SMALL_FONT_WIDTH, IDS_SMALL_FONT_HEIGHT, LTFALSE)) return LTFALSE; if (!InitEngineFont(m_pHelpFont, IDS_SMALL_FONT_NAME, IDS_SMALL_FONT_WIDTH, IDS_SMALL_FONT_HEIGHT, LTFALSE)) return LTFALSE; if (!InitEngineFont(m_pMediumFont, IDS_MEDIUM_FONT_NAME, IDS_MEDIUM_FONT_WIDTH, IDS_MEDIUM_FONT_HEIGHT, LTTRUE)) return LTFALSE; if (!InitEngineFont(m_pLargeFont, IDS_LARGE_FONT_NAME, IDS_LARGE_FONT_WIDTH, IDS_LARGE_FONT_HEIGHT, LTTRUE)) return LTFALSE; if (!InitEngineFont(m_pTitleFont, IDS_TITLE_FONT_NAME, IDS_TITLE_FONT_WIDTH, IDS_TITLE_FONT_HEIGHT, LTTRUE)) return LTFALSE; if (!InitEngineFont(m_pMsgForeFont, IDS_MEDIUM_FONT_NAME, IDS_MEDIUM_FONT_WIDTH, IDS_MEDIUM_FONT_HEIGHT, LTTRUE)) return LTFALSE; if (!InitEngineFont(m_pHUDForeFont, IDS_LARGE_FONT_NAME, IDS_LARGE_FONT_WIDTH, IDS_LARGE_FONT_HEIGHT, LTTRUE)) return LTFALSE; if (!InitEngineFont(m_pAirFont, IDS_LARGE_FONT_NAME, IDS_LARGE_FONT_WIDTH, IDS_LARGE_FONT_HEIGHT, LTTRUE)) return LTFALSE; if (!InitEngineFont(m_pChooserFont, IDS_SMALL_FONT_NAME, IDS_SMALL_FONT_WIDTH, IDS_SMALL_FONT_HEIGHT, LTFALSE)) return LTFALSE; } // TODO: reimplement this stuff // Set the wrapping method // HSTRING hString=g_pLTClient->FormatString(IDS_FONT_WRAP_USE_SPACES); // if (_mbsicmp((const unsigned char*)g_pLTClient->GetStringData(hString), (const unsigned char*)"1") == 0) // { CLTGUIFont::SetWrapMethod(LTTRUE); // } // else // { // CLTGUIFont::SetWrapMethod(LTFALSE); // } return LTTRUE; }