| Summary: | SDL_GetRenderTarget does not return the same texture as SDL_SetRenderTarget | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Adam Bryant <adam.w.bryant> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | martin.veronneau |
| Version: | 2.0.4 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
Yes, this is expected if you're using a texture format that isn't supported by the renderer. Try using SDL_PIXELFORMAT_ARGB8888 instead if you don't want texture conversion. (In reply to Sam Lantinga from comment #1) > Yes, this is expected if you're using a texture format that isn't supported > by the renderer. > > Try using SDL_PIXELFORMAT_ARGB8888 instead if you don't want texture > conversion. Thanks, it works now. I changed my code around to select a supported format. This behaviour should be described in the wiki, as it's a bit unexpected to have a "getter" returning a different value than the "setter". Is it possible to query a `texture->native` pointer to get it's parent `texture` pointer? |
In this sample code: #include <iostream> #include <SDL2/SDL.h> #include <thread> int main() { SDL_Window *window = NULL; SDL_Renderer *renderer = NULL; SDL_CreateWindowAndRenderer(1, 1, 0, &window, &renderer); SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC, 1, 1); SDL_SetRenderTarget(renderer, texture); SDL_Texture *renderTexture = SDL_GetRenderTarget(renderer); if (renderTexture != texture) { throw std::runtime_error("What?"); } std::this_thread::sleep_for(std::chrono::seconds(1)); return 0; } the exception is thrown. Is SDL_GetRenderTarget returning a different address expected behavior?