From dbff40944a72df4b5435520fc09f3fb68e3cebdf Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 28 May 2018 00:48:07 +0200 Subject: Corrected issue with floats on TCC It seems TCC was not casting correctly int values to float in some specific situations --- examples/textures/textures_rectangle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/textures') diff --git a/examples/textures/textures_rectangle.c b/examples/textures/textures_rectangle.c index c90db8ac..e1247746 100644 --- a/examples/textures/textures_rectangle.c +++ b/examples/textures/textures_rectangle.c @@ -27,7 +27,7 @@ int main() Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading Vector2 position = { 350.0f, 280.0f }; - Rectangle frameRec = { 0, 0, scarfy.width/6, scarfy.height }; + Rectangle frameRec = { 0.0f, 0.0f, (float)scarfy.width/6, (float)scarfy.height }; int currentFrame = 0; int framesCounter = 0; @@ -50,7 +50,7 @@ int main() if (currentFrame > 5) currentFrame = 0; - frameRec.x = currentFrame*scarfy.width/6; + frameRec.x = (float)currentFrame*(float)scarfy.width/6; } if (IsKeyPressed(KEY_RIGHT)) framesSpeed++; -- cgit v1.2.3 From 64207b11c07649f034631a3d6fa1916619dcb425 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 30 Jun 2018 19:58:08 +0200 Subject: Removed unused textures --- examples/textures/resources/fudesumi_BC1.dds | Bin 98432 -> 0 bytes examples/textures/resources/fudesumi_BC3.dds | Bin 196736 -> 0 bytes examples/textures/resources/fudesumi_ETC2.ktx | Bin 196708 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/textures/resources/fudesumi_BC1.dds delete mode 100644 examples/textures/resources/fudesumi_BC3.dds delete mode 100644 examples/textures/resources/fudesumi_ETC2.ktx (limited to 'examples/textures') diff --git a/examples/textures/resources/fudesumi_BC1.dds b/examples/textures/resources/fudesumi_BC1.dds deleted file mode 100644 index 4a5b21b9..00000000 Binary files a/examples/textures/resources/fudesumi_BC1.dds and /dev/null differ diff --git a/examples/textures/resources/fudesumi_BC3.dds b/examples/textures/resources/fudesumi_BC3.dds deleted file mode 100644 index 0bf9c1de..00000000 Binary files a/examples/textures/resources/fudesumi_BC3.dds and /dev/null differ diff --git a/examples/textures/resources/fudesumi_ETC2.ktx b/examples/textures/resources/fudesumi_ETC2.ktx deleted file mode 100644 index a0523770..00000000 Binary files a/examples/textures/resources/fudesumi_ETC2.ktx and /dev/null differ -- cgit v1.2.3 From afe81d94cebd0f803327743c867a38b1dceffe76 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 30 Jun 2018 19:58:44 +0200 Subject: Re-added: LoadFontEx() --- examples/textures/textures_image_text.c | 2 +- src/raylib.h | 1 + src/text.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'examples/textures') diff --git a/examples/textures/textures_image_text.c b/examples/textures/textures_image_text.c index 0a939b8d..78d25c14 100644 --- a/examples/textures/textures_image_text.c +++ b/examples/textures/textures_image_text.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing"); // TTF Font loading with custom generation parameters - Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0); + Font font = LoadFontEx("resources/KAISG.ttf", 64, 95, 0); Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) diff --git a/src/raylib.h b/src/raylib.h index eeadbbb7..924d1299 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -965,6 +965,7 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest // Font loading/unloading functions RLAPI Font GetDefaultFont(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 charsCount, int *fontChars); // Load font from file with extended parameters RLAPI CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, bool sdf); // Load font data for further use RLAPI Image GenImageFontAtlas(CharInfo *chars, int fontSize, int charsCount, int padding, int packMethod); // Generate image font atlas using chars info RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM) diff --git a/src/text.c b/src/text.c index 5e02a471..c895540b 100644 --- a/src/text.c +++ b/src/text.c @@ -310,6 +310,23 @@ Font LoadFont(const char *fileName) return font; } +// 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 charsCount, int *fontChars) +{ + Font font = { 0 }; + + font.baseSize = fontSize; + font.charsCount = (charsCount > 0) ? charsCount : 95; + font.chars = LoadFontData(fileName, font.baseSize, fontChars, font.charsCount, false); + Image atlas = GenImageFontAtlas(font.chars, font.charsCount, font.baseSize, 0, 0); + font.texture = LoadTextureFromImage(atlas); + UnloadImage(atlas); + + return font; +} + // Load font data for further use // NOTE: Requires TTF font and can generate SDF data CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, bool sdf) -- cgit v1.2.3