projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e988c97
)
fixed repeated creation of differently sized bitmaps between menu and game
author
Holger Schemel
<info@artsoft.org>
Mon, 13 Nov 2017 22:49:36 +0000
(23:49 +0100)
committer
Holger Schemel
<info@artsoft.org>
Mon, 13 Nov 2017 22:49:36 +0000
(23:49 +0100)
src/libgame/system.c
patch
|
blob
|
history
diff --git
a/src/libgame/system.c
b/src/libgame/system.c
index ed51e626a8f473747e4b9644c532f95e76b9b490..4f90a2d120835da09bda46a89f3877979b700ed5 100644
(file)
--- a/
src/libgame/system.c
+++ b/
src/libgame/system.c
@@
-525,6
+525,18
@@
Bitmap *CreateBitmap(int width, int height, int depth)
void ReCreateBitmap(Bitmap **bitmap, int width, int height)
{
void ReCreateBitmap(Bitmap **bitmap, int width, int height)
{
+ if (*bitmap != NULL)
+ {
+ /* if new bitmap size fits into old one, no need to re-create it */
+ if (width <= (*bitmap)->width &&
+ height <= (*bitmap)->height)
+ return;
+
+ /* else adjust size so that old and new bitmap size fit into it */
+ width = MAX(width, (*bitmap)->width);
+ height = MAX(height, (*bitmap)->height);
+ }
+
Bitmap *new_bitmap = CreateBitmap(width, height, DEFAULT_DEPTH);
if (*bitmap == NULL)
Bitmap *new_bitmap = CreateBitmap(width, height, DEFAULT_DEPTH);
if (*bitmap == NULL)