func (gb *GUIBlock) Bake(renderer *sdl.Renderer) *sdl.Texture { finalTxtr, _ := renderer.CreateTexture(sdl.PIXELFORMAT_RGBA8888, sdl.TEXTUREACCESS_TARGET, 800, 600) originalTarget := renderer.GetRenderTarget() renderer.SetRenderTarget(finalTxtr) defer renderer.SetRenderTarget(originalTarget) renderer.SetDrawColor(1, 1, 1, 0) renderer.FillRect(gb.Pos) for _, el := range gb.Elements { println("Baking: ") println(el.Layer, el.Pos.X, el.Pos.Y) renderer.SetDrawColor(el.BGColor.R, el.BGColor.G, el.BGColor.B, el.BGColor.A) renderer.FillRect(el.Pos) for _, txt := range el.Texts { texture, W, H := txt.Bake(renderer) renderer.Copy( texture, &sdl.Rect{0, 0, W, H}, &sdl.Rect{el.Pos.X + txt.RelPos.X, el.Pos.Y + txt.RelPos.Y, W, H}) } } finalTxtr.SetBlendMode(sdl.BLENDMODE_BLEND) finalTxtr.SetAlphaMod(216) return finalTxtr }