static void TextLayer_Get_Char_BMP ( LCUI_TextStyle *default_style, LCUI_CharData *data ) /* 获取字体位图,字体的样式由文本图层中记录的字体样式决定 */ { LCUI_Font font; int pixel_size; Font_Init( &font ); if(data->data == NULL) { pixel_size = default_style->pixel_size; } else { pixel_size = data->data->pixel_size; } Get_FontBMP( &font, data->char_code, pixel_size, &data->bitmap ); }
static bool Unknown_25C4_000E(void) { Timer_Init(); if (!Video_Init()) return false; Mouse_Init(); /* Add the general tickers */ Timer_Add(Video_Tick, 1000000 / 60); Timer_Add(Timer_Tick, 1000000 / 60); g_var_7097 = -1; GFX_Init(); GFX_ClearScreen(); if (!Font_Init()) { Error( "--------------------------\n" "ERROR LOADING DATA FILE\n" "\n" "Did you copy the Dune2 1.07eu data files into the data directory ?\n" "\n" ); return false; } Font_Select(g_fontNew8p); g_palette_998A = calloc(256 * 3, sizeof(uint8)); memset(&g_palette_998A[45], 63, 3); GFX_SetPalette(g_palette_998A); Tools_RandomLCG_Seed((unsigned)time(NULL)); Widget_SetCurrentWidget(0); return true; }
/** * Initialize Timer, Video, Mouse, GFX, Fonts, Random number generator * and current Widget */ static bool OpenDune_Init(int screen_magnification, VideoScaleFilter filter) { if (!Font_Init()) { Error( "--------------------------\n" "ERROR LOADING DATA FILE\n" "\n" "Did you copy the Dune2 1.07eu data files into the data directory ?\n" "\n" ); return false; } Timer_Init(); if (!Video_Init(screen_magnification, filter)) return false; Mouse_Init(); /* Add the general tickers */ Timer_Add(Timer_Tick, 1000000 / 60, false); Timer_Add(Video_Tick, 1000000 / 60, true); g_mouseDisabled = -1; GFX_Init(); GFX_ClearScreen(); Font_Select(g_fontNew8p); g_palette_998A = calloc(256 * 3, sizeof(uint8)); memset(&g_palette_998A[45], 63, 3); GFX_SetPalette(g_palette_998A); Tools_RandomLCG_Seed((unsigned)time(NULL)); Widget_SetCurrentWidget(0); return true; }
void Util_Init(struct Window *Window) { Mouse.x = 0; Mouse.y = 0; Mouse.justReleased = Mouse.isPressed = Mouse.justPressed = Mouse.isLongedPressed = false; Mouse.isSuper_longPress = Mouse.justSuper_longReleased = false; Mouse.pressedCooldown = 0; Mouse.Faked_Input = false; Game_FPS = 0; Frame_Time_Passed = 0; Keyboard.justPressed = Keyboard.justReleased = Keyboard.justTyped = false; DefaultFontManager = NULL; DefaultFontManager = Font_Init(); check_mem(DefaultFontManager); HighDefaultFont = Font_Add(DefaultFontManager, "Font/Cousine-Regular.ttf", 50); check(HighDefaultFont >= 0, "Couldn't load default font : %s", "Font/Cousine-Regular.ttf"); log_info("Done loading high definition font"); LowDefaultFont = Font_Add(DefaultFontManager, "Font/Cousine-Regular.ttf", 25); check(LowDefaultFont >= 0, "Couldn't load default font : %s", "Font/Cousine-Regular.ttf"); log_info("Done loading low definition font"); Font_Use(DefaultFontManager, HighDefaultFont); ImageEngine_SetUp(); Renderer_SetUp(); log_info("Done initializing util library"); return; error: return; }
static bool Unknown_25C4_000E() { if (!Video_Init()) return false; /* g_var_7097 = -1; */ GFX_Init(); GFX_ClearScreen(); if (!Font_Init()) { Error( "--------------------------\n" "ERROR LOADING DATA FILE\n" "\n" "Did you copy the Dune2 1.07eu data files into the data directory\n" "%s/data ?\n" "\n", g_dune_data_dir ); return false; } Font_Select(g_fontNew8p); memset(g_palette_998A, 0, 3 * 256); memset(&g_palette_998A[45], 63, 3); GFX_SetPalette(g_palette_998A); srand((unsigned)time(NULL)); Tools_RandomLCG_Seed((unsigned)time(NULL)); Widget_SetCurrentWidget(0); return true; }
/* ----------------------------------------------------------------------------- Function: Parameters: Returns: Notes: ----------------------------------------------------------------------------- */ PUBLIC void R_Init() { char renderer_buffer[ 1000 ]; char vendor_buffer[ 1000 ]; int err; int a, b; Com_Printf( "\n------ Display Initialization ------\n" ); Com_Printf( "Initializing OpenGL Subsystem\n" ); R_Register(); // set our "safe" modes gl_state.prev_mode = 0; // get various GL strings gl_config.vendor_string = (char *)pfglGetString( GL_VENDOR ); Com_Printf( "GL_VENDOR: %s\n", gl_config.vendor_string ); gl_config.renderer_string = (char *)pfglGetString( GL_RENDERER ); Com_Printf( "GL_RENDERER: %s\n", gl_config.renderer_string ); gl_config.version_string = (char *)pfglGetString( GL_VERSION ); Com_Printf( "GL_VERSION: %s\n", gl_config.version_string ); gl_config.extensions_string = (char *)pfglGetString( GL_EXTENSIONS ); Com_Printf( "GL_EXTENSIONS: %s\n", gl_config.extensions_string ); my_strlcpy( renderer_buffer, gl_config.renderer_string, sizeof( renderer_buffer ) ); (void)my_strlwr( renderer_buffer ); my_strlcpy( vendor_buffer, gl_config.vendor_string, sizeof( vendor_buffer ) ); (void)my_strlwr( vendor_buffer ); sscanf( gl_config.version_string, "%d.%d", &a, &b ); if( a >= 1 && b >= 2 ) { gl_config.Version_1_2 = true; } pfglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glMaxTexSize ); Com_Printf( "GL_MAX_TEXTURE_SIZE: %d\n", glMaxTexSize); if ( strstr( gl_config.extensions_string, "GL_EXT_discard_framebuffer" ) != 0 ) { gl_config.framebuffer_discard = true; } else { gl_config.framebuffer_discard = false; } InitImmediateModeGL(); GL_SetDefaultState(); TM_Init(); Font_Init(); err = pfglGetError(); if( err != GL_NO_ERROR ) { Com_Printf( "glGetError() = 0x%x\n", err ); } }
void Util_Init(struct Window *Window, void (*error_cb)(int error, const char* description), void (*keyboard_cb)(GLFWwindow *window, int key, int scancode, int action, int mods), void (*character_cb)(GLFWwindow* window, unsigned int codepoint), void (*mouse_pos_cb)(GLFWwindow *window, double x, double y), void (*mouse_button_cb)(GLFWwindow *Window, int button, int action, int mods), void (*mouse_scroll_cb)(GLFWwindow *Window, double x, double y)) { log_info("Initializing Util library"); Mouse.x = 0; Mouse.y = 0; Mouse.justReleased = Mouse.isPressed = Mouse.justPressed = Mouse.isLongedPressed = false; Mouse.isSuper_longPress = Mouse.justSuper_longReleased = false; Mouse.justQuickPressed = false; Mouse.pressedCooldown = 0; Mouse.Faked_Input = false; Game_FPS = 0; Frame_Time_Passed = 0; Keyboard.justPressed = Keyboard.justReleased = Keyboard.justTyped = false; glfwSetErrorCallback(error_cb); glfwSetKeyCallback(Window->Window, keyboard_cb); glfwSetCharCallback(Window->Window, character_cb); glfwSetCursorPosCallback(Window->Window, mouse_pos_cb); glfwSetMouseButtonCallback(Window->Window, mouse_button_cb); glfwSetScrollCallback(Window->Window, mouse_scroll_cb); log_info("Done setting up GLFW"); #ifdef _WIN32 char Path[101]; int PathLength = 100; GetModuleFileName(NULL, &Path[0], PathLength); Path[100] = '\0'; int Length = String_length(&Path[0]) - EXECUTABLE_NAME - 4; #ifndef DEBUG Executable_Path = malloc(sizeof(char) * (Length + 1)); for(int Index = 0; Index < Length; Index++) Executable_Path[Index] = Path[Index]; Executable_Path[Length] = '\0'; #else // DEBUG #ifndef CODE_BLOCKS Length -= 6; Executable_Path = malloc(sizeof(char) * (Length + 1)); for (int Index = 0; Index < Length; Index++) Executable_Path[Index] = Path[Index]; Executable_Path[Length] = '\0'; #else Length -= 10; Executable_Path = malloc(sizeof(char) * (Length + 1)); for (int Index = 0; Index < Length; Index++) Executable_Path[Index] = Path[Index]; Executable_Path[Length] = '\0'; printf("%s\n", Executable_Path); #endif #endif #else char Path[101] = { ' ' }; int PathLength = 100; readlink("/proc/self/exe", &Path[0], PathLength * sizeof(char)); Path[PathLength] = '\0'; int Length = String_length(&Path[0]) - EXECUTABLE_NAME; #ifndef DEBUG Executable_Path = malloc(sizeof(char) * (Length + 1)); for(int Index = 0; Index < Length; Index++) Executable_Path[Index] = Path[Index]; Executable_Path[Length] = '\0'; #else Length -= 6; Executable_Path = malloc(sizeof(char) * (Length + 1)); for (int Index = 0; Index < Length; Index++) Executable_Path[Index] = Path[Index]; Executable_Path[Length] = '\0'; #endif #endif Asset_Path = malloc(sizeof(char) * (String_length(Executable_Path) + String_length("Assets/") + 1)); Asset_Path = memcpy(Asset_Path, Executable_Path, sizeof(char) * (String_length(Executable_Path))); memcpy(Asset_Path + String_length(Executable_Path), "Assets/", sizeof(char) * (String_length("Assets/") + 1)); log_info("Done initializing path"); DefaultFontManager = NULL; DefaultFontManager = Font_Init(); check_mem(DefaultFontManager); HighDefaultFont = Font_Add(DefaultFontManager, "Font/Cousine-Regular.ttf", 50); check(HighDefaultFont >= 0, "Couldn't load default font : %s", "Font/Cousine-Regular.ttf"); log_info("Done loading high definition font"); LowDefaultFont = Font_Add(DefaultFontManager, "Font/Cousine-Regular.ttf", 25); check(LowDefaultFont >= 0, "Couldn't load default font : %s", "Font/Cousine-Regular.ttf"); log_info("Done loading low definition font"); Font_Use(DefaultFontManager, HighDefaultFont); ImageEngine_SetUp(); Renderer_SetUp(); gettimeofday(&Frame_TimePassed, NULL); log_info("Done initializing util library"); return; error: Application_Error(); return; }