@@ -274,57 +274,66 @@ void renderSizableBorderedBitmap(RectI &bounds, U8 frame, TextureHandle &texture
274274
275275void renderSizableBorderedTexture (RectI &bounds, TextureHandle &texture, RectI &TopLeft, RectI &Top, RectI &TopRight, RectI &Left, RectI &Fill, RectI &Right, RectI &BottomLeft, RectI &Bottom, RectI &BottomRight)
276276{
277- dglClearBitmapModulation ();
278- RectI destRect;
279- RectI stretchRect;
280-
281- // top corners
282- dglDrawBitmapSR (texture, bounds.point , TopLeft);
283- dglDrawBitmapSR (texture, Point2I (bounds.point .x + bounds.extent .x - TopRight.extent .x , bounds.point .y ), TopRight);
284-
285- // bottom corners
286- dglDrawBitmapSR (texture, Point2I (bounds.point .x , bounds.point .y + bounds.extent .y - BottomLeft.extent .y ), BottomLeft);
287- dglDrawBitmapSR (texture, Point2I (bounds.point .x + bounds.extent .x - BottomRight.extent .x , bounds.point .y + bounds.extent .y - BottomRight.extent .y ), BottomRight);
288-
289- // top line stretch
290- destRect.point .x = bounds.point .x + TopLeft.extent .x ;
291- destRect.extent .x = bounds.extent .x - TopRight.extent .x - TopLeft.extent .x ;
292- destRect.extent .y = Top.extent .y ;
293- destRect.point .y = bounds.point .y ;
294- stretchRect = Top;
295- dglDrawBitmapStretchSR (texture, destRect, stretchRect);
296-
297- // bottom line stretch
298- destRect.point .x = bounds.point .x + BottomLeft.extent .x ;
299- destRect.extent .x = bounds.extent .x - BottomRight.extent .x - BottomLeft.extent .x ;
300- destRect.extent .y = Bottom.extent .y ;
301- destRect.point .y = bounds.point .y + bounds.extent .y - Bottom.extent .y ;
302- stretchRect = Bottom;
303- dglDrawBitmapStretchSR (texture, destRect, stretchRect);
304-
305- // left line stretch
306- destRect.point .x = bounds.point .x ;
307- destRect.extent .x = Left.extent .x ;
308- destRect.extent .y = bounds.extent .y - TopLeft.extent .y - BottomLeft.extent .y ;
309- destRect.point .y = bounds.point .y + TopLeft.extent .y ;
310- stretchRect = Left;
311- dglDrawBitmapStretchSR (texture, destRect, stretchRect);
312-
313- // right line stretch
314- destRect.point .x = bounds.point .x + bounds.extent .x - Right.extent .x ;
315- destRect.extent .x = Right.extent .x ;
316- destRect.extent .y = bounds.extent .y - TopRight.extent .y - BottomRight.extent .y ;
317- destRect.point .y = bounds.point .y + TopRight.extent .y ;
318- stretchRect = Right;
319- dglDrawBitmapStretchSR (texture, destRect, stretchRect);
320-
321- // fill stretch
322- destRect.point .x = bounds.point .x + Left.extent .x ;
323- destRect.extent .x = (bounds.extent .x ) - Left.extent .x - Right.extent .x ;
324- destRect.extent .y = bounds.extent .y - Top.extent .y - Bottom.extent .y ;
325- destRect.point .y = bounds.point .y + Top.extent .y ;
326- stretchRect = Fill;
327- dglDrawBitmapStretchSR (texture, destRect, stretchRect);
277+ RectI oldClip = dglGetClipRect ();
278+ RectI newClip = RectI (bounds);
279+ if (newClip.intersect (oldClip))
280+ {
281+ dglSetClipRect (newClip);
282+
283+ dglClearBitmapModulation ();
284+ RectI destRect;
285+ RectI stretchRect;
286+
287+ // top corners
288+ dglDrawBitmapSR (texture, bounds.point , TopLeft);
289+ dglDrawBitmapSR (texture, Point2I (bounds.point .x + bounds.extent .x - TopRight.extent .x , bounds.point .y ), TopRight);
290+
291+ // bottom corners
292+ dglDrawBitmapSR (texture, Point2I (bounds.point .x , bounds.point .y + bounds.extent .y - BottomLeft.extent .y ), BottomLeft);
293+ dglDrawBitmapSR (texture, Point2I (bounds.point .x + bounds.extent .x - BottomRight.extent .x , bounds.point .y + bounds.extent .y - BottomRight.extent .y ), BottomRight);
294+
295+ // top line stretch
296+ destRect.point .x = bounds.point .x + TopLeft.extent .x ;
297+ destRect.extent .x = bounds.extent .x - TopRight.extent .x - TopLeft.extent .x ;
298+ destRect.extent .y = Top.extent .y ;
299+ destRect.point .y = bounds.point .y ;
300+ stretchRect = Top;
301+ dglDrawBitmapStretchSR (texture, destRect, stretchRect);
302+
303+ // bottom line stretch
304+ destRect.point .x = bounds.point .x + BottomLeft.extent .x ;
305+ destRect.extent .x = bounds.extent .x - BottomRight.extent .x - BottomLeft.extent .x ;
306+ destRect.extent .y = Bottom.extent .y ;
307+ destRect.point .y = bounds.point .y + bounds.extent .y - Bottom.extent .y ;
308+ stretchRect = Bottom;
309+ dglDrawBitmapStretchSR (texture, destRect, stretchRect);
310+
311+ // left line stretch
312+ destRect.point .x = bounds.point .x ;
313+ destRect.extent .x = Left.extent .x ;
314+ destRect.extent .y = bounds.extent .y - TopLeft.extent .y - BottomLeft.extent .y ;
315+ destRect.point .y = bounds.point .y + TopLeft.extent .y ;
316+ stretchRect = Left;
317+ dglDrawBitmapStretchSR (texture, destRect, stretchRect);
318+
319+ // right line stretch
320+ destRect.point .x = bounds.point .x + bounds.extent .x - Right.extent .x ;
321+ destRect.extent .x = Right.extent .x ;
322+ destRect.extent .y = bounds.extent .y - TopRight.extent .y - BottomRight.extent .y ;
323+ destRect.point .y = bounds.point .y + TopRight.extent .y ;
324+ stretchRect = Right;
325+ dglDrawBitmapStretchSR (texture, destRect, stretchRect);
326+
327+ // fill stretch
328+ destRect.point .x = bounds.point .x + Left.extent .x ;
329+ destRect.extent .x = (bounds.extent .x ) - Left.extent .x - Right.extent .x ;
330+ destRect.extent .y = bounds.extent .y - Top.extent .y - Bottom.extent .y ;
331+ destRect.point .y = bounds.point .y + Top.extent .y ;
332+ stretchRect = Fill;
333+ dglDrawBitmapStretchSR (texture, destRect, stretchRect);
334+
335+ dglSetClipRect (oldClip);
336+ }
328337}
329338
330339// Renders out the fixed bitmap borders based on a multiplier into the bitmap array.
0 commit comments