Commit c8e59e2a authored by Florian Oetke's avatar Florian Oetke
Browse files

extended mesh-converter to bulk-convert images; easier API to load images for nuklear

parent f62a1efb
Pipeline #2330 passed with stage
in 4 minutes and 48 seconds
......@@ -3,6 +3,7 @@
#include "common.hpp"
#include "filesystem.hpp"
#include "material_parser.hpp"
#include "model_parser.hpp"
#include <mirrage/utils/log.hpp>
......@@ -62,7 +63,10 @@ int main(int argc, char** argv)
create_directory(output + "/textures");
for(auto&& input : args) {
convert_model(input, output, config);
if(util::ends_with(input, ".png"))
convert_texture(input, output);
else
convert_model(input, output, config);
}
return res;
......
......@@ -395,4 +395,16 @@ namespace mirrage {
return true;
}
void convert_texture(const std::string& input, const std::string& output_dir)
{
auto data = load_texture2d(input, true);
generate_mip_maps(data, [](auto a, auto b, auto c, auto d) { return (a + b + c + d) / 4.f; });
auto input_path = util::split_on_last(input, "/");
auto input_name = input_path.second.empty() ? input_path.first : input_path.second;
input_name = util::split_on_last(input_name, ".").first;
store_texture(data, output_dir + "/" + input_name + ".ktx", false);
}
} // namespace mirrage
......@@ -13,4 +13,7 @@ namespace mirrage {
const std::string& base_dir,
const std::string& output,
const Mesh_converted_config& cfg);
}
extern void convert_texture(const std::string& input, const std::string& output_dir);
} // namespace mirrage
......@@ -121,6 +121,8 @@ namespace mirrage::gui {
auto ready() const noexcept { return bool(_impl); }
auto load_texture(const asset::AID&) -> std::shared_ptr<struct nk_image>;
private:
template <class>
friend class Gui_renderer_instance;
......
......@@ -508,6 +508,12 @@ namespace mirrage::gui {
return &_impl->ctx.ctx;
}
auto Gui::load_texture(const asset::AID& aid) -> std::shared_ptr<struct nk_image>
{
MIRRAGE_INVARIANT(_renderer, "No gui renderer instantiated when load_texture was called!");
return _renderer->load_texture(aid);
}
auto Gui::centered(int width, int height) -> struct nk_rect {
return nk_rect(_impl->screen_size.x / 2.f - float(width) / 2.f,
_impl->screen_size.y / 2.f - float(height) / 2.f,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment