…if you want center part of image to be stretched or repeated. Since in some cases, you want window to be filled with pattern instead of stretching it (it mostly just look better).
i’ve already have this idea, but it’s not easy to do (simpler to stretch the image’s center)
Not easy? You can borrow some code from extension that repeats sprite continuously (I think it is called Tiled Sprite object) and use it to repeat middle of object (clipping it at edges, of course.)
It needs to create a new texture with only the center part of the original texture to repeat it (using OpenGL texture repeat). (to stretch, you just have to say that you want to draw the center on a bigger rectangle, without the need of another texture).
Yes, repeating an entire texture is easy, but it seems there is no easy way to repeat a part of a texture. ( An creating a new texture with only the center part is tricky, as a new texture would be needed if border are changed at runtime, and creating a new texture is bad for performances and memory. )
You just repeat texture to fill whole area (even if it would overlap), then crop it to size of center of panel box.
No, in this case the borders would also be repeated ( We want the border of the texture to be shown only on the border of the image: Easy to do. Bu we do not want the borders of the texture to be repeated in the center of the object: Harder to do as we cannot repeat only the center part of a texture without creating a new texture, loosing a lot of performance doing that ).
Well, you won’t see if it is in fact “lot” of performance hit until you try . Also texture don’t have to be created at runtime, unless panel graphic is changed at runtime.
You can generate “center” texture at compile time which would go as cache and save some cycles that would be used for generating texture at runtime.