From ad64a43b34bb413f29850ed602df733961b62d60 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Thu, 28 Dec 2023 06:40:03 -0800 Subject: [rshapes] Expose shapes drawing texture and rectangle (#3677) * provide access to the shape texture so that shapes can be extended outside of raylib with the same optimizations as internal raylib functions. * PR feedback, comply with C standards * oops --- src/raylib.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/raylib.h') diff --git a/src/raylib.h b/src/raylib.h index 2ab3f304..cd31da62 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1220,6 +1220,8 @@ RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, f // NOTE: It can be useful when using basic shapes and one single font, // defining a font char white rectangle would allow drawing everything in a single draw call RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing +RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing +RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing // Basic shapes drawing functions RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel -- cgit v1.2.3 From 7cfdf33ff03f2c453f4b525eca66c074cdfe299c Mon Sep 17 00:00:00 2001 From: maverikou Date: Thu, 28 Dec 2023 21:09:49 +0200 Subject: TextReplace const correctness (#3678) * TextReplace const correctness * cleanup --- src/raylib.h | 2 +- src/rtext.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/raylib.h') diff --git a/src/raylib.h b/src/raylib.h index cd31da62..0e6ef23f 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1472,7 +1472,7 @@ RLAPI bool TextIsEqual(const char *text1, const char *text2); RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf() style) RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string -RLAPI char *TextReplace(char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!) +RLAPI char *TextReplace(const char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!) RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!) RLAPI const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings diff --git a/src/rtext.c b/src/rtext.c index 2a6aa127..104e302a 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1514,7 +1514,7 @@ const char *TextSubtext(const char *text, int position, int length) // Replace text string // REQUIRES: strlen(), strstr(), strncpy(), strcpy() // WARNING: Allocated memory must be manually freed -char *TextReplace(char *text, const char *replace, const char *by) +char *TextReplace(const char *text, const char *replace, const char *by) { // Sanity checks and initialization if (!text || !replace || !by) return NULL; -- cgit v1.2.3 From fd5e1e6afb69ef190e74ac780ec3718d36e2d7d1 Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Thu, 28 Dec 2023 19:15:04 -0300 Subject: [rtextures] Fix `LoadImageAnimFromMemory()` warning for `fileData` (#3686) * Fix LoadImageAnimFromMemory() warning for fileData * Add LoadImageAnimFromMemory() to raylib.h * Fix missing ; on previous commit --- src/raylib.h | 1 + src/rtextures.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/raylib.h') diff --git a/src/raylib.h b/src/raylib.h index 0e6ef23f..8b126141 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1302,6 +1302,7 @@ RLAPI Image LoadImage(const char *fileName); RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data RLAPI Image LoadImageSvg(const char *fileNameOrString, int width, int height); // Load image from SVG file data or string with specified size RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data) +RLAPI Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int *frames); // Load image sequence from memory buffer RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png' RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot) diff --git a/src/rtextures.c b/src/rtextures.c index 953458e1..e9fb95cb 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -443,7 +443,7 @@ Image LoadImageAnim(const char *fileName, int *frames) // - Number of frames is returned through 'frames' parameter // - All frames are returned in RGBA format // - Frames delay data is discarded -Image LoadImageAnimFromMemory(const char *fileType,const char *fileData, int dataSize,int *frames) +Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int *frames) { Image image = { 0 }; int frameCount = 0; @@ -2147,14 +2147,14 @@ void ImageKernelConvolution(Image *image, float* kernel, int kernelSize){ { startRange = -kernelWidth/2; endRange = kernelWidth/2; - } else + } else { startRange = -kernelWidth/2; endRange = kernelWidth/2+1; } - for(int x = 0; x < image->height; x++) + for(int x = 0; x < image->height; x++) { - for(int y = 0; y < image->width; y++) + for(int y = 0; y < image->width; y++) { for(int xk = startRange; xk < endRange; xk++) @@ -2232,14 +2232,14 @@ void ImageKernelConvolution(Image *image, float* kernel, int kernelSize){ } } - for (int i = 0; i < (image->width) * (image->height); i++) + for (int i = 0; i < (image->width) * (image->height); i++) { float alpha = (float)imageCopy2[i].w; pixels[i].r = (unsigned char)((imageCopy2[i].x)*255.0f); pixels[i].g = (unsigned char)((imageCopy2[i].y)*255.0f); pixels[i].b = (unsigned char)((imageCopy2[i].z)*255.0f); pixels[i].a = (unsigned char)((alpha)*255.0f); - // printf("pixels[%d] = %d", i, pixels[i].r); + // printf("pixels[%d] = %d", i, pixels[i].r); } @@ -3817,7 +3817,7 @@ 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; } } - } + } else { if (layout == CUBEMAP_LAYOUT_LINE_VERTICAL) cubemap.width = image.height/6; @@ -3836,7 +3836,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layout) Image faces = { 0 }; // Vertical column image Rectangle faceRecs[6] = { 0 }; // Face source rectangles - + for (int i = 0; i < 6; i++) faceRecs[i] = (Rectangle){ 0, 0, (float)size, (float)size }; if (layout == CUBEMAP_LAYOUT_LINE_VERTICAL) -- cgit v1.2.3