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

SDL2 - Guisans rendertarget combined with SDL_Colorkey #3

Open
Johanneslueke opened this issue Jan 23, 2017 · 3 comments
Open

SDL2 - Guisans rendertarget combined with SDL_Colorkey #3

Johanneslueke opened this issue Jan 23, 2017 · 3 comments

Comments

@Johanneslueke
Copy link

At the moment i am experimenting with guisan within my little project. Everything is done sofar with SDL_Texture except Guisan which as you best know utilize SDL_Surfaces instead SDL_Texture for rendering itself if SDL2 is chosen as "Graphics Engine"

Per sé this is absolutly fine. When guisan has finished rendering stuff on its SDL_Surface target I simply convert this Surface into an SDL_Texture or to be more precise I Update an pre-existing SDL_Texture and then Render this specific SDL_Texture. This works perfectly.

Till here everything is fine. I can interact with my GUI and the rest of my application. Then i thought at some point why not use an colour key (0xff00ff) to make the target of guisan transparent except for the parts it is drawing his stuff.

So i started calling:

SDL_FillRect(guisanTarget,NULL,*0xff00ff*);
To Fill my Target with the colour key i am about to hide away, with this call:
SDL_SetColorKey(guisanTarget,SDL_TRUE,SDL_MapRGB(guisanTarget->format,0xff,0x00,0xff));

And here is where my problem occurs... if i try to set my colour key the result will be a black screen. No visible GUI to interact with. If I DO NOT set the colour key via SDL_SetColorKey then i get my GUI with the background colour i filled my Target via SDL_FillRect.

I have no clue why... If anyone has an idea what the reason for this behaviour is please let me know i would appreciate it a lot.

@gbaudic
Copy link
Contributor

gbaudic commented Aug 28, 2017

From what I have noticed so far, it seems to me that this is more an SDL2 problem than an issue with Guisan itself. The problem happens when converting a Surface using a colorkey to a Texture. It would be interesting to see how it goes with the latest version of SDL2 (2.0.5).

@kallisti5
Copy link
Owner

kallisti5 commented Sep 2, 2017

Pull requests welcome on improvements + changes. I'm still around, just not actively invested in guisan at the moment. I have a PCEngine emulator I originally ported GuiChan to SDL2 for, but never got around to using it.

@gbaudic
Copy link
Contributor

gbaudic commented Feb 1, 2019

This issue is now 2 years old, so I am mainly writing this for future reference. Using the latest versions of the SDL libraries, I still run into this problem: filling an SDL_Surface with the color which was used to set the colorkey produces the color instead of transparency.
The workaround I found is to instead "clear" the surface with a transparent color, for example SDL_MapRGBA(0xff, 0, 0xff, 0) for a "transparent magenta" (Invisible Pink Unicorn anyone?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants