Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_GetRenderTarget does not return the same texture as SDL_SetRenderTarget #2931

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed
Labels
invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.4
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2018-06-20 06:48:54 +0000, Adam Bryant wrote:

In this sample code:

#include
#include <SDL2/SDL.h>
#include

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?

On 2018-06-22 17:45:29 +0000, Sam Lantinga wrote:

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.

On 2018-06-22 21:17:25 +0000, Adam Bryant wrote:

(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.

On 2019-06-10 18:44:46 +0000, Martin Vee wrote:

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?

@SDLBugzilla SDLBugzilla added bug invalid This doesn't seem right labels Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant