diff options
Diffstat (limited to 'src/osd/modules/render/bgfx/texturemanager.cpp')
| -rw-r--r-- | src/osd/modules/render/bgfx/texturemanager.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/osd/modules/render/bgfx/texturemanager.cpp b/src/osd/modules/render/bgfx/texturemanager.cpp index d0bcbcb476d..1fe6fe13b60 100644 --- a/src/osd/modules/render/bgfx/texturemanager.cpp +++ b/src/osd/modules/render/bgfx/texturemanager.cpp @@ -59,7 +59,7 @@ bgfx_texture* texture_manager::create_png_texture(std::string path, std::string { bitmap_argb32 bitmap; emu_file file(path, OPEN_FLAG_READ); - if (file.open(file_name) == osd_file::error::NONE) + if (!file.open(file_name)) { render_load_png(bitmap, file); file.close(); @@ -87,7 +87,7 @@ bgfx_texture* texture_manager::create_png_texture(std::string path, std::string { texture_name += std::to_string(screen); } - bgfx_texture* texture = create_texture(texture_name, bgfx::TextureFormat::RGBA8, width, height, data, flags); + bgfx_texture* texture = create_texture(texture_name, bgfx::TextureFormat::BGRA8, width, height, data, flags); delete [] data; @@ -122,8 +122,10 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form { bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = width; - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, &pitch); - bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch); + int width_div_factor = 1; + int width_mul_factor = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, pitch, width_div_factor, width_mul_factor); + bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)((rowpixels * width_mul_factor) / width_div_factor), (uint16_t)height, mem, pitch); return handle; } } @@ -150,8 +152,10 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form { bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = width; - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, &pitch); - bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch); + int width_div_factor = 1; + int width_mul_factor = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, pitch, width_div_factor, width_mul_factor); + bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)((rowpixels * width_mul_factor) / width_div_factor), (uint16_t)height, mem, pitch); return handle; } } @@ -161,9 +165,12 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = width; - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, &pitch); - handle = bgfx::createTexture2D(width, height, false, 1, dst_format, flags, nullptr); - bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch); + int width_div_factor = 1; + int width_mul_factor = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, pitch, width_div_factor, width_mul_factor); + const uint16_t adjusted_width = (uint16_t)((rowpixels * width_mul_factor) / width_div_factor); + handle = bgfx::createTexture2D(adjusted_width, height, false, 1, dst_format, flags, nullptr); + bgfx::updateTexture2D(handle, 0, 0, 0, 0, adjusted_width, (uint16_t)height, mem, pitch); m_mame_textures[key] = { handle, seqid, width, height }; return handle; @@ -201,6 +208,6 @@ void texture_manager::remove_provider(std::string name, bool delete_provider) { delete m_textures[name]; } - m_textures[name] = nullptr; + m_textures.erase(name); } } |
