| 21 | g_gl_state_blend_func ); |
| 22 | |
| 23 | TextDrawerGL::TextDrawerGL( |
| 24 | const RenderingContextGL& rendering_context, |
| 25 | const GameResources& game_resources ) |
| 26 | : viewport_size_(rendering_context.viewport_size) |
| 27 | { |
| 28 | // Texture |
| 29 | const Vfs::FileContent font_file= game_resources.vfs->ReadFile( FontParams::font_file_name ); |
| 30 | const CelTextureHeader* const cel_header= reinterpret_cast<const CelTextureHeader*>( font_file.data() ); |
| 31 | const unsigned char* const font_data= font_file.data() + sizeof(CelTextureHeader); |
| 32 | |
| 33 | const unsigned int pixel_count= cel_header->size[0] * cel_header->size[1]; |
| 34 | std::vector<unsigned char> font_rgba( FontParams::colors_variations * 4u * pixel_count ); |
| 35 | |
| 36 | std::vector<unsigned char> font_data_shifted( pixel_count ); |
| 37 | for( unsigned int c= 0u; c < FontParams::colors_variations; c++ ) |
| 38 | { |
| 39 | ColorShift( |
| 40 | FontParams::start_inner_color, FontParams::end_inner_color, |
| 41 | FontParams::color_shifts[c], |
| 42 | pixel_count, |
| 43 | font_data, font_data_shifted.data() ); |
| 44 | |
| 45 | // Hack. Move "slider" letter from code '\0'; |
| 46 | for( unsigned int y= 0; y < FontParams::letter_place_height; y++ ) |
| 47 | std::memcpy( |
| 48 | font_data_shifted.data() + FontParams::atlas_width * y + FontParams::letter_place_width * ( c_slider_back_letter_code & 15u ) + FontParams::atlas_width * FontParams::letter_place_height * ( c_slider_back_letter_code >> 4u ), |
| 49 | font_data_shifted.data() + FontParams::atlas_width * y, |
| 50 | FontParams::letter_place_width ); |
| 51 | |
| 52 | ConvertToRGBA( |
| 53 | pixel_count, |
| 54 | font_data_shifted.data(), |
| 55 | game_resources.palette, |
| 56 | font_rgba.data() + c * pixel_count * 4u ); |
| 57 | |
| 58 | } |
| 59 | |
| 60 | CalculateLettersWidth( |
| 61 | font_data, |
| 62 | letters_width_ ); |
| 63 | |
| 64 | letters_width_[ c_slider_back_letter_code ]= letters_width_[0]; // Move slider letter. |
| 65 | |
| 66 | texture_= |
| 67 | r_Texture( |
| 68 | r_Texture::PixelFormat::RGBA8, |
| 69 | cel_header->size[0], |
| 70 | cel_header->size[1] * FontParams::colors_variations, |
| 71 | font_rgba.data() ); |
| 72 | |
| 73 | texture_.SetFiltration( |
| 74 | r_Texture::Filtration::Nearest, |
| 75 | r_Texture::Filtration::Nearest ); |
| 76 | |
| 77 | // Vertex buffer |
| 78 | std::vector<unsigned short> indeces( 6u * g_max_letters_per_print ); |
| 79 | vertex_buffer_.resize( 4u * g_max_letters_per_print ); |
| 80 |
nothing calls this directly
no test coverage detected