.................

This commit is contained in:
2025-11-11 22:19:18 -05:00
parent 7e1b8c8b04
commit d7c481a20b
8 changed files with 32 additions and 4 deletions

View File

@@ -16,6 +16,10 @@ namespace anm2ed::resource
if (path && *path) internal = MIX_LoadAudio(mixer_get(), path, true);
}
Audio::Audio(const std::string& path) : Audio(path.c_str()) {}
Audio::Audio(const std::filesystem::path& path) : Audio(path.string()) {}
Audio::Audio(const unsigned char* data, size_t size)
{
SDL_IOStream* io = SDL_IOFromConstMem(data, size);

View File

@@ -1,6 +1,8 @@
#pragma once
#include <SDL3_mixer/SDL_mixer.h>
#include <filesystem>
#include <string>
#include <cstddef>
namespace anm2ed::resource
@@ -15,6 +17,8 @@ namespace anm2ed::resource
public:
Audio(const char*);
Audio(const unsigned char*, size_t);
Audio(const std::string&);
Audio(const std::filesystem::path&);
~Audio();
Audio() = default;
Audio(Audio&&) noexcept;

View File

@@ -1,5 +1,6 @@
#include "texture.h"
#include <filesystem>
#include <lunasvg.h>
#include <memory>
#include <utility>
@@ -123,11 +124,15 @@ namespace anm2ed::resource
}
}
Texture::Texture(const std::filesystem::path& pngPath) : Texture(pngPath.string()) {}
bool Texture::write_png(const std::string& path)
{
return stbi_write_png(path.c_str(), size.x, size.y, CHANNELS, this->pixels.data(), size.x * CHANNELS);
}
bool Texture::write_png(const std::filesystem::path& path) { return write_png(path.string()); }
void Texture::pixel_set(ivec2 position, vec4 color)
{
if (position.x < 0 || position.y < 0 || position.x >= size.x || position.y >= size.y) return;

View File

@@ -1,5 +1,6 @@
#pragma once
#include <filesystem>
#include <string>
#include <vector>
@@ -36,7 +37,9 @@ namespace anm2ed::resource
Texture(const uint8_t*, glm::ivec2);
Texture(const char*, size_t, glm::ivec2);
Texture(const std::string&);
Texture(const std::filesystem::path&);
bool write_png(const std::string&);
bool write_png(const std::filesystem::path&);
void pixel_set(glm::ivec2, glm::vec4);
void pixel_line(glm::ivec2, glm::ivec2, glm::vec4);
};