Compare commits
No commits in common. "a3d193516c8adf4ff4e47330ceea4f97d8080a15" and "a8d8613f2ccb56054dfc01768f4e86964077ff55" have entirely different histories.
a3d193516c
...
a8d8613f2c
9
.github/workflows/cd.yml
vendored
9
.github/workflows/cd.yml
vendored
@ -30,6 +30,9 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
@ -81,6 +84,9 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
@ -132,6 +138,9 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -29,6 +29,9 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test
|
||||
|
||||
macos:
|
||||
timeout-minutes: 10
|
||||
|
||||
@ -72,3 +75,6 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
#include "./sdlrenderer_texture_uploader.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
SDLRendererTextureUploader::SDLRendererTextureUploader(SDL_Renderer* renderer_) :
|
||||
renderer(renderer_)
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter, Access access) {
|
||||
uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter) {
|
||||
// TODO: test if pitch is 4 or 4*width
|
||||
SDL_Surface* surf = SDL_CreateSurfaceFrom(
|
||||
(void*)data,
|
||||
@ -19,14 +17,6 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi
|
||||
);
|
||||
assert(surf); // TODO: add error reporting
|
||||
|
||||
// hacky hint usage
|
||||
if (access == Access::STREAMING) {
|
||||
SDL_SetHint("SDL_TextureAccess", "SDL_TEXTUREACCESS_STREAMING");
|
||||
} else {
|
||||
SDL_SetHint("SDL_TextureAccess", "SDL_TEXTUREACCESS_STATIC");
|
||||
}
|
||||
// TODO: cleanup hints after
|
||||
|
||||
SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf);
|
||||
assert(tex); // TODO: add error reporting
|
||||
|
||||
@ -41,27 +31,6 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi
|
||||
return reinterpret_cast<uint64_t>(tex);
|
||||
}
|
||||
|
||||
bool SDLRendererTextureUploader::updateRGBA(uint64_t tex_id, const uint8_t* data, size_t size) {
|
||||
auto* texture = static_cast<SDL_Texture*>(reinterpret_cast<void*>(tex_id));
|
||||
if (texture == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t* pixels = nullptr;
|
||||
int pitch = 0;
|
||||
|
||||
if (SDL_LockTexture(texture, nullptr, (void**)&pixels, &pitch) != 0) {
|
||||
// TODO: error
|
||||
return false;
|
||||
}
|
||||
|
||||
std::memcpy(pixels, data, size);
|
||||
|
||||
SDL_UnlockTexture(texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDLRendererTextureUploader::destroy(uint64_t tex_id) {
|
||||
SDL_DestroyTexture(static_cast<SDL_Texture*>(reinterpret_cast<void*>(tex_id)));
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ struct SDLRendererTextureUploader : public TextureUploaderI {
|
||||
SDLRendererTextureUploader(SDL_Renderer* renderer_);
|
||||
~SDLRendererTextureUploader(void) = default;
|
||||
|
||||
uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter, Access access) override;
|
||||
bool updateRGBA(uint64_t tex_id, const uint8_t* data, size_t size) override;
|
||||
uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter) override;
|
||||
void destroy(uint64_t tex_id) override;
|
||||
};
|
||||
|
||||
|
@ -1,29 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
struct TextureUploaderI {
|
||||
static constexpr const char* version {"2"};
|
||||
static constexpr const char* version {"1"};
|
||||
|
||||
enum Filter {
|
||||
NEAREST,
|
||||
LINEAR,
|
||||
};
|
||||
|
||||
enum Access {
|
||||
STATIC,
|
||||
STREAMING,
|
||||
// target?
|
||||
};
|
||||
|
||||
virtual ~TextureUploaderI(void) {}
|
||||
|
||||
virtual uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter = LINEAR, Access access = STATIC) = 0;
|
||||
|
||||
// keeps width height filter
|
||||
// TODO: wh instead of size?
|
||||
virtual bool updateRGBA(uint64_t tex_id, const uint8_t* data, size_t size) = 0;
|
||||
virtual uint64_t uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter = LINEAR) = 0;
|
||||
|
||||
virtual void destroy(uint64_t tex_id) = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user