dynamic_string command_line_params::get_value_as_string(const char *pKey, uint32_t key_index, const char *pDef, uint32_t value_index) const { param_map_const_iterator it = get_param(pKey, key_index); if (it == end()) return dynamic_string(pDef); if (value_index >= it->second.m_values.size()) { vogl::console::debug("%s: Trying to retrieve value %u of command line parameter %s, but this parameter only has %u values\n", VOGL_FUNCTION_INFO_CSTR, value_index, pKey, it->second.m_values.size()); return dynamic_string(pDef); } return it->second.m_values[value_index]; }
dynamic_string demangle(const char *pMangled) { // TODO console::debug("TODO: %s\n", VOGL_FUNCTION_NAME); return dynamic_string(pMangled); }
dynamic_string file_utils::generate_temp_filename(const char *prefix) { char buffer[FILENAME_MAX]; plat_gettmpfname(buffer, sizeof(buffer), prefix); return dynamic_string(buffer); }
dynamic_string_array get_command_line_params(int argc, char *argv[]) { dynamic_string_array params; for (int i = 0; i < argc; i++) params.push_back(dynamic_string(argv[i])); return params; }
bool command_line_params::load_string_file(const char *pFilename, dynamic_string_array &strings) { cfile_stream in_stream; if (!in_stream.open(pFilename, cDataStreamReadable | cDataStreamSeekable)) { console::error("Unable to open file \"%s\" for reading!\n", pFilename); return false; } dynamic_string ansi_str; for (;;) { if (!in_stream.read_line(ansi_str)) break; ansi_str.trim(); if (ansi_str.is_empty()) continue; strings.push_back(dynamic_string(ansi_str.get_ptr())); } return true; }
dynamic_string uint64_to_string_with_commas(uint64_t value) { const uint32_t cBufSize = 32; char buf[cBufSize]; uint64_to_string_with_commas(value, buf, sizeof(buf)); return dynamic_string(buf); }
dynamic_string uint_to_string(uint64_t value) { const uint32_t cBufSize = 32; char buf[cBufSize]; uint64_to_string(value, buf, cBufSize); return dynamic_string(buf); }
static bool convert_and_write_normal_texture(mipmapped_texture& work_tex, convert_params& params, const crn_comp_params& comp_params, pixel_format dst_format, progress_params& progress_state, bool formats_differ, bool perceptual, convert_stats& stats) { if (formats_differ) { dxt_image::pack_params pack_params; pack_params.m_perceptual = perceptual; pack_params.m_compressor = comp_params.m_dxt_compressor_type; pack_params.m_pProgress_callback = dxt_progress_callback_func; pack_params.m_pProgress_callback_user_data_ptr = &progress_state; pack_params.m_dxt1a_alpha_threshold = comp_params.m_dxt1a_alpha_threshold; pack_params.m_quality = comp_params.m_dxt_quality; pack_params.m_endpoint_caching = !comp_params.get_flag(cCRNCompFlagDisableEndpointCaching); pack_params.m_grayscale_sampling = comp_params.get_flag(cCRNCompFlagGrayscaleSampling); if ((!comp_params.get_flag(cCRNCompFlagUseBothBlockTypes)) && (!comp_params.get_flag(cCRNCompFlagDXT1AForTransparency))) pack_params.m_use_both_block_types = false; pack_params.m_num_helper_threads = comp_params.m_num_helper_threads; pack_params.m_use_transparent_indices_for_black = comp_params.get_flag(cCRNCompFlagUseTransparentIndicesForBlack); console::info("Converting texture format from %s to %s", pixel_format_helpers::get_pixel_format_string(work_tex.get_format()), pixel_format_helpers::get_pixel_format_string(dst_format)); timer tm; tm.start(); bool status = work_tex.convert(dst_format, pack_params); double t = tm.get_elapsed_secs(); console::info(""); if (!status) { if (progress_state.m_canceled) { params.m_canceled = true; return false; } else { return convert_error(params, "Failed converting texture to output format!"); } } console::info("Texture format conversion took %3.3fs", t); } if (params.m_write_mipmaps_to_multiple_files) { for (uint f = 0; f < work_tex.get_num_faces(); f++) { for (uint l = 0; l < work_tex.get_num_levels(); l++) { dynamic_string filename(params.m_dst_filename.get_ptr()); dynamic_string drv, dir, fn, ext; if (!file_utils::split_path(params.m_dst_filename.get_ptr(), &drv, &dir, &fn, &ext)) return false; fn += dynamic_string(cVarArg, "_face%u_mip%u", f, l).get_ptr(); filename = drv + dir + fn + ext; mip_level* pLevel = work_tex.get_level(f, l); face_vec face(1); face[0].push_back(crnlib_new<mip_level>(*pLevel)); mipmapped_texture new_tex; new_tex.assign(face); console::info("Writing texture face %u mip level %u to file %s", f, l, filename.get_ptr()); if (!new_tex.write_to_file(filename.get_ptr(), params.m_dst_file_type, NULL, NULL, NULL)) return convert_error(params, "Failed writing output file!"); } } } else { console::message("Writing texture to file: \"%s\"", params.m_dst_filename.get_ptr()); if (params.m_dst_stream) { if (!work_tex.write_to_stream(params.m_dst_stream, params.m_dst_file_type, NULL, NULL, NULL)) { return convert_error(params, "Failed writing output stream!"); } } else if (!work_tex.write_to_file(params.m_dst_filename.get_ptr(), params.m_dst_file_type, NULL, NULL, NULL)) { return convert_error(params, "Failed writing output file!"); } if (!params.m_no_stats) { if (!stats.init(params.m_pInput_texture->get_source_filename().get_ptr(), params.m_dst_filename.get_ptr(), *params.m_pIntermediate_texture, params.m_dst_file_type, params.m_lzma_stats)) { console::warning("Unable to compute output statistics for file: %s", params.m_pInput_texture->get_source_filename().get_ptr()); } } } return true; }
dynamic_string to_hex_string(uint32_t value) { return dynamic_string(cVarArg, "0x%X", value); }
dynamic_string to_hex_string(uint64_t value) { return dynamic_string(cVarArg, "0x%" PRIX64, value); }