aboutsummaryrefslogtreecommitdiff
path: root/raylib/rtextures.c
diff options
context:
space:
mode:
authorUneven Prankster <unevenprankster@protonmail.com>2023-08-12 11:28:17 -0300
committerUneven Prankster <unevenprankster@protonmail.com>2023-08-12 11:28:17 -0300
commita2cb2ee59296e466bab94d9a96c331648ef212b0 (patch)
tree56739fa9b47cc8c22cef4515a6d3012f52f26127 /raylib/rtextures.c
parent5baf08556afa833d609a1ea667e7bbdeee7f1f8f (diff)
Merged some new goodies from raylib repo
Diffstat (limited to 'raylib/rtextures.c')
-rw-r--r--raylib/rtextures.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/raylib/rtextures.c b/raylib/rtextures.c
index bc53e1c..53d3f4c 100644
--- a/raylib/rtextures.c
+++ b/raylib/rtextures.c
@@ -138,6 +138,11 @@
defined(SUPPORT_FILEFORMAT_PIC) || \
defined(SUPPORT_FILEFORMAT_PNM))
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wunused-function"
+ #endif
+
#define STBI_MALLOC RL_MALLOC
#define STBI_FREE RL_FREE
#define STBI_REALLOC RL_REALLOC
@@ -145,6 +150,10 @@
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load_from_file()
// NOTE: Used to read image data (multiple formats support)
+
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic pop
+ #endif
#endif
#if (defined(SUPPORT_FILEFORMAT_DDS) || \
@@ -153,9 +162,17 @@
defined(SUPPORT_FILEFORMAT_PVR) || \
defined(SUPPORT_FILEFORMAT_ASTC))
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wunused-function"
+ #endif
+
#define RL_GPUTEX_IMPLEMENTATION
#include "external/rl_gputex.h" // Required for: rl_load_xxx_from_memory()
// NOTE: Used to read compressed textures data (multiple formats support)
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic pop
+ #endif
#endif
#if defined(SUPPORT_FILEFORMAT_QOI)
@@ -3135,26 +3152,28 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
if (rec.height < 0) rec.height = 0;
int sy = (int)rec.y;
- int ey = sy + (int)rec.height;
-
int sx = (int)rec.x;
int bytesPerPixel = GetPixelDataSize(1, 1, dst->format);
- for (int y = sy; y < ey; y++)
- {
- // Fill in the first pixel of the row based on image format
- ImageDrawPixel(dst, sx, y, color);
+ // Fill in the first pixel of the first row based on image format
+ ImageDrawPixel(dst, sx, sy, color);
- int bytesOffset = ((y*dst->width) + sx)*bytesPerPixel;
- unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset;
+ int bytesOffset = ((sy*dst->width) + sx)*bytesPerPixel;
+ unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset;
- // Repeat the first pixel data throughout the row
- for (int x = 1; x < (int)rec.width; x++)
- {
- memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel);
- }
+ // Repeat the first pixel data throughout the row
+ for (int x = 1; x < (int)rec.width; x++)
+ {
+ memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel);
}
+
+ // Repeat the first row data for all other rows
+ int bytesPerRow = bytesPerPixel * (int)rec.width;
+ for (int y = 1; y < (int)rec.height; y++)
+ {
+ memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow);
+ }
}
// Draw rectangle lines within an image
@@ -3367,10 +3386,16 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
if ((image.height/6) == image.width) { layout = CUBEMAP_LAYOUT_LINE_VERTICAL; cubemap.width = image.height/6; }
else if ((image.width/3) == (image.height/4)) { layout = CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR; cubemap.width = image.width/3; }
}
-
- cubemap.height = cubemap.width;
+ } else {
+ if (layout == CUBEMAP_LAYOUT_LINE_VERTICAL) cubemap.width = image.height/6;
+ if (layout == CUBEMAP_LAYOUT_LINE_HORIZONTAL) cubemap.width = image.width/6;
+ if (layout == CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR) cubemap.width = image.width/3;
+ if (layout == CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE) cubemap.width = image.width/4;
+ if (layout == CUBEMAP_LAYOUT_PANORAMA) cubemap.width = image.width/4;
}
+ cubemap.height = cubemap.width;
+
// Layout provided or already auto-detected
if (layout != CUBEMAP_LAYOUT_AUTO_DETECT)
{