17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 21:59:18 +02:00
Files
maszyna/launcher/deferred_image.cppm
maj00r 6550c88536 give importers the headers module templates need
A template defined in a module interface is instantiated in the importing
unit, where its body's types must be complete. A declaration reaching the
importer only through the interface's global module fragment is not
enough for MSVC: cParser::operator>> uses std::stringstream, and every
unit that parsed a float got an incomplete type.

526 headers across 161 units, derived from what each interface's template
bodies actually name.
2026-09-10 01:20:33 +02:00

61 lines
1.2 KiB
C++

module;
#include <cstddef>
#include "glad/glad.h"
#include <string>
#include "global_include/interfaces/ITexture_macros.h"
export module eu07.launcher.deferred_image;
import eu07.glm;
import eu07.global_include.interfaces.itexture;
import eu07.model.texture;
import eu07.rendering.renderer;
export {
class deferred_image {
public:
deferred_image() = default;
deferred_image(const std::string &p) : path(p) { }
deferred_image(const deferred_image&) = delete;
deferred_image(deferred_image&&) = default;
deferred_image &operator=(deferred_image&&) = default;
operator bool() const
{
return image != null_handle || !path.empty();
}
GLuint get() const
{
if (!path.empty()) {
image = GfxRenderer->Fetch_Texture(path, true);
path.clear();
}
if (image != null_handle) {
auto &tex = GfxRenderer->Texture(image);
tex.create();
if (tex.get_is_ready())
return tex.get_id();
}
return -1;
}
glm::ivec2 size() const
{
if (image != null_handle) {
auto &tex = GfxRenderer->Texture(image);
return glm::ivec2(tex.get_width(), tex.get_height());
}
return glm::ivec2();
}
private:
mutable std::string path;
mutable texture_handle image = 0;
};
} // export