# GuiSan | SDL2 - Setting colour key of render target results in having an black screen

At the moment i am experimenting with guisan within my little project. Everything is done sofar with SDL_Texture except Guisan which utilize SDL_Surfaces instead SDL_Texture for rendering itself.

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. see my issue

• Be sure to set SDL_SetTextureBlendMode( yourTexture, SDL_BLENDMODE_BLEND); after you've copied the color-keyed surface into your texture. – TOM__ Jan 24 '17 at 2:26
• Does not work unfortunately, but thanks for the tip sound reasonable but is not the solution – ExOfDe Jan 24 '17 at 9:27
• Hmm, as I understand it the guisanTarget is an SDL_Surface? Under the old SDL backbuffer blitting operations if you didn't want a color you'd color-key the guisanTarget before blitting. You would never need to draw a colored rectangle. Are you using SDL_CreateTextureFromSurface, or SDL_UpdateTexture, or SDL_SetRenderTarget to get your guisan pixels into the texture? SDL_UpdateTexture requires that the target SDL_Texture needs to be created with SDL_TEXTUREACCESS_STREAMING access otherwise the SDL_UpdateTexture will fail. Some code would help greatly in solving your problem. – TOM__ Jan 24 '17 at 16:18