From 6d20430ccc81cf2cb5caa39a097dee5875d810b6 Mon Sep 17 00:00:00 2001 From: atticus Date: Fri, 20 Aug 2021 12:47:51 +0300 Subject: [PATCH 01/31] add NULL check (#1925) --- src/extras/rmem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extras/rmem.h b/src/extras/rmem.h index dbf417fe6..7f50adf8c 100644 --- a/src/extras/rmem.h +++ b/src/extras/rmem.h @@ -276,6 +276,7 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo mempool->arena.offs += iter->size; __RemoveMemNode(list, iter); iter = list->head; + if (iter == NULL) return; } const uintptr_t inode = ( uintptr_t )node; const uintptr_t iiter = ( uintptr_t )iter; From ff523d55ac8e7a715379e8493382a37f43531b85 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 20 Aug 2021 11:56:25 +0200 Subject: [PATCH 02/31] Updated raygui #1939 --- src/extras/raygui.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/extras/raygui.h b/src/extras/raygui.h index fdc8feeb1..95c74942f 100644 --- a/src/extras/raygui.h +++ b/src/extras/raygui.h @@ -137,6 +137,10 @@ #include "raylib.h" #endif +#ifndef RAYGUIDEF + #define RAYGUIDEF // We are building or using rlgl as a static library (or Linux shared library) +#endif + // Define functions scope to be used internally (static) or externally (extern) to the module including this file #if defined(_WIN32) // Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll @@ -144,11 +148,7 @@ #define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll) #elif defined(USE_LIBTYPE_SHARED) #define RAYGUIDEF __declspec(dllimport) // We are using raygui as a Win32 shared library (.dll) - #else - #define RAYGUIDEF // We are building or using raygui as a static library #endif -#else - #define RAYGUIDEF // We are building or using raygui as a static library (or Linux shared library) #endif #if !defined(RAYGUI_MALLOC) && !defined(RAYGUI_CALLOC) && !defined(RAYGUI_FREE) @@ -175,10 +175,6 @@ #define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming -#if defined(__cplusplus) -extern "C" { // Prevents name mangling of functions -#endif - //---------------------------------------------------------------------------------- // Types and Structures Definition // NOTE: Some types are required for RAYGUI_STANDALONE usage @@ -231,7 +227,7 @@ extern "C" { // Prevents name mangling of functions } Texture2D; // Font character info - typedef struct CharInfo CharInfo; + typedef struct GlyphInfo GlyphInfo; // TODO: Font type is very coupled to raylib, mostly required by GuiLoadStyle() // It should be redesigned to be provided by user @@ -240,7 +236,7 @@ extern "C" { // Prevents name mangling of functions int charsCount; // Number of characters Texture2D texture; // Characters texture atlas Rectangle *recs; // Characters rectangles in texture - CharInfo *chars; // Characters info data + GlyphInfo *chars; // Characters info data } Font; #endif @@ -412,6 +408,10 @@ typedef enum { // Module Functions Declaration //---------------------------------------------------------------------------------- +#if defined(__cplusplus) +extern "C" { // Prevents name mangling of functions +#endif + // State modification functions RAYGUIDEF void GuiEnable(void); // Enable gui controls (global state) RAYGUIDEF void GuiDisable(void); // Disable gui controls (global state) @@ -495,7 +495,6 @@ RAYGUIDEF void GuiClearIconPixel(int iconId, int x, int y); // Clear icon pi RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pixel value #endif - #if defined(__cplusplus) } // Prevents name mangling of functions #endif @@ -1407,11 +1406,11 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) if ((GetTextWidth(text) < (maxWidth - GuiGetStyle(DEFAULT, TEXT_SIZE))) && (key >= 32)) { int byteLength = 0; - const char *textUtf8 = CodepointToUtf8(key, &byteLength); + const char *textUTF8 = CodepointToUTF8(key, &byteLength); for (int i = 0; i < byteLength; i++) { - text[keyCount] = textUtf8[i]; + text[keyCount] = textUTF8[i]; keyCount++; } @@ -2890,7 +2889,7 @@ void GuiLoadStyle(const char *fileName) for (int i = 0; i < font.charsCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile); // Load font chars info data - font.chars = (CharInfo *)RAYGUI_CALLOC(font.charsCount, sizeof(CharInfo)); + font.chars = (GlyphInfo *)RAYGUI_CALLOC(font.charsCount, sizeof(GlyphInfo)); for (int i = 0; i < font.charsCount; i++) { fread(&font.chars[i].value, 1, sizeof(int), rgsFile); @@ -3640,8 +3639,8 @@ static int TextToInteger(const char *text) return value*sign; } -// Encode codepoint into utf8 text (char array length returned as parameter) -static const char *CodepointToUtf8(int codepoint, int *byteLength) +// Encode codepoint into UTF-8 text (char array length returned as parameter) +static const char *CodepointToUTF8(int codepoint, int *byteLength) { static char utf8[6] = { 0 }; int length = 0; From aefdb9f9cf10e768cc1818cf6ef7887110833810 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 21 Aug 2021 23:57:41 +0200 Subject: [PATCH 03/31] REMOVED: Old function names defines As far as next raylib version will be 4.0, no backward compatibility hacks will be maintained. --- src/raylib.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index c7b4b282b..11ff587df 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -134,6 +134,8 @@ // Other modules (raymath, rlgl) also require some of those types, so, // to be able to use those other modules as standalone (not depending on raylib) // this defines are very useful for internal check and avoid type (re)definitions +#define RL_COLOR_TYPE +#define RL_RECTANGLE_TYPE #define RL_VECTOR2_TYPE #define RL_VECTOR3_TYPE #define RL_VECTOR4_TYPE @@ -170,14 +172,6 @@ #define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta #define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo) -// WARNING: Temporal hacks to avoid breaking old codebases using -// deprecated raylib implementations or definitions -#define GetImageData LoadImageColors -#define FILTER_POINT TEXTURE_FILTER_POINT -#define FILTER_BILINEAR TEXTURE_FILTER_BILINEAR -#define MAP_DIFFUSE MATERIAL_MAP_DIFFUSE -#define UNCOMPRESSED_R8G8B8A8 PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 - //---------------------------------------------------------------------------------- // Structures Definition //---------------------------------------------------------------------------------- From d98779abef04088206cef7ccc291370ecc1a445e Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 22 Aug 2021 01:07:37 +0200 Subject: [PATCH 04/31] Minor tweak to avoid false error logs --- src/core.c | 7 +++++-- src/raylib.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core.c b/src/core.c index b03216cc2..27b6c31be 100644 --- a/src/core.c +++ b/src/core.c @@ -2281,8 +2281,11 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName) { Shader shader = { 0 }; - char *vShaderStr = LoadFileText(vsFileName); - char *fShaderStr = LoadFileText(fsFileName); + char *vShaderStr = NULL; + char *fShaderStr = NULL; + + if (vsFileName != NULL) vShaderStr = LoadFileText(vsFileName); + if (fsFileName != NULL) fShaderStr = LoadFileText(fsFileName); shader = LoadShaderFromMemory(vShaderStr, fShaderStr); diff --git a/src/raylib.h b/src/raylib.h index 11ff587df..7613dd94c 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -318,7 +318,7 @@ typedef struct Mesh { int vertexCount; // Number of vertices stored in arrays int triangleCount; // Number of triangles stored (indexed or not) - // Default vertex data + // Vertex attributes data float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) From b154bc33f55bf7b7ad3fab5841a8d49043e2e979 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 22 Aug 2021 01:08:11 +0200 Subject: [PATCH 05/31] Added note on GLFW custom allocators for the future --- src/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core.c b/src/core.c index 27b6c31be..52245b80a 100644 --- a/src/core.c +++ b/src/core.c @@ -3583,6 +3583,17 @@ static bool InitGraphicsDevice(int width, int height) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) glfwSetErrorCallback(ErrorCallback); + /* + // Setup custom allocators to match raylib ones + const GLFWallocator allocator = { + .allocate = MemAlloc, + .deallocate = MemFree, + .reallocate = MemRealloc, + .user = NULL + }; + + glfwInitAllocator(&allocator); + */ #if defined(__APPLE__) glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE); From 51fbde178fdc7d7f173cea8e918e630c49ae7bfe Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 22 Aug 2021 01:08:27 +0200 Subject: [PATCH 06/31] Update shaders_shapes_outline.c --- examples/shaders/shaders_shapes_outline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/shaders/shaders_shapes_outline.c b/examples/shaders/shaders_shapes_outline.c index d70f7645d..3f02230e3 100644 --- a/examples/shaders/shaders_shapes_outline.c +++ b/examples/shaders/shaders_shapes_outline.c @@ -1,7 +1,7 @@ /******************************************************************************************* * * raylib [shaders] example - Apply an shdrOutline to a texture -* +* * NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, * OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. * @@ -9,7 +9,7 @@ * * This example has been created using raylib 3.8 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* +* * Example contributed by Samuel Skiff (@GoldenThumbs) * * Copyright (c) 2021 Samuel SKiff (@GoldenThumbs) and Ramon Santamaria (@raysan5) @@ -31,11 +31,11 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an shdrOutline to a texture"); + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture"); Texture2D egg = LoadTexture("resources/egg.png"); Texture2D torus = LoadTexture("resources/torus.png"); - Shader shdrOutline = LoadShader(0, TextFormat("resources/shaders/glsl%i/shdrOutline.fs", GLSL_VERSION)); + Shader shdrOutline = LoadShader(0, TextFormat("resources/shaders/glsl%i/outline.fs", GLSL_VERSION)); float outlineScale = 16.0f; float textureScale[2] = { 16.0f*4, 16.0f*4 }; From 45fd75952dd969e0d8f5aa778d6f0bf82aff0f63 Mon Sep 17 00:00:00 2001 From: Luiz Pestana Date: Mon, 23 Aug 2021 15:05:34 -0300 Subject: [PATCH 07/31] Revert "Ignore generated example binaries (#1884)" (#1946) This reverts commit 4a01139c8d87584b7d62a2c7d60b151d6be5ee9c. --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index dcfa5bce2..45d2d5a84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,6 @@ # Ignore generated files # ... -# Ignore all without extensions -* -!*.* -!*/ - # Ignore VIM's backup generated files *.swp *.swo From 7c1889c28205b83afaa39da73f1831a72bd9c502 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 24 Aug 2021 15:26:59 +0200 Subject: [PATCH 08/31] REVIEWED: Support mouse wheel on x-axis #1948 --- src/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 52245b80a..aff8cdd35 100644 --- a/src/core.c +++ b/src/core.c @@ -5059,7 +5059,8 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) // GLFW3 Srolling Callback, runs on mouse wheel static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset) { - CORE.Input.Mouse.currentWheelMove = (float)yoffset; + if (xoffset != 0.0) CORE.Input.Mouse.currentWheelMove = (float)xoffset; + else CORE.Input.Mouse.currentWheelMove = (float)yoffset; } // GLFW3 CursorEnter Callback, when cursor enters the window From 6575d31379045f34fa7d23b79d9adea2f18899e5 Mon Sep 17 00:00:00 2001 From: Laurentino Luna <81370009+fuserr7@users.noreply.github.com> Date: Tue, 24 Aug 2021 11:34:52 -0300 Subject: [PATCH 09/31] Fix tcc not finding emmintrin.h (#1947) * Fix tcc not finding emmintrin.h This allows to compile raylib with tcc with no errors. * Remove __TINYC__ check from stb_image.h This will be placed under textures.c * Move tcc check to textures.c Avoiding to change stb_image.h --- src/textures.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/textures.c b/src/textures.c index 6d5c2c5f4..f8b693d60 100644 --- a/src/textures.c +++ b/src/textures.c @@ -102,6 +102,10 @@ #define STBI_NO_PIC #define STBI_NO_PNM // Image format .ppm and .pgm +#if defined(__TINYC__) + #define STBI_NO_SIMD +#endif + #if (defined(SUPPORT_FILEFORMAT_BMP) || \ defined(SUPPORT_FILEFORMAT_PNG) || \ defined(SUPPORT_FILEFORMAT_TGA) || \ From 913f185f82028c906fd65242c4375d97b8d0c919 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 25 Aug 2021 00:22:16 +0200 Subject: [PATCH 10/31] Renamed some static functions for more consistent naming --- examples/text/text_rectangle_bounds.c | 18 ++++++++---------- examples/text/text_unicode.c | 12 ++++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c index c763fb2ec..0da1a8ab3 100644 --- a/examples/text/text_rectangle_bounds.c +++ b/examples/text/text_rectangle_bounds.c @@ -13,8 +13,8 @@ #include "raylib.h" -static void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits -static void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection +static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits +static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection // Main entry point int main(void) @@ -92,14 +92,12 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris ClearBackground(RAYWHITE); - DrawRectangleLinesEx(container, 3, borderColor); // Draw container border + DrawRectangleLinesEx(container, 3, borderColor); // Draw container border // Draw text in container (add some padding) - DrawTextRec(font, text, - (Rectangle){ container.x + 4, container.y + 4, container.width - 4, container.height - 4 }, - 20.0f, 2.0f, wordWrap, GRAY); + DrawTextBoxed(font, text, (Rectangle){ container.x + 4, container.y + 4, container.width - 4, container.height - 4 }, 20.0f, 2.0f, wordWrap, GRAY); - DrawRectangleRec(resizer, borderColor); // Draw the resize box + DrawRectangleRec(resizer, borderColor); // Draw the resize box // Draw bottom info DrawRectangle(0, screenHeight - 54, screenWidth, 54, GRAY); @@ -130,13 +128,13 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris //-------------------------------------------------------------------------------------- // Draw text using font inside rectangle limits -static void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint) +static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint) { - DrawTextRecEx(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE); + DrawTextBoxedSelectable(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE); } // Draw text using font inside rectangle limits with support for text selection -static void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint) +static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint) { int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index 2954a28e1..883d2a5cd 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -133,8 +133,8 @@ struct { //-------------------------------------------------------------------------------------- static void RandomizeEmoji(void); // Fills the emoji array with random emojis -static void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits -static void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection +static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits +static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection //-------------------------------------------------------------------------------------- // Global variables @@ -273,7 +273,7 @@ int main(int argc, char **argv) // Draw the main text message Rectangle textRect = { msgRect.x + horizontalPadding/2, msgRect.y + verticalPadding/2, msgRect.width - horizontalPadding, msgRect.height }; - DrawTextRec(*font, messages[message].text, textRect, (float)font->baseSize, 1.0f, true, WHITE); + DrawTextBoxed(*font, messages[message].text, textRect, (float)font->baseSize, 1.0f, true, WHITE); // Draw the info text below the main message int size = (int)strlen(messages[message].text); @@ -329,13 +329,13 @@ static void RandomizeEmoji(void) //-------------------------------------------------------------------------------------- // Draw text using font inside rectangle limits -static void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint) +static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint) { - DrawTextRecEx(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE); + DrawTextBoxedSelectable(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE); } // Draw text using font inside rectangle limits with support for text selection -static void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint) +static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint) { int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop From a04dbe7ffd01701b810f317d1e5eda73c78f9789 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 25 Aug 2021 00:41:48 +0200 Subject: [PATCH 11/31] Update shaders_shapes_outline.c --- examples/shaders/shaders_shapes_outline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/shaders/shaders_shapes_outline.c b/examples/shaders/shaders_shapes_outline.c index 3f02230e3..30194c4b7 100644 --- a/examples/shaders/shaders_shapes_outline.c +++ b/examples/shaders/shaders_shapes_outline.c @@ -63,7 +63,7 @@ int main(void) DrawTextureEx(torus, (Vector2){ 544, 230 }, 0.0, outlineScale, WHITE); EndShaderMode(); - DrawText("Shader-based shdrOutlines for textures", 190, 200, 20, LIGHTGRAY); + DrawText("Shader-based outlines for textures", 190, 200, 20, LIGHTGRAY); DrawFPS(710, 10); From 7749a2805c0f28762c206da0b7c954cbe9e318e2 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 25 Aug 2021 00:51:37 +0200 Subject: [PATCH 12/31] UPDATED: raygui to latest version -WIP- Note this new raygui version embeds ricons and `GuiTextBoxMulti()` is not working properly --- examples/others/embedded_files_loading.c | 2 +- examples/others/resources/audio_data.h | 2 +- src/extras/raygui.h | 643 +++++++++++++++++++++-- src/extras/ricons.h | 556 -------------------- 4 files changed, 597 insertions(+), 606 deletions(-) delete mode 100644 src/extras/ricons.h diff --git a/examples/others/embedded_files_loading.c b/examples/others/embedded_files_loading.c index 60a2a6f0f..5923a9acd 100644 --- a/examples/others/embedded_files_loading.c +++ b/examples/others/embedded_files_loading.c @@ -31,7 +31,7 @@ int main(void) // Same as: Wave wave = LoadWave("sound.wav"); Wave wave = { .data = AUDIO_DATA, - .sampleCount = AUDIO_SAMPLE_COUNT, + .frameCount = AUDIO_FRAME_COUNT, .sampleRate = AUDIO_SAMPLE_RATE, .sampleSize = AUDIO_SAMPLE_SIZE, .channels = AUDIO_CHANNELS diff --git a/examples/others/resources/audio_data.h b/examples/others/resources/audio_data.h index abf344f3b..22cdacc72 100644 --- a/examples/others/resources/audio_data.h +++ b/examples/others/resources/audio_data.h @@ -11,7 +11,7 @@ ////////////////////////////////////////////////////////////////////////////////// // Wave data information -#define AUDIO_SAMPLE_COUNT 24367 +#define AUDIO_FRAME_COUNT 24367 #define AUDIO_SAMPLE_RATE 44100 #define AUDIO_SAMPLE_SIZE 32 #define AUDIO_CHANNELS 1 diff --git a/src/extras/raygui.h b/src/extras/raygui.h index 95c74942f..bb1919004 100644 --- a/src/extras/raygui.h +++ b/src/extras/raygui.h @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raygui v2.9-dev - A simple and easy-to-use immediate-mode gui library +* raygui v3.0-dev - A simple and easy-to-use immediate-mode gui library * * DESCRIPTION: * @@ -54,21 +54,22 @@ * If not defined, the library is in header only mode and can be included in other headers * or source files without problems. But only ONE file should hold the implementation. * -* #define RAYGUI_STATIC (defined by default) -* The generated implementation will stay private inside implementation file and all -* internal symbols and functions will only be visible inside that file. -* * #define RAYGUI_STANDALONE * Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined * internally in the library and input management and drawing functions must be provided by * the user (check library implementation for further details). * -* #define RAYGUI_SUPPORT_ICONS -* Includes riconsdata.h header defining a set of 128 icons (binary format) to be used on -* multiple controls and following raygui styles +* #define RAYGUI_SUPPORT_RICONS +* Includes embedded ricons data (binary format) and definitions (by default 256 16x16 pixels, 2KB) +* +* #define RAYGUI_SUPPORT_CUSTOM_RICONS +* Includes custom ricons.h header defining a set of custom icons, +* this file can be generated using rGuiIcons tool * * * VERSIONS HISTORY: +* +* 3.0-dev (22-Aug-2021) Integrated ricons data to avoid external file * 2.9 (17-Mar-2021) Removed tooltip API * 2.8 (03-May-2020) Centralized rectangles drawing to GuiDrawRectangle() * 2.7 (20-Feb-2020) Added possible tooltips API @@ -96,7 +97,8 @@ * 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria. * * CONTRIBUTORS: -* Ramon Santamaria: Supervision, review, redesign, update and maintenance... +* +* Ramon Santamaria: Supervision, review, redesign, update and maintenance * Vlad Adrian: Complete rewrite of GuiTextBox() to support extended features (2019) * Sergio Martinez: Review, testing (2015) and redesign of multiple controls (2018) * Adria Arranz: Testing and Implementation of additional controls (2018) @@ -131,7 +133,7 @@ #ifndef RAYGUI_H #define RAYGUI_H -#define RAYGUI_VERSION "2.9-dev" +#define RAYGUI_VERSION "3.0-dev" #if !defined(RAYGUI_STANDALONE) #include "raylib.h" @@ -166,14 +168,6 @@ #define RAYGUI_FREE(p) free(p) #endif -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#define NUM_CONTROLS 16 // Number of standard controls -#define NUM_PROPS_DEFAULT 16 // Number of standard properties -#define NUM_PROPS_EXTENDED 8 // Number of extended properties - -#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -236,7 +230,7 @@ int charsCount; // Number of characters Texture2D texture; // Characters texture atlas Rectangle *recs; // Characters rectangles in texture - GlyphInfo *chars; // Characters info data + GlyphInfo *chars; // Characters info data } Font; #endif @@ -471,7 +465,7 @@ RAYGUIDEF float GuiColorBarAlpha(Rectangle bounds, float alpha); RAYGUIDEF float GuiColorBarHue(Rectangle bounds, float value); // Color Bar Hue control // Styles loading functions -RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file (.rgs) +RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file over global style variable (.rgs) RAYGUIDEF void GuiLoadStyleDefault(void); // Load style default over global style /* @@ -482,7 +476,7 @@ RAYGUIDEF void UnloadGuiStyle(GuiStyle style); // Unload style RAYGUIDEF const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported) -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) // Gui icons functionality RAYGUIDEF void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color); @@ -509,11 +503,6 @@ RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pi #if defined(RAYGUI_IMPLEMENTATION) -#if defined(RAYGUI_SUPPORT_ICONS) - #define RICONS_IMPLEMENTATION - #include "ricons.h" // Required for: raygui icons data -#endif - #include // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf() #include // Required for: strlen() [GuiTextBox()] #include // Required for: roundf() [GuiColorPicker()] @@ -528,10 +517,566 @@ RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pi #define RAYGUI_CLITERAL(name) (name) #endif +#if defined(RAYGUI_SUPPORT_RICONS) + +#if defined(RAYGUI_SUPPORT_CUSTOM_RICONS) + +#define RICONS_IMPLEMENTATION +#include "ricons.h" // External icons data provided, it can be generated with rGuiIcons tool + +#else // Embedded raygui icons, no external file provided + +#define RICON_SIZE 16 // Size of icons (squared) +#define RICON_MAX_ICONS 256 // Maximum number of icons +#define RICON_MAX_NAME_LENGTH 32 // Maximum length of icon name id + +// Icons data is defined by bit array (every bit represents one pixel) +// Those arrays are stored as unsigned int data arrays, so every array +// element defines 32 pixels (bits) of information +// Number of elemens depend on RICON_SIZE (by default 16x16 pixels) +#define RICON_DATA_ELEMENTS (RICON_SIZE*RICON_SIZE/32) + //---------------------------------------------------------------------------------- -// Defines and Macros +// Icons enumeration //---------------------------------------------------------------------------------- -//... +typedef enum { + RICON_NONE = 0, + RICON_FOLDER_FILE_OPEN = 1, + RICON_FILE_SAVE_CLASSIC = 2, + RICON_FOLDER_OPEN = 3, + RICON_FOLDER_SAVE = 4, + RICON_FILE_OPEN = 5, + RICON_FILE_SAVE = 6, + RICON_FILE_EXPORT = 7, + RICON_FILE_NEW = 8, + RICON_FILE_DELETE = 9, + RICON_FILETYPE_TEXT = 10, + RICON_FILETYPE_AUDIO = 11, + RICON_FILETYPE_IMAGE = 12, + RICON_FILETYPE_PLAY = 13, + RICON_FILETYPE_VIDEO = 14, + RICON_FILETYPE_INFO = 15, + RICON_FILE_COPY = 16, + RICON_FILE_CUT = 17, + RICON_FILE_PASTE = 18, + RICON_CURSOR_HAND = 19, + RICON_CURSOR_POINTER = 20, + RICON_CURSOR_CLASSIC = 21, + RICON_PENCIL = 22, + RICON_PENCIL_BIG = 23, + RICON_BRUSH_CLASSIC = 24, + RICON_BRUSH_PAINTER = 25, + RICON_WATER_DROP = 26, + RICON_COLOR_PICKER = 27, + RICON_RUBBER = 28, + RICON_COLOR_BUCKET = 29, + RICON_TEXT_T = 30, + RICON_TEXT_A = 31, + RICON_SCALE = 32, + RICON_RESIZE = 33, + RICON_FILTER_POINT = 34, + RICON_FILTER_BILINEAR = 35, + RICON_CROP = 36, + RICON_CROP_ALPHA = 37, + RICON_SQUARE_TOGGLE = 38, + RICON_SYMMETRY = 39, + RICON_SYMMETRY_HORIZONTAL = 40, + RICON_SYMMETRY_VERTICAL = 41, + RICON_LENS = 42, + RICON_LENS_BIG = 43, + RICON_EYE_ON = 44, + RICON_EYE_OFF = 45, + RICON_FILTER_TOP = 46, + RICON_FILTER = 47, + RICON_TARGET_POINT = 48, + RICON_TARGET_SMALL = 49, + RICON_TARGET_BIG = 50, + RICON_TARGET_MOVE = 51, + RICON_CURSOR_MOVE = 52, + RICON_CURSOR_SCALE = 53, + RICON_CURSOR_SCALE_RIGHT = 54, + RICON_CURSOR_SCALE_LEFT = 55, + RICON_UNDO = 56, + RICON_REDO = 57, + RICON_REREDO = 58, + RICON_MUTATE = 59, + RICON_ROTATE = 60, + RICON_REPEAT = 61, + RICON_SHUFFLE = 62, + RICON_EMPTYBOX = 63, + RICON_TARGET = 64, + RICON_TARGET_SMALL_FILL = 65, + RICON_TARGET_BIG_FILL = 66, + RICON_TARGET_MOVE_FILL = 67, + RICON_CURSOR_MOVE_FILL = 68, + RICON_CURSOR_SCALE_FILL = 69, + RICON_CURSOR_SCALE_RIGHT_FILL = 70, + RICON_CURSOR_SCALE_LEFT_FILL = 71, + RICON_UNDO_FILL = 72, + RICON_REDO_FILL = 73, + RICON_REREDO_FILL = 74, + RICON_MUTATE_FILL = 75, + RICON_ROTATE_FILL = 76, + RICON_REPEAT_FILL = 77, + RICON_SHUFFLE_FILL = 78, + RICON_EMPTYBOX_SMALL = 79, + RICON_BOX = 80, + RICON_BOX_TOP = 81, + RICON_BOX_TOP_RIGHT = 82, + RICON_BOX_RIGHT = 83, + RICON_BOX_BOTTOM_RIGHT = 84, + RICON_BOX_BOTTOM = 85, + RICON_BOX_BOTTOM_LEFT = 86, + RICON_BOX_LEFT = 87, + RICON_BOX_TOP_LEFT = 88, + RICON_BOX_CENTER = 89, + RICON_BOX_CIRCLE_MASK = 90, + RICON_POT = 91, + RICON_ALPHA_MULTIPLY = 92, + RICON_ALPHA_CLEAR = 93, + RICON_DITHERING = 94, + RICON_MIPMAPS = 95, + RICON_BOX_GRID = 96, + RICON_GRID = 97, + RICON_BOX_CORNERS_SMALL = 98, + RICON_BOX_CORNERS_BIG = 99, + RICON_FOUR_BOXES = 100, + RICON_GRID_FILL = 101, + RICON_BOX_MULTISIZE = 102, + RICON_ZOOM_SMALL = 103, + RICON_ZOOM_MEDIUM = 104, + RICON_ZOOM_BIG = 105, + RICON_ZOOM_ALL = 106, + RICON_ZOOM_CENTER = 107, + RICON_BOX_DOTS_SMALL = 108, + RICON_BOX_DOTS_BIG = 109, + RICON_BOX_CONCENTRIC = 110, + RICON_BOX_GRID_BIG = 111, + RICON_OK_TICK = 112, + RICON_CROSS = 113, + RICON_ARROW_LEFT = 114, + RICON_ARROW_RIGHT = 115, + RICON_ARROW_BOTTOM = 116, + RICON_ARROW_TOP = 117, + RICON_ARROW_LEFT_FILL = 118, + RICON_ARROW_RIGHT_FILL = 119, + RICON_ARROW_BOTTOM_FILL = 120, + RICON_ARROW_TOP_FILL = 121, + RICON_AUDIO = 122, + RICON_FX = 123, + RICON_WAVE = 124, + RICON_WAVE_SINUS = 125, + RICON_WAVE_SQUARE = 126, + RICON_WAVE_TRIANGULAR = 127, + RICON_CROSS_SMALL = 128, + RICON_PLAYER_PREVIOUS = 129, + RICON_PLAYER_PLAY_BACK = 130, + RICON_PLAYER_PLAY = 131, + RICON_PLAYER_PAUSE = 132, + RICON_PLAYER_STOP = 133, + RICON_PLAYER_NEXT = 134, + RICON_PLAYER_RECORD = 135, + RICON_MAGNET = 136, + RICON_LOCK_CLOSE = 137, + RICON_LOCK_OPEN = 138, + RICON_CLOCK = 139, + RICON_TOOLS = 140, + RICON_GEAR = 141, + RICON_GEAR_BIG = 142, + RICON_BIN = 143, + RICON_HAND_POINTER = 144, + RICON_LASER = 145, + RICON_COIN = 146, + RICON_EXPLOSION = 147, + RICON_1UP = 148, + RICON_PLAYER = 149, + RICON_PLAYER_JUMP = 150, + RICON_KEY = 151, + RICON_DEMON = 152, + RICON_TEXT_POPUP = 153, + RICON_GEAR_EX = 154, + RICON_CRACK = 155, + RICON_CRACK_POINTS = 156, + RICON_STAR = 157, + RICON_DOOR = 158, + RICON_EXIT = 159, + RICON_MODE_2D = 160, + RICON_MODE_3D = 161, + RICON_CUBE = 162, + RICON_CUBE_FACE_TOP = 163, + RICON_CUBE_FACE_LEFT = 164, + RICON_CUBE_FACE_FRONT = 165, + RICON_CUBE_FACE_BOTTOM = 166, + RICON_CUBE_FACE_RIGHT = 167, + RICON_CUBE_FACE_BACK = 168, + RICON_CAMERA = 169, + RICON_SPECIAL = 170, + RICON_LINK_NET = 171, + RICON_LINK_BOXES = 172, + RICON_LINK_MULTI = 173, + RICON_LINK = 174, + RICON_LINK_BROKE = 175, + RICON_TEXT_NOTES = 176, + RICON_NOTEBOOK = 177, + RICON_SUITCASE = 178, + RICON_SUITCASE_ZIP = 179, + RICON_MAILBOX = 180, + RICON_MONITOR = 181, + RICON_PRINTER = 182, + RICON_PHOTO_CAMERA = 183, + RICON_PHOTO_CAMERA_FLASH = 184, + RICON_HOUSE = 185, + RICON_HEART = 186, + RICON_CORNER = 187, + RICON_VERTICAL_BARS = 188, + RICON_VERTICAL_BARS_FILL = 189, + RICON_LIFE_BARS = 190, + RICON_INFO = 191, + RICON_CROSSLINE = 192, + RICON_HELP = 193, + RICON_FILETYPE_ALPHA = 194, + RICON_FILETYPE_HOME = 195, + RICON_LAYERS_VISIBLE = 196, + RICON_LAYERS = 197, + RICON_WINDOW = 198, + RICON_HIDPI = 199, + RICON_200 = 200, + RICON_201 = 201, + RICON_202 = 202, + RICON_203 = 203, + RICON_204 = 204, + RICON_205 = 205, + RICON_206 = 206, + RICON_207 = 207, + RICON_208 = 208, + RICON_209 = 209, + RICON_210 = 210, + RICON_211 = 211, + RICON_212 = 212, + RICON_213 = 213, + RICON_214 = 214, + RICON_215 = 215, + RICON_216 = 216, + RICON_217 = 217, + RICON_218 = 218, + RICON_219 = 219, + RICON_220 = 220, + RICON_221 = 221, + RICON_222 = 222, + RICON_223 = 223, + RICON_224 = 224, + RICON_225 = 225, + RICON_226 = 226, + RICON_227 = 227, + RICON_228 = 228, + RICON_229 = 229, + RICON_230 = 230, + RICON_231 = 231, + RICON_232 = 232, + RICON_233 = 233, + RICON_234 = 234, + RICON_235 = 235, + RICON_236 = 236, + RICON_237 = 237, + RICON_238 = 238, + RICON_239 = 239, + RICON_240 = 240, + RICON_241 = 241, + RICON_242 = 242, + RICON_243 = 243, + RICON_244 = 244, + RICON_245 = 245, + RICON_246 = 246, + RICON_247 = 247, + RICON_248 = 248, + RICON_249 = 249, + RICON_250 = 250, + RICON_251 = 251, + RICON_252 = 252, + RICON_253 = 253, + RICON_254 = 254, + RICON_255 = 255, +} guiIconName; + +//---------------------------------------------------------------------------------- +// Icons data (allocated on memory data section by default) +// NOTE: A new icon set could be loaded over this array using GuiLoadIcons(), +// just note that loaded icons set must be same RICON_SIZE +//---------------------------------------------------------------------------------- +static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_NONE + 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // RICON_FOLDER_FILE_OPEN + 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // RICON_FILE_SAVE_CLASSIC + 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // RICON_FOLDER_OPEN + 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // RICON_FOLDER_SAVE + 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // RICON_FILE_OPEN + 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // RICON_FILE_SAVE + 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // RICON_FILE_EXPORT + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // RICON_FILE_NEW + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // RICON_FILE_DELETE + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_FILETYPE_TEXT + 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // RICON_FILETYPE_AUDIO + 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // RICON_FILETYPE_IMAGE + 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // RICON_FILETYPE_PLAY + 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // RICON_FILETYPE_VIDEO + 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // RICON_FILETYPE_INFO + 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // RICON_FILE_COPY + 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // RICON_FILE_CUT + 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // RICON_FILE_PASTE + 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_CURSOR_HAND + 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // RICON_CURSOR_POINTER + 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // RICON_CURSOR_CLASSIC + 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // RICON_PENCIL + 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // RICON_PENCIL_BIG + 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // RICON_BRUSH_CLASSIC + 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // RICON_BRUSH_PAINTER + 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // RICON_WATER_DROP + 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // RICON_COLOR_PICKER + 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // RICON_RUBBER + 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // RICON_COLOR_BUCKET + 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // RICON_TEXT_T + 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // RICON_TEXT_A + 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // RICON_SCALE + 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // RICON_RESIZE + 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_POINT + 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_BILINEAR + 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // RICON_CROP + 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // RICON_CROP_ALPHA + 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // RICON_SQUARE_TOGGLE + 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // RICON_SIMMETRY + 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // RICON_SIMMETRY_HORIZONTAL + 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // RICON_SIMMETRY_VERTICAL + 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // RICON_LENS + 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // RICON_LENS_BIG + 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // RICON_EYE_ON + 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // RICON_EYE_OFF + 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // RICON_FILTER_TOP + 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // RICON_FILTER + 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_POINT + 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL + 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG + 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // RICON_TARGET_MOVE + 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // RICON_CURSOR_MOVE + 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // RICON_CURSOR_SCALE + 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // RICON_CURSOR_SCALE_RIGHT + 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // RICON_CURSOR_SCALE_LEFT + 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO + 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO + 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // RICON_REREDO + 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // RICON_MUTATE + 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // RICON_ROTATE + 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // RICON_REPEAT + 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // RICON_SHUFFLE + 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // RICON_EMPTYBOX + 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // RICON_TARGET + 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL_FILL + 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG_FILL + 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // RICON_TARGET_MOVE_FILL + 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // RICON_CURSOR_MOVE_FILL + 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // RICON_CURSOR_SCALE_FILL + 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // RICON_CURSOR_SCALE_RIGHT + 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // RICON_CURSOR_SCALE_LEFT + 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO_FILL + 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO_FILL + 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // RICON_REREDO_FILL + 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // RICON_MUTATE_FILL + 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // RICON_ROTATE_FILL + 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // RICON_REPEAT_FILL + 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // RICON_SHUFFLE_FILL + 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // RICON_EMPTYBOX_SMALL + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX + 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP + 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // RICON_BOX_BOTTOM_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // RICON_BOX_BOTTOM + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // RICON_BOX_BOTTOM_LEFT + 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_LEFT + 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_LEFT + 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_CIRCLE_MASK + 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // RICON_BOX_CENTER + 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // RICON_POT + 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // RICON_ALPHA_MULTIPLY + 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // RICON_ALPHA_CLEAR + 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // RICON_DITHERING + 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // RICON_MIPMAPS + 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // RICON_BOX_GRID + 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // RICON_GRID + 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // RICON_BOX_CORNERS_SMALL + 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // RICON_BOX_CORNERS_BIG + 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // RICON_FOUR_BOXES + 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // RICON_GRID_FILL + 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // RICON_BOX_MULTISIZE + 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_SMALL + 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_MEDIUM + 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // RICON_ZOOM_BIG + 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // RICON_ZOOM_ALL + 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // RICON_ZOOM_CENTER + 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // RICON_BOX_DOTS_SMALL + 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // RICON_BOX_DOTS_BIG + 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // RICON_BOX_CONCENTRIC + 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // RICON_BOX_GRID_BIG + 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // RICON_OK_TICK + 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // RICON_CROSS + 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // RICON_ARROW_LEFT + 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // RICON_ARROW_RIGHT + 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM + 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP + 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // RICON_ARROW_LEFT_FILL + 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // RICON_ARROW_RIGHT_FILL + 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM_FILL + 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP_FILL + 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // RICON_AUDIO + 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // RICON_FX + 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // RICON_WAVE + 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // RICON_WAVE_SINUS + 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // RICON_WAVE_SQUARE + 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // RICON_WAVE_TRIANGULAR + 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // RICON_CROSS_SMALL + 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // RICON_PLAYER_PREVIOUS + 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // RICON_PLAYER_PLAY_BACK + 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // RICON_PLAYER_PLAY + 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // RICON_PLAYER_PAUSE + 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // RICON_PLAYER_STOP + 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // RICON_PLAYER_NEXT + 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // RICON_PLAYER_RECORD + 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // RICON_MAGNET + 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_CLOSE + 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_OPEN + 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // RICON_CLOCK + 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // RICON_TOOLS + 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // RICON_GEAR + 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // RICON_GEAR_BIG + 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // RICON_BIN + 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // RICON_HAND_POINTER + 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // RICON_LASER + 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // RICON_COIN + 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // RICON_EXPLOSION + 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // RICON_1UP + 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // RICON_PLAYER + 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // RICON_PLAYER_JUMP + 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // RICON_KEY + 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // RICON_DEMON + 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // RICON_TEXT_POPUP + 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // RICON_GEAR_EX + 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK + 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK_POINTS + 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // RICON_STAR + 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // RICON_DOOR + 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // RICON_EXIT + 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // RICON_MODE_2D + 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // RICON_MODE_3D + 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE + 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_TOP + 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // RICON_CUBE_FACE_LEFT + 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // RICON_CUBE_FACE_FRONT + 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // RICON_CUBE_FACE_BOTTOM + 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // RICON_CUBE_FACE_RIGHT + 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_BACK + 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // RICON_CAMERA + 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // RICON_SPECIAL + 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // RICON_LINK_NET + 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // RICON_LINK_BOXES + 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // RICON_LINK_MULTI + 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // RICON_LINK + 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // RICON_LINK_BROKE + 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_TEXT_NOTES + 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // RICON_NOTEBOOK + 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // RICON_SUITCASE + 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // RICON_SUITCASE_ZIP + 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // RICON_MAILBOX + 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // RICON_MONITOR + 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // RICON_PRINTER + 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA + 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA_FLASH + 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // RICON_HOUSE + 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // RICON_HEART + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // RICON_CORNER + 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // RICON_VERTICAL_BARS + 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // RICON_VERTICAL_BARS_FILL + 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // RICON_LIFE_BARS + 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // RICON_INFO + 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // RICON_CROSSLINE + 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // RICON_HELP + 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // RICON_FILETYPE_ALPHA + 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // RICON_FILETYPE_HOME + 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS_VISIBLE + 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS + 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // RICON_WINDOW + 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // RICON_HIDPI + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_200 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_201 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_202 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_203 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_204 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_205 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_206 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_207 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_208 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_209 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_210 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_211 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_212 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_213 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_214 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_215 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_216 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_217 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_218 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_219 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_220 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_221 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_222 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_223 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_224 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_225 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_226 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_227 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_228 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_229 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_230 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_231 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_232 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_233 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_234 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_235 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_236 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_237 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_238 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_239 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_240 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_241 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_242 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_243 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_244 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_245 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_246 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_247 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_248 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_249 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_250 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_251 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_252 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_253 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_254 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_255 +}; + +#endif // RAYGUI_SUPPORT_CUSTOM_RICONS + +#endif // RAYGUI_SUPPORT_RICONS + +#ifndef RICON_SIZE + #define RICON_SIZE 0 +#endif + +#define RAYGUI_MAX_CONTROLS 16 // Maximum number of standard controls +#define RAYGUI_MAX_PROPS_DEFAULT 16 // Maximum number of standard properties +#define RAYGUI_MAX_PROPS_EXTENDED 8 // Maximum number of extended properties + +// TODO: Avoid animations and time-based states +// Functions using it: GuiTextBox(), GuiValueBox(), GuiTextBoxMulti() +#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -552,7 +1097,7 @@ static float guiAlpha = 1.0f; // Gui element transpacency on drawing // NOTE: In raygui we manage a single int array with all the possible style properties. // When a new style is loaded, it loads over the global style... but default gui style // could always be recovered with GuiLoadStyleDefault() -static unsigned int guiStyle[NUM_CONTROLS*(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED)] = { 0 }; +static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_DEFAULT + RAYGUI_MAX_PROPS_EXTENDED)] = { 0 }; static bool guiStyleLoaded = false; // Style loaded flag for lazy style initialization //---------------------------------------------------------------------------------- @@ -593,7 +1138,7 @@ static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color static void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // -- GuiDropdownBox(), GuiScrollBar() static void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // -- GuiImageButtonEx() -static void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // -- GuiTextBoxMulti() +//static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // -- GuiTextBoxMulti() //------------------------------------------------------------------------------- // Text required functions @@ -692,12 +1237,12 @@ Font GuiGetFont(void) void GuiSetStyle(int control, int property, int value) { if (!guiStyleLoaded) GuiLoadStyleDefault(); - guiStyle[control*(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED) + property] = value; + guiStyle[control*(RAYGUI_MAX_PROPS_DEFAULT + RAYGUI_MAX_PROPS_EXTENDED) + property] = value; // Default properties are propagated to all controls - if ((control == 0) && (property < NUM_PROPS_DEFAULT)) + if ((control == 0) && (property < RAYGUI_MAX_PROPS_DEFAULT)) { - for (int i = 1; i < NUM_CONTROLS; i++) guiStyle[i*(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED) + property] = value; + for (int i = 1; i < RAYGUI_MAX_CONTROLS; i++) guiStyle[i*(RAYGUI_MAX_PROPS_DEFAULT + RAYGUI_MAX_PROPS_EXTENDED) + property] = value; } } @@ -705,7 +1250,7 @@ void GuiSetStyle(int control, int property, int value) int GuiGetStyle(int control, int property) { if (!guiStyleLoaded) GuiLoadStyleDefault(); - return guiStyle[control*(NUM_PROPS_DEFAULT + NUM_PROPS_EXTENDED) + property]; + return guiStyle[control*(RAYGUI_MAX_PROPS_DEFAULT + RAYGUI_MAX_PROPS_EXTENDED) + property]; } //---------------------------------------------------------------------------------- @@ -746,7 +1291,7 @@ bool GuiWindowBox(Rectangle bounds, const char *title) int tempTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); GuiSetStyle(BUTTON, BORDER_WIDTH, 1); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) clicked = GuiButton(closeButtonRec, GuiIconText(RICON_CROSS_SMALL, NULL)); #else clicked = GuiButton(closeButtonRec, "x"); @@ -1533,7 +2078,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in GuiSetStyle(BUTTON, BORDER_WIDTH, GuiGetStyle(SPINNER, BORDER_WIDTH)); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) if (GuiButton(leftButtonBound, GuiIconText(RICON_ARROW_LEFT_FILL, NULL))) tempValue--; if (GuiButton(rightButtonBound, GuiIconText(RICON_ARROW_RIGHT_FILL, NULL))) tempValue++; #else @@ -1806,7 +2351,9 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) } else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK); - DrawTextRec(guiFont, text, textAreaBounds, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), true, Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); + // TODO: Review to support boxed text with word-wrap + //DrawTextBoxed(guiFont, text, textAreaBounds, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), true, Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); + DrawTextEx(guiFont, text, (Vector2){ textAreaBounds.x, textAreaBounds.y }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- return pressed; @@ -2839,7 +3386,7 @@ void GuiLoadStyle(const char *fileName) // NOTE: All DEFAULT properties should be defined first in the file GuiSetStyle(0, (int)propertyId, propertyValue); - if (propertyId < NUM_PROPS_DEFAULT) for (int i = 1; i < NUM_CONTROLS; i++) GuiSetStyle(i, (int)propertyId, propertyValue); + if (propertyId < RAYGUI_MAX_PROPS_DEFAULT) for (int i = 1; i < RAYGUI_MAX_CONTROLS; i++) GuiSetStyle(i, (int)propertyId, propertyValue); } else GuiSetStyle((int)controlId, (int)propertyId, propertyValue); } @@ -2997,7 +3544,7 @@ void GuiLoadStyleDefault(void) // a number that can change between ricon versions const char *GuiIconText(int iconId, const char *text) { -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) static char buffer[1024] = { 0 }; memset(buffer, 0, 1024); @@ -3018,7 +3565,7 @@ const char *GuiIconText(int iconId, const char *text) #endif } -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) // Get full icons data pointer unsigned int *GuiGetIcons(void) { return guiIcons; } @@ -3164,7 +3711,7 @@ bool GuiCheckIconPixel(int iconId, int x, int y) return (BIT_CHECK(guiIcons[iconId*8 + y/2], x + (y%2*16))); } -#endif // RAYGUI_SUPPORT_ICONS +#endif // RAYGUI_SUPPORT_RICONS //---------------------------------------------------------------------------------- // Module specific Functions Definition @@ -3213,7 +3760,7 @@ static Rectangle GetTextBounds(int control, Rectangle bounds) // NOTE: We support up to 999 values for iconId static const char *GetTextIcon(const char *text, int *iconId) { -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) *iconId = -1; if (text[0] == '#') // Maybe we have an icon! { @@ -3252,7 +3799,7 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color // Get text position depending on alignment and iconId //--------------------------------------------------------------------------------- - #define ICON_TEXT_PADDING 4 + #define RICON_TEXT_PADDING 4 Vector2 position = { bounds.x, bounds.y }; @@ -3260,15 +3807,15 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color int textWidth = GetTextWidth(text); int textHeight = GuiGetStyle(DEFAULT, TEXT_SIZE); -#if defined(RAYGUI_SUPPORT_ICONS) + // If text requires an icon, add size to measure if (iconId >= 0) { textWidth += RICON_SIZE; // WARNING: If only icon provided, text could be pointing to eof character! - if ((text != NULL) && (text[0] != '\0')) textWidth += ICON_TEXT_PADDING; + if ((text != NULL) && (text[0] != '\0')) textWidth += RICON_TEXT_PADDING; } -#endif + // Check guiTextAlign global variables switch (alignment) { @@ -3298,12 +3845,12 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color // Draw text (with icon if available) //--------------------------------------------------------------------------------- -#if defined(RAYGUI_SUPPORT_ICONS) +#if defined(RAYGUI_SUPPORT_RICONS) if (iconId >= 0) { // NOTE: We consider icon height, probably different than text size GuiDrawIcon(iconId, RAYGUI_CLITERAL(Vector2){ position.x, bounds.y + bounds.height/2 - RICON_SIZE/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height) }, 1, tint); - position.x += (RICON_SIZE + ICON_TEXT_PADDING); + position.x += (RICON_SIZE + RICON_TEXT_PADDING); } #endif DrawTextEx(guiFont, text, position, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), tint); diff --git a/src/extras/ricons.h b/src/extras/ricons.h deleted file mode 100644 index 121cf5432..000000000 --- a/src/extras/ricons.h +++ /dev/null @@ -1,556 +0,0 @@ -/********************************************************************************************** -* -* rIcons - Icons pack intended for tools development with raygui -* -* LICENSE: zlib/libpng -* -* Copyright (c) 2019-2020 Ramon Santamaria (@raysan5) -* -**********************************************************************************************/ - -#ifndef RICONS_H -#define RICONS_H - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#define RICON_MAX_ICONS 256 // Maximum number of icons -#define RICON_SIZE 16 // Size of icons (squared) - -#define RICON_MAX_NAME_LENGTH 32 // Maximum length of icon name id - -// Icons data is defined by bit array (every bit represents one pixel) -// Those arrays are stored as unsigned int data arrays, so every array -// element defines 32 pixels (bits) of information -// Number of elemens depend on RICON_SIZE (by default 16x16 pixels) -#define RICON_DATA_ELEMENTS (RICON_SIZE*RICON_SIZE/32) - -//---------------------------------------------------------------------------------- -// Icons enumeration -//---------------------------------------------------------------------------------- -typedef enum { - RICON_NONE = 0, - RICON_FOLDER_FILE_OPEN = 1, - RICON_FILE_SAVE_CLASSIC = 2, - RICON_FOLDER_OPEN = 3, - RICON_FOLDER_SAVE = 4, - RICON_FILE_OPEN = 5, - RICON_FILE_SAVE = 6, - RICON_FILE_EXPORT = 7, - RICON_FILE_NEW = 8, - RICON_FILE_DELETE = 9, - RICON_FILETYPE_TEXT = 10, - RICON_FILETYPE_AUDIO = 11, - RICON_FILETYPE_IMAGE = 12, - RICON_FILETYPE_PLAY = 13, - RICON_FILETYPE_VIDEO = 14, - RICON_FILETYPE_INFO = 15, - RICON_FILE_COPY = 16, - RICON_FILE_CUT = 17, - RICON_FILE_PASTE = 18, - RICON_CURSOR_HAND = 19, - RICON_CURSOR_POINTER = 20, - RICON_CURSOR_CLASSIC = 21, - RICON_PENCIL = 22, - RICON_PENCIL_BIG = 23, - RICON_BRUSH_CLASSIC = 24, - RICON_BRUSH_PAINTER = 25, - RICON_WATER_DROP = 26, - RICON_COLOR_PICKER = 27, - RICON_RUBBER = 28, - RICON_COLOR_BUCKET = 29, - RICON_TEXT_T = 30, - RICON_TEXT_A = 31, - RICON_SCALE = 32, - RICON_RESIZE = 33, - RICON_FILTER_POINT = 34, - RICON_FILTER_BILINEAR = 35, - RICON_CROP = 36, - RICON_CROP_ALPHA = 37, - RICON_SQUARE_TOGGLE = 38, - RICON_SYMMETRY = 39, - RICON_SYMMETRY_HORIZONTAL = 40, - RICON_SYMMETRY_VERTICAL = 41, - RICON_LENS = 42, - RICON_LENS_BIG = 43, - RICON_EYE_ON = 44, - RICON_EYE_OFF = 45, - RICON_FILTER_TOP = 46, - RICON_FILTER = 47, - RICON_TARGET_POINT = 48, - RICON_TARGET_SMALL = 49, - RICON_TARGET_BIG = 50, - RICON_TARGET_MOVE = 51, - RICON_CURSOR_MOVE = 52, - RICON_CURSOR_SCALE = 53, - RICON_CURSOR_SCALE_RIGHT = 54, - RICON_CURSOR_SCALE_LEFT = 55, - RICON_UNDO = 56, - RICON_REDO = 57, - RICON_REREDO = 58, - RICON_MUTATE = 59, - RICON_ROTATE = 60, - RICON_REPEAT = 61, - RICON_SHUFFLE = 62, - RICON_EMPTYBOX = 63, - RICON_TARGET = 64, - RICON_TARGET_SMALL_FILL = 65, - RICON_TARGET_BIG_FILL = 66, - RICON_TARGET_MOVE_FILL = 67, - RICON_CURSOR_MOVE_FILL = 68, - RICON_CURSOR_SCALE_FILL = 69, - RICON_CURSOR_SCALE_RIGHT_FILL = 70, - RICON_CURSOR_SCALE_LEFT_FILL = 71, - RICON_UNDO_FILL = 72, - RICON_REDO_FILL = 73, - RICON_REREDO_FILL = 74, - RICON_MUTATE_FILL = 75, - RICON_ROTATE_FILL = 76, - RICON_REPEAT_FILL = 77, - RICON_SHUFFLE_FILL = 78, - RICON_EMPTYBOX_SMALL = 79, - RICON_BOX = 80, - RICON_BOX_TOP = 81, - RICON_BOX_TOP_RIGHT = 82, - RICON_BOX_RIGHT = 83, - RICON_BOX_BOTTOM_RIGHT = 84, - RICON_BOX_BOTTOM = 85, - RICON_BOX_BOTTOM_LEFT = 86, - RICON_BOX_LEFT = 87, - RICON_BOX_TOP_LEFT = 88, - RICON_BOX_CENTER = 89, - RICON_BOX_CIRCLE_MASK = 90, - RICON_POT = 91, - RICON_ALPHA_MULTIPLY = 92, - RICON_ALPHA_CLEAR = 93, - RICON_DITHERING = 94, - RICON_MIPMAPS = 95, - RICON_BOX_GRID = 96, - RICON_GRID = 97, - RICON_BOX_CORNERS_SMALL = 98, - RICON_BOX_CORNERS_BIG = 99, - RICON_FOUR_BOXES = 100, - RICON_GRID_FILL = 101, - RICON_BOX_MULTISIZE = 102, - RICON_ZOOM_SMALL = 103, - RICON_ZOOM_MEDIUM = 104, - RICON_ZOOM_BIG = 105, - RICON_ZOOM_ALL = 106, - RICON_ZOOM_CENTER = 107, - RICON_BOX_DOTS_SMALL = 108, - RICON_BOX_DOTS_BIG = 109, - RICON_BOX_CONCENTRIC = 110, - RICON_BOX_GRID_BIG = 111, - RICON_OK_TICK = 112, - RICON_CROSS = 113, - RICON_ARROW_LEFT = 114, - RICON_ARROW_RIGHT = 115, - RICON_ARROW_BOTTOM = 116, - RICON_ARROW_TOP = 117, - RICON_ARROW_LEFT_FILL = 118, - RICON_ARROW_RIGHT_FILL = 119, - RICON_ARROW_BOTTOM_FILL = 120, - RICON_ARROW_TOP_FILL = 121, - RICON_AUDIO = 122, - RICON_FX = 123, - RICON_WAVE = 124, - RICON_WAVE_SINUS = 125, - RICON_WAVE_SQUARE = 126, - RICON_WAVE_TRIANGULAR = 127, - RICON_CROSS_SMALL = 128, - RICON_PLAYER_PREVIOUS = 129, - RICON_PLAYER_PLAY_BACK = 130, - RICON_PLAYER_PLAY = 131, - RICON_PLAYER_PAUSE = 132, - RICON_PLAYER_STOP = 133, - RICON_PLAYER_NEXT = 134, - RICON_PLAYER_RECORD = 135, - RICON_MAGNET = 136, - RICON_LOCK_CLOSE = 137, - RICON_LOCK_OPEN = 138, - RICON_CLOCK = 139, - RICON_TOOLS = 140, - RICON_GEAR = 141, - RICON_GEAR_BIG = 142, - RICON_BIN = 143, - RICON_HAND_POINTER = 144, - RICON_LASER = 145, - RICON_COIN = 146, - RICON_EXPLOSION = 147, - RICON_1UP = 148, - RICON_PLAYER = 149, - RICON_PLAYER_JUMP = 150, - RICON_KEY = 151, - RICON_DEMON = 152, - RICON_TEXT_POPUP = 153, - RICON_GEAR_EX = 154, - RICON_CRACK = 155, - RICON_CRACK_POINTS = 156, - RICON_STAR = 157, - RICON_DOOR = 158, - RICON_EXIT = 159, - RICON_MODE_2D = 160, - RICON_MODE_3D = 161, - RICON_CUBE = 162, - RICON_CUBE_FACE_TOP = 163, - RICON_CUBE_FACE_LEFT = 164, - RICON_CUBE_FACE_FRONT = 165, - RICON_CUBE_FACE_BOTTOM = 166, - RICON_CUBE_FACE_RIGHT = 167, - RICON_CUBE_FACE_BACK = 168, - RICON_CAMERA = 169, - RICON_SPECIAL = 170, - RICON_LINK_NET = 171, - RICON_LINK_BOXES = 172, - RICON_LINK_MULTI = 173, - RICON_LINK = 174, - RICON_LINK_BROKE = 175, - RICON_TEXT_NOTES = 176, - RICON_NOTEBOOK = 177, - RICON_SUITCASE = 178, - RICON_SUITCASE_ZIP = 179, - RICON_MAILBOX = 180, - RICON_MONITOR = 181, - RICON_PRINTER = 182, - RICON_PHOTO_CAMERA = 183, - RICON_PHOTO_CAMERA_FLASH = 184, - RICON_HOUSE = 185, - RICON_HEART = 186, - RICON_CORNER = 187, - RICON_VERTICAL_BARS = 188, - RICON_VERTICAL_BARS_FILL = 189, - RICON_LIFE_BARS = 190, - RICON_INFO = 191, - RICON_CROSSLINE = 192, - RICON_HELP = 193, - RICON_FILETYPE_ALPHA = 194, - RICON_FILETYPE_HOME = 195, - RICON_LAYERS_VISIBLE = 196, - RICON_LAYERS = 197, - RICON_WINDOW = 198, - RICON_HIDPI = 199, - RICON_200 = 200, - RICON_201 = 201, - RICON_202 = 202, - RICON_203 = 203, - RICON_204 = 204, - RICON_205 = 205, - RICON_206 = 206, - RICON_207 = 207, - RICON_208 = 208, - RICON_209 = 209, - RICON_210 = 210, - RICON_211 = 211, - RICON_212 = 212, - RICON_213 = 213, - RICON_214 = 214, - RICON_215 = 215, - RICON_216 = 216, - RICON_217 = 217, - RICON_218 = 218, - RICON_219 = 219, - RICON_220 = 220, - RICON_221 = 221, - RICON_222 = 222, - RICON_223 = 223, - RICON_224 = 224, - RICON_225 = 225, - RICON_226 = 226, - RICON_227 = 227, - RICON_228 = 228, - RICON_229 = 229, - RICON_230 = 230, - RICON_231 = 231, - RICON_232 = 232, - RICON_233 = 233, - RICON_234 = 234, - RICON_235 = 235, - RICON_236 = 236, - RICON_237 = 237, - RICON_238 = 238, - RICON_239 = 239, - RICON_240 = 240, - RICON_241 = 241, - RICON_242 = 242, - RICON_243 = 243, - RICON_244 = 244, - RICON_245 = 245, - RICON_246 = 246, - RICON_247 = 247, - RICON_248 = 248, - RICON_249 = 249, - RICON_250 = 250, - RICON_251 = 251, - RICON_252 = 252, - RICON_253 = 253, - RICON_254 = 254, - RICON_255 = 255, -} guiIconName; - -#endif // RICONS_H - -#if defined(RICONS_IMPLEMENTATION) -//---------------------------------------------------------------------------------- -// Icons data (allocated on memory data section by default) -// NOTE: A new icon set could be loaded over this array using GuiLoadIcons(), -// just note that loaded icons set must be same RICON_SIZE -//---------------------------------------------------------------------------------- -static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_NONE - 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // RICON_FOLDER_FILE_OPEN - 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // RICON_FILE_SAVE_CLASSIC - 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // RICON_FOLDER_OPEN - 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // RICON_FOLDER_SAVE - 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // RICON_FILE_OPEN - 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // RICON_FILE_SAVE - 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // RICON_FILE_EXPORT - 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // RICON_FILE_NEW - 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // RICON_FILE_DELETE - 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_FILETYPE_TEXT - 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // RICON_FILETYPE_AUDIO - 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // RICON_FILETYPE_IMAGE - 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // RICON_FILETYPE_PLAY - 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // RICON_FILETYPE_VIDEO - 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // RICON_FILETYPE_INFO - 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // RICON_FILE_COPY - 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // RICON_FILE_CUT - 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // RICON_FILE_PASTE - 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_CURSOR_HAND - 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // RICON_CURSOR_POINTER - 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // RICON_CURSOR_CLASSIC - 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // RICON_PENCIL - 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // RICON_PENCIL_BIG - 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // RICON_BRUSH_CLASSIC - 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // RICON_BRUSH_PAINTER - 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // RICON_WATER_DROP - 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // RICON_COLOR_PICKER - 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // RICON_RUBBER - 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // RICON_COLOR_BUCKET - 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // RICON_TEXT_T - 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // RICON_TEXT_A - 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // RICON_SCALE - 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // RICON_RESIZE - 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_POINT - 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_BILINEAR - 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // RICON_CROP - 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // RICON_CROP_ALPHA - 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // RICON_SQUARE_TOGGLE - 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // RICON_SIMMETRY - 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // RICON_SIMMETRY_HORIZONTAL - 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // RICON_SIMMETRY_VERTICAL - 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // RICON_LENS - 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // RICON_LENS_BIG - 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // RICON_EYE_ON - 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // RICON_EYE_OFF - 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // RICON_FILTER_TOP - 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // RICON_FILTER - 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_POINT - 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL - 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG - 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // RICON_TARGET_MOVE - 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // RICON_CURSOR_MOVE - 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // RICON_CURSOR_SCALE - 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // RICON_CURSOR_SCALE_RIGHT - 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // RICON_CURSOR_SCALE_LEFT - 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO - 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO - 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // RICON_REREDO - 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // RICON_MUTATE - 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // RICON_ROTATE - 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // RICON_REPEAT - 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // RICON_SHUFFLE - 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // RICON_EMPTYBOX - 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // RICON_TARGET - 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL_FILL - 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG_FILL - 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // RICON_TARGET_MOVE_FILL - 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // RICON_CURSOR_MOVE_FILL - 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // RICON_CURSOR_SCALE_FILL - 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // RICON_CURSOR_SCALE_RIGHT - 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // RICON_CURSOR_SCALE_LEFT - 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO_FILL - 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO_FILL - 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // RICON_REREDO_FILL - 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // RICON_MUTATE_FILL - 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // RICON_ROTATE_FILL - 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // RICON_REPEAT_FILL - 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // RICON_SHUFFLE_FILL - 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // RICON_EMPTYBOX_SMALL - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX - 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP - 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_RIGHT - 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_RIGHT - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // RICON_BOX_BOTTOM_RIGHT - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // RICON_BOX_BOTTOM - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // RICON_BOX_BOTTOM_LEFT - 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_LEFT - 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_LEFT - 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_CIRCLE_MASK - 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // RICON_BOX_CENTER - 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // RICON_POT - 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // RICON_ALPHA_MULTIPLY - 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // RICON_ALPHA_CLEAR - 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // RICON_DITHERING - 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // RICON_MIPMAPS - 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // RICON_BOX_GRID - 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // RICON_GRID - 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // RICON_BOX_CORNERS_SMALL - 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // RICON_BOX_CORNERS_BIG - 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // RICON_FOUR_BOXES - 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // RICON_GRID_FILL - 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // RICON_BOX_MULTISIZE - 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_SMALL - 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_MEDIUM - 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // RICON_ZOOM_BIG - 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // RICON_ZOOM_ALL - 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // RICON_ZOOM_CENTER - 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // RICON_BOX_DOTS_SMALL - 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // RICON_BOX_DOTS_BIG - 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // RICON_BOX_CONCENTRIC - 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // RICON_BOX_GRID_BIG - 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // RICON_OK_TICK - 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // RICON_CROSS - 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // RICON_ARROW_LEFT - 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // RICON_ARROW_RIGHT - 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM - 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP - 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // RICON_ARROW_LEFT_FILL - 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // RICON_ARROW_RIGHT_FILL - 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM_FILL - 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP_FILL - 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // RICON_AUDIO - 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // RICON_FX - 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // RICON_WAVE - 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // RICON_WAVE_SINUS - 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // RICON_WAVE_SQUARE - 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // RICON_WAVE_TRIANGULAR - 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // RICON_CROSS_SMALL - 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // RICON_PLAYER_PREVIOUS - 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // RICON_PLAYER_PLAY_BACK - 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // RICON_PLAYER_PLAY - 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // RICON_PLAYER_PAUSE - 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // RICON_PLAYER_STOP - 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // RICON_PLAYER_NEXT - 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // RICON_PLAYER_RECORD - 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // RICON_MAGNET - 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_CLOSE - 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_OPEN - 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // RICON_CLOCK - 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // RICON_TOOLS - 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // RICON_GEAR - 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // RICON_GEAR_BIG - 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // RICON_BIN - 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // RICON_HAND_POINTER - 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // RICON_LASER - 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // RICON_COIN - 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // RICON_EXPLOSION - 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // RICON_1UP - 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // RICON_PLAYER - 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // RICON_PLAYER_JUMP - 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // RICON_KEY - 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // RICON_DEMON - 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // RICON_TEXT_POPUP - 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // RICON_GEAR_EX - 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK - 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK_POINTS - 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // RICON_STAR - 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // RICON_DOOR - 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // RICON_EXIT - 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // RICON_MODE_2D - 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // RICON_MODE_3D - 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE - 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_TOP - 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // RICON_CUBE_FACE_LEFT - 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // RICON_CUBE_FACE_FRONT - 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // RICON_CUBE_FACE_BOTTOM - 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // RICON_CUBE_FACE_RIGHT - 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_BACK - 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // RICON_CAMERA - 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // RICON_SPECIAL - 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // RICON_LINK_NET - 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // RICON_LINK_BOXES - 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // RICON_LINK_MULTI - 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // RICON_LINK - 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // RICON_LINK_BROKE - 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_TEXT_NOTES - 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // RICON_NOTEBOOK - 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // RICON_SUITCASE - 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // RICON_SUITCASE_ZIP - 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // RICON_MAILBOX - 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // RICON_MONITOR - 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // RICON_PRINTER - 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA - 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA_FLASH - 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // RICON_HOUSE - 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // RICON_HEART - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // RICON_CORNER - 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // RICON_VERTICAL_BARS - 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // RICON_VERTICAL_BARS_FILL - 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // RICON_LIFE_BARS - 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // RICON_INFO - 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // RICON_CROSSLINE - 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // RICON_HELP - 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // RICON_FILETYPE_ALPHA - 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // RICON_FILETYPE_HOME - 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS_VISIBLE - 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS - 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // RICON_WINDOW - 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // RICON_HIDPI - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_200 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_201 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_202 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_203 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_204 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_205 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_206 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_207 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_208 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_209 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_210 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_211 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_212 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_213 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_214 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_215 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_216 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_217 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_218 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_219 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_220 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_221 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_222 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_223 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_224 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_225 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_226 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_227 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_228 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_229 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_230 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_231 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_232 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_233 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_234 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_235 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_236 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_237 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_238 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_239 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_240 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_241 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_242 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_243 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_244 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_245 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_246 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_247 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_248 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_249 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_250 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_251 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_252 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_253 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_254 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_255 -}; -#endif // RICONS_IMPLEMENTATION From 14e443afbac0c8742e11fb97edc6eea6f0865bc5 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 25 Aug 2021 23:41:33 +0200 Subject: [PATCH 13/31] REVIEWED: OpenGL 1.1 compilation issue --- src/rlgl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index 7d9b8d140..ce99c40e4 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -2956,9 +2956,9 @@ void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps = mipmapCount + 1; RL_FREE(texData); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data - TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Mipmaps generated manually on CPU side, total: %i", texture->id, texture->mipmaps); + TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Mipmaps generated manually on CPU side, total: %i", id, *mipmaps); } - else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps for provided texture format", texture->id); + else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps for provided texture format", id); } #endif #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) From 3d33c559e72340184d1cdb524faf8e6eb841022c Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 26 Aug 2021 00:14:34 +0200 Subject: [PATCH 14/31] REVIEWED: Examples compilation --- examples/core/core_window_letterbox.c | 2 +- examples/models/models_animation.c | 2 +- examples/models/models_material_pbr.c | 10 +++++----- examples/text/text_font_sdf.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/core/core_window_letterbox.c b/examples/core/core_window_letterbox.c index 2933ca422..1e0765163 100644 --- a/examples/core/core_window_letterbox.c +++ b/examples/core/core_window_letterbox.c @@ -43,7 +43,7 @@ int main(void) // Render texture initialization, used to hold the rendering result so we can easily resize it RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight); - SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use + SetTextureFilter(target.texture, TEXTURE_FILTER_BILINEAR); // Texture scale filter to use Color colors[10] = { 0 }; for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; diff --git a/examples/models/models_animation.c b/examples/models/models_animation.c index 2c3348c0f..4fde9baf3 100644 --- a/examples/models/models_animation.c +++ b/examples/models/models_animation.c @@ -41,7 +41,7 @@ int main(void) Model model = LoadModel("resources/guy/guy.iqm"); // Load the animated model mesh and basic data Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material - SetMaterialTexture(&model.materials[0], MAP_DIFFUSE, texture); // Set model material map texture + SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c index dfef69da1..7f11fd70e 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -162,11 +162,11 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness) mat.maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png"); // Set textures filtering for better quality - SetTextureFilter(mat.maps[MATERIAL_MAP_ALBEDO].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MATERIAL_MAP_NORMAL].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MATERIAL_MAP_METALNESS].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MATERIAL_MAP_ROUGHNESS].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MATERIAL_MAP_OCCLUSION].texture, FILTER_BILINEAR); + SetTextureFilter(mat.maps[MATERIAL_MAP_ALBEDO].texture, TEXTURE_FILTER_BILINEAR); + SetTextureFilter(mat.maps[MATERIAL_MAP_NORMAL].texture, TEXTURE_FILTER_BILINEAR); + SetTextureFilter(mat.maps[MATERIAL_MAP_METALNESS].texture, TEXTURE_FILTER_BILINEAR); + SetTextureFilter(mat.maps[MATERIAL_MAP_ROUGHNESS].texture, TEXTURE_FILTER_BILINEAR); + SetTextureFilter(mat.maps[MATERIAL_MAP_OCCLUSION].texture, TEXTURE_FILTER_BILINEAR); // Enable sample usage in shader for assigned textures SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT); diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index f9517bdc3..7de7986b3 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -64,7 +64,7 @@ int main(void) // Load SDF required shader (we use default vertex shader) Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/sdf.fs", GLSL_VERSION)); - SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font + SetTextureFilter(fontSDF.texture, TEXTURE_FILTER_BILINEAR); // Required for SDF font Vector2 fontPosition = { 40, screenHeight/2.0f - 50 }; Vector2 textSize = { 0.0f, 0.0f }; From 1286bc076f2f121b5375554c2ff26d2c1c72e0eb Mon Sep 17 00:00:00 2001 From: irishgreencitrus <43090499+irishgreencitrus@users.noreply.github.com> Date: Thu, 26 Aug 2021 16:27:31 +0100 Subject: [PATCH 15/31] Add raylib.v binding (#1955) Added raylib.v binding for Vlang --- BINDINGS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BINDINGS.md b/BINDINGS.md index b154dc7b2..2311406b4 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -82,6 +82,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to | jaylib | 3.0 | [Janet](https://janet-lang.org/) | https://github.com/janet-lang/jaylib | | raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit | | vraylib | 3.5 | [V](https://vlang.io/) | https://github.com/waotzi/vraylib | +| raylib.v | 3.7 | [V](https://vlang.io/) | https://github.com/irishgreencitrus/raylib.v | | ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod | | raylib-ocaml | 3.7 | [OCaml](https://ocaml.org/) | https://github.com/tjammer/raylib-ocaml | | raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic | From cac856119c23898579fc237703a8ff3bda207dc6 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 26 Aug 2021 16:31:01 +0100 Subject: [PATCH 16/31] Change GetColor to take unsigned int (#1954) --- parser/raylib_api.txt | 2 +- projects/Notepad++/raylib_npp_parser/raylib_to_parse.h | 2 +- src/extras/raygui.h | 4 ++-- src/raylib.h | 2 +- src/textures.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/parser/raylib_api.txt b/parser/raylib_api.txt index 07e1614c8..c90fc40d9 100644 --- a/parser/raylib_api.txt +++ b/parser/raylib_api.txt @@ -2505,7 +2505,7 @@ Function 308: GetColor() (1 input parameters) Name: GetColor Return type: Color Description: Get Color structure from hexadecimal value - Param[1]: hexValue (type: int) + Param[1]: hexValue (type: unsigned int) Function 309: GetPixelColor() (2 input parameters) Name: GetPixelColor Return type: Color diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h index f7f252975..1281fa693 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h @@ -389,7 +389,7 @@ RLAPI Vector3 ColorToHSV(Color color); // R RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Returns a Color from HSV values RLAPI Color ColorAlpha(Color color, float alpha); // Returns color with alpha applied, alpha goes from 0.0f to 1.0f RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Returns src alpha-blended into dst color with tint -RLAPI Color GetColor(int hexValue); // Get Color structure from hexadecimal value +RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format diff --git a/src/extras/raygui.h b/src/extras/raygui.h index bb1919004..31b7ca774 100644 --- a/src/extras/raygui.h +++ b/src/extras/raygui.h @@ -1154,7 +1154,7 @@ static const char *GetDirectoryPath(const char *filePath); // -- GuiLoadStyle() // raylib functions already implemented in raygui //------------------------------------------------------------------------------- -static Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value +static Color GetColor(unsigned int hexValue); // Returns a Color struct from hexadecimal value static int ColorToInt(Color color); // Returns hexadecimal value for a Color static Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f static bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle @@ -4061,7 +4061,7 @@ static Vector3 ConvertHSVtoRGB(Vector3 hsv) #if defined(RAYGUI_STANDALONE) // Returns a Color struct from hexadecimal value -static Color GetColor(int hexValue) +static Color GetColor(unsigned int hexValue) { Color color; diff --git a/src/raylib.h b/src/raylib.h index 7613dd94c..fb0be1783 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1297,7 +1297,7 @@ RLAPI Vector3 ColorToHSV(Color color); // G RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1] RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint -RLAPI Color GetColor(int hexValue); // Get Color structure from hexadecimal value +RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format diff --git a/src/textures.c b/src/textures.c index f8b693d60..ff55eedf7 100644 --- a/src/textures.c +++ b/src/textures.c @@ -3711,7 +3711,7 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint) } // Get a Color struct from hexadecimal value -Color GetColor(int hexValue) +Color GetColor(unsigned int hexValue) { Color color; From b7ae0df3d99e750922183ff7f06227981822e6b4 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 27 Aug 2021 12:13:44 +0200 Subject: [PATCH 17/31] REVIEWED: Decouple `DrawMesh()` and `DrawMeshInstanced()` #1958 --- src/models.c | 301 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 226 insertions(+), 75 deletions(-) diff --git a/src/models.c b/src/models.c index bd200d5f7..411538d1d 100644 --- a/src/models.c +++ b/src/models.c @@ -972,12 +972,6 @@ void UpdateMeshBuffer(Mesh mesh, int index, void *data, int dataSize, int offset // Draw a 3d mesh with material and transform void DrawMesh(Mesh mesh, Material material, Matrix transform) -{ - DrawMeshInstanced(mesh, material, &transform, 1); -} - -// Draw multiple mesh instances with material and different transforms -void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int instances) { #if defined(GRAPHICS_API_OPENGL_11) #define GL_VERTEX_ARRAY 0x8074 @@ -993,7 +987,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins rlEnableStatePointer(GL_COLOR_ARRAY, mesh.colors); rlPushMatrix(); - rlMultMatrixf(MatrixToFloat(transforms[0])); + rlMultMatrixf(MatrixToFloat(transform)); rlColor4ub(material.maps[MATERIAL_MAP_DIFFUSE].color.r, material.maps[MATERIAL_MAP_DIFFUSE].color.g, material.maps[MATERIAL_MAP_DIFFUSE].color.b, @@ -1012,13 +1006,6 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins #endif #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - // Check instancing - bool instancing = false; - if (instances < 1) return; - else if (instances > 1) instancing = true; - float16 *instanceTransforms = NULL; - unsigned int instancesVboId = 0; - // Bind shader program rlEnableShader(material.shader.id); @@ -1064,51 +1051,16 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins if (material.shader.locs[SHADER_LOC_MATRIX_VIEW] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_VIEW], matView); if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection); - if (instancing) - { - // Create instances buffer - instanceTransforms = (float16 *)RL_MALLOC(instances*sizeof(float16)); + // Model transformation matrix is send to shader uniform location: SHADER_LOC_MATRIX_MODEL + if (material.shader.locs[SHADER_LOC_MATRIX_MODEL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MODEL], transform); - // Fill buffer with instances transformations as float16 arrays - for (int i = 0; i < instances; i++) instanceTransforms[i] = MatrixToFloatV(transforms[i]); + // Accumulate several model transformations: + // transform: model transformation provided (includes DrawModel() params combined with model.transform) + // rlGetMatrixTransform(): rlgl internal transform matrix due to push/pop matrix stack + matModel = MatrixMultiply(transform, rlGetMatrixTransform()); - // Enable mesh VAO to attach new buffer - rlEnableVertexArray(mesh.vaoId); - - // This could alternatively use a static VBO and either glMapBuffer() or glBufferSubData(). - // It isn't clear which would be reliably faster in all cases and on all platforms, - // anecdotally glMapBuffer() seems very slow (syncs) while glBufferSubData() seems - // no faster, since we're transferring all the transform matrices anyway - instancesVboId = rlLoadVertexBuffer(instanceTransforms, instances*sizeof(float16), false); - - // Instances transformation matrices are send to shader attribute location: SHADER_LOC_MATRIX_MODEL - for (unsigned int i = 0; i < 4; i++) - { - rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i); - rlSetVertexAttribute(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i, 4, RL_FLOAT, 0, sizeof(Matrix), (void *)(i*sizeof(Vector4))); - rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i, 1); - } - - rlDisableVertexBuffer(); - rlDisableVertexArray(); - - // Accumulate internal matrix transform (push/pop) and view matrix - // NOTE: In this case, model instance transformation must be computed in the shader - matModelView = MatrixMultiply(rlGetMatrixTransform(), matView); - } - else - { - // Model transformation matrix is send to shader uniform location: SHADER_LOC_MATRIX_MODEL - if (material.shader.locs[SHADER_LOC_MATRIX_MODEL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MODEL], transforms[0]); - - // Accumulate several model transformations: - // transforms[0]: model transformation provided (includes DrawModel() params combined with model.transform) - // rlGetMatrixTransform(): rlgl internal transform matrix due to push/pop matrix stack - matModel = MatrixMultiply(transforms[0], rlGetMatrixTransform()); - - // Get model-view matrix - matModelView = MatrixMultiply(matModel, matView); - } + // Get model-view matrix + matModelView = MatrixMultiply(matModel, matView); // Upload model normal matrix (if locations available) if (material.shader.locs[SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModel))); @@ -1210,16 +1162,9 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins // Send combined model-view-projection matrix to shader rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MVP], matModelViewProjection); - if (instancing) // Draw mesh instanced - { - if (mesh.indices != NULL) rlDrawVertexArrayElementsInstanced(0, mesh.triangleCount*3, 0, instances); - else rlDrawVertexArrayInstanced(0, mesh.vertexCount, instances); - } - else // Draw mesh - { - if (mesh.indices != NULL) rlDrawVertexArrayElements(0, mesh.triangleCount*3, 0); - else rlDrawVertexArray(0, mesh.vertexCount); - } + // Draw mesh + if (mesh.indices != NULL) rlDrawVertexArrayElements(0, mesh.triangleCount*3, 0); + else rlDrawVertexArray(0, mesh.vertexCount); } // Unbind all binded texture maps @@ -1243,18 +1188,224 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins // Disable shader program rlDisableShader(); - if (instancing) + // Restore rlgl internal modelview and projection matrices + rlSetMatrixModelview(matView); + rlSetMatrixProjection(matProjection); +#endif +} + +// Draw multiple mesh instances with material and different transforms +void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int instances) +{ +#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) + // Instancing required variables + float16 *instanceTransforms = NULL; + unsigned int instancesVboId = 0; + + // Bind shader program + rlEnableShader(material.shader.id); + + // Send required data to shader (matrices, values) + //----------------------------------------------------- + // Upload to shader material.colDiffuse + if (material.shader.locs[SHADER_LOC_COLOR_DIFFUSE] != -1) { - // Remove instance transforms buffer - rlUnloadVertexBuffer(instancesVboId); - RL_FREE(instanceTransforms); + float values[4] = { + (float)material.maps[MATERIAL_MAP_DIFFUSE].color.r/255.0f, + (float)material.maps[MATERIAL_MAP_DIFFUSE].color.g/255.0f, + (float)material.maps[MATERIAL_MAP_DIFFUSE].color.b/255.0f, + (float)material.maps[MATERIAL_MAP_DIFFUSE].color.a/255.0f + }; + + rlSetUniform(material.shader.locs[SHADER_LOC_COLOR_DIFFUSE], values, SHADER_UNIFORM_VEC4, 1); } - else + + // Upload to shader material.colSpecular (if location available) + if (material.shader.locs[SHADER_LOC_COLOR_SPECULAR] != -1) { - // Restore rlgl internal modelview and projection matrices - rlSetMatrixModelview(matView); - rlSetMatrixProjection(matProjection); + float values[4] = { + (float)material.maps[SHADER_LOC_COLOR_SPECULAR].color.r/255.0f, + (float)material.maps[SHADER_LOC_COLOR_SPECULAR].color.g/255.0f, + (float)material.maps[SHADER_LOC_COLOR_SPECULAR].color.b/255.0f, + (float)material.maps[SHADER_LOC_COLOR_SPECULAR].color.a/255.0f + }; + + rlSetUniform(material.shader.locs[SHADER_LOC_COLOR_SPECULAR], values, SHADER_UNIFORM_VEC4, 1); } + + // Get a copy of current matrices to work with, + // just in case stereo render is required and we need to modify them + // NOTE: At this point the modelview matrix just contains the view matrix (camera) + // That's because BeginMode3D() sets it and there is no model-drawing function + // that modifies it, all use rlPushMatrix() and rlPopMatrix() + Matrix matModel = MatrixIdentity(); + Matrix matView = rlGetMatrixModelview(); + Matrix matModelView = MatrixIdentity(); + Matrix matProjection = rlGetMatrixProjection(); + + // Upload view and projection matrices (if locations available) + if (material.shader.locs[SHADER_LOC_MATRIX_VIEW] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_VIEW], matView); + if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection); + + // Create instances buffer + instanceTransforms = (float16 *)RL_MALLOC(instances*sizeof(float16)); + + // Fill buffer with instances transformations as float16 arrays + for (int i = 0; i < instances; i++) instanceTransforms[i] = MatrixToFloatV(transforms[i]); + + // Enable mesh VAO to attach new buffer + rlEnableVertexArray(mesh.vaoId); + + // This could alternatively use a static VBO and either glMapBuffer() or glBufferSubData(). + // It isn't clear which would be reliably faster in all cases and on all platforms, + // anecdotally glMapBuffer() seems very slow (syncs) while glBufferSubData() seems + // no faster, since we're transferring all the transform matrices anyway + instancesVboId = rlLoadVertexBuffer(instanceTransforms, instances*sizeof(float16), false); + + // Instances transformation matrices are send to shader attribute location: SHADER_LOC_MATRIX_MODEL + for (unsigned int i = 0; i < 4; i++) + { + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i, 4, RL_FLOAT, 0, sizeof(Matrix), (void *)(i*sizeof(Vector4))); + rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i, 1); + } + + rlDisableVertexBuffer(); + rlDisableVertexArray(); + + // Accumulate internal matrix transform (push/pop) and view matrix + // NOTE: In this case, model instance transformation must be computed in the shader + matModelView = MatrixMultiply(rlGetMatrixTransform(), matView); + + // Upload model normal matrix (if locations available) + if (material.shader.locs[SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModel))); + //----------------------------------------------------- + + // Bind active texture maps (if available) + for (int i = 0; i < MAX_MATERIAL_MAPS; i++) + { + if (material.maps[i].texture.id > 0) + { + // Select current shader texture slot + rlActiveTextureSlot(i); + + // Enable texture for active slot + if ((i == MATERIAL_MAP_IRRADIANCE) || + (i == MATERIAL_MAP_PREFILTER) || + (i == MATERIAL_MAP_CUBEMAP)) rlEnableTextureCubemap(material.maps[i].texture.id); + else rlEnableTexture(material.maps[i].texture.id); + + rlSetUniform(material.shader.locs[SHADER_LOC_MAP_DIFFUSE + i], &i, SHADER_UNIFORM_INT, 1); + } + } + + // Try binding vertex array objects (VAO) + // or use VBOs if not possible + if (!rlEnableVertexArray(mesh.vaoId)) + { + // Bind mesh VBO data: vertex position (shader-location = 0) + rlEnableVertexBuffer(mesh.vboId[0]); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_POSITION], 3, RL_FLOAT, 0, 0, 0); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_POSITION]); + + // Bind mesh VBO data: vertex texcoords (shader-location = 1) + rlEnableVertexBuffer(mesh.vboId[1]); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD01], 2, RL_FLOAT, 0, 0, 0); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD01]); + + if (material.shader.locs[SHADER_LOC_VERTEX_NORMAL] != -1) + { + // Bind mesh VBO data: vertex normals (shader-location = 2) + rlEnableVertexBuffer(mesh.vboId[2]); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_NORMAL], 3, RL_FLOAT, 0, 0, 0); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_NORMAL]); + } + + // Bind mesh VBO data: vertex colors (shader-location = 3, if available) + if (material.shader.locs[SHADER_LOC_VERTEX_COLOR] != -1) + { + if (mesh.vboId[3] != 0) + { + rlEnableVertexBuffer(mesh.vboId[3]); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR], 4, RL_UNSIGNED_BYTE, 1, 0, 0); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]); + } + else + { + // Set default value for unused attribute + // NOTE: Required when using default shader and no VAO support + float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; + rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC2, 4); + rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]); + } + } + + // Bind mesh VBO data: vertex tangents (shader-location = 4, if available) + if (material.shader.locs[SHADER_LOC_VERTEX_TANGENT] != -1) + { + rlEnableVertexBuffer(mesh.vboId[4]); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TANGENT], 4, RL_FLOAT, 0, 0, 0); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TANGENT]); + } + + // Bind mesh VBO data: vertex texcoords2 (shader-location = 5, if available) + if (material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02] != -1) + { + rlEnableVertexBuffer(mesh.vboId[5]); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02], 2, RL_FLOAT, 0, 0, 0); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]); + } + + if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]); + } + + int eyesCount = 1; + if (rlIsStereoRenderEnabled()) eyesCount = 2; + + for (int eye = 0; eye < eyesCount; eye++) + { + // Calculate model-view-projection matrix (MVP) + Matrix matModelViewProjection = MatrixIdentity(); + if (eyesCount == 1) matModelViewProjection = MatrixMultiply(matModelView, matProjection); + else + { + // Setup current eye viewport (half screen width) + rlViewport(eye*rlGetFramebufferWidth()/2, 0, rlGetFramebufferWidth()/2, rlGetFramebufferHeight()); + matModelViewProjection = MatrixMultiply(MatrixMultiply(matModelView, rlGetMatrixViewOffsetStereo(eye)), rlGetMatrixProjectionStereo(eye)); + } + + // Send combined model-view-projection matrix to shader + rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MVP], matModelViewProjection); + + // Draw mesh instanced + if (mesh.indices != NULL) rlDrawVertexArrayElementsInstanced(0, mesh.triangleCount*3, 0, instances); + else rlDrawVertexArrayInstanced(0, mesh.vertexCount, instances); + } + + // Unbind all binded texture maps + for (int i = 0; i < MAX_MATERIAL_MAPS; i++) + { + // Select current shader texture slot + rlActiveTextureSlot(i); + + // Disable texture for active slot + if ((i == MATERIAL_MAP_IRRADIANCE) || + (i == MATERIAL_MAP_PREFILTER) || + (i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap(); + else rlDisableTexture(); + } + + // Disable all possible vertex array objects (or VBOs) + rlDisableVertexArray(); + rlDisableVertexBuffer(); + rlDisableVertexBufferElement(); + + // Disable shader program + rlDisableShader(); + + // Remove instance transforms buffer + rlUnloadVertexBuffer(instancesVboId); + RL_FREE(instanceTransforms); #endif } From 18af18479f1b2b08c0c7c0d2ed2662cb60bcb793 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 27 Aug 2021 18:49:03 +0200 Subject: [PATCH 18/31] REVIEWED: ExportWaveAsCode() --- src/raudio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/raudio.c b/src/raudio.c index f48888a98..706efedd0 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -967,12 +967,13 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) bytesCount += sprintf(txtData + bytesCount, "// Wave data information\n"); bytesCount += sprintf(txtData + bytesCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount); - bytesCount += sprintf(txtData + bytesCount, "#define %s_SAMPLE_COUNT %u\n", varFileName, wave.frameCount*wave.channels); + bytesCount += sprintf(txtData + bytesCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount); bytesCount += sprintf(txtData + bytesCount, "#define %s_SAMPLE_RATE %u\n", varFileName, wave.sampleRate); bytesCount += sprintf(txtData + bytesCount, "#define %s_SAMPLE_SIZE %u\n", varFileName, wave.sampleSize); bytesCount += sprintf(txtData + bytesCount, "#define %s_CHANNELS %u\n\n", varFileName, wave.channels); // Write byte data as hexadecimal text + // NOTE: Frame data exported is interlaced: Frame01[Sample-Channel01, Sample-Channel02, ...], Frame02[], Frame03[] bytesCount += sprintf(txtData + bytesCount, "static unsigned char %s_DATA[%i] = { ", varFileName, waveDataSize); for (int i = 0; i < waveDataSize - 1; i++) bytesCount += sprintf(txtData + bytesCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]); bytesCount += sprintf(txtData + bytesCount, "0x%x };\n", ((unsigned char *)wave.data)[waveDataSize - 1]); From 936199d8de3fecf3ff57bab4d5e35ed9c5ffa54b Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 27 Aug 2021 18:50:02 +0200 Subject: [PATCH 19/31] Review dates --- src/raudio.c | 2 +- src/textures.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index 706efedd0..771fa50db 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -952,7 +952,7 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) bytesCount += sprintf(txtData + bytesCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); bytesCount += sprintf(txtData + bytesCount, "// feedback and support: ray[at]raylib.com //\n"); bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// Copyright (c) 2018 Ramon Santamaria (@raysan5) //\n"); + bytesCount += sprintf(txtData + bytesCount, "// Copyright (c) 2018-2021 Ramon Santamaria (@raysan5) //\n"); bytesCount += sprintf(txtData + bytesCount, "// //\n"); bytesCount += sprintf(txtData + bytesCount, "//////////////////////////////////////////////////////////////////////////////////\n\n"); diff --git a/src/textures.c b/src/textures.c index ff55eedf7..8435d2677 100644 --- a/src/textures.c +++ b/src/textures.c @@ -528,7 +528,7 @@ bool ExportImageAsCode(Image image, const char *fileName) bytesCount += sprintf(txtData + bytesCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); bytesCount += sprintf(txtData + bytesCount, "// feedback and support: ray[at]raylib.com //\n"); bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// Copyright (c) 2020 Ramon Santamaria (@raysan5) //\n"); + bytesCount += sprintf(txtData + bytesCount, "// Copyright (c) 2018-2021 Ramon Santamaria (@raysan5) //\n"); bytesCount += sprintf(txtData + bytesCount, "// //\n"); bytesCount += sprintf(txtData + bytesCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); From 66c6ec44650d56cbe0bfb5c60d84b7225fccc1e5 Mon Sep 17 00:00:00 2001 From: Hussein Sarea <54902350+Ho011@users.noreply.github.com> Date: Sat, 28 Aug 2021 10:57:13 +0300 Subject: [PATCH 20/31] Add pyraylib (#1961) --- BINDINGS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 2311406b4..163692620 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -45,9 +45,10 @@ Some people ported raylib to other languages in form of bindings or wrappers to | raylib-ruby-ffi | 2.0 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/D3nX/raylib-ruby-ffi | | raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby | | raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby | +| pyraylib | 3.7 | [Python](https://www.python.org/) | https://github.com/Ho011/pyraylib | | raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py | | raylib-python-cffi | 3.7 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi | -| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg | +| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg | | jaylib | 3.7 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ | | raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java | | raylib-j | 3.5 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/CreedVI/Raylib-J | From d98e61c6ebf2bca919e1d1a0e8da6164f888d04a Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 28 Aug 2021 12:01:16 +0200 Subject: [PATCH 21/31] Minor format tweaks --- src/models.c | 36 ++++++++++++++++++------------------ src/raudio.c | 2 +- src/textures.c | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/models.c b/src/models.c index 411538d1d..a464c9fdf 100644 --- a/src/models.c +++ b/src/models.c @@ -123,13 +123,13 @@ static ModelAnimation *LoadIQMModelAnimations(const char *fileName, int *animCou static Model LoadGLTF(const char *fileName); // Load GLTF mesh data static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount); // Load GLTF animation data static void LoadGLTFMaterial(Model *model, const char *fileName, const cgltf_data *data); -static void LoadGLTFMesh(cgltf_data *data, cgltf_mesh* mesh, Model* outModel, Matrix currentTransform, int* primitiveIndex, const char *fileName); -static void LoadGLTFNode(cgltf_data *data, cgltf_node* node, Model* outModel, Matrix currentTransform, int* primitiveIndex, const char *fileName); +static void LoadGLTFMesh(cgltf_data *data, cgltf_mesh *mesh, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName); +static void LoadGLTFNode(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName); static void InitGLTFBones(Model *model, const cgltf_data *data); static void BindGLTFPrimitiveToBones(Model *model, const cgltf_data *data, int primitiveIndex); -static void GetGLTFPrimitiveCount(cgltf_node* node, int* outCount); -static bool ReadGLTFValue(cgltf_accessor* acc, unsigned int index, void *variable); -static void *ReadGLTFValuesAs(cgltf_accessor* acc, cgltf_component_type type, bool adjustOnDownCasting); +static void GetGLTFPrimitiveCount(cgltf_node *node, int *outCount); +static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variable); +static void *ReadGLTFValuesAs(cgltf_accessor *acc, cgltf_component_type type, bool adjustOnDownCasting); #endif //---------------------------------------------------------------------------------- @@ -4891,7 +4891,7 @@ static Model LoadGLTF(const char *fileName) return model; } -static void InitGLTFBones(Model* model, const cgltf_data* data) +static void InitGLTFBones(Model *model, const cgltf_data *data) { for (unsigned int j = 0; j < data->nodes_count; j++) { @@ -4914,7 +4914,7 @@ static void InitGLTFBones(Model* model, const cgltf_data* data) } { - bool* completedBones = RL_CALLOC(model->boneCount, sizeof(bool)); + bool *completedBones = RL_CALLOC(model->boneCount, sizeof(bool)); int numberCompletedBones = 0; while (numberCompletedBones < model->boneCount) @@ -5022,7 +5022,7 @@ static void LoadGLTFMaterial(Model *model, const char *fileName, const cgltf_dat model->materials[model->materialCount - 1] = LoadMaterialDefault(); } -static void BindGLTFPrimitiveToBones(Model* model, const cgltf_data* data, int primitiveIndex) +static void BindGLTFPrimitiveToBones(Model *model, const cgltf_data *data, int primitiveIndex) { for (unsigned int nodeId = 0; nodeId < data->nodes_count; nodeId++) { @@ -5030,12 +5030,12 @@ static void BindGLTFPrimitiveToBones(Model* model, const cgltf_data* data, int p { if (model->meshes[primitiveIndex].boneIds == NULL) { - model->meshes[primitiveIndex].boneIds = RL_CALLOC(4*model->meshes[primitiveIndex].vertexCount, sizeof(int)); - model->meshes[primitiveIndex].boneWeights = RL_CALLOC(4*model->meshes[primitiveIndex].vertexCount, sizeof(float)); + model->meshes[primitiveIndex].boneIds = RL_CALLOC(model->meshes[primitiveIndex].vertexCount*4, sizeof(int)); + model->meshes[primitiveIndex].boneWeights = RL_CALLOC(model->meshes[primitiveIndex].vertexCount*4, sizeof(float)); - for (int b = 0; b < 4*model->meshes[primitiveIndex].vertexCount; b++) + for (int b = 0; b < model->meshes[primitiveIndex].vertexCount*4; b++) { - if (b % 4 == 0) + if (b%4 == 0) { model->meshes[primitiveIndex].boneIds[b] = nodeId; model->meshes[primitiveIndex].boneWeights[b] = 1.0f; @@ -5112,7 +5112,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo // Getting the max animation time to consider for animation duration for (unsigned int i = 0; i < animation->channels_count; i++) { - cgltf_animation_channel* channel = animation->channels + i; + cgltf_animation_channel *channel = animation->channels + i; int frameCounts = (int)channel->sampler->input->count; float lastFrameTime = 0.0f; @@ -5159,8 +5159,8 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo // for each single transformation type on single bone for (unsigned int channelId = 0; channelId < animation->channels_count; channelId++) { - cgltf_animation_channel* channel = animation->channels + channelId; - cgltf_animation_sampler* sampler = channel->sampler; + cgltf_animation_channel *channel = animation->channels + channelId; + cgltf_animation_sampler *sampler = channel->sampler; int boneId = (int)(channel->target_node - data->nodes); @@ -5318,7 +5318,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo return animations; } -void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix currentTransform, int* primitiveIndex, const char *fileName) +void LoadGLTFMesh(cgltf_data *data, cgltf_mesh *mesh, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName) { for (unsigned int p = 0; p < mesh->primitives_count; p++) { @@ -5443,7 +5443,7 @@ void LoadGLTFMesh(cgltf_data* data, cgltf_mesh* mesh, Model* outModel, Matrix cu } } -void LoadGLTFNode(cgltf_data* data, cgltf_node* node, Model* outModel, Matrix currentTransform, int* primitiveIndex, const char *fileName) +void LoadGLTFNode(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName) { Matrix nodeTransform = { node->matrix[0], node->matrix[4], node->matrix[8], node->matrix[12], @@ -5458,7 +5458,7 @@ void LoadGLTFNode(cgltf_data* data, cgltf_node* node, Model* outModel, Matrix cu for (unsigned int i = 0; i < node->children_count; i++) LoadGLTFNode(data, node->children[i], outModel, currentTransform, primitiveIndex, fileName); } -static void GetGLTFPrimitiveCount(cgltf_node* node, int* outCount) +static void GetGLTFPrimitiveCount(cgltf_node *node, int *outCount) { if (node->mesh != NULL) *outCount += node->mesh->primitives_count; diff --git a/src/raudio.c b/src/raudio.c index 771fa50db..78bbcd810 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -942,7 +942,7 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) // NOTE: Text data buffer size is estimated considering wave data size in bytes // and requiring 6 char bytes for every byte: "0x00, " - char *txtData = (char *)RL_CALLOC(6*waveDataSize + 2000, sizeof(char)); + char *txtData = (char *)RL_CALLOC(waveDataSize*6 + 2000, sizeof(char)); int bytesCount = 0; bytesCount += sprintf(txtData + bytesCount, "\n//////////////////////////////////////////////////////////////////////////////////\n"); diff --git a/src/textures.c b/src/textures.c index 8435d2677..92ed19fad 100644 --- a/src/textures.c +++ b/src/textures.c @@ -518,7 +518,7 @@ bool ExportImageAsCode(Image image, const char *fileName) // NOTE: Text data buffer size is estimated considering image data size in bytes // and requiring 6 char bytes for every byte: "0x00, " - char *txtData = (char *)RL_CALLOC(6*dataSize + 2000, sizeof(char)); + char *txtData = (char *)RL_CALLOC(dataSize*6 + 2000, sizeof(char)); int bytesCount = 0; bytesCount += sprintf(txtData + bytesCount, "////////////////////////////////////////////////////////////////////////////////////////\n"); From 68bcfa119243e716eaf00ffe521d0358c084b74f Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 28 Aug 2021 22:54:47 +0200 Subject: [PATCH 22/31] Minor tweak --- examples/textures/textures_image_loading.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/textures/textures_image_loading.c b/examples/textures/textures_image_loading.c index 527ed35ae..8babce693 100644 --- a/examples/textures/textures_image_loading.c +++ b/examples/textures/textures_image_loading.c @@ -26,8 +26,8 @@ int main(void) Image image = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM) Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) - UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //--------------------------------------------------------------------------------------- From e8fa7ceb79613188c495b80a332875a1afdab8cf Mon Sep 17 00:00:00 2001 From: Tristan Schulz Date: Wed, 1 Sep 2021 21:29:20 +0200 Subject: [PATCH 23/31] [models] Fixed counting loop for face amount per material (#1967) --- src/models.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/models.c b/src/models.c index a464c9fdf..b175dd94d 100644 --- a/src/models.c +++ b/src/models.c @@ -3491,6 +3491,11 @@ RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Ve //---------------------------------------------------------------------------------- #if defined(SUPPORT_FILEFORMAT_OBJ) // Load OBJ mesh data +// +// Keep the following information in mind when reading this +// - A mesh is created for every material present in the obj file +// - the model.meshCount is therefore the materialCount returned from tinyobj +// - the mesh is automatically triangulated by tinyobj static Model LoadOBJ(const char *fileName) { Model model = { 0 }; @@ -3542,15 +3547,12 @@ static Model LoadOBJ(const char *fileName) // Count the faces for each material int *matFaces = RL_CALLOC(materialCount, sizeof(int)); - for (unsigned int mi = 0; mi < meshCount; mi++) - { - for (unsigned int fi = 0; fi < meshes[mi].length; fi++) - { - int idx = attrib.material_ids[meshes[mi].face_offset + fi]; - if (idx == -1) idx = 0; // for no material face (which could be the whole model) - matFaces[idx]++; - } + for(int fi = 0; fi< attrib.num_faces; fi++){ + tinyobj_vertex_index_t face = attrib.faces[fi]; + int idx = attrib.material_ids[fi]; + matFaces[idx]++; } + //-------------------------------------- // Create the material meshes From a0f8682905fee1b65c903f1f46adff6e06ab6ae7 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Sep 2021 23:09:30 +0200 Subject: [PATCH 24/31] REVIEWED: Count for consistency Following english rules, it should be singular name before Count. --- src/core.c | 46 +++++++++++------------ src/models.c | 71 ++++++++++++++++++----------------- src/raudio.c | 50 ++++++++++++------------- src/rlgl.h | 100 ++++++++++++++++++++++++------------------------- src/shapes.c | 24 ++++++------ src/textures.c | 66 ++++++++++++++++---------------- 6 files changed, 178 insertions(+), 179 deletions(-) diff --git a/src/core.c b/src/core.c index aff8cdd35..89b9874ac 100644 --- a/src/core.c +++ b/src/core.c @@ -385,7 +385,7 @@ typedef struct CoreData { Matrix screenScale; // Matrix to scale screen (framebuffer rendering) char **dropFilesPath; // Store dropped files paths as strings - int dropFilesCount; // Count dropped files strings + int dropFileCount; // Count dropped files strings } Window; #if defined(PLATFORM_ANDROID) @@ -411,7 +411,7 @@ typedef struct CoreData { int keyPressedQueue[MAX_KEY_PRESSED_QUEUE]; // Input keys queue int keyPressedQueueCount; // Input keys queue count - int charPressedQueue[MAX_CHAR_PRESSED_QUEUE]; // Input characters queue + int charPressedQueue[MAX_CHAR_PRESSED_QUEUE]; // Input characters queue (unicode) int charPressedQueueCount; // Input characters queue count #if defined(PLATFORM_RPI) || defined(PLATFORM_DRM) @@ -481,14 +481,14 @@ typedef struct CoreData { static CoreData CORE = { 0 }; // Global CORE state context static char **dirFilesPath = NULL; // Store directory files paths as strings -static int dirFilesCount = 0; // Count directory files strings +static int dirFileCount = 0; // Count directory files strings #if defined(SUPPORT_SCREEN_CAPTURE) static int screenshotCounter = 0; // Screenshots counter #endif #if defined(SUPPORT_GIF_RECORDING) -static int gifFramesCounter = 0; // GIF frames counter +static int gifFrameCounter = 0; // GIF frames counter static bool gifRecording = false; // GIF recording state static MsfGifState gifState = { 0 }; // MSGIF context state #endif @@ -1926,10 +1926,10 @@ void EndDrawing(void) if (gifRecording) { #define GIF_RECORD_FRAMERATE 10 - gifFramesCounter++; + gifFrameCounter++; // NOTE: We record one gif frame every 10 game frames - if ((gifFramesCounter%GIF_RECORD_FRAMERATE) == 0) + if ((gifFrameCounter%GIF_RECORD_FRAMERATE) == 0) { // Get image data for the current frame (from backbuffer) // NOTE: This process is quite slow... :( @@ -1939,7 +1939,7 @@ void EndDrawing(void) RL_FREE(screenData); // Free image data } - if (((gifFramesCounter/15)%2) == 1) + if (((gifFrameCounter/15)%2) == 1) { DrawCircle(30, CORE.Window.screen.height - 20, 10, MAROON); DrawText("GIF RECORDING", 50, CORE.Window.screen.height - 25, 10, RED); @@ -1953,9 +1953,9 @@ void EndDrawing(void) // Draw record/play indicator if (eventsRecording) { - gifFramesCounter++; + gifFrameCounter++; - if (((gifFramesCounter/15)%2) == 1) + if (((gifFrameCounter/15)%2) == 1) { DrawCircle(30, CORE.Window.screen.height - 20, 10, MAROON); DrawText("EVENTS RECORDING", 50, CORE.Window.screen.height - 25, 10, RED); @@ -1965,9 +1965,9 @@ void EndDrawing(void) } else if (eventsPlaying) { - gifFramesCounter++; + gifFrameCounter++; - if (((gifFramesCounter/15)%2) == 1) + if (((gifFrameCounter/15)%2) == 1) { DrawCircle(30, CORE.Window.screen.height - 20, 10, LIME); DrawText("EVENTS PLAYING", 50, CORE.Window.screen.height - 25, 10, GREEN); @@ -2895,8 +2895,8 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount) } else TRACELOG(LOG_WARNING, "FILEIO: Failed to open requested directory"); // Maybe it's a file... - dirFilesCount = counter; - *fileCount = dirFilesCount; + dirFileCount = counter; + *fileCount = dirFileCount; return dirFilesPath; } @@ -2904,14 +2904,14 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount) // Clear directory files paths buffers void ClearDirectoryFiles(void) { - if (dirFilesCount > 0) + if (dirFileCount > 0) { for (int i = 0; i < MAX_DIRECTORY_FILES; i++) RL_FREE(dirFilesPath[i]); RL_FREE(dirFilesPath); } - dirFilesCount = 0; + dirFileCount = 0; } // Change working directory, returns true on success @@ -2927,27 +2927,27 @@ bool ChangeDirectory(const char *dir) // Check if a file has been dropped into window bool IsFileDropped(void) { - if (CORE.Window.dropFilesCount > 0) return true; + if (CORE.Window.dropFileCount > 0) return true; else return false; } // Get dropped files names char **GetDroppedFiles(int *count) { - *count = CORE.Window.dropFilesCount; + *count = CORE.Window.dropFileCount; return CORE.Window.dropFilesPath; } // Clear dropped files paths buffer void ClearDroppedFiles(void) { - if (CORE.Window.dropFilesCount > 0) + if (CORE.Window.dropFileCount > 0) { - for (int i = 0; i < CORE.Window.dropFilesCount; i++) RL_FREE(CORE.Window.dropFilesPath[i]); + for (int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilesPath[i]); RL_FREE(CORE.Window.dropFilesPath); - CORE.Window.dropFilesCount = 0; + CORE.Window.dropFileCount = 0; } } @@ -4922,7 +4922,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i else { gifRecording = true; - gifFramesCounter = 0; + gifFrameCounter = 0; msf_gif_begin(&gifState, CORE.Window.screen.width, CORE.Window.screen.height); screenshotCounter++; @@ -5085,7 +5085,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths strcpy(CORE.Window.dropFilesPath[i], paths[i]); } - CORE.Window.dropFilesCount = count; + CORE.Window.dropFileCount = count; } #endif @@ -5145,7 +5145,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd) /* if (assetsReloadRequired) { - for (int i = 0; i < assetsCount; i++) + for (int i = 0; i < assetCount; i++) { // TODO: Unload old asset if required diff --git a/src/models.c b/src/models.c index b175dd94d..b233cf2af 100644 --- a/src/models.c +++ b/src/models.c @@ -201,16 +201,16 @@ void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color) } // Draw a triangle strip defined by points -void DrawTriangleStrip3D(Vector3 *points, int pointsCount, Color color) +void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color) { - if (pointsCount >= 3) + if (pointCount >= 3) { - rlCheckRenderBatchLimit(3*(pointsCount - 2)); + rlCheckRenderBatchLimit(3*(pointCount - 2)); rlBegin(RL_TRIANGLES); rlColor4ub(color.r, color.g, color.b, color.a); - for (int i = 2; i < pointsCount; i++) + for (int i = 2; i < pointCount; i++) { if ((i%2) == 0) { @@ -1144,14 +1144,14 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform) if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]); } - int eyesCount = 1; - if (rlIsStereoRenderEnabled()) eyesCount = 2; + int eyeCount = 1; + if (rlIsStereoRenderEnabled()) eyeCount = 2; - for (int eye = 0; eye < eyesCount; eye++) + for (int eye = 0; eye < eyeCount; eye++) { // Calculate model-view-projection matrix (MVP) Matrix matModelViewProjection = MatrixIdentity(); - if (eyesCount == 1) matModelViewProjection = MatrixMultiply(matModelView, matProjection); + if (eyeCount == 1) matModelViewProjection = MatrixMultiply(matModelView, matProjection); else { // Setup current eye viewport (half screen width) @@ -1359,14 +1359,14 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]); } - int eyesCount = 1; - if (rlIsStereoRenderEnabled()) eyesCount = 2; + int eyeCount = 1; + if (rlIsStereoRenderEnabled()) eyeCount = 2; - for (int eye = 0; eye < eyesCount; eye++) + for (int eye = 0; eye < eyeCount; eye++) { // Calculate model-view-projection matrix (MVP) Matrix matModelViewProjection = MatrixIdentity(); - if (eyesCount == 1) matModelViewProjection = MatrixMultiply(matModelView, matProjection); + if (eyeCount == 1) matModelViewProjection = MatrixMultiply(matModelView, matProjection); else { // Setup current eye viewport (half screen width) @@ -1448,43 +1448,43 @@ bool ExportMesh(Mesh mesh, const char *fileName) // NOTE: Text data buffer size is estimated considering mesh data size char *txtData = (char *)RL_CALLOC(dataSize + 2000, sizeof(char)); - int bytesCount = 0; - bytesCount += sprintf(txtData + bytesCount, "# //////////////////////////////////////////////////////////////////////////////////\n"); - bytesCount += sprintf(txtData + bytesCount, "# // //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // rMeshOBJ exporter v1.0 - Mesh exported as triangle faces and not optimized //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // more info and bugs-report: github.com/raysan5/raylib //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // feedback and support: ray[at]raylib.com //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // Copyright (c) 2018 Ramon Santamaria (@raysan5) //\n"); - bytesCount += sprintf(txtData + bytesCount, "# // //\n"); - bytesCount += sprintf(txtData + bytesCount, "# //////////////////////////////////////////////////////////////////////////////////\n\n"); - bytesCount += sprintf(txtData + bytesCount, "# Vertex Count: %i\n", mesh.vertexCount); - bytesCount += sprintf(txtData + bytesCount, "# Triangle Count: %i\n\n", mesh.triangleCount); + int byteCount = 0; + byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n"); + byteCount += sprintf(txtData + byteCount, "# // //\n"); + byteCount += sprintf(txtData + byteCount, "# // rMeshOBJ exporter v1.0 - Mesh exported as triangle faces and not optimized //\n"); + byteCount += sprintf(txtData + byteCount, "# // //\n"); + byteCount += sprintf(txtData + byteCount, "# // more info and bugs-report: github.com/raysan5/raylib //\n"); + byteCount += sprintf(txtData + byteCount, "# // feedback and support: ray[at]raylib.com //\n"); + byteCount += sprintf(txtData + byteCount, "# // //\n"); + byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "# // //\n"); + byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n\n"); + byteCount += sprintf(txtData + byteCount, "# Vertex Count: %i\n", mesh.vertexCount); + byteCount += sprintf(txtData + byteCount, "# Triangle Count: %i\n\n", mesh.triangleCount); - bytesCount += sprintf(txtData + bytesCount, "g mesh\n"); + byteCount += sprintf(txtData + byteCount, "g mesh\n"); for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3) { - bytesCount += sprintf(txtData + bytesCount, "v %.2f %.2f %.2f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]); + byteCount += sprintf(txtData + byteCount, "v %.2f %.2f %.2f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]); } for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 2) { - bytesCount += sprintf(txtData + bytesCount, "vt %.3f %.3f\n", mesh.texcoords[v], mesh.texcoords[v + 1]); + byteCount += sprintf(txtData + byteCount, "vt %.3f %.3f\n", mesh.texcoords[v], mesh.texcoords[v + 1]); } for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3) { - bytesCount += sprintf(txtData + bytesCount, "vn %.3f %.3f %.3f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]); + byteCount += sprintf(txtData + byteCount, "vn %.3f %.3f %.3f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]); } for (int i = 0; i < mesh.triangleCount; i += 3) { - bytesCount += sprintf(txtData + bytesCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", i, i, i, i + 1, i + 1, i + 1, i + 2, i + 2, i + 2); + byteCount += sprintf(txtData + byteCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", i, i, i, i + 1, i + 1, i + 1, i + 2, i + 2, i + 2); } - bytesCount += sprintf(txtData + bytesCount, "\n"); + byteCount += sprintf(txtData + byteCount, "\n"); // NOTE: Text data length exported is determined by '\0' (NULL) character success = SaveFileText(fileName, txtData); @@ -3547,7 +3547,8 @@ static Model LoadOBJ(const char *fileName) // Count the faces for each material int *matFaces = RL_CALLOC(materialCount, sizeof(int)); - for(int fi = 0; fi< attrib.num_faces; fi++){ + for (int fi = 0; fi< attrib.num_faces; fi++) + { tinyobj_vertex_index_t face = attrib.faces[fi]; int idx = attrib.material_ids[fi]; matFaces[idx]++; @@ -4858,14 +4859,14 @@ static Model LoadGLTF(const char *fileName) if (data->scenes_count > 1) TRACELOG(LOG_INFO, "MODEL: [%s] Has multiple scenes but only the first one will be loaded", fileName); - int primitivesCount = 0; + int primitiveCount = 0; for (unsigned int i = 0; i < data->scene->nodes_count; i++) { - GetGLTFPrimitiveCount(data->scene->nodes[i], &primitivesCount); + GetGLTFPrimitiveCount(data->scene->nodes[i], &primitiveCount); } // Process glTF data and map to model - model.meshCount = primitivesCount; + model.meshCount = primitiveCount; model.meshes = RL_CALLOC(model.meshCount, sizeof(Mesh)); model.materialCount = (int)data->materials_count + 1; model.materials = RL_MALLOC(model.materialCount*sizeof(Material)); diff --git a/src/raudio.c b/src/raudio.c index 78bbcd810..5ed3de7c2 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -877,14 +877,14 @@ void UnloadSound(Sound sound) } // Update sound buffer with new data -void UpdateSound(Sound sound, const void *data, int samplesCount) +void UpdateSound(Sound sound, const void *data, int sampleCount) { if (sound.stream.buffer != NULL) { StopAudioBuffer(sound.stream.buffer); // TODO: May want to lock/unlock this since this data buffer is read at mixing time - memcpy(sound.stream.buffer->data, data, samplesCount*ma_get_bytes_per_frame(sound.stream.buffer->converter.config.formatIn, sound.stream.buffer->converter.config.channelsIn)); + memcpy(sound.stream.buffer->data, data, sampleCount*ma_get_bytes_per_frame(sound.stream.buffer->converter.config.formatIn, sound.stream.buffer->converter.config.channelsIn)); } } @@ -944,17 +944,17 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) // and requiring 6 char bytes for every byte: "0x00, " char *txtData = (char *)RL_CALLOC(waveDataSize*6 + 2000, sizeof(char)); - int bytesCount = 0; - bytesCount += sprintf(txtData + bytesCount, "\n//////////////////////////////////////////////////////////////////////////////////\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// WaveAsCode exporter v1.0 - Wave data exported as an array of bytes //\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); - bytesCount += sprintf(txtData + bytesCount, "// feedback and support: ray[at]raylib.com //\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// Copyright (c) 2018-2021 Ramon Santamaria (@raysan5) //\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "//////////////////////////////////////////////////////////////////////////////////\n\n"); + int byteCount = 0; + byteCount += sprintf(txtData + byteCount, "\n//////////////////////////////////////////////////////////////////////////////////\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// WaveAsCode exporter v1.0 - Wave data exported as an array of bytes //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); + byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2021 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "//////////////////////////////////////////////////////////////////////////////////\n\n"); char varFileName[256] = { 0 }; #if !defined(RAUDIO_STANDALONE) @@ -965,18 +965,18 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) strcpy(varFileName, fileName); #endif - bytesCount += sprintf(txtData + bytesCount, "// Wave data information\n"); - bytesCount += sprintf(txtData + bytesCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount); - bytesCount += sprintf(txtData + bytesCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount); - bytesCount += sprintf(txtData + bytesCount, "#define %s_SAMPLE_RATE %u\n", varFileName, wave.sampleRate); - bytesCount += sprintf(txtData + bytesCount, "#define %s_SAMPLE_SIZE %u\n", varFileName, wave.sampleSize); - bytesCount += sprintf(txtData + bytesCount, "#define %s_CHANNELS %u\n\n", varFileName, wave.channels); + byteCount += sprintf(txtData + byteCount, "// Wave data information\n"); + byteCount += sprintf(txtData + byteCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount); + byteCount += sprintf(txtData + byteCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount); + byteCount += sprintf(txtData + byteCount, "#define %s_SAMPLE_RATE %u\n", varFileName, wave.sampleRate); + byteCount += sprintf(txtData + byteCount, "#define %s_SAMPLE_SIZE %u\n", varFileName, wave.sampleSize); + byteCount += sprintf(txtData + byteCount, "#define %s_CHANNELS %u\n\n", varFileName, wave.channels); // Write byte data as hexadecimal text // NOTE: Frame data exported is interlaced: Frame01[Sample-Channel01, Sample-Channel02, ...], Frame02[], Frame03[] - bytesCount += sprintf(txtData + bytesCount, "static unsigned char %s_DATA[%i] = { ", varFileName, waveDataSize); - for (int i = 0; i < waveDataSize - 1; i++) bytesCount += sprintf(txtData + bytesCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]); - bytesCount += sprintf(txtData + bytesCount, "0x%x };\n", ((unsigned char *)wave.data)[waveDataSize - 1]); + byteCount += sprintf(txtData + byteCount, "static unsigned char %s_DATA[%i] = { ", varFileName, waveDataSize); + for (int i = 0; i < waveDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)wave.data)[i]); + byteCount += sprintf(txtData + byteCount, "0x%x };\n", ((unsigned char *)wave.data)[waveDataSize - 1]); // NOTE: Text data length exported is determined by '\0' (NULL) character success = SaveFileText(fileName, txtData); @@ -1505,9 +1505,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char *data, int d // Copy data to allocated memory for default UnloadMusicStream unsigned char *newData = (unsigned char *)RL_MALLOC(dataSize); int it = dataSize/sizeof(unsigned char); - for (int i = 0; i < it; i++){ - newData[i] = data[i]; - } + for (int i = 0; i < it; i++) newData[i] = data[i]; // Memory loaded version for jar_mod_load_file() if (dataSize && dataSize < 32*1024*1024) @@ -1716,7 +1714,7 @@ void UpdateMusicStream(Music music) #if defined(SUPPORT_FILEFORMAT_XM) case MUSIC_MODULE_XM: { - // NOTE: Internally we consider 2 channels generation, so samplesCount/2 + // NOTE: Internally we consider 2 channels generation, so sampleCount/2 if (AUDIO_DEVICE_FORMAT == ma_format_f32) jar_xm_generate_samples((jar_xm_context_t *)music.ctxData, (float *)pcm, frameCountToStream); else if (AUDIO_DEVICE_FORMAT == ma_format_s16) jar_xm_generate_samples_16bit((jar_xm_context_t *)music.ctxData, (short *)pcm, frameCountToStream); else if (AUDIO_DEVICE_FORMAT == ma_format_u8) jar_xm_generate_samples_8bit((jar_xm_context_t *)music.ctxData, (char *)pcm, frameCountToStream); diff --git a/src/rlgl.h b/src/rlgl.h index ce99c40e4..ea46c537e 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -279,7 +279,7 @@ typedef enum { // Dynamic vertex buffers (position + texcoords + colors + indices arrays) typedef struct rlVertexBuffer { - int elementsCount; // Number of elements in the buffer (QUADS) + int elementCount; // Number of elements in the buffer (QUADS) int vCounter; // Vertex position counter to process (and draw) from full buffer int tcCounter; // Vertex texcoord counter to process (and draw) from full buffer @@ -316,12 +316,12 @@ typedef struct rlDrawCall { // rlRenderBatch type typedef struct rlRenderBatch { - int buffersCount; // Number of vertex buffers (multi-buffering support) + int bufferCount; // Number of vertex buffers (multi-buffering support) int currentBuffer; // Current buffer tracking in case of multi-buffering rlVertexBuffer *vertexBuffer; // Dynamic buffer(s) for vertex data rlDrawCall *draws; // Draw calls array, depends on textureId - int drawsCounter; // Draw calls counter + int drawCounterer; // Draw calls counter float currentDepth; // Current depth value for next draw } rlRenderBatch; @@ -1210,34 +1210,34 @@ void rlBegin(int mode) { // Draw mode can be RL_LINES, RL_TRIANGLES and RL_QUADS // NOTE: In all three cases, vertex are accumulated over default internal vertex buffer - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode != mode) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode != mode) { - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount > 0) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount > 0) { // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4, // that way, following QUADS drawing will keep aligned with index processing // It implies adding some extra alignment vertex at the end of the draw, // those vertex are not processed but they are considered as an additional offset // for the next set of vertex to be drawn - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount%4); - else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount%4))); - else RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment = 0; + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4); + else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4))); + else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = 0; - if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment)) + if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment)) { - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; - RLGL.currentBatch->drawsCounter++; + RLGL.currentBatch->drawCounterer++; } } - if (RLGL.currentBatch->drawsCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); + if (RLGL.currentBatch->drawCounterer >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); - RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode = mode; - RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount = 0; - RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].textureId = RLGL.State.defaultTextureId; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode = mode; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount = 0; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].textureId = RLGL.State.defaultTextureId; } } @@ -1285,7 +1285,7 @@ void rlEnd(void) // Verify internal buffers limits // NOTE: This check is combined with usage of rlCheckRenderBatchLimit() if ((RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter) >= - (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementsCount*4 - 4)) + (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4)) { // WARNING: If we are between rlPushMatrix() and rlPopMatrix() and we need to force a rlDrawRenderBatch(), // we need to call rlPopMatrix() before to recover *RLGL.State.currentMatrix (RLGL.State.modelview) for the next forced draw call! @@ -1312,14 +1312,14 @@ void rlVertex3f(float x, float y, float z) } // Verify that current vertex buffer elements limit has not been reached - if (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter < (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementsCount*4)) + if (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter < (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4)) { RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter] = tx; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter + 1] = ty; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter + 2] = tz; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter++; - RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount++; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount++; } else TRACELOG(RL_LOG_ERROR, "RLGL: Batch elements overflow"); } @@ -1390,7 +1390,7 @@ void rlSetTexture(unsigned int id) #else // NOTE: If quads batch limit is reached, we force a draw call and next batch starts if (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter >= - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementsCount*4) + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4) { rlDrawRenderBatch(RLGL.currentBatch); } @@ -1401,33 +1401,33 @@ void rlSetTexture(unsigned int id) #if defined(GRAPHICS_API_OPENGL_11) rlEnableTexture(id); #else - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].textureId != id) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].textureId != id) { - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount > 0) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount > 0) { // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4, // that way, following QUADS drawing will keep aligned with index processing // It implies adding some extra alignment vertex at the end of the draw, // those vertex are not processed but they are considered as an additional offset // for the next set of vertex to be drawn - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount%4); - else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount%4))); - else RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment = 0; + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4); + else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4))); + else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = 0; - if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment)) + if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment)) { - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; - RLGL.currentBatch->drawsCounter++; + RLGL.currentBatch->drawCounterer++; } } - if (RLGL.currentBatch->drawsCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); + if (RLGL.currentBatch->drawCounterer >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); - RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].textureId = id; - RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount = 0; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].textureId = id; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount = 0; } #endif } @@ -2169,7 +2169,7 @@ rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements) for (int i = 0; i < numBuffers; i++) { - batch.vertexBuffer[i].elementsCount = bufferElements; + batch.vertexBuffer[i].elementCount = bufferElements; batch.vertexBuffer[i].vertices = (float *)RL_MALLOC(bufferElements*3*4*sizeof(float)); // 3 float by vertex, 4 vertex by quad batch.vertexBuffer[i].texcoords = (float *)RL_MALLOC(bufferElements*2*4*sizeof(float)); // 2 float by texcoord, 4 texcoord by quad @@ -2274,8 +2274,8 @@ rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements) //batch.draws[i].RLGL.State.modelview = rlMatrixIdentity(); } - batch.buffersCount = numBuffers; // Record buffer count - batch.drawsCounter = 1; // Reset draws counter + batch.bufferCount = numBuffers; // Record buffer count + batch.drawCounterer = 1; // Reset draws counter batch.currentDepth = -1.0f; // Reset depth value //-------------------------------------------------------------------------------------------- #endif @@ -2297,7 +2297,7 @@ void rlUnloadRenderBatch(rlRenderBatch batch) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // Unload all vertex buffers data - for (int i = 0; i < batch.buffersCount; i++) + for (int i = 0; i < batch.bufferCount; i++) { // Delete VBOs from GPU (VRAM) glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[0]); @@ -2338,17 +2338,17 @@ void rlDrawRenderBatch(rlRenderBatch *batch) // Vertex positions buffer glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[0]); glBufferSubData(GL_ARRAY_BUFFER, 0, batch->vertexBuffer[batch->currentBuffer].vCounter*3*sizeof(float), batch->vertexBuffer[batch->currentBuffer].vertices); - //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementsCount, batch->vertexBuffer[batch->currentBuffer].vertices, GL_DYNAMIC_DRAW); // Update all buffer + //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].vertices, GL_DYNAMIC_DRAW); // Update all buffer // Texture coordinates buffer glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[1]); glBufferSubData(GL_ARRAY_BUFFER, 0, batch->vertexBuffer[batch->currentBuffer].vCounter*2*sizeof(float), batch->vertexBuffer[batch->currentBuffer].texcoords); - //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*4*batch->vertexBuffer[batch->currentBuffer].elementsCount, batch->vertexBuffer[batch->currentBuffer].texcoords, GL_DYNAMIC_DRAW); // Update all buffer + //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].texcoords, GL_DYNAMIC_DRAW); // Update all buffer // Colors buffer glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[2]); glBufferSubData(GL_ARRAY_BUFFER, 0, batch->vertexBuffer[batch->currentBuffer].vCounter*4*sizeof(unsigned char), batch->vertexBuffer[batch->currentBuffer].colors); - //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementsCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer + //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer // NOTE: glMapBuffer() causes sync issue. // If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job. @@ -2375,12 +2375,12 @@ void rlDrawRenderBatch(rlRenderBatch *batch) Matrix matProjection = RLGL.State.projection; Matrix matModelView = RLGL.State.modelview; - int eyesCount = 1; - if (RLGL.State.stereoRender) eyesCount = 2; + int eyeCount = 1; + if (RLGL.State.stereoRender) eyeCount = 2; - for (int eye = 0; eye < eyesCount; eye++) + for (int eye = 0; eye < eyeCount; eye++) { - if (eyesCount == 2) + if (eyeCount == 2) { // Setup current eye viewport (half screen width) rlViewport(eye*RLGL.State.framebufferWidth/2, 0, RLGL.State.framebufferWidth/2, RLGL.State.framebufferHeight); @@ -2447,7 +2447,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch) // NOTE: Batch system accumulates calls by texture0 changes, additional textures are enabled for all the draw calls glActiveTexture(GL_TEXTURE0); - for (int i = 0, vertexOffset = 0; i < batch->drawsCounter; i++) + for (int i = 0, vertexOffset = 0; i < batch->drawCounterer; i++) { // Bind current draw call texture, activated as GL_TEXTURE0 and binded to sampler2D texture0 by default glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId); @@ -2456,7 +2456,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch) else { #if defined(GRAPHICS_API_OPENGL_33) - // We need to define the number of indices to be processed: quadsCount*6 + // We need to define the number of indices to be processed: elementCount*6 // NOTE: The final parameter tells the GPU the offset in bytes from the // start of the index buffer to the location of the first index to process glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(vertexOffset/4*6*sizeof(GLuint))); @@ -2510,12 +2510,12 @@ void rlDrawRenderBatch(rlRenderBatch *batch) for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0; // Reset draws counter to one draw for the batch - batch->drawsCounter = 1; + batch->drawCounterer = 1; //------------------------------------------------------------------------------------------------------------ // Change to next buffer in the list (in case of multi-buffering) batch->currentBuffer++; - if (batch->currentBuffer >= batch->buffersCount) batch->currentBuffer = 0; + if (batch->currentBuffer >= batch->bufferCount) batch->currentBuffer = 0; #endif } @@ -2546,7 +2546,7 @@ bool rlCheckRenderBatchLimit(int vCount) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) if ((RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter + vCount) >= - (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementsCount*4)) + (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4)) { overflow = true; rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside diff --git a/src/shapes.c b/src/shapes.c index 104aef0a7..86e7c97a2 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -190,16 +190,16 @@ void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, fl } // Draw lines sequence -void DrawLineStrip(Vector2 *points, int pointsCount, Color color) +void DrawLineStrip(Vector2 *points, int pointCount, Color color) { - if (pointsCount >= 2) + if (pointCount >= 2) { - rlCheckRenderBatchLimit(pointsCount); + rlCheckRenderBatchLimit(pointCount); rlBegin(RL_LINES); rlColor4ub(color.r, color.g, color.b, color.a); - for (int i = 0; i < pointsCount - 1; i++) + for (int i = 0; i < pointCount - 1; i++) { rlVertex2f(points[i].x, points[i].y); rlVertex2f(points[i + 1].x, points[i + 1].y); @@ -1318,17 +1318,17 @@ void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color) // Draw a triangle fan defined by points // NOTE: First vertex provided is the center, shared by all triangles // By default, following vertex should be provided in counter-clockwise order -void DrawTriangleFan(Vector2 *points, int pointsCount, Color color) +void DrawTriangleFan(Vector2 *points, int pointCount, Color color) { - if (pointsCount >= 3) + if (pointCount >= 3) { - rlCheckRenderBatchLimit((pointsCount - 2)*4); + rlCheckRenderBatchLimit((pointCount - 2)*4); rlSetTexture(texShapes.id); rlBegin(RL_QUADS); rlColor4ub(color.r, color.g, color.b, color.a); - for (int i = 1; i < pointsCount - 1; i++) + for (int i = 1; i < pointCount - 1; i++) { rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height); rlVertex2f(points[0].x, points[0].y); @@ -1349,16 +1349,16 @@ void DrawTriangleFan(Vector2 *points, int pointsCount, Color color) // Draw a triangle strip defined by points // NOTE: Every new vertex connects with previous two -void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color) +void DrawTriangleStrip(Vector2 *points, int pointCount, Color color) { - if (pointsCount >= 3) + if (pointCount >= 3) { - rlCheckRenderBatchLimit(3*(pointsCount - 2)); + rlCheckRenderBatchLimit(3*(pointCount - 2)); rlBegin(RL_TRIANGLES); rlColor4ub(color.r, color.g, color.b, color.a); - for (int i = 2; i < pointsCount; i++) + for (int i = 2; i < pointCount; i++) { if ((i%2) == 0) { diff --git a/src/textures.c b/src/textures.c index 92ed19fad..41a0a077b 100644 --- a/src/textures.c +++ b/src/textures.c @@ -258,7 +258,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int Image LoadImageAnim(const char *fileName, int *frames) { Image image = { 0 }; - int framesCount = 1; + int frameCount = 1; #if defined(SUPPORT_FILEFORMAT_GIF) if (IsFileExtension(fileName, ".gif")) @@ -270,7 +270,7 @@ Image LoadImageAnim(const char *fileName, int *frames) { int comp = 0; int **delays = NULL; - image.data = stbi_load_gif_from_memory(fileData, dataSize, delays, &image.width, &image.height, &framesCount, &comp, 4); + image.data = stbi_load_gif_from_memory(fileData, dataSize, delays, &image.width, &image.height, &frameCount, &comp, 4); image.mipmaps = 1; image.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8; @@ -286,7 +286,7 @@ Image LoadImageAnim(const char *fileName, int *frames) // TODO: Support APNG animated images? - *frames = framesCount; + *frames = frameCount; return image; } @@ -520,17 +520,17 @@ bool ExportImageAsCode(Image image, const char *fileName) // and requiring 6 char bytes for every byte: "0x00, " char *txtData = (char *)RL_CALLOC(dataSize*6 + 2000, sizeof(char)); - int bytesCount = 0; - bytesCount += sprintf(txtData + bytesCount, "////////////////////////////////////////////////////////////////////////////////////////\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// ImageAsCode exporter v1.0 - Image pixel data exported as an array of bytes //\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); - bytesCount += sprintf(txtData + bytesCount, "// feedback and support: ray[at]raylib.com //\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "// Copyright (c) 2018-2021 Ramon Santamaria (@raysan5) //\n"); - bytesCount += sprintf(txtData + bytesCount, "// //\n"); - bytesCount += sprintf(txtData + bytesCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); + int byteCount = 0; + byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// ImageAsCode exporter v1.0 - Image pixel data exported as an array of bytes //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); + byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2021 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); // Get file name from path and convert variable name to uppercase char varFileName[256] = { 0 }; @@ -538,14 +538,14 @@ bool ExportImageAsCode(Image image, const char *fileName) for (int i = 0; varFileName[i] != '\0'; i++) if ((varFileName[i] >= 'a') && (varFileName[i] <= 'z')) { varFileName[i] = varFileName[i] - 32; } // Add image information - bytesCount += sprintf(txtData + bytesCount, "// Image data information\n"); - bytesCount += sprintf(txtData + bytesCount, "#define %s_WIDTH %i\n", varFileName, image.width); - bytesCount += sprintf(txtData + bytesCount, "#define %s_HEIGHT %i\n", varFileName, image.height); - bytesCount += sprintf(txtData + bytesCount, "#define %s_FORMAT %i // raylib internal pixel format\n\n", varFileName, image.format); + byteCount += sprintf(txtData + byteCount, "// Image data information\n"); + byteCount += sprintf(txtData + byteCount, "#define %s_WIDTH %i\n", varFileName, image.width); + byteCount += sprintf(txtData + byteCount, "#define %s_HEIGHT %i\n", varFileName, image.height); + byteCount += sprintf(txtData + byteCount, "#define %s_FORMAT %i // raylib internal pixel format\n\n", varFileName, image.format); - bytesCount += sprintf(txtData + bytesCount, "static unsigned char %s_DATA[%i] = { ", varFileName, dataSize); - for (int i = 0; i < dataSize - 1; i++) bytesCount += sprintf(txtData + bytesCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]); - bytesCount += sprintf(txtData + bytesCount, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]); + byteCount += sprintf(txtData + byteCount, "static unsigned char %s_DATA[%i] = { ", varFileName, dataSize); + for (int i = 0; i < dataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]); + byteCount += sprintf(txtData + byteCount, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]); // NOTE: Text data length exported is determined by '\0' (NULL) character success = SaveFileText(fileName, txtData); @@ -765,11 +765,11 @@ Image GenImageCellular(int width, int height, int tileSize) int seedsPerRow = width/tileSize; int seedsPerCol = height/tileSize; - int seedsCount = seedsPerRow*seedsPerCol; + int seedCount = seedsPerRow*seedsPerCol; - Vector2 *seeds = (Vector2 *)RL_MALLOC(seedsCount*sizeof(Vector2)); + Vector2 *seeds = (Vector2 *)RL_MALLOC(seedCount*sizeof(Vector2)); - for (int i = 0; i < seedsCount; i++) + for (int i = 0; i < seedCount; i++) { int y = (i/seedsPerRow)*tileSize + GetRandomValue(0, tileSize - 1); int x = (i%seedsPerRow)*tileSize + GetRandomValue(0, tileSize - 1); @@ -1180,12 +1180,12 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co { if ((codepoint != ' ') && (codepoint != '\t')) { - Rectangle rec = { (float)(textOffsetX + font.chars[index].offsetX), (float)(textOffsetY + font.chars[index].offsetY), (float)font.recs[index].width, (float)font.recs[index].height }; - ImageDraw(&imText, font.chars[index].image, (Rectangle){ 0, 0, (float)font.chars[index].image.width, (float)font.chars[index].image.height }, rec, tint); + Rectangle rec = { (float)(textOffsetX + font.glyphs[index].offsetX), (float)(textOffsetY + font.glyphs[index].offsetY), (float)font.recs[index].width, (float)font.recs[index].height }; + ImageDraw(&imText, font.glyphs[index].image, (Rectangle){ 0, 0, (float)font.glyphs[index].image.width, (float)font.glyphs[index].image.height }, rec, tint); } - if (font.chars[index].advanceX == 0) textOffsetX += (int)(font.recs[index].width + spacing); - else textOffsetX += font.chars[index].advanceX + (int)spacing; + if (font.glyphs[index].advanceX == 0) textOffsetX += (int)(font.recs[index].width + spacing); + else textOffsetX += font.glyphs[index].advanceX + (int)spacing; } i += (codepointByteCount - 1); // Move text bytes counter to next codepoint @@ -2185,7 +2185,7 @@ Color *LoadImageColors(Image image) // Load colors palette from image as a Color array (RGBA - 32bit) // NOTE: Memory allocated should be freed using UnloadImagePalette() -Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorsCount) +Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount) { #define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a)) @@ -2234,7 +2234,7 @@ Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorsCount) UnloadImageColors(pixels); } - *colorsCount = palCount; + *colorCount = palCount; return palette; } @@ -3487,9 +3487,9 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, // Draw textured polygon, defined by vertex and texturecoordinates // NOTE: Polygon center must have straight line path to all points // without crossing perimeter, points must be in anticlockwise order -void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint) +void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint) { - rlCheckRenderBatchLimit((pointsCount - 1)*4); + rlCheckRenderBatchLimit((pointCount - 1)*4); rlSetTexture(texture.id); @@ -3498,7 +3498,7 @@ void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 rlColor4ub(tint.r, tint.g, tint.b, tint.a); - for (int i = 0; i < pointsCount - 1; i++) + for (int i = 0; i < pointCount - 1; i++) { rlTexCoord2f(0.5f, 0.5f); rlVertex2f(center.x, center.y); From 6e76baa6a93d039e132fe11eedc74958971bf4a3 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Sep 2021 23:11:31 +0200 Subject: [PATCH 25/31] WARNING: BREAKING: RENAMED: Font struct variables RENAMED: GetCodepointsCount() -> GetCodepointCount() RENAMED: GetTouchPointsCount() -> GetTouchPointCount() --- examples/text/text_rectangle_bounds.c | 2 +- examples/text/text_unicode.c | 4 +- src/gestures.h | 4 +- src/raylib.h | 42 +++--- src/text.c | 184 +++++++++++++------------- 5 files changed, 118 insertions(+), 118 deletions(-) diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c index 0da1a8ab3..b4884fb36 100644 --- a/examples/text/text_rectangle_bounds.c +++ b/examples/text/text_rectangle_bounds.c @@ -166,7 +166,7 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float glyphWidth = 0; if (codepoint != '\n') { - glyphWidth = (font.chars[index].advanceX == 0) ? font.recs[index].width*scaleFactor : font.chars[index].advanceX*scaleFactor; + glyphWidth = (font.glyphs[index].advanceX == 0) ? font.recs[index].width*scaleFactor : font.glyphs[index].advanceX*scaleFactor; if (i + 1 < length) glyphWidth = glyphWidth + spacing; } diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index 883d2a5cd..4b6b7780f 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -277,7 +277,7 @@ int main(int argc, char **argv) // Draw the info text below the main message int size = (int)strlen(messages[message].text); - int len = GetCodepointsCount(messages[message].text); + int len = GetCodepointCount(messages[message].text); const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, len, size); sz = MeasureTextEx(GetFontDefault(), info, 10, 1.0f); Vector2 pos = { textRect.x + textRect.width - sz.x, msgRect.y + msgRect.height - sz.y - 2 }; @@ -367,7 +367,7 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float glyphWidth = 0; if (codepoint != '\n') { - glyphWidth = (font.chars[index].advanceX == 0) ? font.recs[index].width*scaleFactor : font.chars[index].advanceX*scaleFactor; + glyphWidth = (font.glyphs[index].advanceX == 0) ? font.recs[index].width*scaleFactor : font.glyphs[index].advanceX*scaleFactor; if (i + 1 < length) glyphWidth = glyphWidth + spacing; } diff --git a/src/gestures.h b/src/gestures.h index 355f60817..09adffd02 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -118,7 +118,7 @@ void UpdateGestures(void); // Update gestures detec void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags bool IsGestureDetected(int gesture); // Check if a gesture have been detected int GetGestureDetected(void); // Get latest detected gesture -int GetTouchPointsCount(void); // Get touch points count +int GetTouchPointCount(void); // Get touch points count float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds Vector2 GetGestureDragVector(void); // Get gesture drag vector float GetGestureDragAngle(void); // Get gesture drag angle @@ -431,7 +431,7 @@ void UpdateGestures(void) } // Get number of touch points -int GetTouchPointsCount(void) +int GetTouchPointCount(void) { // NOTE: point count is calculated when ProcessGestureEvent(GestureEvent event) is called diff --git a/src/raylib.h b/src/raylib.h index fb0be1783..6b26713d4 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -287,11 +287,11 @@ typedef struct GlyphInfo { // Font, font texture and GlyphInfo array data typedef struct Font { int baseSize; // Base size (default chars height) - int charsCount; // Number of characters - int charsPadding; // Padding around the chars - Texture2D texture; // Characters texture atlas - Rectangle *recs; // Characters rectangles in texture - GlyphInfo *chars; // Characters glyphs info data + int glyphCount; // Number of glyph characters + int glyphPadding; // Padding around the glyph characters + Texture2D texture; // Texture atlas containing the glyphs + Rectangle *recs; // Rectangles in texture for the glyphs + GlyphInfo *glyphs; // Glyphs info data } Font; // Camera, defines position/orientation in 3d space @@ -1111,7 +1111,7 @@ RLAPI Vector2 GetTouchPosition(int index); // Get touch posit RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags RLAPI bool IsGestureDetected(int gesture); // Check if a gesture have been detected RLAPI int GetGestureDetected(void); // Get latest detected gesture -RLAPI int GetTouchPointsCount(void); // Get touch points count +RLAPI int GetTouchPointCount(void); // Get touch points count RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector RLAPI float GetGestureDragAngle(void); // Get gesture drag angle @@ -1145,7 +1145,7 @@ RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out RLAPI void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); //Draw line using quadratic bezier curves with a control point -RLAPI void DrawLineStrip(Vector2 *points, int pointsCount, Color color); // Draw lines sequence +RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle RLAPI void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw circle sector outline @@ -1169,8 +1169,8 @@ RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Co RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, float lineThick, Color color); // Draw rectangle with rounded edges outline RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!) RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline (vertex in counter-clockwise order!) -RLAPI void DrawTriangleFan(Vector2 *points, int pointsCount, Color color); // Draw a triangle fan defined by points (first vertex is the center) -RLAPI void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color); // Draw a triangle strip defined by points +RLAPI void DrawTriangleFan(Vector2 *points, int pointCount, Color color); // Draw a triangle fan defined by points (first vertex is the center) +RLAPI void DrawTriangleStrip(Vector2 *points, int pointCount, Color color); // Draw a triangle strip defined by points RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a polygon outline of n sides RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters @@ -1239,7 +1239,7 @@ RLAPI void ImageColorContrast(Image *image, float contrast); RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color RLAPI Color *LoadImageColors(Image image); // Load color data from image as a Color array (RGBA - 32bit) -RLAPI Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorsCount); // Load colors palette from image as a Color array (RGBA - 32bit) +RLAPI Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount); // Load colors palette from image as a Color array (RGBA - 32bit) RLAPI void UnloadImageColors(Color *colors); // Unload color data loaded with LoadImageColors() RLAPI void UnloadImagePalette(Color *colors); // Unload colors palette loaded with LoadImagePalette() RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle @@ -1286,7 +1286,7 @@ RLAPI void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Re RLAPI void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest. RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely -RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint); // Draw a textured polygon +RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint); // Draw a textured polygon // Color/pixel related functions RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f @@ -1309,12 +1309,12 @@ RLAPI int GetPixelDataSize(int width, int height, int format); // G // Font loading/unloading functions RLAPI Font GetFontDefault(void); // Get the default Font RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM) -RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // Load font from file with extended parameters +RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // Load font from file with extended parameters RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style) -RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' -RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use -RLAPI Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info -RLAPI void UnloadFontData(GlyphInfo *chars, int charsCount); // Unload font chars info data (RAM) +RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' +RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type); // Load font data for further use +RLAPI Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **recs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info +RLAPI void UnloadFontData(GlyphInfo *chars, int glyphCount); // Unload font chars info data (RAM) RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM) // Text drawing functions @@ -1334,7 +1334,7 @@ RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Text codepoints management functions (unicode characters) RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory -RLAPI int GetCodepointsCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string +RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string RLAPI int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure RLAPI const char *CodepointToUTF8(int codepoint, int *byteLength); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) RLAPI char *TextCodepointsToUTF8(int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) @@ -1366,7 +1366,7 @@ RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); RLAPI void DrawPoint3D(Vector3 position, Color color); // Draw a point in 3D space, actually a small line RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space RLAPI void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!) -RLAPI void DrawTriangleStrip3D(Vector3 *points, int pointsCount, Color color); // Draw a triangle strip defined by points +RLAPI void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color); // Draw a triangle strip defined by points RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires @@ -1434,7 +1434,7 @@ RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh // Model animations loading/unloading functions -RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animsCount); // Load model animations from file +RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data RLAPI void UnloadModelAnimations(ModelAnimation* animations, unsigned int count); // Unload animation array data @@ -1466,7 +1466,7 @@ RLAPI Wave LoadWave(const char *fileName); // Load wa RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav' RLAPI Sound LoadSound(const char *fileName); // Load sound from file RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data -RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data +RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data RLAPI void UnloadWave(Wave wave); // Unload wave data RLAPI void UnloadSound(Sound sound); // Unload sound RLAPI bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success @@ -1507,7 +1507,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur // AudioStream management functions RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data) RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory -RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int framesCount); // Update audio stream buffers with data +RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream diff --git a/src/text.c b/src/text.c index 66a08eb19..ae6f38661 100644 --- a/src/text.c +++ b/src/text.c @@ -129,8 +129,8 @@ extern void LoadFontDefault(void) // NOTE: Using UTF-8 encoding table for Unicode U+0000..U+00FF Basic Latin + Latin-1 Supplement // Ref: http://www.utf8-chartable.de/unicode-utf8-table.pl - defaultFont.charsCount = 224; // Number of chars included in our default font - defaultFont.charsPadding = 0; // Characters padding + defaultFont.glyphCount = 224; // Number of chars included in our default font + defaultFont.glyphPadding = 0; // Characters padding // Default font is directly defined here (data generated from a sprite font image) // This way, we reconstruct Font without creating large global variables @@ -220,21 +220,21 @@ extern void LoadFontDefault(void) defaultFont.texture = LoadTextureFromImage(imFont); - // Reconstruct charSet using charsWidth[], charsHeight, charsDivisor, charsCount + // Reconstruct charSet using charsWidth[], charsHeight, charsDivisor, glyphCount //------------------------------------------------------------------------------ // Allocate space for our characters info data // NOTE: This memory should be freed at end! --> CloseWindow() - defaultFont.chars = (GlyphInfo *)RL_MALLOC(defaultFont.charsCount*sizeof(GlyphInfo)); - defaultFont.recs = (Rectangle *)RL_MALLOC(defaultFont.charsCount*sizeof(Rectangle)); + defaultFont.glyphs = (GlyphInfo *)RL_MALLOC(defaultFont.glyphCount*sizeof(GlyphInfo)); + defaultFont.recs = (Rectangle *)RL_MALLOC(defaultFont.glyphCount*sizeof(Rectangle)); int currentLine = 0; int currentPosX = charsDivisor; int testPosX = charsDivisor; - for (int i = 0; i < defaultFont.charsCount; i++) + for (int i = 0; i < defaultFont.glyphCount; i++) { - defaultFont.chars[i].value = 32 + i; // First char is 32 + defaultFont.glyphs[i].value = 32 + i; // First char is 32 defaultFont.recs[i].x = (float)currentPosX; defaultFont.recs[i].y = (float)(charsDivisor + currentLine*(charsHeight + charsDivisor)); @@ -255,12 +255,12 @@ extern void LoadFontDefault(void) else currentPosX = testPosX; // NOTE: On default font character offsets and xAdvance are not required - defaultFont.chars[i].offsetX = 0; - defaultFont.chars[i].offsetY = 0; - defaultFont.chars[i].advanceX = 0; + defaultFont.glyphs[i].offsetX = 0; + defaultFont.glyphs[i].offsetY = 0; + defaultFont.glyphs[i].advanceX = 0; // Fill character image data from fontClear data - defaultFont.chars[i].image = ImageFromImage(imFont, defaultFont.recs[i]); + defaultFont.glyphs[i].image = ImageFromImage(imFont, defaultFont.recs[i]); } UnloadImage(imFont); @@ -273,9 +273,9 @@ extern void LoadFontDefault(void) // Unload raylib default font extern void UnloadFontDefault(void) { - for (int i = 0; i < defaultFont.charsCount; i++) UnloadImage(defaultFont.chars[i].image); + for (int i = 0; i < defaultFont.glyphCount; i++) UnloadImage(defaultFont.glyphs[i].image); UnloadTexture(defaultFont.texture); - RL_FREE(defaultFont.chars); + RL_FREE(defaultFont.glyphs); RL_FREE(defaultFont.recs); } #endif // SUPPORT_DEFAULT_FONT @@ -337,7 +337,7 @@ Font LoadFont(const char *fileName) // Load Font from TTF font file with generation parameters // NOTE: You can pass an array with desired characters, those characters should be available in the font // if array is NULL, default char set is selected 32..126 -Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount) +Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount) { Font font = { 0 }; @@ -348,7 +348,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCou if (fileData != NULL) { // Loading font from memory data - font = LoadFontFromMemory(GetFileExtension(fileName), fileData, fileSize, fontSize, fontChars, charsCount); + font = LoadFontFromMemory(GetFileExtension(fileName), fileData, fileSize, fontSize, fontChars, glyphCount); RL_FREE(fileData); } @@ -449,28 +449,28 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) Font font = { 0 }; font.texture = LoadTextureFromImage(fontClear); // Convert processed image to OpenGL texture - font.charsCount = index; - font.charsPadding = 0; + font.glyphCount = index; + font.glyphPadding = 0; // We got tempCharValues and tempCharsRecs populated with chars data // Now we move temp data to sized charValues and charRecs arrays - font.chars = (GlyphInfo *)RL_MALLOC(font.charsCount*sizeof(GlyphInfo)); - font.recs = (Rectangle *)RL_MALLOC(font.charsCount*sizeof(Rectangle)); + font.glyphs = (GlyphInfo *)RL_MALLOC(font.glyphCount*sizeof(GlyphInfo)); + font.recs = (Rectangle *)RL_MALLOC(font.glyphCount*sizeof(Rectangle)); - for (int i = 0; i < font.charsCount; i++) + for (int i = 0; i < font.glyphCount; i++) { - font.chars[i].value = tempCharValues[i]; + font.glyphs[i].value = tempCharValues[i]; // Get character rectangle in the font atlas texture font.recs[i] = tempCharRecs[i]; // NOTE: On image based fonts (XNA style), character offsets and xAdvance are not required (set to 0) - font.chars[i].offsetX = 0; - font.chars[i].offsetY = 0; - font.chars[i].advanceX = 0; + font.glyphs[i].offsetX = 0; + font.glyphs[i].offsetY = 0; + font.glyphs[i].advanceX = 0; // Fill character image data from fontClear data - font.chars[i].image = ImageFromImage(fontClear, tempCharRecs[i]); + font.glyphs[i].image = ImageFromImage(fontClear, tempCharRecs[i]); } UnloadImage(fontClear); // Unload processed image once converted to texture @@ -481,7 +481,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) } // Load font from memory buffer, fileType refers to extension: i.e. ".ttf" -Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount) +Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount) { Font font = { 0 }; @@ -493,22 +493,22 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int TextIsEqual(fileExtLower, ".otf")) { font.baseSize = fontSize; - font.charsCount = (charsCount > 0)? charsCount : 95; - font.charsPadding = 0; - font.chars = LoadFontData(fileData, dataSize, font.baseSize, fontChars, font.charsCount, FONT_DEFAULT); + font.glyphCount = (glyphCount > 0)? glyphCount : 95; + font.glyphPadding = 0; + font.glyphs = LoadFontData(fileData, dataSize, font.baseSize, fontChars, font.glyphCount, FONT_DEFAULT); - if (font.chars != NULL) + if (font.glyphs != NULL) { - font.charsPadding = FONT_TTF_DEFAULT_CHARS_PADDING; + font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING; - Image atlas = GenImageFontAtlas(font.chars, &font.recs, font.charsCount, font.baseSize, font.charsPadding, 0); + Image atlas = GenImageFontAtlas(font.glyphs, &font.recs, font.glyphCount, font.baseSize, font.glyphPadding, 0); font.texture = LoadTextureFromImage(atlas); - // Update chars[i].image to use alpha, required to be used on ImageDrawText() - for (int i = 0; i < font.charsCount; i++) + // Update glyphs[i].image to use alpha, required to be used on ImageDrawText() + for (int i = 0; i < font.glyphCount; i++) { - UnloadImage(font.chars[i].image); - font.chars[i].image = ImageFromImage(atlas, font.recs[i]); + UnloadImage(font.glyphs[i].image); + font.glyphs[i].image = ImageFromImage(atlas, font.recs[i]); } UnloadImage(atlas); @@ -524,7 +524,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int // Load font data for further use // NOTE: Requires TTF font memory data and can generate SDF data -GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type) +GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type) { // NOTE: Using some SDF generation default values, // trades off precision with ability to handle *smaller* sizes @@ -562,22 +562,22 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap); // In case no chars count provided, default to 95 - charsCount = (charsCount > 0)? charsCount : 95; + glyphCount = (glyphCount > 0)? glyphCount : 95; // Fill fontChars in case not provided externally - // NOTE: By default we fill charsCount consecutevely, starting at 32 (Space) + // NOTE: By default we fill glyphCount consecutevely, starting at 32 (Space) if (fontChars == NULL) { - fontChars = (int *)RL_MALLOC(charsCount*sizeof(int)); - for (int i = 0; i < charsCount; i++) fontChars[i] = i + 32; + fontChars = (int *)RL_MALLOC(glyphCount*sizeof(int)); + for (int i = 0; i < glyphCount; i++) fontChars[i] = i + 32; genFontChars = true; } - chars = (GlyphInfo *)RL_MALLOC(charsCount*sizeof(GlyphInfo)); + chars = (GlyphInfo *)RL_MALLOC(glyphCount*sizeof(GlyphInfo)); // NOTE: Using simple packaging, one char after another - for (int i = 0; i < charsCount; i++) + for (int i = 0; i < glyphCount; i++) { int chw = 0, chh = 0; // Character width and height (on generation) int ch = fontChars[i]; // Character value to get info for @@ -650,7 +650,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz // Generate image font atlas using chars info // NOTE: Packing method: 0-Default, 1-Skyline #if defined(SUPPORT_FILEFORMAT_TTF) -Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int charsCount, int fontSize, int padding, int packMethod) +Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphCount, int fontSize, int padding, int packMethod) { Image atlas = { 0 }; @@ -663,17 +663,17 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int charsC *charRecs = NULL; // In case no chars count provided we suppose default of 95 - charsCount = (charsCount > 0)? charsCount : 95; + glyphCount = (glyphCount > 0)? glyphCount : 95; // NOTE: Rectangles memory is loaded here! - Rectangle *recs = (Rectangle *)RL_MALLOC(charsCount*sizeof(Rectangle)); + Rectangle *recs = (Rectangle *)RL_MALLOC(glyphCount*sizeof(Rectangle)); // Calculate image size based on required pixel area // NOTE 1: Image is forced to be squared and POT... very conservative! // NOTE 2: SDF font characters already contain an internal padding, // so image size would result bigger than default font type float requiredArea = 0; - for (int i = 0; i < charsCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(chars[i].image.height + 2*padding)); + for (int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(chars[i].image.height + 2*padding)); float guessSize = sqrtf(requiredArea)*1.3f; int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT @@ -692,7 +692,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int charsC int offsetY = padding; // NOTE: Using simple packaging, one char after another - for (int i = 0; i < charsCount; i++) + for (int i = 0; i < glyphCount; i++) { // Copy pixel data from fc.data to atlas for (int y = 0; y < chars[i].image.height; y++) @@ -728,13 +728,13 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int charsC else if (packMethod == 1) // Use Skyline rect packing algorythm (stb_pack_rect) { stbrp_context *context = (stbrp_context *)RL_MALLOC(sizeof(*context)); - stbrp_node *nodes = (stbrp_node *)RL_MALLOC(charsCount*sizeof(*nodes)); + stbrp_node *nodes = (stbrp_node *)RL_MALLOC(glyphCount*sizeof(*nodes)); - stbrp_init_target(context, atlas.width, atlas.height, nodes, charsCount); - stbrp_rect *rects = (stbrp_rect *)RL_MALLOC(charsCount*sizeof(stbrp_rect)); + stbrp_init_target(context, atlas.width, atlas.height, nodes, glyphCount); + stbrp_rect *rects = (stbrp_rect *)RL_MALLOC(glyphCount*sizeof(stbrp_rect)); // Fill rectangles for packaging - for (int i = 0; i < charsCount; i++) + for (int i = 0; i < glyphCount; i++) { rects[i].id = i; rects[i].w = chars[i].image.width + 2*padding; @@ -742,9 +742,9 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int charsC } // Package rectangles into atlas - stbrp_pack_rects(context, rects, charsCount); + stbrp_pack_rects(context, rects, glyphCount); - for (int i = 0; i < charsCount; i++) + for (int i = 0; i < glyphCount; i++) { // It return char rectangles in atlas recs[i].x = rects[i].x + (float)padding; @@ -792,12 +792,12 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int charsC } #endif -// Unload font chars info data (RAM) -void UnloadFontData(GlyphInfo *chars, int charsCount) +// Unload font glyphs info data (RAM) +void UnloadFontData(GlyphInfo *glyphs, int glyphCount) { - for (int i = 0; i < charsCount; i++) UnloadImage(chars[i].image); + for (int i = 0; i < glyphCount; i++) UnloadImage(glyphs[i].image); - RL_FREE(chars); + RL_FREE(glyphs); } // Unload Font from GPU memory (VRAM) @@ -806,7 +806,7 @@ void UnloadFont(Font font) // NOTE: Make sure font is not default font (fallback) if (font.texture.id != GetFontDefault().texture.id) { - UnloadFontData(font.chars, font.charsCount); + UnloadFontData(font.glyphs, font.glyphCount); UnloadTexture(font.texture); RL_FREE(font.recs); @@ -883,8 +883,8 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f DrawTextCodepoint(font, codepoint, (Vector2){ position.x + textOffsetX, position.y + textOffsetY }, fontSize, tint); } - if (font.chars[index].advanceX == 0) textOffsetX += ((float)font.recs[index].width*scaleFactor + spacing); - else textOffsetX += ((float)font.chars[index].advanceX*scaleFactor + spacing); + if (font.glyphs[index].advanceX == 0) textOffsetX += ((float)font.recs[index].width*scaleFactor + spacing); + else textOffsetX += ((float)font.glyphs[index].advanceX*scaleFactor + spacing); } i += codepointByteCount; // Move text bytes counter to next codepoint @@ -914,16 +914,16 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor // Character destination rectangle on screen - // NOTE: We consider charsPadding on drawing - Rectangle dstRec = { position.x + font.chars[index].offsetX*scaleFactor - (float)font.charsPadding*scaleFactor, - position.y + font.chars[index].offsetY*scaleFactor - (float)font.charsPadding*scaleFactor, - (font.recs[index].width + 2.0f*font.charsPadding)*scaleFactor, - (font.recs[index].height + 2.0f*font.charsPadding)*scaleFactor }; + // NOTE: We consider glyphPadding on drawing + Rectangle dstRec = { position.x + font.glyphs[index].offsetX*scaleFactor - (float)font.glyphPadding*scaleFactor, + position.y + font.glyphs[index].offsetY*scaleFactor - (float)font.glyphPadding*scaleFactor, + (font.recs[index].width + 2.0f*font.glyphPadding)*scaleFactor, + (font.recs[index].height + 2.0f*font.glyphPadding)*scaleFactor }; // Character source rectangle from font texture atlas // NOTE: We consider chars padding when drawing, it could be required for outline/glow shader effects - Rectangle srcRec = { font.recs[index].x - (float)font.charsPadding, font.recs[index].y - (float)font.charsPadding, - font.recs[index].width + 2.0f*font.charsPadding, font.recs[index].height + 2.0f*font.charsPadding }; + Rectangle srcRec = { font.recs[index].x - (float)font.glyphPadding, font.recs[index].y - (float)font.glyphPadding, + font.recs[index].width + 2.0f*font.glyphPadding, font.recs[index].height + 2.0f*font.glyphPadding }; // Draw the character texture on the screen DrawTexturePro(font.texture, srcRec, dstRec, (Vector2){ 0, 0 }, 0.0f, tint); @@ -978,8 +978,8 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing if (letter != '\n') { - if (font.chars[index].advanceX != 0) textWidth += font.chars[index].advanceX; - else textWidth += (font.recs[index].width + font.chars[index].offsetX); + if (font.glyphs[index].advanceX != 0) textWidth += font.glyphs[index].advanceX; + else textWidth += (font.recs[index].width + font.glyphs[index].offsetX); } else { @@ -1014,9 +1014,9 @@ int GetGlyphIndex(Font font, int codepoint) #if defined(SUPPORT_UNORDERED_CHARSET) int index = GLYPH_NOTFOUND_CHAR_FALLBACK; - for (int i = 0; i < font.charsCount; i++) + for (int i = 0; i < font.glyphCount; i++) { - if (font.chars[i].value == codepoint) + if (font.glyphs[i].value == codepoint) { index = i; break; @@ -1035,7 +1035,7 @@ GlyphInfo GetGlyphInfo(Font font, int codepoint) { GlyphInfo info = { 0 }; - info = font.chars[GetGlyphIndex(font, codepoint)]; + info = font.glyphs[GetGlyphIndex(font, codepoint)]; return info; } @@ -1472,22 +1472,22 @@ int *LoadCodepoints(const char *text, int *count) int textLength = TextLength(text); int bytesProcessed = 0; - int codepointsCount = 0; + int codepointCount = 0; // Allocate a big enough buffer to store as many codepoints as text bytes int *codepoints = RL_CALLOC(textLength, sizeof(int)); - for (int i = 0; i < textLength; codepointsCount++) + for (int i = 0; i < textLength; codepointCount++) { - codepoints[codepointsCount] = GetCodepoint(text + i, &bytesProcessed); + codepoints[codepointCount] = GetCodepoint(text + i, &bytesProcessed); i += bytesProcessed; } // Re-allocate buffer to the actual number of codepoints loaded - void *temp = RL_REALLOC(codepoints, codepointsCount*sizeof(int)); + void *temp = RL_REALLOC(codepoints, codepointCount*sizeof(int)); if (temp != NULL) codepoints = temp; - *count = codepointsCount; + *count = codepointCount; return codepoints; } @@ -1500,7 +1500,7 @@ void UnloadCodepoints(int *codepoints) // Get total number of characters(codepoints) in a UTF-8 encoded text, until '\0' is found // NOTE: If an invalid UTF-8 sequence is encountered a '?'(0x3f) codepoint is counted instead -int GetCodepointsCount(const char *text) +int GetCodepointCount(const char *text) { unsigned int len = 0; char *ptr = (char *)&text[0]; @@ -1657,7 +1657,7 @@ static Font LoadBMFont(const char *fileName) char *searchPoint = NULL; int fontSize = 0; - int charsCount = 0; + int glyphCount = 0; int imWidth = 0; int imHeight = 0; @@ -1694,10 +1694,10 @@ static Font LoadBMFont(const char *fileName) lineBytes = GetLine(fileTextPtr, buffer, MAX_BUFFER_SIZE); searchPoint = strstr(buffer, "count"); - sscanf(searchPoint, "count=%i", &charsCount); + sscanf(searchPoint, "count=%i", &glyphCount); fileTextPtr += (lineBytes + 1); - TRACELOGD(" > Chars count: %i", charsCount); + TRACELOGD(" > Chars count: %i", glyphCount); // Compose correct path using route of .fnt file (fileName) and imFileName char *imPath = NULL; @@ -1746,14 +1746,14 @@ static Font LoadBMFont(const char *fileName) // Fill font characters info data font.baseSize = fontSize; - font.charsCount = charsCount; - font.charsPadding = 0; - font.chars = (GlyphInfo *)RL_MALLOC(charsCount*sizeof(GlyphInfo)); - font.recs = (Rectangle *)RL_MALLOC(charsCount*sizeof(Rectangle)); + font.glyphCount = glyphCount; + font.glyphPadding = 0; + font.glyphs = (GlyphInfo *)RL_MALLOC(glyphCount*sizeof(GlyphInfo)); + font.recs = (Rectangle *)RL_MALLOC(glyphCount*sizeof(Rectangle)); int charId, charX, charY, charWidth, charHeight, charOffsetX, charOffsetY, charAdvanceX; - for (int i = 0; i < charsCount; i++) + for (int i = 0; i < glyphCount; i++) { lineBytes = GetLine(fileTextPtr, buffer, MAX_BUFFER_SIZE); sscanf(buffer, "char id=%i x=%i y=%i width=%i height=%i xoffset=%i yoffset=%i xadvance=%i", @@ -1764,13 +1764,13 @@ static Font LoadBMFont(const char *fileName) font.recs[i] = (Rectangle){ (float)charX, (float)charY, (float)charWidth, (float)charHeight }; // Save data properly in sprite font - font.chars[i].value = charId; - font.chars[i].offsetX = charOffsetX; - font.chars[i].offsetY = charOffsetY; - font.chars[i].advanceX = charAdvanceX; + font.glyphs[i].value = charId; + font.glyphs[i].offsetX = charOffsetX; + font.glyphs[i].offsetY = charOffsetY; + font.glyphs[i].advanceX = charAdvanceX; // Fill character image data from imFont data - font.chars[i].image = ImageFromImage(imFont, font.recs[i]); + font.glyphs[i].image = ImageFromImage(imFont, font.recs[i]); } UnloadImage(imFont); From dfadb3ee379f60f9fdb3d3a1535c716555e05dcc Mon Sep 17 00:00:00 2001 From: atticus Date: Thu, 2 Sep 2021 00:15:32 +0300 Subject: [PATCH 26/31] fix various memory leaks (#1969) --- src/extras/rmem.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/extras/rmem.h b/src/extras/rmem.h index 7f50adf8c..43005cfec 100644 --- a/src/extras/rmem.h +++ b/src/extras/rmem.h @@ -276,7 +276,10 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo mempool->arena.offs += iter->size; __RemoveMemNode(list, iter); iter = list->head; - if (iter == NULL) return; + if (iter == NULL) { + list->head = node; + return; + } } const uintptr_t inode = ( uintptr_t )node; const uintptr_t iiter = ( uintptr_t )iter; @@ -293,6 +296,14 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo iter->size += node->size; return; } + else if (iter->next == NULL) + { + // we reached the end of the free list -> append the node + iter->next = node; + node->prev = iter; + list->len++; + return; + } } else if (iter > node) { @@ -326,7 +337,7 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo } else { - __InsertMemNodeBefore(list, iter, node); + __InsertMemNodeBefore(list, node, iter); list->len++; return; } From 9362eaf9c670c86e3ce4045b7465e55db47bddb7 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Sep 2021 23:40:51 +0200 Subject: [PATCH 27/31] REVIEWED: Naming: length vs size --- examples/text/text_unicode.c | 4 +-- src/core.c | 4 +-- src/raylib.h | 2 +- src/rlgl.h | 70 ++++++++++++++++++------------------ src/text.c | 40 ++++++++++----------- src/textures.c | 6 ++-- 6 files changed, 63 insertions(+), 63 deletions(-) diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index 4b6b7780f..c1521996f 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -277,8 +277,8 @@ int main(int argc, char **argv) // Draw the info text below the main message int size = (int)strlen(messages[message].text); - int len = GetCodepointCount(messages[message].text); - const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, len, size); + int length = GetCodepointCount(messages[message].text); + const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, length, size); sz = MeasureTextEx(GetFontDefault(), info, 10, 1.0f); Vector2 pos = { textRect.x + textRect.width - sz.x, msgRect.y + msgRect.height - sz.y - 2 }; DrawText(info, (int)pos.x, (int)pos.y, 10, RAYWHITE); diff --git a/src/core.c b/src/core.c index 89b9874ac..043f99e90 100644 --- a/src/core.c +++ b/src/core.c @@ -2767,9 +2767,9 @@ const char *GetFileNameWithoutExt(const char *filePath) if (filePath != NULL) strcpy(fileName, GetFileName(filePath)); // Get filename with extension - int len = (int)strlen(fileName); + int size = (int)strlen(fileName); // Get size in bytes - for (int i = 0; (i < len) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++) + for (int i = 0; (i < size) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++) { if (fileName[i] == '.') { diff --git a/src/raylib.h b/src/raylib.h index 6b26713d4..9e46e842e 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1336,7 +1336,7 @@ RLAPI int *LoadCodepoints(const char *text, int *count); // Load al RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string RLAPI int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -RLAPI const char *CodepointToUTF8(int codepoint, int *byteLength); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) +RLAPI const char *CodepointToUTF8(int codepoint, int *byteSize); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) RLAPI char *TextCodepointsToUTF8(int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) // Text strings management functions (no UTF-8 strings, only byte chars) diff --git a/src/rlgl.h b/src/rlgl.h index ea46c537e..0bed58044 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -321,7 +321,7 @@ typedef struct rlRenderBatch { rlVertexBuffer *vertexBuffer; // Dynamic buffer(s) for vertex data rlDrawCall *draws; // Draw calls array, depends on textureId - int drawCounterer; // Draw calls counter + int drawCounter; // Draw calls counter float currentDepth; // Current depth value for next draw } rlRenderBatch; @@ -1210,34 +1210,34 @@ void rlBegin(int mode) { // Draw mode can be RL_LINES, RL_TRIANGLES and RL_QUADS // NOTE: In all three cases, vertex are accumulated over default internal vertex buffer - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode != mode) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode) { - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount > 0) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0) { // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4, // that way, following QUADS drawing will keep aligned with index processing // It implies adding some extra alignment vertex at the end of the draw, // those vertex are not processed but they are considered as an additional offset // for the next set of vertex to be drawn - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4); - else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4))); - else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = 0; + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4); + else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4))); + else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0; - if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment)) + if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment)) { - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; - RLGL.currentBatch->drawCounterer++; + RLGL.currentBatch->drawCounter++; } } - if (RLGL.currentBatch->drawCounterer >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); + if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode = mode; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount = 0; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].textureId = RLGL.State.defaultTextureId; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId; } } @@ -1319,7 +1319,7 @@ void rlVertex3f(float x, float y, float z) RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter + 2] = tz; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter++; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount++; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount++; } else TRACELOG(RL_LOG_ERROR, "RLGL: Batch elements overflow"); } @@ -1401,33 +1401,33 @@ void rlSetTexture(unsigned int id) #if defined(GRAPHICS_API_OPENGL_11) rlEnableTexture(id); #else - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].textureId != id) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id) { - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount > 0) + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0) { // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4, // that way, following QUADS drawing will keep aligned with index processing // It implies adding some extra alignment vertex at the end of the draw, // those vertex are not processed but they are considered as an additional offset // for the next set of vertex to be drawn - if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4); - else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount%4))); - else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment = 0; + if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4); + else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4))); + else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0; - if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment)) + if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment)) { - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; - RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].cCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; + RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].tcCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; - RLGL.currentBatch->drawCounterer++; + RLGL.currentBatch->drawCounter++; } } - if (RLGL.currentBatch->drawCounterer >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); + if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].textureId = id; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounterer - 1].vertexCount = 0; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = id; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0; } #endif } @@ -1910,12 +1910,12 @@ void rlLoadExtensions(void *loader) const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string // NOTE: We have to duplicate string because glGetString() returns a const string - int len = strlen(extensions) + 1; - char *extensionsDup = (char *)RL_CALLOC(len, sizeof(char)); + int size = strlen(extensions) + 1; // Get extensions string size in bytes + char *extensionsDup = (char *)RL_CALLOC(size, sizeof(char)); strcpy(extensionsDup, extensions); extList[numExt] = extensionsDup; - for (int i = 0; i < len; i++) + for (int i = 0; i < size; i++) { if (extensionsDup[i] == ' ') { @@ -2275,7 +2275,7 @@ rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements) } batch.bufferCount = numBuffers; // Record buffer count - batch.drawCounterer = 1; // Reset draws counter + batch.drawCounter = 1; // Reset draws counter batch.currentDepth = -1.0f; // Reset depth value //-------------------------------------------------------------------------------------------- #endif @@ -2447,7 +2447,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch) // NOTE: Batch system accumulates calls by texture0 changes, additional textures are enabled for all the draw calls glActiveTexture(GL_TEXTURE0); - for (int i = 0, vertexOffset = 0; i < batch->drawCounterer; i++) + for (int i = 0, vertexOffset = 0; i < batch->drawCounter; i++) { // Bind current draw call texture, activated as GL_TEXTURE0 and binded to sampler2D texture0 by default glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId); @@ -2510,7 +2510,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch) for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0; // Reset draws counter to one draw for the batch - batch->drawCounterer = 1; + batch->drawCounter = 1; //------------------------------------------------------------------------------------------------------------ // Change to next buffer in the list (in case of multi-buffering) diff --git a/src/text.c b/src/text.c index ae6f38661..a7736bffb 100644 --- a/src/text.c +++ b/src/text.c @@ -851,14 +851,14 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f { if (font.texture.id == 0) font = GetFontDefault(); // Security check in case of not valid font - int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop + int size = TextLength(text); // Total size in bytes of the text, scanned by codepoints in loop int textOffsetY = 0; // Offset between lines (on line break '\n') float textOffsetX = 0.0f; // Offset X to next character to draw float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor - for (int i = 0; i < length;) + for (int i = 0; i < size;) { // Get next codepoint from byte string and glyph index in font int codepointByteCount = 0; @@ -950,9 +950,9 @@ int MeasureText(const char *text, int fontSize) // Measure string size for Font Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing) { - int len = TextLength(text); - int tempLen = 0; // Used to count longer text line num chars - int lenCounter = 0; + int size = TextLength(text); // Get size in bytes of text + int tempByteCounter = 0; // Used to count longer text line num chars + int byteCounter = 0; float textWidth = 0.0f; float tempTextWidth = 0.0f; // Used to count longer text line width @@ -963,9 +963,9 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing int letter = 0; // Current character int index = 0; // Index position in sprite font - for (int i = 0; i < len; i++) + for (int i = 0; i < size; i++) { - lenCounter++; + byteCounter++; int next = 0; letter = GetCodepoint(&text[i], &next); @@ -984,18 +984,18 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing else { if (tempTextWidth < textWidth) tempTextWidth = textWidth; - lenCounter = 0; + byteCounter = 0; textWidth = 0; textHeight += ((float)font.baseSize*1.5f); // NOTE: Fixed line spacing of 1.5 lines } - if (tempLen < lenCounter) tempLen = lenCounter; + if (tempByteCounter < byteCounter) tempByteCounter = byteCounter; } if (tempTextWidth < textWidth) tempTextWidth = textWidth; Vector2 vec = { 0 }; - vec.x = tempTextWidth*scaleFactor + (float)((tempLen - 1)*spacing); // Adds chars spacing to measure + vec.x = tempTextWidth*scaleFactor + (float)((tempByteCounter - 1)*spacing); // Adds chars spacing to measure vec.y = textHeight*scaleFactor; return vec; @@ -1429,28 +1429,28 @@ char *TextCodepointsToUTF8(int *codepoints, int length) // Encode codepoint into utf8 text (char array length returned as parameter) // NOTE: It uses a static array to store UTF-8 bytes -RLAPI const char *CodepointToUTF8(int codepoint, int *byteLength) +RLAPI const char *CodepointToUTF8(int codepoint, int *byteSize) { static char utf8[6] = { 0 }; - int length = 0; + int size = 0; // Byte size of codepoint if (codepoint <= 0x7f) { utf8[0] = (char)codepoint; - length = 1; + size = 1; } else if (codepoint <= 0x7ff) { utf8[0] = (char)(((codepoint >> 6) & 0x1f) | 0xc0); utf8[1] = (char)((codepoint & 0x3f) | 0x80); - length = 2; + size = 2; } else if (codepoint <= 0xffff) { utf8[0] = (char)(((codepoint >> 12) & 0x0f) | 0xe0); utf8[1] = (char)(((codepoint >> 6) & 0x3f) | 0x80); utf8[2] = (char)((codepoint & 0x3f) | 0x80); - length = 3; + size = 3; } else if (codepoint <= 0x10ffff) { @@ -1458,10 +1458,10 @@ RLAPI const char *CodepointToUTF8(int codepoint, int *byteLength) utf8[1] = (char)(((codepoint >> 12) & 0x3f) | 0x80); utf8[2] = (char)(((codepoint >> 6) & 0x3f) | 0x80); utf8[3] = (char)((codepoint & 0x3f) | 0x80); - length = 4; + size = 4; } - *byteLength = length; + *byteSize = size; return utf8; } @@ -1502,7 +1502,7 @@ void UnloadCodepoints(int *codepoints) // NOTE: If an invalid UTF-8 sequence is encountered a '?'(0x3f) codepoint is counted instead int GetCodepointCount(const char *text) { - unsigned int len = 0; + unsigned int length = 0; char *ptr = (char *)&text[0]; while (*ptr != '\0') @@ -1513,10 +1513,10 @@ int GetCodepointCount(const char *text) if (letter == 0x3f) ptr += 1; else ptr += next; - len++; + length++; } - return len; + return length; } #endif // SUPPORT_TEXT_MANIPULATION diff --git a/src/textures.c b/src/textures.c index 41a0a077b..6caaa5bb8 100644 --- a/src/textures.c +++ b/src/textures.c @@ -547,7 +547,7 @@ bool ExportImageAsCode(Image image, const char *fileName) for (int i = 0; i < dataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), ((unsigned char *)image.data)[i]); byteCount += sprintf(txtData + byteCount, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]); - // NOTE: Text data length exported is determined by '\0' (NULL) character + // NOTE: Text data size exported is determined by '\0' (NULL) character success = SaveFileText(fileName, txtData); RL_FREE(txtData); @@ -1147,7 +1147,7 @@ Image ImageText(const char *text, int fontSize, Color color) // Create an image from text (custom sprite font) Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint) { - int length = (int)strlen(text); + int size = (int)strlen(text); // Get size in bytes of text int textOffsetX = 0; // Image drawing position X int textOffsetY = 0; // Offset between lines (on line break '\n') @@ -1158,7 +1158,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co // Create image to store text Image imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK); - for (int i = 0; i < length; i++) + for (int i = 0; i < size; i++) { // Get next codepoint from byte string and glyph index in font int codepointByteCount = 0; From 59e7275464f9323a617a0f8ce30a5b69746a1915 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 2 Sep 2021 00:35:55 +0200 Subject: [PATCH 28/31] REVIEWED: Glyphs --- examples/text/text_draw_3d.c | 41 ++++++++++++++--------------------- examples/text/text_font_sdf.c | 20 ++++++++--------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/examples/text/text_draw_3d.c b/examples/text/text_draw_3d.c index 04b6e18ca..a140b1194 100644 --- a/examples/text/text_draw_3d.c +++ b/examples/text/text_draw_3d.c @@ -454,16 +454,16 @@ void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontS // Character destination rectangle on screen // NOTE: We consider charsPadding on drawing - position.x += (float)(font.chars[index].offsetX - font.charsPadding)/(float)font.baseSize*scale; - position.z += (float)(font.chars[index].offsetY - font.charsPadding)/(float)font.baseSize*scale; + position.x += (float)(font.glyphs[index].offsetX - font.glyphPadding)/(float)font.baseSize*scale; + position.z += (float)(font.glyphs[index].offsetY - font.glyphPadding)/(float)font.baseSize*scale; // Character source rectangle from font texture atlas // NOTE: We consider chars padding when drawing, it could be required for outline/glow shader effects - Rectangle srcRec = { font.recs[index].x - (float)font.charsPadding, font.recs[index].y - (float)font.charsPadding, - font.recs[index].width + 2.0f*font.charsPadding, font.recs[index].height + 2.0f*font.charsPadding }; + Rectangle srcRec = { font.recs[index].x - (float)font.glyphPadding, font.recs[index].y - (float)font.glyphPadding, + font.recs[index].width + 2.0f*font.glyphPadding, font.recs[index].height + 2.0f*font.glyphPadding }; - float width = (float)(font.recs[index].width + 2.0f*font.charsPadding)/(float)font.baseSize*scale; - float height = (float)(font.recs[index].height + 2.0f*font.charsPadding)/(float)font.baseSize*scale; + float width = (float)(font.recs[index].width + 2.0f*font.glyphPadding)/(float)font.baseSize*scale; + float height = (float)(font.recs[index].height + 2.0f*font.glyphPadding)/(float)font.baseSize*scale; if (font.texture.id > 0) { @@ -477,16 +477,11 @@ void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontS const float tw = (srcRec.x+srcRec.width)/font.texture.width; const float th = (srcRec.y+srcRec.height)/font.texture.height; - if (SHOW_LETTER_BOUNDRY) - DrawCubeWiresV((Vector3){ position.x + width/2, position.y, position.z + height/2}, (Vector3){ width, LETTER_BOUNDRY_SIZE, height }, LETTER_BOUNDRY_COLOR); + if (SHOW_LETTER_BOUNDRY) DrawCubeWiresV((Vector3){ position.x + width/2, position.y, position.z + height/2}, (Vector3){ width, LETTER_BOUNDRY_SIZE, height }, LETTER_BOUNDRY_COLOR); -#if defined(RAYLIB_NEW_RLGL) rlCheckRenderBatchLimit(4 + 4*backface); rlSetTexture(font.texture.id); -#else - if (rlCheckBufferLimit(4 + 4*backface)) rlglDraw(); - rlEnableTexture(font.texture.id); -#endif + rlPushMatrix(); rlTranslatef(position.x, position.y, position.z); @@ -512,11 +507,7 @@ void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontS rlEnd(); rlPopMatrix(); -#if defined(RAYLIB_NEW_RLGL) rlSetTexture(0); -#else - rlDisableTexture(); -#endif } } @@ -554,8 +545,8 @@ void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, f DrawTextCodepoint3D(font, codepoint, (Vector3){ position.x + textOffsetX, position.y, position.z + textOffsetY }, fontSize, backface, tint); } - if (font.chars[index].advanceX == 0) textOffsetX += (float)(font.recs[index].width + fontSpacing)/(float)font.baseSize*scale; - else textOffsetX += (float)(font.chars[index].advanceX + fontSpacing)/(float)font.baseSize*scale; + if (font.glyphs[index].advanceX == 0) textOffsetX += (float)(font.recs[index].width + fontSpacing)/(float)font.baseSize*scale; + else textOffsetX += (float)(font.glyphs[index].advanceX + fontSpacing)/(float)font.baseSize*scale; } i += codepointByteCount; // Move text bytes counter to next codepoint @@ -592,8 +583,8 @@ Vector3 MeasureText3D(Font font, const char* text, float fontSize, float fontSpa if (letter != '\n') { - if (font.chars[index].advanceX != 0) textWidth += (font.chars[index].advanceX+fontSpacing)/(float)font.baseSize*scale; - else textWidth += (font.recs[index].width + font.chars[index].offsetX)/(float)font.baseSize*scale; + if (font.glyphs[index].advanceX != 0) textWidth += (font.glyphs[index].advanceX+fontSpacing)/(float)font.baseSize*scale; + else textWidth += (font.recs[index].width + font.glyphs[index].offsetX)/(float)font.baseSize*scale; } else { @@ -670,8 +661,8 @@ void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSiz DrawTextCodepoint3D(font, codepoint, (Vector3){ pos.x + textOffsetX, pos.y, pos.z + textOffsetY }, fontSize, backface, tint); } - if (font.chars[index].advanceX == 0) textOffsetX += (float)(font.recs[index].width + fontSpacing)/(float)font.baseSize*scale; - else textOffsetX += (float)(font.chars[index].advanceX + fontSpacing)/(float)font.baseSize*scale; + if (font.glyphs[index].advanceX == 0) textOffsetX += (float)(font.recs[index].width + fontSpacing)/(float)font.baseSize*scale; + else textOffsetX += (float)(font.glyphs[index].advanceX + fontSpacing)/(float)font.baseSize*scale; } i += codepointByteCount; // Move text bytes counter to next codepoint @@ -714,8 +705,8 @@ Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fon } else { - if (font.chars[index].advanceX != 0) textWidth += (font.chars[index].advanceX+fontSpacing)/(float)font.baseSize*scale; - else textWidth += (font.recs[index].width + font.chars[index].offsetX)/(float)font.baseSize*scale; + if (font.glyphs[index].advanceX != 0) textWidth += (font.glyphs[index].advanceX+fontSpacing)/(float)font.baseSize*scale; + else textWidth += (font.recs[index].width + font.glyphs[index].offsetX)/(float)font.baseSize*scale; } } else diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index 7de7986b3..8a2c0d773 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -39,24 +39,24 @@ int main(void) // Default font generation from TTF font Font fontDefault = { 0 }; fontDefault.baseSize = 16; - fontDefault.charsCount = 95; + fontDefault.glyphCount = 95; // Loading font data from memory data - // Parameters > font size: 16, no chars array provided (0), chars count: 95 (autogenerate chars array) - fontDefault.chars = LoadFontData(fileData, fileSize, 16, 0, 95, FONT_DEFAULT); - // Parameters > chars count: 95, font size: 16, chars padding in image: 4 px, pack method: 0 (default) - Image atlas = GenImageFontAtlas(fontDefault.chars, &fontDefault.recs, 95, 16, 4, 0); + // Parameters > font size: 16, no glyphs array provided (0), glyphs count: 95 (autogenerate chars array) + fontDefault.glyphs = LoadFontData(fileData, fileSize, 16, 0, 95, FONT_DEFAULT); + // Parameters > glyphs count: 95, font size: 16, glyphs padding in image: 4 px, pack method: 0 (default) + Image atlas = GenImageFontAtlas(fontDefault.glyphs, &fontDefault.recs, 95, 16, 4, 0); fontDefault.texture = LoadTextureFromImage(atlas); UnloadImage(atlas); // SDF font generation from TTF font Font fontSDF = { 0 }; fontSDF.baseSize = 16; - fontSDF.charsCount = 95; - // Parameters > font size: 16, no chars array provided (0), chars count: 0 (defaults to 95) - fontSDF.chars = LoadFontData(fileData, fileSize, 16, 0, 0, FONT_SDF); - // Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm) - atlas = GenImageFontAtlas(fontSDF.chars, &fontSDF.recs, 95, 16, 0, 1); + fontSDF.glyphCount = 95; + // Parameters > font size: 16, no glyphs array provided (0), glyphs count: 0 (defaults to 95) + fontSDF.glyphs = LoadFontData(fileData, fileSize, 16, 0, 0, FONT_SDF); + // Parameters > glyphs count: 95, font size: 16, glyphs padding in image: 0 px, pack method: 1 (Skyline algorythm) + atlas = GenImageFontAtlas(fontSDF.glyphs, &fontSDF.recs, 95, 16, 0, 1); fontSDF.texture = LoadTextureFromImage(atlas); UnloadImage(atlas); From 9ff8ad853c77453768c59b5f9ae5206ec63f1bdb Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 2 Sep 2021 00:39:47 +0200 Subject: [PATCH 29/31] Update raygui.h --- src/extras/raygui.h | 379 +++++++++++++++++++++++--------------------- 1 file changed, 196 insertions(+), 183 deletions(-) diff --git a/src/extras/raygui.h b/src/extras/raygui.h index 31b7ca774..5aada37e4 100644 --- a/src/extras/raygui.h +++ b/src/extras/raygui.h @@ -220,14 +220,20 @@ int format; // Data format (PixelFormat type) } Texture2D; - // Font character info - typedef struct GlyphInfo GlyphInfo; + // GlyphInfo, font characters glyphs info + typedef struct GlyphInfo { + int value; // Character value (Unicode) + int offsetX; // Character offset X when drawing + int offsetY; // Character offset Y when drawing + int advanceX; // Character advance position X + Image image; // Character image data + } GlyphInfo; // TODO: Font type is very coupled to raylib, mostly required by GuiLoadStyle() // It should be redesigned to be provided by user typedef struct Font { int baseSize; // Base size (default chars height) - int charsCount; // Number of characters + int glyphCount; // Number of characters Texture2D texture; // Characters texture atlas Rectangle *recs; // Characters rectangles in texture GlyphInfo *chars; // Characters info data @@ -406,7 +412,7 @@ typedef enum { extern "C" { // Prevents name mangling of functions #endif -// State modification functions +// Global gui state control functions RAYGUIDEF void GuiEnable(void); // Enable gui controls (global state) RAYGUIDEF void GuiDisable(void); // Disable gui controls (global state) RAYGUIDEF void GuiLock(void); // Lock gui controls (global state) @@ -1067,7 +1073,7 @@ static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = { #endif // RAYGUI_SUPPORT_RICONS #ifndef RICON_SIZE - #define RICON_SIZE 0 + #define RICON_SIZE 0 #endif #define RAYGUI_MAX_CONTROLS 16 // Maximum number of standard controls @@ -1076,7 +1082,7 @@ static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = { // TODO: Avoid animations and time-based states // Functions using it: GuiTextBox(), GuiValueBox(), GuiTextBoxMulti() -#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming +//#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -1147,14 +1153,14 @@ static Font GetFontDefault(void); // -- GuiLoadStyleDe static Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // -- GetTextWidth(), GuiTextBoxMulti() static void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // -- GuiDrawText() -static Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // -- GuiLoadStyle() +static Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // -- GuiLoadStyle() static char *LoadFileText(const char *fileName); // -- GuiLoadStyle() static const char *GetDirectoryPath(const char *filePath); // -- GuiLoadStyle() //------------------------------------------------------------------------------- // raylib functions already implemented in raygui //------------------------------------------------------------------------------- -static Color GetColor(unsigned int hexValue); // Returns a Color struct from hexadecimal value +static Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value static int ColorToInt(Color color); // Returns hexadecimal value for a Color static Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f static bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle @@ -1594,7 +1600,7 @@ bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rec //-------------------------------------------------------------------- GuiDrawRectangle(bounds, GuiGetStyle(BUTTON, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(BUTTON, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(BUTTON, BASE + (state*3))), guiAlpha)); - if (text != NULL) GuiDrawText(text, GetTextBounds(BUTTON, bounds), GuiGetStyle(BUTTON, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, GetTextBounds(BUTTON, bounds), GuiGetStyle(BUTTON, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha)); if (texture.id > 0) DrawTextureRec(texture, texSource, RAYGUI_CLITERAL(Vector2){ bounds.x + bounds.width/2 - texSource.width/2, bounds.y + bounds.height/2 - texSource.height/2 }, Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha)); //------------------------------------------------------------------ @@ -1654,12 +1660,12 @@ int GuiToggleGroup(Rectangle bounds, const char *text, int active) // Get substrings items from text (items pointers) int rows[TOGGLEGROUP_MAX_ELEMENTS] = { 0 }; - int itemsCount = 0; - const char **items = GuiTextSplit(text, &itemsCount, rows); + int itemCount = 0; + const char **items = GuiTextSplit(text, &itemCount, rows); int prevRow = rows[0]; - for (int i = 0; i < itemsCount; i++) + for (int i = 0; i < itemCount; i++) { if (prevRow != rows[i]) { @@ -1730,7 +1736,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked) GuiDrawRectangle(check, 0, BLANK, Fade(GetColor(GuiGetStyle(CHECKBOX, TEXT + state*3)), guiAlpha)); } - if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- return checked; @@ -1747,15 +1753,15 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) (float)bounds.y, (float)GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH), (float)bounds.height }; // Get substrings items from text (items pointers, lengths and count) - int itemsCount = 0; - const char **items = GuiTextSplit(text, &itemsCount, NULL); + int itemCount = 0; + const char **items = GuiTextSplit(text, &itemCount, NULL); if (active < 0) active = 0; - else if (active > itemsCount - 1) active = itemsCount - 1; + else if (active > itemCount - 1) active = itemCount - 1; // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemsCount > 1)) + if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemCount > 1)) { Vector2 mousePoint = GetMousePosition(); @@ -1765,7 +1771,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { active += 1; - if (active >= itemsCount) active = 0; + if (active >= itemCount) active = 0; } if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; @@ -1787,7 +1793,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) GuiSetStyle(BUTTON, BORDER_WIDTH, 1); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); - GuiButton(selector, TextFormat("%i/%i", active + 1, itemsCount)); + GuiButton(selector, TextFormat("%i/%i", active + 1, itemCount)); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign); GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth); @@ -1805,11 +1811,11 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo int itemFocused = -1; // Get substrings items from text (items pointers, lengths and count) - int itemsCount = 0; - const char **items = GuiTextSplit(text, &itemsCount, NULL); + int itemCount = 0; + const char **items = GuiTextSplit(text, &itemCount, NULL); Rectangle boundsOpen = bounds; - boundsOpen.height = (itemsCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); + boundsOpen.height = (itemCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); Rectangle itemBounds = bounds; @@ -1817,7 +1823,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemsCount > 1)) + if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemCount > 1)) { Vector2 mousePoint = GetMousePosition(); @@ -1835,7 +1841,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo if (CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; // Check focused and selected item - for (int i = 0; i < itemsCount; i++) + for (int i = 0; i < itemCount; i++) { // Update item rectangle y position for next item itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); @@ -1879,7 +1885,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo if (editMode) { // Draw visible items - for (int i = 0; i < itemsCount; i++) + for (int i = 0; i < itemCount; i++) { // Update item rectangle y position for next item itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); @@ -1913,19 +1919,16 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo } // Text Box control, updates input text -// NOTE 1: Requires static variables: framesCounter // NOTE 2: Returns if KEY_ENTER pressed (useful for data validation) bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) { - static int framesCounter = 0; // Blinking cursor counter - GuiControlState state = guiState; bool pressed = false; Rectangle cursor = { bounds.x + GuiGetStyle(TEXTBOX, TEXT_PADDING) + GetTextWidth(text) + 2, bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE), - 1, + 4, (float)GuiGetStyle(DEFAULT, TEXT_SIZE)*2 }; @@ -1938,8 +1941,7 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) if (editMode) { state = GUI_STATE_PRESSED; - framesCounter++; - + int key = GetCharPressed(); // Returns codepoint as Unicode int keyCount = (int)strlen(text); @@ -1950,10 +1952,10 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) if ((GetTextWidth(text) < (maxWidth - GuiGetStyle(DEFAULT, TEXT_SIZE))) && (key >= 32)) { - int byteLength = 0; - const char *textUTF8 = CodepointToUTF8(key, &byteLength); + int byteSize = 0; + const char *textUTF8 = CodepointToUTF8(key, &byteSize); - for (int i = 0; i < byteLength; i++) + for (int i = 0; i < byteSize; i++) { text[keyCount] = textUTF8[i]; keyCount++; @@ -1970,13 +1972,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) { keyCount--; text[keyCount] = '\0'; - framesCounter = 0; - if (keyCount < 0) keyCount = 0; - } - else if (IsKeyDown(KEY_BACKSPACE)) - { - if ((framesCounter > TEXTEDIT_CURSOR_BLINK_FRAMES) && (framesCounter%2) == 0) keyCount--; - text[keyCount] = '\0'; if (keyCount < 0) keyCount = 0; } } @@ -1996,8 +1991,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } } - - if (pressed) framesCounter = 0; } //-------------------------------------------------------------------- @@ -2006,9 +1999,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) if (state == GUI_STATE_PRESSED) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha)); - - // Draw blinking cursor - if (editMode && ((framesCounter/20)%2 == 0)) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha)); } else if (state == GUI_STATE_DISABLED) { @@ -2017,6 +2007,9 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK); GuiDrawText(text, GetTextBounds(TEXTBOX, bounds), GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); + + // Draw cursor + if (editMode) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha)); //-------------------------------------------------------------------- return pressed; @@ -2090,7 +2083,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth); // Draw text label if provided - if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- *value = tempValue; @@ -2098,15 +2091,13 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in } // Value Box control, updates input text with numbers -// NOTE: Requires static variables: framesCounter +// NOTE: Requires static variables: frameCounter bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode) { #if !defined(VALUEBOX_MAX_CHARS) #define VALUEBOX_MAX_CHARS 32 #endif - static int framesCounter = 0; // Blinking cursor counter - GuiControlState state = guiState; bool pressed = false; @@ -2135,8 +2126,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i { state = GUI_STATE_PRESSED; - framesCounter++; - int keyCount = (int)strlen(textValue); // Only allow keys in range [48..57] @@ -2161,14 +2150,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i { keyCount--; textValue[keyCount] = '\0'; - framesCounter = 0; - if (keyCount < 0) keyCount = 0; - valueHasChanged = true; - } - else if (IsKeyDown(KEY_BACKSPACE)) - { - if ((framesCounter > TEXTEDIT_CURSOR_BLINK_FRAMES) && (framesCounter%2) == 0) keyCount--; - textValue[keyCount] = '\0'; if (keyCount < 0) keyCount = 0; valueHasChanged = true; } @@ -2189,8 +2170,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } } - - if (pressed) framesCounter = 0; } //-------------------------------------------------------------------- @@ -2204,16 +2183,16 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i GuiDrawRectangle(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), guiAlpha), baseColor); GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))), guiAlpha)); - // Draw blinking cursor - if ((state == GUI_STATE_PRESSED) && (editMode && ((framesCounter/20)%2 == 0))) + // Draw cursor + if (editMode) { // NOTE: ValueBox internal text is always centered - Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 1, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) }; + Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) }; GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha)); } // Draw text label if provided - if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- return pressed; @@ -2222,8 +2201,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i // Text Box control with multiple lines bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) { - static int framesCounter = 0; // Blinking cursor counter - GuiControlState state = guiState; bool pressed = false; @@ -2235,10 +2212,9 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) }; // Cursor position, [x, y] values should be updated - Rectangle cursor = { 0, 0, 1, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 }; - - int textWidth = 0; - int currentLine = 0; + Rectangle cursor = { 0, -1, 4, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 }; + + float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/(float)guiFont.baseSize; // Character rectangle scaling factor // Update control //-------------------------------------------------------------------- @@ -2249,77 +2225,52 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) if (editMode) { state = GUI_STATE_PRESSED; - framesCounter++; - int character = GetCharPressed(); - int keyCount = (int)strlen(text); + // We get an Unicode codepoint + int codepoint = GetCharPressed(); + int textLength = (int)strlen(text); // Length in bytes (UTF-8 string) // Introduce characters - if (keyCount < (textSize - 1)) + if (textLength < (textSize - 1)) { - Vector2 textSize = MeasureTextEx(guiFont, text, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); - - if (textSize.y < (textAreaBounds.height - GuiGetStyle(DEFAULT, TEXT_SIZE))) + if (IsKeyPressed(KEY_ENTER)) { - if (IsKeyPressed(KEY_ENTER)) - { - text[keyCount] = '\n'; - keyCount++; - } - else if (((character >= 32) && (character < 255))) // TODO: Support Unicode inputs - { - text[keyCount] = (char)character; - keyCount++; - } + text[textLength] = '\n'; + textLength++; + } + else if (codepoint >= 32) + { + // Supports Unicode inputs -> Encoded to UTF-8 + int charUTF8Length = 0; + const char *charEncoded = CodepointToUTF8(codepoint, &charUTF8Length); + memcpy(text + textLength, charEncoded, charUTF8Length); + textLength += charUTF8Length; } } // Delete characters - if (keyCount > 0) + if (textLength > 0) { if (IsKeyPressed(KEY_BACKSPACE)) { - keyCount--; - text[keyCount] = '\0'; - framesCounter = 0; - - if (keyCount < 0) keyCount = 0; - } - else if (IsKeyDown(KEY_BACKSPACE)) - { - if ((framesCounter > TEXTEDIT_CURSOR_BLINK_FRAMES) && (framesCounter%2) == 0) keyCount--; - text[keyCount] = '\0'; - - if (keyCount < 0) keyCount = 0; + if ((unsigned char)text[textLength - 1] < 127) + { + // Remove ASCII equivalent character (1 byte) + textLength--; + text[textLength] = '\0'; + } + else + { + // Remove latest UTF-8 unicode character introduced (n bytes) + int charUTF8Length = 0; + while (((unsigned char)text[textLength - 1 - charUTF8Length] & 0b01000000) == 0) charUTF8Length++; + + textLength -= (charUTF8Length + 1); + text[textLength] = '\0'; + } } } - // Calculate cursor position considering text - char oneCharText[2] = { 0 }; - int lastBreakingPos = -1; - - for (int i = 0; i < keyCount && currentLine < keyCount; i++) - { - oneCharText[0] = text[i]; - textWidth += (GetTextWidth(oneCharText) + GuiGetStyle(DEFAULT, TEXT_SPACING)); - - if (text[i] == ' ' || text[i] == '\n') lastBreakingPos = i; - - if ( text[i] == '\n' || textWidth >= textAreaBounds.width) - { - currentLine++; - textWidth = 0; - - if (lastBreakingPos > 0) i = lastBreakingPos; - else textWidth += (GetTextWidth(oneCharText) + GuiGetStyle(DEFAULT, TEXT_SPACING)); - - lastBreakingPos = -1; - } - } - - cursor.x = bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING) + textWidth - GuiGetStyle(DEFAULT, TEXT_SPACING); - cursor.y = bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)/2 + ((GuiGetStyle(DEFAULT, TEXT_SIZE) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING))*currentLine); - // Exit edit mode if (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } @@ -2331,8 +2282,6 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } } - - if (pressed) framesCounter = 0; // Reset blinking cursor } //-------------------------------------------------------------------- @@ -2341,9 +2290,6 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) if (state == GUI_STATE_PRESSED) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha)); - - // Draw blinking cursor - if (editMode && ((framesCounter/20)%2 == 0)) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha)); } else if (state == GUI_STATE_DISABLED) { @@ -2351,9 +2297,76 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) } else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK); - // TODO: Review to support boxed text with word-wrap - //DrawTextBoxed(guiFont, text, textAreaBounds, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), true, Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); - DrawTextEx(guiFont, text, (Vector2){ textAreaBounds.x, textAreaBounds.y }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); + int wrapMode = 1; // 0-No wrap, 1-Char wrap, 2-Word wrap + Vector2 cursorPos = { textAreaBounds.x, textAreaBounds.y }; + + //int lastSpacePos = 0; + //int lastSpaceWidth = 0; + //int lastSpaceCursorPos = 0; + + for (int i = 0, codepointLength = 0; text[i] != '\0'; i += codepointLength) + { + int codepoint = GetCodepoint(text + i, &codepointLength); + int index = GetGlyphIndex(guiFont, codepoint); // If requested codepoint is not found, we get '?' (0x3f) -> TODO: review that case! + Rectangle atlasRec = guiFont.recs[index]; + GlyphInfo glyphInfo = guiFont.glyphs[index]; // Glyph measures + + if ((codepointLength == 1) && (codepoint == '\n')) + { + cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_PADDING)); // Line feed + cursorPos.x = textAreaBounds.x; // Carriage return + } + else + { + if (wrapMode == 1) + { + int glyphWidth = 0; + if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX; + else glyphWidth += (atlasRec.width + glyphInfo.offsetX); + + // Jump line if the end of the text box area has been reached + if ((cursorPos.x + (glyphWidth*scaleFactor)) > (textAreaBounds.x + textAreaBounds.width)) + { + cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_PADDING)); // Line feed + cursorPos.x = textAreaBounds.x; // Carriage return + } + } + else if (wrapMode == 2) + { + /* + if ((codepointLength == 1) && (codepoint == ' ')) + { + lastSpacePos = i; + lastSpaceWidth = 0; + lastSpaceCursorPos = cursorPos.x; + } + + // Jump line if last word reaches end of text box area + if ((lastSpaceCursorPos + lastSpaceWidth) > (textAreaBounds.x + textAreaBounds.width)) + { + cursorPos.y += 12; // Line feed + cursorPos.x = textAreaBounds.x; // Carriage return + } + */ + } + + // Draw current character glyph + DrawTextCodepoint(guiFont, codepoint, cursorPos, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha)); + + int glyphWidth = 0; + if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX; + else glyphWidth += (atlasRec.width + glyphInfo.offsetX); + + cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); + //if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); + } + } + + cursor.x = cursorPos.x; + cursor.y = cursorPos.y; + + // Draw cursor position considering text glyphs + if (editMode) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha)); //-------------------------------------------------------------------- return pressed; @@ -2698,12 +2711,12 @@ int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue) // List View control int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active) { - int itemsCount = 0; + int itemCount = 0; const char **items = NULL; - if (text != NULL) items = GuiTextSplit(text, &itemsCount, NULL); + if (text != NULL) items = GuiTextSplit(text, &itemCount, NULL); - return GuiListViewEx(bounds, items, itemsCount, NULL, scrollIndex, active); + return GuiListViewEx(bounds, items, itemCount, NULL, scrollIndex, active); } // List View control with extended parameters @@ -3096,12 +3109,12 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons int clicked = -1; // Returns clicked button from buttons list, 0 refers to closed window button - int buttonsCount = 0; - const char **buttonsText = GuiTextSplit(buttons, &buttonsCount, NULL); + int buttonCount = 0; + const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL); Rectangle buttonBounds = { 0 }; buttonBounds.x = bounds.x + MESSAGEBOX_BUTTON_PADDING; buttonBounds.y = bounds.y + bounds.height - MESSAGEBOX_BUTTON_HEIGHT - MESSAGEBOX_BUTTON_PADDING; - buttonBounds.width = (bounds.width - MESSAGEBOX_BUTTON_PADDING*(buttonsCount + 1))/buttonsCount; + buttonBounds.width = (bounds.width - MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount; buttonBounds.height = MESSAGEBOX_BUTTON_HEIGHT; Vector2 textSize = MeasureTextEx(guiFont, message, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), 1); @@ -3124,7 +3137,7 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons prevTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); - for (int i = 0; i < buttonsCount; i++) + for (int i = 0; i < buttonCount; i++) { if (GuiButton(buttonBounds, buttonsText[i])) clicked = i + 1; buttonBounds.x += (buttonBounds.width + MESSAGEBOX_BUTTON_PADDING); @@ -3151,12 +3164,12 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co int btnIndex = -1; - int buttonsCount = 0; - const char **buttonsText = GuiTextSplit(buttons, &buttonsCount, NULL); + int buttonCount = 0; + const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL); Rectangle buttonBounds = { 0 }; buttonBounds.x = bounds.x + TEXTINPUTBOX_BUTTON_PADDING; buttonBounds.y = bounds.y + bounds.height - TEXTINPUTBOX_BUTTON_HEIGHT - TEXTINPUTBOX_BUTTON_PADDING; - buttonBounds.width = (bounds.width - TEXTINPUTBOX_BUTTON_PADDING*(buttonsCount + 1))/buttonsCount; + buttonBounds.width = (bounds.width - TEXTINPUTBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount; buttonBounds.height = TEXTINPUTBOX_BUTTON_HEIGHT; int messageInputHeight = (int)bounds.height - WINDOW_STATUSBAR_HEIGHT - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - TEXTINPUTBOX_BUTTON_HEIGHT - 2*TEXTINPUTBOX_BUTTON_PADDING; @@ -3198,7 +3211,7 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); - for (int i = 0; i < buttonsCount; i++) + for (int i = 0; i < buttonCount; i++) { if (GuiButton(buttonBounds, buttonsText[i])) btnIndex = i + 1; buttonBounds.x += (buttonBounds.width + MESSAGEBOX_BUTTON_PADDING); @@ -3322,20 +3335,20 @@ void GuiLoadStyle(const char *fileName) char *charValues = LoadFileText(charmapFileName); if (charValues != NULL) { - int charsCount = 0; - const char **chars = TextSplit(charValues, '\n', &charsCount); + int glyphCount = 0; + const char **chars = TextSplit(charValues, '\n', &glyphCount); - int *values = (int *)RAYGUI_MALLOC(charsCount*sizeof(int)); - for (int i = 0; i < charsCount; i++) values[i] = TextToInteger(chars[i]); + int *values = (int *)RAYGUI_MALLOC(glyphCount*sizeof(int)); + for (int i = 0; i < glyphCount; i++) values[i] = TextToInteger(chars[i]); - font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, values, charsCount); + font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, values, glyphCount); RAYGUI_FREE(values); } } else font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, NULL, 0); - if ((font.texture.id > 0) && (font.charsCount > 0)) GuiSetFont(font); + if ((font.texture.id > 0) && (font.glyphCount > 0)) GuiSetFont(font); } break; default: break; @@ -3358,12 +3371,12 @@ void GuiLoadStyle(const char *fileName) char signature[5] = ""; short version = 0; short reserved = 0; - int propertiesCount = 0; + int propertyCount = 0; fread(signature, 1, 4, rgsFile); fread(&version, 1, sizeof(short), rgsFile); fread(&reserved, 1, sizeof(short), rgsFile); - fread(&propertiesCount, 1, sizeof(int), rgsFile); + fread(&propertyCount, 1, sizeof(int), rgsFile); if ((signature[0] == 'r') && (signature[1] == 'G') && @@ -3374,7 +3387,7 @@ void GuiLoadStyle(const char *fileName) short propertyId = 0; int propertyValue = 0; - for (int i = 0; i < propertiesCount; i++) + for (int i = 0; i < propertyCount; i++) { fread(&controlId, 1, sizeof(short), rgsFile); fread(&propertyId, 1, sizeof(short), rgsFile); @@ -3405,7 +3418,7 @@ void GuiLoadStyle(const char *fileName) Rectangle whiteRec = { 0 }; fread(&font.baseSize, 1, sizeof(int), rgsFile); - fread(&font.charsCount, 1, sizeof(int), rgsFile); + fread(&font.glyphCount, 1, sizeof(int), rgsFile); fread(&fontType, 1, sizeof(int), rgsFile); // Load font white rectangle @@ -3432,17 +3445,17 @@ void GuiLoadStyle(const char *fileName) } // Load font recs data - font.recs = (Rectangle *)RAYGUI_CALLOC(font.charsCount, sizeof(Rectangle)); - for (int i = 0; i < font.charsCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile); + font.recs = (Rectangle *)RAYGUI_CALLOC(font.glyphCount, sizeof(Rectangle)); + for (int i = 0; i < font.glyphCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile); // Load font chars info data - font.chars = (GlyphInfo *)RAYGUI_CALLOC(font.charsCount, sizeof(GlyphInfo)); - for (int i = 0; i < font.charsCount; i++) + font.glyphs = (GlyphInfo *)RAYGUI_CALLOC(font.glyphCount, sizeof(GlyphInfo)); + for (int i = 0; i < font.glyphCount; i++) { - fread(&font.chars[i].value, 1, sizeof(int), rgsFile); - fread(&font.chars[i].offsetX, 1, sizeof(int), rgsFile); - fread(&font.chars[i].offsetY, 1, sizeof(int), rgsFile); - fread(&font.chars[i].advanceX, 1, sizeof(int), rgsFile); + fread(&font.glyphs[i].value, 1, sizeof(int), rgsFile); + fread(&font.glyphs[i].offsetX, 1, sizeof(int), rgsFile); + fread(&font.glyphs[i].offsetY, 1, sizeof(int), rgsFile); + fread(&font.glyphs[i].advanceX, 1, sizeof(int), rgsFile); } GuiSetFont(font); @@ -3572,7 +3585,7 @@ unsigned int *GuiGetIcons(void) { return guiIcons; } // Load raygui icons file (.rgi) // NOTE: In case nameIds are required, they can be requested with loadIconsName, -// they are returned as a guiIconsName[iconsCount][RICON_MAX_NAME_LENGTH], +// they are returned as a guiIconsName[iconCount][RICON_MAX_NAME_LENGTH], // guiIconsName[]][] memory should be manually freed! char **GuiLoadIcons(const char *fileName, bool loadIconsName) { @@ -3609,14 +3622,14 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName) char signature[5] = ""; short version = 0; short reserved = 0; - short iconsCount = 0; - short iconsSize = 0; + short iconCount = 0; + short iconSize = 0; fread(signature, 1, 4, rgiFile); fread(&version, 1, sizeof(short), rgiFile); fread(&reserved, 1, sizeof(short), rgiFile); - fread(&iconsCount, 1, sizeof(short), rgiFile); - fread(&iconsSize, 1, sizeof(short), rgiFile); + fread(&iconCount, 1, sizeof(short), rgiFile); + fread(&iconSize, 1, sizeof(short), rgiFile); if ((signature[0] == 'r') && (signature[1] == 'G') && @@ -3625,17 +3638,17 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName) { if (loadIconsName) { - guiIconsName = (char **)RAYGUI_MALLOC(iconsCount*sizeof(char **)); - for (int i = 0; i < iconsCount; i++) + guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char **)); + for (int i = 0; i < iconCount; i++) { guiIconsName[i] = (char *)RAYGUI_MALLOC(RICON_MAX_NAME_LENGTH); fread(guiIconsName[i], RICON_MAX_NAME_LENGTH, 1, rgiFile); } } - else fseek(rgiFile, iconsCount*RICON_MAX_NAME_LENGTH, SEEK_CUR); + else fseek(rgiFile, iconCount*RICON_MAX_NAME_LENGTH, SEEK_CUR); // Read icons data directly over guiIcons data array - fread(guiIcons, iconsCount*(iconsSize*iconsSize/32), sizeof(unsigned int), rgiFile); + fread(guiIcons, iconCount*(iconSize*iconSize/32), sizeof(unsigned int), rgiFile); } fclose(rgiFile); @@ -4061,7 +4074,7 @@ static Vector3 ConvertHSVtoRGB(Vector3 hsv) #if defined(RAYGUI_STANDALONE) // Returns a Color struct from hexadecimal value -static Color GetColor(unsigned int hexValue) +static Color GetColor(int hexValue) { Color color; @@ -4186,29 +4199,29 @@ static int TextToInteger(const char *text) return value*sign; } -// Encode codepoint into UTF-8 text (char array length returned as parameter) -static const char *CodepointToUTF8(int codepoint, int *byteLength) +// Encode codepoint into UTF-8 text (char array size returned as parameter) +static const char *CodepointToUTF8(int codepoint, int *byteSize) { static char utf8[6] = { 0 }; - int length = 0; + int size = 0; if (codepoint <= 0x7f) { utf8[0] = (char)codepoint; - length = 1; + size = 1; } else if (codepoint <= 0x7ff) { utf8[0] = (char)(((codepoint >> 6) & 0x1f) | 0xc0); utf8[1] = (char)((codepoint & 0x3f) | 0x80); - length = 2; + size = 2; } else if (codepoint <= 0xffff) { utf8[0] = (char)(((codepoint >> 12) & 0x0f) | 0xe0); utf8[1] = (char)(((codepoint >> 6) & 0x3f) | 0x80); utf8[2] = (char)((codepoint & 0x3f) | 0x80); - length = 3; + size = 3; } else if (codepoint <= 0x10ffff) { @@ -4216,10 +4229,10 @@ static const char *CodepointToUTF8(int codepoint, int *byteLength) utf8[1] = (char)(((codepoint >> 12) & 0x3f) | 0x80); utf8[2] = (char)(((codepoint >> 6) & 0x3f) | 0x80); utf8[3] = (char)((codepoint & 0x3f) | 0x80); - length = 4; + size = 4; } - *byteLength = length; + *byteSize = size; return utf8; } From 93168304cd377fabec9dfa88469f2cc635cd6326 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 3 Sep 2021 15:24:05 +0200 Subject: [PATCH 30/31] Update shell.html --- src/shell.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shell.html b/src/shell.html index aa0210c32..31714f473 100644 --- a/src/shell.html +++ b/src/shell.html @@ -192,7 +192,8 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB