SDL_Renderer backend and SDL_image texture loader

This commit is contained in:
2024-08-01 20:47:26 +03:00
parent 7471c09452
commit 87296180ee
11 changed files with 231 additions and 81 deletions

View File

@@ -1,7 +1,7 @@
#include <unordered_map>
#include <fstream>
#include <sstream>
#include "../UsefulException.hpp"
#include "../exceptions.hpp"
#include "../format.hpp"
#include "Resources.hpp"
#include "embedded_resources.h"
@@ -19,16 +19,27 @@ MemoryStreamBuf::MemoryStreamBuf(void* _p, const std::size_t n){
setp(p, p + n);
}
class MemoryStreamRead : public std::istream {
public:
MemoryStreamRead(const void* p, const std::size_t n)
: std::istream(new MemoryStreamBuf((void*)p, n))
{}
std::istream::pos_type MemoryStreamBuf::seekoff(
std::istream::off_type off,
std::ios_base::seekdir dir,
std::ios_base::openmode which)
{
if (dir == std::ios_base::cur)
gbump(off);
else if (dir == std::ios_base::end)
setg(eback(), egptr() + off, egptr());
else if (dir == std::ios_base::beg)
setg(eback(), eback() + off, egptr());
return gptr() - eback();
}
virtual ~MemoryStreamRead(){
delete rdbuf();
}
};
MemoryStreamRead::MemoryStreamRead(const void* p, const std::size_t n)
: std::istream(new MemoryStreamBuf((void*)p, n))
{}
MemoryStreamRead::~MemoryStreamRead(){
delete rdbuf();
}
static std::unordered_map<std::string, Resource>* _resourceMap = nullptr;