Compare commits

..

2 Commits

Author SHA1 Message Date
887705969f
make texture streaming actually work 2024-03-09 16:26:35 +01:00
316871523d
update nixos target 2024-03-09 11:50:55 +01:00
3 changed files with 16 additions and 15 deletions

8
flake.lock generated
View File

@ -20,16 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1694553957, "lastModified": 1709953752,
"narHash": "sha256-8o15HEax53lBJjjcr5VHMpuuT6vBcrzSNB6y2iGlPaU=", "narHash": "sha256-LW84B4vM1cn7E6cDNQn2LndT9iJXI1dRE5fwbNFbQa8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e7fe745d22df5fa282b321e577fe18d4f62e0f0b", "rev": "fcaa81ed3c273237217330cf342ef1873b77c80a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "release-23.05", "ref": "release-23.11",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View File

@ -4,7 +4,7 @@
# append '.?submodules=1' to the nix commands. # append '.?submodules=1' to the nix commands.
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05"; nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };

View File

@ -4,6 +4,8 @@
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <iostream>
SDLRendererTextureUploader::SDLRendererTextureUploader(SDL_Renderer* renderer_) : SDLRendererTextureUploader::SDLRendererTextureUploader(SDL_Renderer* renderer_) :
renderer(renderer_) renderer(renderer_)
{ {
@ -19,16 +21,15 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi
); );
assert(surf); // TODO: add error reporting assert(surf); // TODO: add error reporting
// hacky hint usage SDL_Texture* tex = SDL_CreateTexture(
if (access == Access::STREAMING) { renderer,
SDL_SetHint("SDL_TextureAccess", "SDL_TEXTUREACCESS_STREAMING"); surf->format->format,
} else { access == Access::STREAMING ? SDL_TEXTUREACCESS_STREAMING : SDL_TEXTUREACCESS_STATIC,
SDL_SetHint("SDL_TextureAccess", "SDL_TEXTUREACCESS_STATIC"); surf->w, surf->h
} );
// TODO: cleanup hints after
SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surf);
assert(tex); // TODO: add error reporting assert(tex); // TODO: add error reporting
// TODO: error reporting
SDL_UpdateTexture(tex, nullptr, surf->pixels, surf->pitch);
if (filter == NEAREST) { if (filter == NEAREST) {
SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST);
@ -51,7 +52,7 @@ bool SDLRendererTextureUploader::updateRGBA(uint64_t tex_id, const uint8_t* data
int pitch = 0; int pitch = 0;
if (SDL_LockTexture(texture, nullptr, (void**)&pixels, &pitch) != 0) { if (SDL_LockTexture(texture, nullptr, (void**)&pixels, &pitch) != 0) {
// TODO: error std::cerr << "SDLRTU error: failed locking texture '" << SDL_GetError() << "'\n";
return false; return false;
} }