From 8f5ff64420dda659583c156b9c5e42e60384e247 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 19 Mar 2017 12:52:58 +0100 Subject: Working on file header comments... --- src/audio.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 659ead0f..e0964e02 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,26 +1,24 @@ /********************************************************************************************** * -* raylib.audio +* raylib.audio - Basic funtionality to work with audio * -* This module provides basic functionality to work with audio: -* Manage audio device (init/close) -* Load and Unload audio files (WAV, OGG, FLAC, XM, MOD) -* Play/Stop/Pause/Resume loaded audio -* Manage mixing channels -* Manage raw audio context +* DESCRIPTION: * -* NOTES: -* -* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS) -* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32) +* This module provides basic functionality to: +* - Manage audio device (init/close) +* - Load and unload audio files +* - Format wave data (sample rate, size, channels) +* - Play/Stop/Pause/Resume loaded audio +* - Manage mixing channels +* - Manage raw audio context * * CONFIGURATION: * * #define AUDIO_STANDALONE -* If defined, the module can be used as standalone library (independently of raylib). +* Define to use the module as standalone library (independently of raylib). * Required types and functions are defined in the same module. * -* #define SUPPORT_FILEFORMAT_WAV / SUPPORT_LOAD_WAV / ENABLE_LOAD_WAV +* #define SUPPORT_FILEFORMAT_WAV / SUPPORT_LOAD_WAV * #define SUPPORT_FILEFORMAT_OGG * #define SUPPORT_FILEFORMAT_XM * #define SUPPORT_FILEFORMAT_MOD @@ -29,6 +27,12 @@ * supported by default, to remove support, just comment unrequired #define in this module * * #define SUPPORT_RAW_AUDIO_BUFFERS +* Support creating raw audio buffers to send raw data. Buffers must be managed by the user, +* it means initialization, refilling and cleaning. +* +* LIMITATIONS: +* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS) +* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32) * * DEPENDENCIES: * OpenAL Soft - Audio device management (http://kcat.strangesoft.net/openal.html) @@ -38,12 +42,11 @@ * dr_flac - FLAC audio file loading * * CONTRIBUTORS: -* -* Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: -* XM audio module support (jar_xm) -* MOD audio module support (jar_mod) -* Mixing channels support -* Raw audio context support +* Joshua Reisenauer (github: @kd7tck): +* - XM audio module support (jar_xm) +* - MOD audio module support (jar_mod) +* - Mixing channels support +* - Raw audio context support * * * LICENSE: zlib/libpng -- cgit v1.2.3 From 59652c75b43d0437217c0000b03428545905801e Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 20 Mar 2017 20:34:44 +0100 Subject: Review some comments --- src/audio.c | 18 ++++++++---------- src/audio.h | 2 +- src/camera.h | 4 ++-- src/core.c | 18 +++++++++--------- src/gestures.h | 4 ++-- src/models.c | 2 +- src/raylib.h | 2 +- src/raymath.h | 2 +- src/rlgl.c | 47 ++++++++++++++++++----------------------------- src/rlgl.h | 45 +++++++++++++++++++++++++++++++-------------- src/rres.h | 4 +--- src/shapes.c | 2 +- src/text.c | 2 +- src/textures.c | 2 +- src/utils.c | 2 +- src/utils.h | 7 ++++--- 16 files changed, 83 insertions(+), 80 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index e0964e02..68bd88e9 100644 --- a/src/audio.c +++ b/src/audio.c @@ -2,15 +2,13 @@ * * raylib.audio - Basic funtionality to work with audio * -* DESCRIPTION: -* -* This module provides basic functionality to: -* - Manage audio device (init/close) -* - Load and unload audio files -* - Format wave data (sample rate, size, channels) -* - Play/Stop/Pause/Resume loaded audio -* - Manage mixing channels -* - Manage raw audio context +* FEATURES: +* - Manage audio device (init/close) +* - Load and unload audio files +* - Format wave data (sample rate, size, channels) +* - Play/Stop/Pause/Resume loaded audio +* - Manage mixing channels +* - Manage raw audio context * * CONFIGURATION: * @@ -51,7 +49,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/audio.h b/src/audio.h index a0279e3a..8047d9bb 100644 --- a/src/audio.h +++ b/src/audio.h @@ -29,7 +29,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/camera.h b/src/camera.h index 87ba1942..e1b00ac2 100644 --- a/src/camera.h +++ b/src/camera.h @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib Camera System - Camera Modes Setup and Control Functions +* raylib.camera - Camera system with multiple modes support * * NOTE: Memory footprint of this library is aproximately 52 bytes (global variables) * @@ -22,7 +22,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2015-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2015-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/core.c b/src/core.c index f55a70db..5b892cdf 100644 --- a/src/core.c +++ b/src/core.c @@ -2,14 +2,14 @@ * * raylib.core - Basic functions to manage windows, OpenGL context and input on multiple platforms * -* The following platforms are supported: -* Windows (win32/Win64) -* Linux (tested on Ubuntu) -* Mac (OSX) -* Android (API Level 9 or greater) -* Raspberry Pi (Raspbian) -* HTML5 (Chrome, Firefox) -* Oculus Rift CV1 +* PLATFORMS SUPPORTED: +* - Windows (win32/Win64) +* - Linux (tested on Ubuntu) +* - Mac (OSX) +* - Android (API Level 9 or greater) +* - Raspberry Pi (Raspbian) +* - HTML5 (Chrome, Firefox) +* - Oculus Rift CV1 * * CONFIGURATION: * @@ -49,7 +49,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/gestures.h b/src/gestures.h index 99f49d2a..42ced889 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib Gestures System - Gestures Processing based on input gesture events (touch/mouse) +* raylib.gestures - Gestures system, gestures processing based on input events (touch/mouse) * * NOTE: Memory footprint of this library is aproximately 128 bytes (global variables) * @@ -24,7 +24,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/models.c b/src/models.c index 8297358b..67e1693c 100644 --- a/src/models.c +++ b/src/models.c @@ -13,7 +13,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/raylib.h b/src/raylib.h index 4fd4b5df..cdefceb2 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -47,7 +47,7 @@ * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software: * -* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/raymath.h b/src/raymath.h index a2263f19..7e760957 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raymath v1.0 - Some useful functions to work with Vector3, Matrix and Quaternions +* raymath v1.0 - Math functions to work with Vector3, Matrix and Quaternions * * CONFIGURATION: * diff --git a/src/rlgl.c b/src/rlgl.c index 00998624..d76f90bb 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -2,10 +2,8 @@ * * rlgl - raylib OpenGL abstraction layer * -* DESCRIPTION: -* -* rlgl allows usage of OpenGL 1.1 style functions (rlVertex) that are internally mapped to -* selected OpenGL version (1.1, 2.1, 3.3 Core, ES 2.0). +* rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to +* pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...). * * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal * VBO buffers (and VAOs if available). It requires calling 3 functions: @@ -16,32 +14,19 @@ * CONFIGURATION: * * #define GRAPHICS_API_OPENGL_11 -* Use OpenGL 1.1 backend -* * #define GRAPHICS_API_OPENGL_21 -* Use OpenGL 2.1 backend -* * #define GRAPHICS_API_OPENGL_33 -* Use OpenGL 3.3 Core profile backend -* * #define GRAPHICS_API_OPENGL_ES2 -* Use OpenGL ES 2.0 backend +* Use selected OpenGL backend * * #define RLGL_STANDALONE * Use rlgl as standalone library (no raylib dependency) * -* #define RLGL_NO_DISTORTION_SHADER -* Avoid stereo rendering distortion sahder (shader_distortion.h) inclusion -* -* #define SUPPORT_SHADER_DEFAULT / ENABLE_SHADER_DEFAULT +* #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING +* Support VR simulation functionality (stereo rendering) * * #define SUPPORT_SHADER_DISTORTION -* -* #define SUPPORT_VR_SIMULATION -* -* #define SUPPORT_STEREO_RENDERING -* -* #define RLGL_NO_DEFAULT_SHADER +* Include stereo rendering distortion shader (shader_distortion.h) * * DEPENDENCIES: * raymath - 3D math functionality (Vector3, Matrix, Quaternion) @@ -50,7 +35,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. @@ -295,6 +280,13 @@ static bool texCompETC1Supported = false; // ETC1 texture compression support static bool texCompETC2Supported = false; // ETC2/EAC texture compression support static bool texCompPVRTSupported = false; // PVR texture compression support static bool texCompASTCSupported = false; // ASTC texture compression support + +// VR global variables +static VrDeviceInfo hmd; // Current VR device info +static VrStereoConfig vrConfig; // VR stereo configuration for simulator +static bool vrSimulatorReady = false; // VR simulator ready flag +static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag + // NOTE: This flag is useful to render data over stereo image (i.e. FPS) #endif // Extension supported flag: Anisotropic filtering @@ -304,13 +296,6 @@ static float maxAnisotropicLevel = 0.0f; // Maximum anisotropy level supp // Extension supported flag: Clamp mirror wrap mode static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported -// VR global variables -static VrDeviceInfo hmd; // Current VR device info -static VrStereoConfig vrConfig; // VR stereo configuration for simulator -static bool vrSimulatorReady = false; // VR simulator ready flag -static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag - // NOTE: This flag is useful to render data over stereo image (i.e. FPS) - #if defined(GRAPHICS_API_OPENGL_ES2) // NOTE: VAO functionality is exposed through extensions (OES) static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays; @@ -2636,7 +2621,11 @@ void CloseVrSimulator(void) // Detect if VR simulator is running bool IsVrSimulatorReady(void) { +#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) return vrSimulatorReady; +#else + return false; +#endif } // Enable/Disable VR experience (device or simulator) diff --git a/src/rlgl.h b/src/rlgl.h index 344da987..a870a907 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -2,8 +2,8 @@ * * rlgl - raylib OpenGL abstraction layer * -* rlgl allows usage of OpenGL 1.1 style functions (rlVertex) that are internally mapped to -* selected OpenGL version (1.1, 2.1, 3.3 Core, ES 2.0). +* rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to +* pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...). * * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal * VBO buffers (and VAOs if available). It requires calling 3 functions: @@ -11,18 +11,29 @@ * rlglDraw() - Process internal buffers and send required draw calls * rlglClose() - De-initialize internal buffers data and other auxiliar resources * -* External libs: +* CONFIGURATION: +* +* #define GRAPHICS_API_OPENGL_11 +* #define GRAPHICS_API_OPENGL_21 +* #define GRAPHICS_API_OPENGL_33 +* #define GRAPHICS_API_OPENGL_ES2 +* Use selected OpenGL backend +* +* #define RLGL_STANDALONE +* Use rlgl as standalone library (no raylib dependency) +* +* #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING +* Support VR simulation functionality (stereo rendering) +* +* #define SUPPORT_SHADER_DISTORTION +* Include stereo rendering distortion shader (shader_distortion.h) +* +* DEPENDENCIES: * raymath - 3D math functionality (Vector3, Matrix, Quaternion) * GLAD - OpenGL extensions loading (OpenGL 3.3 Core only) * -* Module Configuration Flags: -* GRAPHICS_API_OPENGL_11 - Use OpenGL 1.1 backend -* GRAPHICS_API_OPENGL_21 - Use OpenGL 2.1 backend -* GRAPHICS_API_OPENGL_33 - Use OpenGL 3.3 Core profile backend -* GRAPHICS_API_OPENGL_ES2 - Use OpenGL ES 2.0 backend -* -* RLGL_STANDALONE - Use rlgl as standalone library (no raylib dependency) * +* LICENSE: zlib/libpng * * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * @@ -124,15 +135,21 @@ #define RL_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE #define RL_WRAP_CLAMP_MIRROR 0x8742 // GL_MIRROR_CLAMP_EXT +// Matrix modes (equivalent to OpenGL) +#define RL_MODELVIEW 0x1700 // GL_MODELVIEW +#define RL_PROJECTION 0x1701 // GL_PROJECTION +#define RL_TEXTURE 0x1702 // GL_TEXTURE + +// Primitive assembly draw modes +#define RL_LINES 0x0001 // GL_LINES +#define RL_TRIANGLES 0x0004 // GL_TRIANGLES +#define RL_QUADS 0x0007 // GL_QUADS + //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- typedef enum { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } GlVersion; -typedef enum { RL_PROJECTION, RL_MODELVIEW, RL_TEXTURE } MatrixMode; - -typedef enum { RL_LINES, RL_TRIANGLES, RL_QUADS } DrawMode; - typedef unsigned char byte; #if defined(RLGL_STANDALONE) diff --git a/src/rres.h b/src/rres.h index 362da10d..65ebdbba 100644 --- a/src/rres.h +++ b/src/rres.h @@ -1,8 +1,6 @@ /********************************************************************************************** * -* rres - raylib Resource custom format management functions -* -* Basic functions to load/save rRES resource files +* rres v1.0 - raylib resource (rRES) custom fileformat management functions * * CONFIGURATION: * diff --git a/src/shapes.c b/src/shapes.c index 5ed633f6..2a924476 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -13,7 +13,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/text.c b/src/text.c index 18ebf482..2d249b6d 100644 --- a/src/text.c +++ b/src/text.c @@ -18,7 +18,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/textures.c b/src/textures.c index 7db3bf56..f323f352 100644 --- a/src/textures.c +++ b/src/textures.c @@ -31,7 +31,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/utils.c b/src/utils.c index 54923e34..4d30cbc7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -25,7 +25,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. diff --git a/src/utils.h b/src/utils.h index 037d7e94..45ffcf81 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,10 +1,11 @@ /********************************************************************************************** * -* raylib.utils +* raylib.utils - Some common utility functions * -* Some utility functions * -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) +* LICENSE: zlib/libpng +* +* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. -- cgit v1.2.3 From 0c16af01e543cdf8c787ed65a022cc89f42b3ef9 Mon Sep 17 00:00:00 2001 From: RDR8 Date: Sat, 25 Mar 2017 20:41:04 -0500 Subject: Replaced font.size with font.baseSize. Uncommented linux libs. Typo or two --- games/drturtle/04_drturtle_gui.c | 20 ++++----- games/drturtle/05_drturtle_audio.c | 20 ++++----- games/drturtle/06_drturtle_final.c | 20 ++++----- games/drturtle/drturtle_final_web.c | 20 ++++----- games/drturtle/makefile | 4 +- games/just_do/makefile | 2 +- games/light_my_ritual/makefile | 9 ++-- games/light_my_ritual/screens/screen_gameplay.c | 6 +-- games/light_my_ritual/screens/screen_title.c | 4 +- games/raylib_demo/makefile | 2 +- games/raylib_demo/raylib_demo.c | 58 ++++++++++++------------- games/skully_escape/makefile | 2 +- games/skully_escape/screens/screen_aisle01.c | 8 ++-- games/skully_escape/screens/screen_aisle02.c | 8 ++-- games/skully_escape/screens/screen_armory.c | 8 ++-- games/skully_escape/screens/screen_attic.c | 8 ++-- games/skully_escape/screens/screen_bathroom.c | 8 ++-- games/skully_escape/screens/screen_ending.c | 6 +-- games/skully_escape/screens/screen_kitchen.c | 8 ++-- games/skully_escape/screens/screen_livingroom.c | 8 ++-- src/audio.c | 2 +- 21 files changed, 117 insertions(+), 114 deletions(-) (limited to 'src/audio.c') diff --git a/games/drturtle/04_drturtle_gui.c b/games/drturtle/04_drturtle_gui.c index 081ba437..5be8f1f1 100644 --- a/games/drturtle/04_drturtle_gui.c +++ b/games/drturtle/04_drturtle_gui.c @@ -338,7 +338,7 @@ int main() DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 0, WHITE); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); } break; case GAMEPLAY: @@ -388,8 +388,8 @@ int main() DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangleLines(20, 20, 400, 40, BLACK); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); if (gameraMode) { @@ -403,15 +403,15 @@ int main() // Draw a transparent black rectangle that covers all screen DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); + DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); } break; default: break; @@ -444,4 +444,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} diff --git a/games/drturtle/05_drturtle_audio.c b/games/drturtle/05_drturtle_audio.c index f3660633..3645c657 100644 --- a/games/drturtle/05_drturtle_audio.c +++ b/games/drturtle/05_drturtle_audio.c @@ -354,7 +354,7 @@ int main() DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 0, WHITE); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); } break; case GAMEPLAY: @@ -404,8 +404,8 @@ int main() DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangleLines(20, 20, 400, 40, BLACK); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); if (gameraMode) { @@ -419,15 +419,15 @@ int main() // Draw a transparent black rectangle that covers all screen DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); + DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); } break; default: break; @@ -468,4 +468,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} diff --git a/games/drturtle/06_drturtle_final.c b/games/drturtle/06_drturtle_final.c index b75cce81..2edebe87 100644 --- a/games/drturtle/06_drturtle_final.c +++ b/games/drturtle/06_drturtle_final.c @@ -379,7 +379,7 @@ int main() DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 0, WHITE); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); } break; case GAMEPLAY: @@ -429,8 +429,8 @@ int main() DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangleLines(20, 20, 400, 40, BLACK); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); if (gameraMode) { @@ -444,15 +444,15 @@ int main() // Draw a transparent black rectangle that covers all screen DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); + DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); } break; default: break; @@ -493,4 +493,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} diff --git a/games/drturtle/drturtle_final_web.c b/games/drturtle/drturtle_final_web.c index 21e8067a..84f3b1c2 100644 --- a/games/drturtle/drturtle_final_web.c +++ b/games/drturtle/drturtle_final_web.c @@ -460,7 +460,7 @@ void UpdateDrawFrame(void) DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 1, WHITE); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 1, WHITE); } break; case GAMEPLAY: @@ -510,8 +510,8 @@ void UpdateDrawFrame(void) DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangleLines(20, 20, 400, 40, BLACK); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); if (gameraMode) { @@ -525,15 +525,15 @@ void UpdateDrawFrame(void) // Draw a transparent black rectangle that covers all screen DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); + DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); + DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); + DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); + DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); + if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); } break; default: break; @@ -541,4 +541,4 @@ void UpdateDrawFrame(void) EndDrawing(); //---------------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/games/drturtle/makefile b/games/drturtle/makefile index 52f95c77..ab7fd206 100644 --- a/games/drturtle/makefile +++ b/games/drturtle/makefile @@ -66,7 +66,7 @@ endif ifeq ($(PLATFORM),PLATFORM_RPI) CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline else - CFLAGS = -O2 -Wall -std=c99 + CFLAGS = -O2 -Wall -std=c99 endif ifeq ($(PLATFORM),PLATFORM_WEB) CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources -s ALLOW_MEMORY_GROWTH=1 --shell-file ../../templates/web_shell/shell.html @@ -114,7 +114,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl # on XWindow could require also below libraries, just uncomment - #LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor else ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling diff --git a/games/just_do/makefile b/games/just_do/makefile index a3b5da2d..6bb973c0 100644 --- a/games/just_do/makefile +++ b/games/just_do/makefile @@ -119,7 +119,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl # on XWindow could require also below libraries, just uncomment - #LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor else ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling diff --git a/games/light_my_ritual/makefile b/games/light_my_ritual/makefile index b86809c3..f3763858 100644 --- a/games/light_my_ritual/makefile +++ b/games/light_my_ritual/makefile @@ -68,7 +68,7 @@ endif ifeq ($(PLATFORM),PLATFORM_RPI) CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline else - CFLAGS = -O2 -Wall -std=c99 + CFLAGS = -O2 -Wall -std=c99 -D_DEFAULT_SOURCE endif ifeq ($(PLATFORM),PLATFORM_WEB) CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources -s ALLOW_MEMORY_GROWTH=1 --shell-file ../../templates/web_shell/shell.html @@ -114,14 +114,17 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # libraries for Debian GNU/Linux desktop compiling # requires the following packages: # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal + LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -lpthread -ldl + # on XWindow could require also below libraries, just uncomment + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor endif ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling # requires the following packages: # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa - else + endif + ifeq ($(PLATFORM_OS),WINDOWS) # libraries for Windows desktop compiling # NOTE: GLFW3 and OpenAL Soft libraries should be installed LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 diff --git a/games/light_my_ritual/screens/screen_gameplay.c b/games/light_my_ritual/screens/screen_gameplay.c index ae929013..a2e70f89 100644 --- a/games/light_my_ritual/screens/screen_gameplay.c +++ b/games/light_my_ritual/screens/screen_gameplay.c @@ -687,7 +687,7 @@ void DrawGameplayScreen(void) } // Draw time left for ritual - DrawTextEx(font, FormatText("%02.2f", (99.0f - ritualTime)), (Vector2){ 560, 20 }, font.size, 0, WHITE); + DrawTextEx(font, FormatText("%02.2f", (99.0f - ritualTime)), (Vector2){ 560, 20 }, font.baseSize, 0, WHITE); // Draw light energy bar DrawRectangle(20, 30, 400, 20, GRAY); @@ -703,7 +703,7 @@ void DrawGameplayScreen(void) // Show message: "You run out of light!!!" if player.lightEnergy <= 0 if (player.lightEnergy < 2) { - if ((framesCounter/20)%2) DrawTextEx(font, "YOU'RE RUNNING OUT OF LIGHT!", (Vector2){ 20, 60 }, font.size/2, 0, WHITE); + if ((framesCounter/20)%2) DrawTextEx(font, "YOU'RE RUNNING OUT OF LIGHT!", (Vector2){ 20, 60 }, 24/2, 0, WHITE); } } else if (!timeOver) // LEVEL_FINISHED @@ -846,4 +846,4 @@ static void EnemyReset(Enemy *enemy) enemy->speed = (float)GetRandomValue(8, 18)/10.0f; enemy->awakeFramesDelay = GetRandomValue(180, 1200); } -} \ No newline at end of file +} diff --git a/games/light_my_ritual/screens/screen_title.c b/games/light_my_ritual/screens/screen_title.c index 8f40c8c5..a6f3dfb2 100644 --- a/games/light_my_ritual/screens/screen_title.c +++ b/games/light_my_ritual/screens/screen_title.c @@ -85,7 +85,7 @@ void DrawTitleScreen(void) DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 20, GetScreenHeight() - 40, 20, LIGHTGRAY); - if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawTextEx(font, "PRESS ENTER to START LIGHTING", (Vector2){ 230, 450 }, font.size, -2, WHITE); + if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawTextEx(font, "PRESS ENTER to START LIGHTING", (Vector2){ 230, 450 }, 24, -2, WHITE); } // Title Screen Unload logic @@ -102,4 +102,4 @@ void UnloadTitleScreen(void) int FinishTitleScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/raylib_demo/makefile b/games/raylib_demo/makefile index 7a5737ac..4e8a9b1c 100644 --- a/games/raylib_demo/makefile +++ b/games/raylib_demo/makefile @@ -119,7 +119,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl # on XWindow could require also below libraries, just uncomment - #LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor else ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling diff --git a/games/raylib_demo/raylib_demo.c b/games/raylib_demo/raylib_demo.c index b1267c26..62f26c3f 100644 --- a/games/raylib_demo/raylib_demo.c +++ b/games/raylib_demo/raylib_demo.c @@ -709,11 +709,11 @@ void UpdateDrawOneFrame(void) { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x5c5a5aff)); - DrawTextEx(fontRomulus, "Open-Close Window", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); - DrawTextEx(fontRomulus, "Manage Drawing Area", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); - DrawTextEx(fontRomulus, "Manage Inputs", (Vector2){ 48, 290 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); - DrawTextEx(fontRomulus, "Manage Timming", (Vector2){ 48, 320 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); - DrawTextEx(fontRomulus, "Auxiliar Functions", (Vector2){ 48, 350 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); + DrawTextEx(fontRomulus, "Open-Close Window", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff)); + DrawTextEx(fontRomulus, "Manage Drawing Area", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff)); + DrawTextEx(fontRomulus, "Manage Inputs", (Vector2){ 48, 290 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff)); + DrawTextEx(fontRomulus, "Manage Timming", (Vector2){ 48, 320 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff)); + DrawTextEx(fontRomulus, "Auxiliar Functions", (Vector2){ 48, 350 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff)); switch (coreWindow) { @@ -739,16 +739,16 @@ void UpdateDrawOneFrame(void) if (framesCounter > 140) { - DrawTextEx(fontMecha, "MOVE ME", (Vector2){ ballPosition.x - 26, ballPosition.y - 20 }, fontMecha.size, 2, BLACK); - DrawTextEx(fontMecha, "[ W A S D ]", (Vector2){ ballPosition.x - 36, ballPosition.y }, fontMecha.size, 2, BLACK); + DrawTextEx(fontMecha, "MOVE ME", (Vector2){ ballPosition.x - 26, ballPosition.y - 20 }, fontMecha.baseSize, 2, BLACK); + DrawTextEx(fontMecha, "[ W A S D ]", (Vector2){ ballPosition.x - 36, ballPosition.y }, fontMecha.baseSize, 2, BLACK); } } break; case SHAPES: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0xcd5757ff)); - DrawTextEx(fontRomulus, "Draw Basic Shapes", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0xcd5757ff)); - DrawTextEx(fontRomulus, "Basic Collision Detection", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0xcd5757ff)); + DrawTextEx(fontRomulus, "Draw Basic Shapes", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0xcd5757ff)); + DrawTextEx(fontRomulus, "Basic Collision Detection", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0xcd5757ff)); DrawCircle(screenWidth/4, 120 + 240, 35, DARKBLUE); DrawCircleGradient(screenWidth/4, 220 + 240, 60, GREEN, SKYBLUE); @@ -769,8 +769,8 @@ void UpdateDrawOneFrame(void) { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x60815aff)); - DrawTextEx(fontRomulus, "Load Images and Textures", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x60815aff)); - DrawTextEx(fontRomulus, "Draw Textures", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x60815aff)); + DrawTextEx(fontRomulus, "Load Images and Textures", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x60815aff)); + DrawTextEx(fontRomulus, "Draw Textures", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x60815aff)); DrawRectangle(138, 348, 260, 260, GRAY); DrawTexturePro(lena, (Rectangle){ 0, 0, lena.width, lena.height }, (Rectangle){ 140 + 128, 350 + 128, lena.width/2*scaleFactor, lena.height/2*scaleFactor }, (Vector2){ lena.width/4*scaleFactor, lena.height/4*scaleFactor }, 0.0f, WHITE); @@ -786,21 +786,21 @@ void UpdateDrawOneFrame(void) { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x377764ff)); - DrawTextEx(fontRomulus, "Load SpriteFonts", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x377764ff)); - DrawTextEx(fontRomulus, "Draw Text", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x377764ff)); - DrawTextEx(fontRomulus, "Text Formatting", (Vector2){ 48, 290 }, fontRomulus.size*2, 4, GetColor(0x377764ff)); + DrawTextEx(fontRomulus, "Load SpriteFonts", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x377764ff)); + DrawTextEx(fontRomulus, "Draw Text", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x377764ff)); + DrawTextEx(fontRomulus, "Text Formatting", (Vector2){ 48, 290 }, fontRomulus.baseSize*2, 4, GetColor(0x377764ff)); DrawTexture(texAlagard, 60, 360, WHITE); - DrawTextEx(fontMechaC, msg1, (Vector2){ 540 + 168, 210 }, fontMechaC.size, -3, WHITE); - DrawTextEx(fontAlagardC, msg2, (Vector2){ 460 + 140, 260 }, fontAlagardC.size, -2, WHITE); - DrawTextEx(fontJupiterC, msg3, (Vector2){ 640 + 70, 300 }, fontJupiterC.size, 2, WHITE); + DrawTextEx(fontMechaC, msg1, (Vector2){ 540 + 168, 210 }, fontMechaC.baseSize, -3, WHITE); + DrawTextEx(fontAlagardC, msg2, (Vector2){ 460 + 140, 260 }, fontAlagardC.baseSize, -2, WHITE); + DrawTextEx(fontJupiterC, msg3, (Vector2){ 640 + 70, 300 }, fontJupiterC.baseSize, 2, WHITE); - DrawTextEx(fontAlagard, "It also includes some...", (Vector2){ 650 + 70, 400 }, fontAlagard.size*2, 2, MAROON); - DrawTextEx(fontPixelplay, "...free fonts in rBMF format...", (Vector2){ 705 - 26, 450 }, fontPixelplay.size*2, 4, ORANGE); - DrawTextEx(fontMecha, "...to be used even in...", (Vector2){ 700 + 40, 500 }, fontMecha.size*2, 4, DARKGREEN); - DrawTextEx(fontSetback, "...comercial projects...", (Vector2){ 710, 550 }, fontSetback.size*2, 4, DARKBLUE); - DrawTextEx(fontRomulus, "...completely for free!", (Vector2){ 710 + 17, 600 }, fontRomulus.size*2, 3, DARKPURPLE); + DrawTextEx(fontAlagard, "It also includes some...", (Vector2){ 650 + 70, 400 }, fontAlagard.baseSize*2, 2, MAROON); + DrawTextEx(fontPixelplay, "...free fonts in rBMF format...", (Vector2){ 705 - 26, 450 }, fontPixelplay.baseSize*2, 4, ORANGE); + DrawTextEx(fontMecha, "...to be used even in...", (Vector2){ 700 + 40, 500 }, fontMecha.baseSize*2, 4, DARKGREEN); + DrawTextEx(fontSetback, "...commercial projects...", (Vector2){ 710, 550 }, fontSetback.baseSize*2, 4, DARKBLUE); + DrawTextEx(fontRomulus, "...completely for free!", (Vector2){ 710 + 17, 600 }, fontRomulus.baseSize*2, 3, DARKPURPLE); DrawText("This is a custom font spritesheet, raylib can load it automatically!", 228, 360 + 295, 10, GRAY); @@ -809,9 +809,9 @@ void UpdateDrawOneFrame(void) { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x417794ff)); - DrawTextEx(fontRomulus, "Draw Geometric Models", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x417794ff)); - DrawTextEx(fontRomulus, "Load 3D Models", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x417794ff)); - DrawTextEx(fontRomulus, "Draw 3D Models", (Vector2){ 48, 290 }, fontRomulus.size*2, 4, GetColor(0x417794ff)); + DrawTextEx(fontRomulus, "Draw Geometric Models", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x417794ff)); + DrawTextEx(fontRomulus, "Load 3D Models", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x417794ff)); + DrawTextEx(fontRomulus, "Draw 3D Models", (Vector2){ 48, 290 }, fontRomulus.baseSize*2, 4, GetColor(0x417794ff)); Begin3dMode(camera); @@ -843,8 +843,8 @@ void UpdateDrawOneFrame(void) { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x8c7539ff)); - DrawTextEx(fontRomulus, "Load and Play Sounds", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x8c7539ff)); - DrawTextEx(fontRomulus, "Play Music (streaming)", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x8c7539ff)); + DrawTextEx(fontRomulus, "Load and Play Sounds", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x8c7539ff)); + DrawTextEx(fontRomulus, "Play Music (streaming)", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x8c7539ff)); DrawText("PRESS SPACE to START PLAYING MUSIC", 135, 350, 20, GRAY); DrawRectangle(150, 390, 400, 12, LIGHTGRAY); @@ -897,7 +897,7 @@ void UpdateDrawOneFrame(void) case ENDING: { // Draw ENDING screen - DrawTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", (Vector2){ screenWidth/2 - MeasureTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", fontAlagard.size*4, 4).x/2, 80 }, fontAlagard.size*4, 4, MAROON); + DrawTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", (Vector2){ screenWidth/2 - MeasureTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", fontAlagard.baseSize*4, 4).x/2, 80 }, fontAlagard.baseSize*4, 4, MAROON); DrawTexture(raylibLogoA, logoPositionX, logoPositionY - 40, WHITE); @@ -929,4 +929,4 @@ void UpdateDrawOneFrame(void) EndDrawing(); //---------------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/games/skully_escape/makefile b/games/skully_escape/makefile index ee2e08c0..7cfd3190 100644 --- a/games/skully_escape/makefile +++ b/games/skully_escape/makefile @@ -116,7 +116,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl # on XWindow could require also below libraries, just uncomment - #LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor else ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling diff --git a/games/skully_escape/screens/screen_aisle01.c b/games/skully_escape/screens/screen_aisle01.c index 3ddf7da5..78bb20c4 100644 --- a/games/skully_escape/screens/screen_aisle01.c +++ b/games/skully_escape/screens/screen_aisle01.c @@ -362,11 +362,11 @@ void DrawAisle01Screen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -374,7 +374,7 @@ void DrawAisle01Screen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(picture.bounds, Fade(RED, 0.6f)); @@ -406,4 +406,4 @@ void UnloadAisle01Screen(void) int FinishAisle01Screen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_aisle02.c b/games/skully_escape/screens/screen_aisle02.c index 43bb226b..9dc02d37 100644 --- a/games/skully_escape/screens/screen_aisle02.c +++ b/games/skully_escape/screens/screen_aisle02.c @@ -393,11 +393,11 @@ void DrawAisle02Screen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -405,7 +405,7 @@ void DrawAisle02Screen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(arc.bounds, Fade(RED, 0.6f)); @@ -441,4 +441,4 @@ void UnloadAisle02Screen(void) int FinishAisle02Screen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_armory.c b/games/skully_escape/screens/screen_armory.c index 54c40059..e05ca4e7 100644 --- a/games/skully_escape/screens/screen_armory.c +++ b/games/skully_escape/screens/screen_armory.c @@ -355,11 +355,11 @@ void DrawArmoryScreen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -367,7 +367,7 @@ void DrawArmoryScreen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(blazon01.bounds, Fade(RED, 0.6f)); DrawRectangleRec(blazon02.bounds, Fade(RED, 0.6f)); @@ -401,4 +401,4 @@ void UnloadArmoryScreen(void) int FinishArmoryScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_attic.c b/games/skully_escape/screens/screen_attic.c index f19b8856..87bffaa2 100644 --- a/games/skully_escape/screens/screen_attic.c +++ b/games/skully_escape/screens/screen_attic.c @@ -285,11 +285,11 @@ void DrawAtticScreen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -297,7 +297,7 @@ void DrawAtticScreen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(arc.bounds, Fade(RED, 0.6f)); @@ -329,4 +329,4 @@ void UnloadAtticScreen(void) int FinishAtticScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_bathroom.c b/games/skully_escape/screens/screen_bathroom.c index 170898bf..1f228803 100644 --- a/games/skully_escape/screens/screen_bathroom.c +++ b/games/skully_escape/screens/screen_bathroom.c @@ -334,11 +334,11 @@ void DrawBathroomScreen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -346,7 +346,7 @@ void DrawBathroomScreen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(mirror.bounds, Fade(RED, 0.6f)); @@ -380,4 +380,4 @@ void UnloadBathroomScreen(void) int FinishBathroomScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_ending.c b/games/skully_escape/screens/screen_ending.c index 4f2cc1bb..deffbb82 100644 --- a/games/skully_escape/screens/screen_ending.c +++ b/games/skully_escape/screens/screen_ending.c @@ -71,8 +71,8 @@ void DrawEndingScreen(void) { DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY); - DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.size*3, 2, Fade(WHITE, alpha)); - DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.size*3, 2, Fade(WHITE, alpha)); + DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.baseSize*3, 2, Fade(WHITE, alpha)); + DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.baseSize*3, 2, Fade(WHITE, alpha)); if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER or CLICK", 380, 545, 40, BLACK); } @@ -87,4 +87,4 @@ void UnloadEndingScreen(void) int FinishEndingScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_kitchen.c b/games/skully_escape/screens/screen_kitchen.c index 36f56443..01ce326a 100644 --- a/games/skully_escape/screens/screen_kitchen.c +++ b/games/skully_escape/screens/screen_kitchen.c @@ -354,11 +354,11 @@ void DrawKitchenScreen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -366,7 +366,7 @@ void DrawKitchenScreen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(closet.bounds, Fade(RED, 0.6f)); DrawRectangleRec(window.bounds, Fade(RED, 0.6f)); @@ -400,4 +400,4 @@ void UnloadKitchenScreen(void) int FinishKitchenScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/games/skully_escape/screens/screen_livingroom.c b/games/skully_escape/screens/screen_livingroom.c index d66ec819..fa465bfa 100644 --- a/games/skully_escape/screens/screen_livingroom.c +++ b/games/skully_escape/screens/screen_livingroom.c @@ -354,11 +354,11 @@ void DrawLivingroomScreen(void) if (msgState == 0) { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); } else if (msgState == 1) { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); + DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); } @@ -366,7 +366,7 @@ void DrawLivingroomScreen(void) { if ((msgCounter/30)%2) { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); + DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); DrawRectangleRec(candle.bounds, Fade(RED, 0.6f)); DrawRectangleRec(phone.bounds, Fade(RED, 0.6f)); @@ -400,4 +400,4 @@ void UnloadLivingroomScreen(void) int FinishLivingroomScreen(void) { return finishScreen; -} \ No newline at end of file +} diff --git a/src/audio.c b/src/audio.c index 68bd88e9..a23d11e7 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1207,7 +1207,7 @@ static Wave LoadOGG(const char *fileName) wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile); - if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio lenght is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds); + if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds); wave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short)); -- cgit v1.2.3 From b7a8a40e71f6c4467afd260c1f66e2c46891397f Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 26 Mar 2017 22:49:01 +0200 Subject: Work on configuration flags --- src/audio.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- src/audio.h | 26 +++++++++-------- src/models.c | 26 +++++++++++++++-- src/text.c | 29 ++++++++++++++----- src/utils.c | 41 +++++++++++++++------------ 5 files changed, 159 insertions(+), 55 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 68bd88e9..159b45ac 100644 --- a/src/audio.c +++ b/src/audio.c @@ -16,7 +16,7 @@ * Define to use the module as standalone library (independently of raylib). * Required types and functions are defined in the same module. * -* #define SUPPORT_FILEFORMAT_WAV / SUPPORT_LOAD_WAV +* #define SUPPORT_FILEFORMAT_WAV * #define SUPPORT_FILEFORMAT_OGG * #define SUPPORT_FILEFORMAT_XM * #define SUPPORT_FILEFORMAT_MOD @@ -24,9 +24,6 @@ * Selected desired fileformats to be supported for loading. Some of those formats are * supported by default, to remove support, just comment unrequired #define in this module * -* #define SUPPORT_RAW_AUDIO_BUFFERS -* Support creating raw audio buffers to send raw data. Buffers must be managed by the user, -* it means initialization, refilling and cleaning. * * LIMITATIONS: * Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS) @@ -70,6 +67,12 @@ //#define AUDIO_STANDALONE // NOTE: To use the audio module as standalone lib, just uncomment this line +// Default configuration flags (supported features) +//------------------------------------------------- +#define SUPPORT_FILEFORMAT_WAV +#define SUPPORT_FILEFORMAT_OGG +//------------------------------------------------- + #if defined(AUDIO_STANDALONE) #include "audio.h" #include // Required for: va_list, va_start(), vfprintf(), va_end() @@ -94,18 +97,26 @@ #include // Required for: strcmp(), strncmp() #include // Required for: FILE, fopen(), fclose(), fread() -//#define STB_VORBIS_HEADER_ONLY -#include "external/stb_vorbis.h" // OGG loading functions +#if defined(SUPPORT_FILEFORMAT_OGG) + //#define STB_VORBIS_HEADER_ONLY + #include "external/stb_vorbis.h" // OGG loading functions +#endif -#define JAR_XM_IMPLEMENTATION -#include "external/jar_xm.h" // XM loading functions +#if defined(SUPPORT_FILEFORMAT_XM) + #define JAR_XM_IMPLEMENTATION + #include "external/jar_xm.h" // XM loading functions +#endif -#define JAR_MOD_IMPLEMENTATION -#include "external/jar_mod.h" // MOD loading functions +#if defined(SUPPORT_FILEFORMAT_MOD) + #define JAR_MOD_IMPLEMENTATION + #include "external/jar_mod.h" // MOD loading functions +#endif -#define DR_FLAC_IMPLEMENTATION -#define DR_FLAC_NO_WIN32_IO -#include "external/dr_flac.h" // FLAC loading functions +#if defined(SUPPORT_FILEFORMAT_FLAC) + #define DR_FLAC_IMPLEMENTATION + #define DR_FLAC_NO_WIN32_IO + #include "external/dr_flac.h" // FLAC loading functions +#endif #ifdef _MSC_VER #undef bool @@ -140,10 +151,18 @@ typedef enum { MUSIC_AUDIO_OGG = 0, MUSIC_AUDIO_FLAC, MUSIC_MODULE_XM, MUSIC_MOD // Music type (file streaming from memory) typedef struct MusicData { MusicContextType ctxType; // Type of music context (OGG, XM, MOD) +#if defined(SUPPORT_FILEFORMAT_OGG) stb_vorbis *ctxOgg; // OGG audio context +#endif +#if defined(SUPPORT_FILEFORMAT_FLAC) drflac *ctxFlac; // FLAC audio context +#endif +#if defined(SUPPORT_FILEFORMAT_XM) jar_xm_context_t *ctxXm; // XM chiptune context +#endif +#if defined(SUPPORT_FILEFORMAT_MOD) jar_mod_context_t ctxMod; // MOD chiptune context +#endif AudioStream stream; // Audio stream (double buffering) @@ -164,9 +183,15 @@ typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType; //---------------------------------------------------------------------------------- // Module specific Functions Declaration //---------------------------------------------------------------------------------- +#if defined(SUPPORT_FILEFORMAT_WAV) static Wave LoadWAV(const char *fileName); // Load WAV file +#endif +#if defined(SUPPORT_FILEFORMAT_OGG) static Wave LoadOGG(const char *fileName); // Load OGG file +#endif +#if defined(SUPPORT_FILEFORMAT_FLAC) static Wave LoadFLAC(const char *fileName); // Load FLAC file +#endif #if defined(AUDIO_STANDALONE) const char *GetExtension(const char *fileName); // Get the extension for a filename @@ -261,8 +286,13 @@ Wave LoadWave(const char *fileName) Wave wave = { 0 }; if (strcmp(GetExtension(fileName), "wav") == 0) wave = LoadWAV(fileName); +#if defined(SUPPORT_FILEFORMAT_OGG) else if (strcmp(GetExtension(fileName), "ogg") == 0) wave = LoadOGG(fileName); +#endif +#if defined(SUPPORT_FILEFORMAT_FLAC) else if (strcmp(GetExtension(fileName), "flac") == 0) wave = LoadFLAC(fileName); +#endif +#if !defined(AUDIO_STANDALONE) else if (strcmp(GetExtension(fileName),"rres") == 0) { RRES rres = LoadResource(fileName, 0); @@ -274,7 +304,8 @@ Wave LoadWave(const char *fileName) UnloadResource(rres); } - else TraceLog(WARNING, "[%s] File extension not recognized, it can't be loaded", fileName); +#endif + else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName); return wave; } @@ -664,6 +695,7 @@ Music LoadMusicStream(const char *fileName) TraceLog(DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required); } } +#if defined(SUPPORT_FILEFORMAT_FLAC) else if (strcmp(GetExtension(fileName), "flac") == 0) { music->ctxFlac = drflac_open_file(fileName); @@ -683,6 +715,8 @@ Music LoadMusicStream(const char *fileName) TraceLog(DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels); } } +#endif +#if defined(SUPPORT_FILEFORMAT_XM) else if (strcmp(GetExtension(fileName), "xm") == 0) { int result = jar_xm_create_context_from_file(&music->ctxXm, 48000, fileName); @@ -703,6 +737,8 @@ Music LoadMusicStream(const char *fileName) } else TraceLog(WARNING, "[%s] XM file could not be opened", fileName); } +#endif +#if defined(SUPPORT_FILEFORMAT_MOD) else if (strcmp(GetExtension(fileName), "mod") == 0) { jar_mod_init(&music->ctxMod); @@ -720,7 +756,8 @@ Music LoadMusicStream(const char *fileName) } else TraceLog(WARNING, "[%s] MOD file could not be opened", fileName); } - else TraceLog(WARNING, "[%s] Music extension not recognized, it can't be loaded", fileName); +#endif + else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName); return music; } @@ -731,9 +768,15 @@ void UnloadMusicStream(Music music) CloseAudioStream(music->stream); if (music->ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close(music->ctxOgg); +#if defined(SUPPORT_FILEFORMAT_FLAC) else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_free(music->ctxFlac); +#endif +#if defined(SUPPORT_FILEFORMAT_XM) else if (music->ctxType == MUSIC_MODULE_XM) jar_xm_free_context(music->ctxXm); +#endif +#if defined(SUPPORT_FILEFORMAT_MOD) else if (music->ctxType == MUSIC_MODULE_MOD) jar_mod_unload(&music->ctxMod); +#endif free(music); } @@ -778,8 +821,15 @@ void StopMusicStream(Music music) switch (music->ctxType) { case MUSIC_AUDIO_OGG: stb_vorbis_seek_start(music->ctxOgg); break; +#if defined(SUPPORT_FILEFORMAT_FLAC) + case MUSIC_MODULE_FLAC: /* TODO: Restart FLAC context */ break; +#endif +#if defined(SUPPORT_FILEFORMAT_XM) case MUSIC_MODULE_XM: /* TODO: Restart XM context */ break; +#endif +#if defined(SUPPORT_FILEFORMAT_MOD) case MUSIC_MODULE_MOD: jar_mod_seek_start(&music->ctxMod); break; +#endif default: break; } @@ -821,14 +871,20 @@ void UpdateMusicStream(Music music) int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, samplesCount*music->stream.channels); } break; + #if defined(SUPPORT_FILEFORMAT_FLAC) case MUSIC_AUDIO_FLAC: { // NOTE: Returns the number of samples to process unsigned int numSamplesFlac = (unsigned int)drflac_read_s16(music->ctxFlac, samplesCount*music->stream.channels, (short *)pcm); } break; + #endif + #if defined(SUPPORT_FILEFORMAT_XM) case MUSIC_MODULE_XM: jar_xm_generate_samples_16bit(music->ctxXm, pcm, samplesCount); break; + #endif + #if defined(SUPPORT_FILEFORMAT_MOD) case MUSIC_MODULE_MOD: jar_mod_fillbuffer(&music->ctxMod, pcm, samplesCount, 0); break; + #endif default: break; } @@ -1067,6 +1123,7 @@ void StopAudioStream(AudioStream stream) // Module specific Functions Definition //---------------------------------------------------------------------------------- +#if defined(SUPPORT_FILEFORMAT_WAV) // Load WAV file into Wave structure static Wave LoadWAV(const char *fileName) { @@ -1183,7 +1240,9 @@ static Wave LoadWAV(const char *fileName) return wave; } +#endif +#if defined(SUPPORT_FILEFORMAT_OGG) // Load OGG file into Wave structure // NOTE: Using stb_vorbis library static Wave LoadOGG(const char *fileName) @@ -1223,7 +1282,9 @@ static Wave LoadOGG(const char *fileName) return wave; } +#endif +#if defined(SUPPORT_FILEFORMAT_FLAC) // Load FLAC file into Wave structure // NOTE: Using dr_flac library static Wave LoadFLAC(const char *fileName) @@ -1245,6 +1306,7 @@ static Wave LoadFLAC(const char *fileName) return wave; } +#endif // Some required functions for audio standalone module version #if defined(AUDIO_STANDALONE) diff --git a/src/audio.h b/src/audio.h index 8047d9bb..51f858da 100644 --- a/src/audio.h +++ b/src/audio.h @@ -2,22 +2,24 @@ * * raylib.audio - Basic funtionality to work with audio * -* DESCRIPTION: +* FEATURES: +* - Manage audio device (init/close) +* - Load and unload audio files +* - Format wave data (sample rate, size, channels) +* - Play/Stop/Pause/Resume loaded audio +* - Manage mixing channels +* - Manage raw audio context * -* This module provides basic functionality to: -* - Manage audio device (init/close) -* - Load and unload audio files -* - Format wave data (sample rate, size, channels) -* - Play/Stop/Pause/Resume loaded audio -* - Manage mixing channels -* - Manage raw audio context +* LIMITATIONS: +* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS) +* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32) * * DEPENDENCIES: * OpenAL Soft - Audio device management (http://kcat.strangesoft.net/openal.html) * stb_vorbis - OGG audio files loading (http://www.nothings.org/stb_vorbis/) -* jar_xm - XM module file loading -* jar_mod - MOD audio file loading -* dr_flac - FLAC audio file loading +* jar_xm - XM module file loading (#define SUPPORT_FILEFORMAT_XM) +* jar_mod - MOD audio file loading (#define SUPPORT_FILEFORMAT_MOD) +* dr_flac - FLAC audio file loading (#define SUPPORT_FILEFORMAT_FLAC) * * CONTRIBUTORS: * Joshua Reisenauer (github: @kd7tck): @@ -152,7 +154,7 @@ float GetMusicTimePlayed(Music music); // Get current m AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Init audio stream (to stream raw audio pcm data) -void UpdateAudioStream(AudioStream stream, void *data, int samplesCount); // Update audio stream buffers with data +void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data void CloseAudioStream(AudioStream stream); // Close audio stream and free memory bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill void PlayAudioStream(AudioStream stream); // Play audio stream diff --git a/src/models.c b/src/models.c index 67e1693c..6aff59c4 100644 --- a/src/models.c +++ b/src/models.c @@ -4,7 +4,7 @@ * * CONFIGURATION: * -* #define SUPPORT_FILEFORMAT_OBJ / SUPPORT_LOAD_OBJ +* #define SUPPORT_FILEFORMAT_OBJ * Selected desired fileformats to be supported for loading. * * #define SUPPORT_FILEFORMAT_MTL @@ -32,6 +32,12 @@ * **********************************************************************************************/ +// Default configuration flags (supported features) +//------------------------------------------------- +#define SUPPORT_FILEFORMAT_OBJ +#define SUPPORT_FILEFORMAT_MTL +//------------------------------------------------- + #include "raylib.h" #if defined(PLATFORM_ANDROID) @@ -63,8 +69,12 @@ //---------------------------------------------------------------------------------- // Module specific Functions Declaration //---------------------------------------------------------------------------------- +#if defined(SUPPORT_FILEFORMAT_OBJ) static Mesh LoadOBJ(const char *fileName); // Load OBJ mesh data +#endif +#if defined(SUPPORT_FILEFORMAT_MTL) static Material LoadMTL(const char *fileName); // Load MTL material data +#endif static Mesh GenMeshHeightmap(Image image, Vector3 size); static Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); @@ -582,8 +592,11 @@ Mesh LoadMesh(const char *fileName) { Mesh mesh = { 0 }; +#if defined(SUPPORT_FILEFORMAT_OBJ) if (strcmp(GetExtension(fileName), "obj") == 0) mesh = LoadOBJ(fileName); - else TraceLog(WARNING, "[%s] Mesh extension not recognized, it can't be loaded", fileName); +#else + TraceLog(WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName); +#endif if (mesh.vertexCount == 0) TraceLog(WARNING, "Mesh could not be loaded"); else rlglLoadMesh(&mesh, false); // Upload vertex data to GPU (static mesh) @@ -692,8 +705,11 @@ Material LoadMaterial(const char *fileName) { Material material = { 0 }; +#if defined(SUPPORT_FILEFORMAT_MTL) if (strcmp(GetExtension(fileName), "mtl") == 0) material = LoadMTL(fileName); - else TraceLog(WARNING, "[%s] Material extension not recognized, it can't be loaded", fileName); +#else + TraceLog(WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName); +#endif return material; } @@ -1590,6 +1606,7 @@ BoundingBox CalculateBoundingBox(Mesh mesh) // Module specific Functions Definition //---------------------------------------------------------------------------------- +#if defined(SUPPORT_FILEFORMAT_OBJ) // Load OBJ mesh data static Mesh LoadOBJ(const char *fileName) { @@ -1838,7 +1855,9 @@ static Mesh LoadOBJ(const char *fileName) return mesh; } +#endif +#if defined(SUPPORT_FILEFORMAT_MTL) // Load MTL material data (specs: http://paulbourke.net/dataformats/mtl/) // NOTE: Texture map parameters are not supported static Material LoadMTL(const char *fileName) @@ -2002,3 +2021,4 @@ static Material LoadMTL(const char *fileName) return material; } +#endif diff --git a/src/text.c b/src/text.c index 13a01469..04a860cf 100644 --- a/src/text.c +++ b/src/text.c @@ -5,8 +5,7 @@ * CONFIGURATION: * * #define SUPPORT_FILEFORMAT_FNT -* #define SUPPORT_FILEFORMAT_TTF / INCLUDE_STB_TRUETYPE -* #define SUPPORT_FILEFORMAT_IMAGE_FONT +* #define SUPPORT_FILEFORMAT_TTF * Selected desired fileformats to be supported for loading. Some of those formats are * supported by default, to remove support, just comment unrequired #define in this module * @@ -51,10 +50,12 @@ #include "utils.h" // Required for: GetExtension() -// Following libs are used on LoadTTF() -#define STBTT_STATIC // Define stb_truetype functions static to this module -#define STB_TRUETYPE_IMPLEMENTATION -#include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() +#if defined(SUPPORT_FILEFORMAT_TTF) + // Following libs are used on LoadTTF() + #define STBTT_STATIC // Define stb_truetype functions static to this module + #define STB_TRUETYPE_IMPLEMENTATION + #include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() +#endif // Rectangle packing functions (not used at the moment) //#define STB_RECT_PACK_IMPLEMENTATION @@ -91,8 +92,12 @@ static int GetCharIndex(SpriteFont font, int letter); static SpriteFont LoadImageFont(Image image, Color key, int firstChar); // Load a Image font file (XNA style) static SpriteFont LoadRBMF(const char *fileName); // Load a rBMF font file (raylib BitMap Font) +#if defined(SUPPORT_FILEFORMAT_FNT) static SpriteFont LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file) +#endif +#if defined(SUPPORT_FILEFORMAT_TTF) static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load spritefont from TTF data +#endif #if defined(SUPPORT_DEFAULT_FONT) extern void LoadDefaultFont(void); @@ -284,8 +289,12 @@ SpriteFont LoadSpriteFont(const char *fileName) // Check file extension if (strcmp(GetExtension(fileName),"rbmf") == 0) spriteFont = LoadRBMF(fileName); // TODO: DELETE... SOON... +#if defined(SUPPORT_FILEFORMAT_TTF) else if (strcmp(GetExtension(fileName),"ttf") == 0) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL); +#endif +#if defined(SUPPORT_FILEFORMAT_FNT) else if (strcmp(GetExtension(fileName),"fnt") == 0) spriteFont = LoadBMFont(fileName); +#endif else if (strcmp(GetExtension(fileName),"rres") == 0) { // TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA) @@ -336,6 +345,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount, { SpriteFont spriteFont = { 0 }; +#if defined(SUPPORT_FILEFORMAT_TTF) if (strcmp(GetExtension(fileName),"ttf") == 0) { if ((fontChars == NULL) || (charsCount == 0)) @@ -350,6 +360,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount, } else spriteFont = LoadTTF(fileName, fontSize, charsCount, fontChars); } +#endif if (spriteFont.texture.id == 0) { @@ -845,6 +856,7 @@ static SpriteFont LoadRBMF(const char *fileName) return spriteFont; } +#if defined(SUPPORT_FILEFORMAT_FNT) // Load a BMFont file (AngelCode font file) static SpriteFont LoadBMFont(const char *fileName) { @@ -962,7 +974,9 @@ static SpriteFont LoadBMFont(const char *fileName) return font; } +#endif +#if defined(SUPPORT_FILEFORMAT_TTF) // Generate a sprite font from TTF file data (font size required) // TODO: Review texture packing method and generation (use oversampling) static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars) @@ -1054,4 +1068,5 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in free(charData); return font; -} \ No newline at end of file +} +#endif diff --git a/src/utils.c b/src/utils.c index b6b309cc..6a07f301 100644 --- a/src/utils.c +++ b/src/utils.c @@ -153,6 +153,29 @@ void SavePNG(const char *fileName, unsigned char *imgData, int width, int height #endif #endif +// Keep track of memory allocated +// NOTE: mallocType defines the type of data allocated +/* +void RecordMalloc(int mallocType, int mallocSize, const char *msg) +{ + // TODO: Investigate how to record memory allocation data... + // Maybe creating my own malloc function... +} +*/ + +bool IsFileExtension(const char *fileName, const char *ext) +{ + return (strcmp(GetExtension(fileName), ext) == 0); +} + +// Get the extension for a filename +const char *GetExtension(const char *fileName) +{ + const char *dot = strrchr(fileName, '.'); + if (!dot || dot == fileName) return ""; + return (dot + 1); +} + #if defined(PLATFORM_ANDROID) // Initialize asset manager from android app void InitAssetManager(AAssetManager *manager) @@ -173,24 +196,6 @@ FILE *android_fopen(const char *fileName, const char *mode) } #endif -// Keep track of memory allocated -// NOTE: mallocType defines the type of data allocated -/* -void RecordMalloc(int mallocType, int mallocSize, const char *msg) -{ - // TODO: Investigate how to record memory allocation data... - // Maybe creating my own malloc function... -} -*/ - -// Get the extension for a filename -const char *GetExtension(const char *fileName) -{ - const char *dot = strrchr(fileName, '.'); - if (!dot || dot == fileName) return ""; - return (dot + 1); -} - //---------------------------------------------------------------------------------- // Module specific Functions Definition //---------------------------------------------------------------------------------- -- cgit v1.2.3 From 080a79f0b03bd40a4ac6dfb8c6f90a3a7379d7ad Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 29 Mar 2017 00:35:42 +0200 Subject: Added IsFileExtension() Replaced old GetExtension() function Make IsFileExtension() public to the API --- src/audio.c | 39 +++++++++++++++++++++------------------ src/audio.h | 7 ++++--- src/core.c | 22 ++++++++++++++++++---- src/models.c | 4 ++-- src/raylib.h | 5 +++-- src/text.c | 10 +++++----- src/textures.c | 46 +++++++++++++++++++++++----------------------- src/utils.c | 22 +++++----------------- src/utils.h | 5 ++--- 9 files changed, 83 insertions(+), 77 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 5edabf41..34be4789 100644 --- a/src/audio.c +++ b/src/audio.c @@ -24,7 +24,6 @@ * Selected desired fileformats to be supported for loading. Some of those formats are * supported by default, to remove support, just comment unrequired #define in this module * -* * LIMITATIONS: * Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS) * Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32) @@ -65,8 +64,6 @@ * **********************************************************************************************/ -//#define AUDIO_STANDALONE // NOTE: To use the audio module as standalone lib, just uncomment this line - // Default configuration flags (supported features) //------------------------------------------------- #define SUPPORT_FILEFORMAT_WAV @@ -194,8 +191,8 @@ static Wave LoadFLAC(const char *fileName); // Load FLAC file #endif #if defined(AUDIO_STANDALONE) -const char *GetExtension(const char *fileName); // Get the extension for a filename -void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message (INFO, ERROR, WARNING) +bool IsFileExtension(const char *fileName, const char *ext); // Check file extension +void TraceLog(int msgType, const char *text, ...); // Outputs trace log message (INFO, ERROR, WARNING) #endif //---------------------------------------------------------------------------------- @@ -285,15 +282,15 @@ Wave LoadWave(const char *fileName) { Wave wave = { 0 }; - if (strcmp(GetExtension(fileName), "wav") == 0) wave = LoadWAV(fileName); + if (IsFileExtension(fileName, ".wav")) wave = LoadWAV(fileName); #if defined(SUPPORT_FILEFORMAT_OGG) - else if (strcmp(GetExtension(fileName), "ogg") == 0) wave = LoadOGG(fileName); + else if (IsFileExtension(fileName, ".ogg")) wave = LoadOGG(fileName); #endif #if defined(SUPPORT_FILEFORMAT_FLAC) - else if (strcmp(GetExtension(fileName), "flac") == 0) wave = LoadFLAC(fileName); + else if (IsFileExtension(fileName, ".flac")) wave = LoadFLAC(fileName); #endif #if !defined(AUDIO_STANDALONE) - else if (strcmp(GetExtension(fileName),"rres") == 0) + else if (IsFileExtension(fileName, ".rres")) { RRES rres = LoadResource(fileName, 0); @@ -672,7 +669,7 @@ Music LoadMusicStream(const char *fileName) { Music music = (MusicData *)malloc(sizeof(MusicData)); - if (strcmp(GetExtension(fileName), "ogg") == 0) + if (IsFileExtension(fileName, ".ogg")) { // Open ogg audio stream music->ctxOgg = stb_vorbis_open_filename(fileName, NULL, NULL); @@ -696,7 +693,7 @@ Music LoadMusicStream(const char *fileName) } } #if defined(SUPPORT_FILEFORMAT_FLAC) - else if (strcmp(GetExtension(fileName), "flac") == 0) + else if (IsFileExtension(fileName, ".flac")) { music->ctxFlac = drflac_open_file(fileName); @@ -717,7 +714,7 @@ Music LoadMusicStream(const char *fileName) } #endif #if defined(SUPPORT_FILEFORMAT_XM) - else if (strcmp(GetExtension(fileName), "xm") == 0) + else if (IsFileExtension(fileName, ".xm")) { int result = jar_xm_create_context_from_file(&music->ctxXm, 48000, fileName); @@ -739,7 +736,7 @@ Music LoadMusicStream(const char *fileName) } #endif #if defined(SUPPORT_FILEFORMAT_MOD) - else if (strcmp(GetExtension(fileName), "mod") == 0) + else if (IsFileExtension(fileName, ".mod")) { jar_mod_init(&music->ctxMod); @@ -1310,12 +1307,18 @@ static Wave LoadFLAC(const char *fileName) // Some required functions for audio standalone module version #if defined(AUDIO_STANDALONE) -// Get the extension for a filename -const char *GetExtension(const char *fileName) +// Check file extension +bool IsFileExtension(const char *fileName, const char *ext) { - const char *dot = strrchr(fileName, '.'); - if (!dot || dot == fileName) return ""; - return (dot + 1); + bool result = false; + const char *fileExt; + + if ((fileExt = strrchr(fileName, '.')) != NULL) + { + if (strcmp(fileExt, ext) == 0) result = true; + } + + return result; } // Outputs a trace log message (INFO, ERROR, WARNING) diff --git a/src/audio.h b/src/audio.h index 51f858da..48ef7403 100644 --- a/src/audio.h +++ b/src/audio.h @@ -123,7 +123,7 @@ Wave LoadWave(const char *fileName); // Load wave dat Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data Sound LoadSound(const char *fileName); // Load sound from file Sound LoadSoundFromWave(Wave wave); // Load sound from wave data -void UpdateSound(Sound sound, const void *data, int samplesCount); // Update sound buffer with new data +void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data void UnloadWave(Wave wave); // Unload wave data void UnloadSound(Sound sound); // Unload sound void PlaySound(Sound sound); // Play a sound @@ -151,9 +151,10 @@ void SetMusicLoopCount(Music music, float count); // Set music loo float GetMusicTimeLength(Music music); // Get music time length (in seconds) float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) +// Raw audio stream functions AudioStream InitAudioStream(unsigned int sampleRate, - unsigned int sampleSize, - unsigned int channels); // Init audio stream (to stream raw audio pcm data) + unsigned int sampleSize, + unsigned int channels); // Init audio stream (to stream raw audio pcm data) void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data void CloseAudioStream(AudioStream stream); // Close audio stream and free memory bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill diff --git a/src/core.c b/src/core.c index b8d822a8..b9ea9315 100644 --- a/src/core.c +++ b/src/core.c @@ -102,7 +102,7 @@ #include // Required for: typedef unsigned long long int uint64_t, used by hi-res timer #include // Required for: time() - Android/RPI hi-res timer (NOTE: Linux only!) #include // Required for: tan() [Used in Begin3dMode() to set perspective] -#include // Required for: strcmp() +#include // Required for: strrchr(), strcmp() //#include // Macros for reporting and retrieving error conditions through error codes #if defined __linux__ || defined(PLATFORM_WEB) @@ -978,6 +978,12 @@ Color Fade(Color color, float alpha) return (Color){color.r, color.g, color.b, (unsigned char)colorAlpha}; } +// Activates raylib logo at startup +void ShowLogo(void) +{ + showLogo = true; +} + // Enable some window/system configurations void SetConfigFlags(char flags) { @@ -987,10 +993,18 @@ void SetConfigFlags(char flags) if (configFlags & FLAG_FULLSCREEN_MODE) fullscreen = true; } -// Activates raylib logo at startup -void ShowLogo(void) +// Check file extension +bool IsFileExtension(const char *fileName, const char *ext) { - showLogo = true; + bool result = false; + const char *fileExt; + + if ((fileExt = strrchr(fileName, '.')) != NULL) + { + if (strcmp(fileExt, ext) == 0) result = true; + } + + return result; } #if defined(PLATFORM_DESKTOP) diff --git a/src/models.c b/src/models.c index 6aff59c4..47220af8 100644 --- a/src/models.c +++ b/src/models.c @@ -593,7 +593,7 @@ Mesh LoadMesh(const char *fileName) Mesh mesh = { 0 }; #if defined(SUPPORT_FILEFORMAT_OBJ) - if (strcmp(GetExtension(fileName), "obj") == 0) mesh = LoadOBJ(fileName); + if (IsFileExtension(fileName, ".obj")) mesh = LoadOBJ(fileName); #else TraceLog(WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName); #endif @@ -706,7 +706,7 @@ Material LoadMaterial(const char *fileName) Material material = { 0 }; #if defined(SUPPORT_FILEFORMAT_MTL) - if (strcmp(GetExtension(fileName), "mtl") == 0) material = LoadMTL(fileName); + if (IsFileExtension(fileName, ".mtl")) material = LoadMTL(fileName); #else TraceLog(WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName); #endif diff --git a/src/raylib.h b/src/raylib.h index 24d6e1fd..3e6c68ff 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -687,9 +687,10 @@ RLAPI float *MatrixToFloat(Matrix mat); // Converts Ma RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f -RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags RLAPI void ShowLogo(void); // Activates raylib logo at startup (can be done with flags) -//RLAPI void TraceLog(int logType, const char *text, ...); // Trace log messages showing (INFO, WARNING, ERROR, DEBUG) +RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags +//RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG) +RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension RLAPI bool IsFileDropped(void); // Check if a file have been dropped into window RLAPI char **GetDroppedFiles(int *count); // Retrieve dropped files into window diff --git a/src/text.c b/src/text.c index c736d5ad..09f69ff6 100644 --- a/src/text.c +++ b/src/text.c @@ -48,7 +48,7 @@ #include // Required for: va_list, va_start(), vfprintf(), va_end() #include // Required for: FILE, fopen(), fclose(), fscanf(), feof(), rewind(), fgets() -#include "utils.h" // Required for: GetExtension() +#include "utils.h" // Required for: IsFileExtension() #if defined(SUPPORT_FILEFORMAT_TTF) // Following libs are used on LoadTTF() @@ -287,7 +287,7 @@ SpriteFont LoadSpriteFont(const char *fileName) SpriteFont spriteFont = { 0 }; // Check file extension - if (strcmp(GetExtension(fileName),"rres") == 0) + if (IsFileExtension(fileName, ".rres")) { // TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA) RRES rres = LoadResource(fileName, 0); @@ -314,10 +314,10 @@ SpriteFont LoadSpriteFont(const char *fileName) //UnloadResource(rres[0]); } #if defined(SUPPORT_FILEFORMAT_TTF) - else if (strcmp(GetExtension(fileName),"ttf") == 0) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL); + else if (IsFileExtension(fileName, ".ttf")) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL); #endif #if defined(SUPPORT_FILEFORMAT_FNT) - else if (strcmp(GetExtension(fileName),"fnt") == 0) spriteFont = LoadBMFont(fileName); + else if (IsFileExtension(fileName, ".fnt")) spriteFont = LoadBMFont(fileName); #endif else { @@ -344,7 +344,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount, SpriteFont spriteFont = { 0 }; #if defined(SUPPORT_FILEFORMAT_TTF) - if (strcmp(GetExtension(fileName),"ttf") == 0) + if (IsFileExtension(fileName, ".ttf")) { if ((fontChars == NULL) || (charsCount == 0)) { diff --git a/src/textures.c b/src/textures.c index 6fff8e75..fff0e4e9 100644 --- a/src/textures.c +++ b/src/textures.c @@ -163,21 +163,32 @@ Image LoadImage(const char *fileName) image.mipmaps = 0; image.format = 0; - if ((strcmp(GetExtension(fileName),"png") == 0) + if (IsFileExtension(fileName, ".rres")) + { + RRES rres = LoadResource(fileName, 0); + + // NOTE: Parameters for RRES_TYPE_IMAGE are: width, height, format, mipmaps + + if (rres[0].type == RRES_TYPE_IMAGE) image = LoadImagePro(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3); + else TraceLog(WARNING, "[%s] Resource file does not contain image data", fileName); + + UnloadResource(rres); + } + else if ((IsFileExtension(fileName, ".png")) #if defined(SUPPORT_FILEFORMAT_BMP) - || (strcmp(GetExtension(fileName),"bmp") == 0) + || (IsFileExtension(fileName, ".bmp")) #endif #if defined(SUPPORT_FILEFORMAT_TGA) - || (strcmp(GetExtension(fileName),"tga") == 0) + || (IsFileExtension(fileName, ".tga")) #endif #if defined(SUPPORT_FILEFORMAT_JPG) - || (strcmp(GetExtension(fileName),"jpg") == 0) + || (IsFileExtension(fileName, ".jpg")) #endif #if defined(SUPPORT_FILEFORMAT_DDS) - || (strcmp(GetExtension(fileName),"gif") == 0) + || (IsFileExtension(fileName, ".gif")) #endif #if defined(SUPPORT_FILEFORMAT_PSD) - || (strcmp(GetExtension(fileName),"psd") == 0) + || (IsFileExtension(fileName, ".psd")) #endif ) { @@ -198,32 +209,21 @@ Image LoadImage(const char *fileName) else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8; } #if defined(SUPPORT_FILEFORMAT_DDS) - else if (strcmp(GetExtension(fileName),"dds") == 0) image = LoadDDS(fileName); + else if (IsFileExtension(fileName, ".dds")) image = LoadDDS(fileName); #endif #if defined(SUPPORT_FILEFORMAT_PKM) - else if (strcmp(GetExtension(fileName),"pkm") == 0) image = LoadPKM(fileName); + else if (IsFileExtension(fileName, ".pkm")) image = LoadPKM(fileName); #endif #if defined(SUPPORT_FILEFORMAT_KTX) - else if (strcmp(GetExtension(fileName),"ktx") == 0) image = LoadKTX(fileName); + else if (IsFileExtension(fileName, ".ktx")) image = LoadKTX(fileName); #endif #if defined(SUPPORT_FILEFORMAT_PVR) - else if (strcmp(GetExtension(fileName),"pvr") == 0) image = LoadPVR(fileName); + else if (IsFileExtension(fileName, ".pvr")) image = LoadPVR(fileName); #endif #if defined(SUPPORT_FILEFORMAT_ASTC) - else if (strcmp(GetExtension(fileName),"astc") == 0) image = LoadASTC(fileName); + else if (IsFileExtension(fileName, ".astc")) image = LoadASTC(fileName); #endif - else if (strcmp(GetExtension(fileName),"rres") == 0) - { - RRES rres = LoadResource(fileName, 0); - - // NOTE: Parameters for RRES_TYPE_IMAGE are: width, height, format, mipmaps - - if (rres[0].type == RRES_TYPE_IMAGE) image = LoadImagePro(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3); - else TraceLog(WARNING, "[%s] Resource file does not contain image data", fileName); - - UnloadResource(rres); - } - else TraceLog("[%s] Image fileformat not supported", fileName); + else TraceLog(WARNING, "[%s] Image fileformat not supported", fileName); if (image.data != NULL) TraceLog(INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height); else TraceLog(WARNING, "[%s] Image could not be loaded", fileName); diff --git a/src/utils.c b/src/utils.c index 6a07f301..649fda4f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -88,14 +88,15 @@ static int android_close(void *cookie); //---------------------------------------------------------------------------------- // Module Functions Definition - Utilities //---------------------------------------------------------------------------------- -// Outputs a trace log message + +// Output trace log messages void TraceLog(int msgType, const char *text, ...) { -#if !defined(NO_TRACELOG) +#if defined(SUPPORT_TRACELOG) static char buffer[128]; int traceDebugMsgs = 1; -#ifdef DO_NOT_TRACE_DEBUG_MSGS +#if defined(SUPPORT_TRACELOG_DEBUG) traceDebugMsgs = 0; #endif @@ -131,7 +132,7 @@ void TraceLog(int msgType, const char *text, ...) if (msgType == ERROR) exit(1); // If ERROR message, exit program -#endif // NO_TRACELOG +#endif // SUPPORT_TRACELOG } #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) @@ -163,19 +164,6 @@ void RecordMalloc(int mallocType, int mallocSize, const char *msg) } */ -bool IsFileExtension(const char *fileName, const char *ext) -{ - return (strcmp(GetExtension(fileName), ext) == 0); -} - -// Get the extension for a filename -const char *GetExtension(const char *fileName) -{ - const char *dot = strrchr(fileName, '.'); - if (!dot || dot == fileName) return ""; - return (dot + 1); -} - #if defined(PLATFORM_ANDROID) // Initialize asset manager from android app void InitAssetManager(AAssetManager *manager) diff --git a/src/utils.h b/src/utils.h index 45ffcf81..2b4d838b 100644 --- a/src/utils.h +++ b/src/utils.h @@ -60,8 +60,7 @@ extern "C" { // Prevents name mangling of functions //---------------------------------------------------------------------------------- // Module Functions Declaration //---------------------------------------------------------------------------------- -void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message -const char *GetExtension(const char *fileName); // Returns extension of a filename +void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) #if defined(SUPPORT_SAVE_BMP) @@ -74,7 +73,7 @@ void SavePNG(const char *fileName, unsigned char *imgData, int width, int height #if defined(PLATFORM_ANDROID) void InitAssetManager(AAssetManager *manager); // Initialize asset manager from android app -FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen() +FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen() #endif #ifdef __cplusplus -- cgit v1.2.3 From ecfe31bf1d2647dc52b8e1584e4b7f022049e09b Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 21 Apr 2017 00:08:00 +0200 Subject: Make TraceLog() public to the API enum LogType could require some revision... --- src/audio.c | 2 +- src/core.c | 2 +- src/raylib.h | 28 ++++++++++++++++++++++++---- src/text.c | 2 +- src/textures.c | 2 +- src/utils.h | 4 ---- 6 files changed, 28 insertions(+), 12 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 34be4789..9a7779f4 100644 --- a/src/audio.c +++ b/src/audio.c @@ -75,7 +75,7 @@ #include // Required for: va_list, va_start(), vfprintf(), va_end() #else #include "raylib.h" - #include "utils.h" // Required for: fopen() Android mapping, TraceLog() + #include "utils.h" // Required for: fopen() Android mapping #endif #ifdef __APPLE__ diff --git a/src/core.c b/src/core.c index 3f3bc6ea..ee069d97 100644 --- a/src/core.c +++ b/src/core.c @@ -81,7 +81,7 @@ #include "raylib.h" #include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 -#include "utils.h" // Required for: fopen() Android mapping, TraceLog() +#include "utils.h" // Required for: fopen() Android mapping #define RAYMATH_IMPLEMENTATION // Use raymath as a header-only library (includes implementation) #define RAYMATH_EXTERN_INLINE // Compile raymath functions as static inline (remember, it's a compiler hint) diff --git a/src/raylib.h b/src/raylib.h index b82ec342..286494c7 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -295,7 +295,7 @@ #define RAYWHITE CLITERAL{ 245, 245, 245, 255 } // My own White (raylib logo) //---------------------------------------------------------------------------------- -// Types and Structures Definition +// Structures Definition //---------------------------------------------------------------------------------- #ifndef __cplusplus // Boolean type @@ -516,6 +516,18 @@ typedef struct AudioStream { unsigned int buffers[2]; // OpenAL audio buffers (double buffering) } AudioStream; +//---------------------------------------------------------------------------------- +// Enumerators Definition +//---------------------------------------------------------------------------------- +// Trace log type +typedef enum { + INFO = 0, + WARNING, + ERROR, + DEBUG, + OTHER +} LogType; + // Texture formats // NOTE: Support depends on OpenGL version and platform typedef enum { @@ -552,10 +564,18 @@ typedef enum { } TextureFilterMode; // Texture parameters: wrap mode -typedef enum { WRAP_REPEAT = 0, WRAP_CLAMP, WRAP_MIRROR } TextureWrapMode; +typedef enum { + WRAP_REPEAT = 0, + WRAP_CLAMP, + WRAP_MIRROR +} TextureWrapMode; // Color blending modes (pre-defined) -typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode; +typedef enum { + BLEND_ALPHA = 0, + BLEND_ADDITIVE, + BLEND_MULTIPLIED +} BlendMode; // Gestures type // NOTE: It could be used as flags to enable only some gestures @@ -689,7 +709,7 @@ RLAPI Color Fade(Color color, float alpha); // Color fade- RLAPI void ShowLogo(void); // Activates raylib logo at startup (can be done with flags) RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags -//RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG) +RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG) RLAPI void TakeScreenshot(void); // Takes a screenshot and saves it in the same folder as executable RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension diff --git a/src/text.c b/src/text.c index a057e347..ebc8b0ff 100644 --- a/src/text.c +++ b/src/text.c @@ -50,7 +50,7 @@ #include // Required for: va_list, va_start(), vfprintf(), va_end() #include // Required for: FILE, fopen(), fclose(), fscanf(), feof(), rewind(), fgets() -#include "utils.h" // Required for: IsFileExtension() +#include "utils.h" // Required for: fopen() Android mapping #if defined(SUPPORT_FILEFORMAT_TTF) // Following libs are used on LoadTTF() diff --git a/src/textures.c b/src/textures.c index af95f9dc..7013038d 100644 --- a/src/textures.c +++ b/src/textures.c @@ -65,7 +65,7 @@ // Required for: rlglLoadTexture() rlDeleteTextures(), // rlglGenerateMipmaps(), some funcs for DrawTexturePro() -#include "utils.h" // Required for: fopen() Android mapping, TraceLog() +#include "utils.h" // Required for: fopen() Android mapping // Support only desired texture formats on stb_image #if !defined(SUPPORT_FILEFORMAT_BMP) diff --git a/src/utils.h b/src/utils.h index 2b4d838b..64592c73 100644 --- a/src/utils.h +++ b/src/utils.h @@ -46,8 +46,6 @@ //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType; - #ifdef __cplusplus extern "C" { // Prevents name mangling of functions #endif @@ -60,8 +58,6 @@ extern "C" { // Prevents name mangling of functions //---------------------------------------------------------------------------------- // Module Functions Declaration //---------------------------------------------------------------------------------- -void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message - #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) #if defined(SUPPORT_SAVE_BMP) void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize); -- cgit v1.2.3 From 7bcae5947778cd18981530e28b453dd4d4d61fa2 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 23 Apr 2017 12:06:05 +0200 Subject: Support XM modules by default --- src/audio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 9a7779f4..d63047a8 100644 --- a/src/audio.c +++ b/src/audio.c @@ -68,6 +68,7 @@ //------------------------------------------------- #define SUPPORT_FILEFORMAT_WAV #define SUPPORT_FILEFORMAT_OGG +#define SUPPORT_FILEFORMAT_XM //------------------------------------------------- #if defined(AUDIO_STANDALONE) -- cgit v1.2.3 From 2d5c8e61b1d34b9b482b807f5bef555f532533fd Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 3 May 2017 14:16:53 +0200 Subject: Some code tweaks --- src/audio.c | 20 ++++++++------------ src/textures.c | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index d63047a8..e8e80985 100644 --- a/src/audio.c +++ b/src/audio.c @@ -570,7 +570,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels) // NOTE: Only supported mono <--> stereo if (wave->channels != channels) { - void *data = malloc(wave->sampleCount*channels*wave->sampleSize/8); + void *data = malloc(wave->sampleCount*wave->sampleSize/8*channels); if ((wave->channels == 1) && (channels == 2)) // mono ---> stereo (duplicate mono information) { @@ -607,7 +607,7 @@ Wave WaveCopy(Wave wave) { Wave newWave = { 0 }; - newWave.data = malloc(wave.sampleCount*wave.channels*wave.sampleSize/8); + newWave.data = malloc(wave.sampleCount*wave.sampleSize/8*wave.channels); if (newWave.data != NULL) { @@ -632,7 +632,7 @@ void WaveCrop(Wave *wave, int initSample, int finalSample) { int sampleCount = finalSample - initSample; - void *data = malloc(sampleCount*wave->channels*wave->sampleSize/8); + void *data = malloc(sampleCount*wave->sampleSize/8*wave->channels); memcpy(data, (unsigned char*)wave->data + (initSample*wave->channels*wave->sampleSize/8), sampleCount*wave->channels*wave->sampleSize/8); @@ -849,7 +849,7 @@ void UpdateMusicStream(Music music) bool active = true; // NOTE: Using dynamic allocation because it could require more than 16KB - void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.channels*music->stream.sampleSize/8, 1); + void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, 1); int numBuffersToProcess = processed; int samplesCount = 0; // Total size of data steamed in L+R samples for xm floats, @@ -1245,23 +1245,19 @@ static Wave LoadWAV(const char *fileName) // NOTE: Using stb_vorbis library static Wave LoadOGG(const char *fileName) { - Wave wave; + Wave wave = { 0 }; stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL); - if (oggFile == NULL) - { - TraceLog(WARNING, "[%s] OGG file could not be opened", fileName); - wave.data = NULL; - } + if (oggFile == NULL) TraceLog(WARNING, "[%s] OGG file could not be opened", fileName); else { stb_vorbis_info info = stb_vorbis_get_info(oggFile); - + wave.sampleRate = info.sample_rate; wave.sampleSize = 16; // 16 bit per sample (short) wave.channels = info.channels; - wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); + wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); // Independent by channel float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile); if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds); diff --git a/src/textures.c b/src/textures.c index 2b61c241..d944bd64 100644 --- a/src/textures.c +++ b/src/textures.c @@ -98,7 +98,7 @@ defined(SUPPORT_FILEFORMAT_JPG) || defined(SUPPORT_FILEFORMAT_PSD) || defined(SUPPORT_FILEFORMAT_GIF) || \ defined(SUPPORT_FILEFORMAT_HDR)) #define STB_IMAGE_IMPLEMENTATION - #include "external/stb_image.h" // Required for: stbi_load() + #include "external/stb_image.h" // Required for: stbi_load_from_file() // NOTE: Used to read image data (multiple formats support) #endif -- cgit v1.2.3 From 3861bc80f273452837be3561ed236d79fcc62660 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 8 May 2017 00:55:47 +0200 Subject: StopMusicStream() review --- src/audio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index e8e80985..2393e5a4 100644 --- a/src/audio.c +++ b/src/audio.c @@ -810,7 +810,8 @@ void StopMusicStream(Music music) for (int i = 0; i < MAX_STREAM_BUFFERS; i++) { - alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate); + UpdateAudioStream(music->stream, pcm, AUDIO_BUFFER_SIZE); + //alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate); } free(pcm); @@ -853,7 +854,7 @@ void UpdateMusicStream(Music music) int numBuffersToProcess = processed; int samplesCount = 0; // Total size of data steamed in L+R samples for xm floats, - //individual L or R for ogg shorts + // individual L or R for ogg shorts for (int i = 0; i < numBuffersToProcess; i++) { -- cgit v1.2.3 From 822c2ddad59e9839aeb029f5a3dc26681188612b Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 8 May 2017 02:47:44 +0200 Subject: Some defines tweaks for consistency --- src/audio.c | 4 ++-- src/core.c | 12 ++++++------ src/rlgl.c | 18 +++++++----------- src/rlgl.h | 8 +++----- 4 files changed, 18 insertions(+), 24 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 2393e5a4..39befbbc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -79,7 +79,7 @@ #include "utils.h" // Required for: fopen() Android mapping #endif -#ifdef __APPLE__ +#if defined(__APPLE__) #include "OpenAL/al.h" // OpenAL basic header #include "OpenAL/alc.h" // OpenAL context header (like OpenGL, OpenAL requires a context to work) #else @@ -1326,7 +1326,7 @@ void TraceLog(int msgType, const char *text, ...) va_list args; int traceDebugMsgs = 0; -#ifdef DO_NOT_TRACE_DEBUG_MSGS +#if defined(DO_NOT_TRACE_DEBUG_MSGS) traceDebugMsgs = 0; #endif diff --git a/src/core.c b/src/core.c index 459b99fb..1448743f 100644 --- a/src/core.c +++ b/src/core.c @@ -118,7 +118,7 @@ //#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 #include // GLFW3 library: Windows, OpenGL context and Input management - #ifdef(__linux__) + #if defined(__linux__) #define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting #define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window #include // which are required for hiding mouse @@ -668,7 +668,7 @@ int GetScreenHeight(void) void ShowCursor() { #if defined(PLATFORM_DESKTOP) - #ifdef __linux__ + #if defined(__linux__) XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window)); #else glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); @@ -681,7 +681,7 @@ void ShowCursor() void HideCursor() { #if defined(PLATFORM_DESKTOP) - #ifdef __linux__ + #if defined(__linux__) XColor col; const char nil[] = {0}; @@ -1679,7 +1679,7 @@ static void InitGraphicsDevice(int width, int height) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above! // Other values: GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE -#ifdef __APPLE__ +#if defined(__APPLE__) glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // OSX Requires #else glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); // Fordward Compatibility Hint: Only 3.3 and above! @@ -1964,7 +1964,7 @@ static void InitGraphicsDevice(int width, int height) // Set viewport parameters static void SetupViewport(void) { -#ifdef __APPLE__ +#if defined(__APPLE__) // Get framebuffer size of current window // NOTE: Required to handle HighDPI display correctly on OSX because framebuffer // is automatically reasized to adapt to new DPI. @@ -3279,7 +3279,7 @@ static void *GamepadThread(void *arg) // Plays raylib logo appearing animation static void LogoAnimation(void) { -#ifndef PLATFORM_WEB +#if !defined(PLATFORM_WEB) int logoPositionX = screenWidth/2 - 128; int logoPositionY = screenHeight/2 - 128; diff --git a/src/rlgl.c b/src/rlgl.c index 1dc83314..edf9e60b 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -67,12 +67,12 @@ #include // Required for: strcmp(), strlen(), strtok() [Used only in extensions loading] #include // Required for: atan2() -#ifndef RLGL_STANDALONE +#if !defined(RLGL_STANDALONE) #include "raymath.h" // Required for: Vector3 and Matrix functions #endif #if defined(GRAPHICS_API_OPENGL_11) - #ifdef __APPLE__ + #if defined(__APPLE__) #include // OpenGL 1.1 library for OSX #else #include // OpenGL 1.1 library @@ -84,7 +84,7 @@ #endif #if defined(GRAPHICS_API_OPENGL_33) - #ifdef __APPLE__ + #if defined(__APPLE__) #include // OpenGL 3 library for OSX #else #define GLAD_IMPLEMENTATION @@ -1286,21 +1286,17 @@ void rlglLoadExtensions(void *loader) { #if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33) // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions) - #ifndef __APPLE__ + #if !defined(__APPLE__) if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions"); else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully"); - #endif -#if defined(GRAPHICS_API_OPENGL_21) - #ifndef __APPLE__ + #if defined(GRAPHICS_API_OPENGL_21) if (GLAD_GL_VERSION_2_1) TraceLog(INFO, "OpenGL 2.1 profile supported"); - #endif -#elif defined(GRAPHICS_API_OPENGL_33) - #ifndef __APPLE__ + #elif defined(GRAPHICS_API_OPENGL_33) if(GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported"); else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported"); + #endif #endif -#endif // With GLAD, we can check if an extension is supported using the GLAD_GL_xxx booleans //if (GLAD_GL_ARB_vertex_array_object) // Use GL_ARB_vertex_array_object diff --git a/src/rlgl.h b/src/rlgl.h index 300949f9..b51d1c49 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -59,12 +59,10 @@ #ifndef RLGL_H #define RLGL_H -#ifndef RLGL_STANDALONE - #include "raylib.h" // Required for: Model, Shader, Texture2D, TraceLog() -#endif - -#ifdef RLGL_STANDALONE +#if defined(RLGL_STANDALONE) #define RAYMATH_STANDALONE +#else + #include "raylib.h" // Required for: Model, Shader, Texture2D, TraceLog() #endif #include "raymath.h" // Required for: Vector3, Matrix -- cgit v1.2.3 From 16842233c92cec78bb3771c711269b43be33c241 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 10 May 2017 19:34:57 +0200 Subject: Review issue and added some comments --- src/audio.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 39befbbc..3005586f 100644 --- a/src/audio.c +++ b/src/audio.c @@ -801,20 +801,26 @@ void ResumeMusicStream(Music music) } // Stop music playing (close stream) +// TODO: To clear a buffer, make sure they have been already processed! void StopMusicStream(Music music) { alSourceStop(music->stream.source); + /* // Clear stream buffers + // WARNING: Queued buffers must have been processed before unqueueing and reloaded with data!!! void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, 1); - + for (int i = 0; i < MAX_STREAM_BUFFERS; i++) { - UpdateAudioStream(music->stream, pcm, AUDIO_BUFFER_SIZE); - //alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate); + + + //UpdateAudioStream(music->stream, pcm, AUDIO_BUFFER_SIZE); // Update one buffer at a time + alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate); } free(pcm); + */ // Restart music context switch (music->ctxType) @@ -896,9 +902,9 @@ void UpdateMusicStream(Music music) break; } } - - // This error is registered when UpdateAudioStream() fails - if (alGetError() == AL_INVALID_VALUE) TraceLog(WARNING, "OpenAL: Error buffering data..."); + + // Free allocated pcm data + free(pcm); // Reset audio stream for looping if (!active) @@ -918,8 +924,6 @@ void UpdateMusicStream(Music music) // just make sure to play again on window restore if (state != AL_PLAYING) PlayMusicStream(music); } - - free(pcm); } } @@ -1066,7 +1070,8 @@ void CloseAudioStream(AudioStream stream) } // Update audio stream buffers with data -// NOTE: Only updates one buffer per call +// NOTE 1: Only updates one buffer of the stream source: unqueue -> update -> queue +// NOTE 2: To unqueue a buffer it needs to be processed: IsAudioBufferProcessed() void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount) { ALuint buffer = 0; @@ -1075,9 +1080,10 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount) // Check if any buffer was available for unqueue if (alGetError() != AL_INVALID_VALUE) { - alBufferData(buffer, stream.format, data, samplesCount*stream.channels*stream.sampleSize/8, stream.sampleRate); + alBufferData(buffer, stream.format, data, samplesCount*stream.sampleSize/8*stream.channels, stream.sampleRate); alSourceQueueBuffers(stream.source, 1, &buffer); } + else TraceLog(WARNING, "[AUD ID %i] Audio buffer not available for unqueuing", stream.source); } // Check if any audio stream buffers requires refill -- cgit v1.2.3 From 01e65664dd99c71c6e62c4b132d7387accf82fdd Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 14 May 2017 18:32:47 +0200 Subject: Reviewed some comments... --- src/audio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/audio.c') diff --git a/src/audio.c b/src/audio.c index 3005586f..b81d5572 100644 --- a/src/audio.c +++ b/src/audio.c @@ -797,7 +797,11 @@ void ResumeMusicStream(Music music) ALenum state; alGetSourcei(music->stream.source, AL_SOURCE_STATE, &state); - if (state == AL_PAUSED) alSourcePlay(music->stream.source); + if (state == AL_PAUSED) + { + TraceLog(INFO, "[AUD ID %i] Resume music stream playing", music->stream.source); + alSourcePlay(music->stream.source); + } } // Stop music playing (close stream) @@ -813,8 +817,6 @@ void StopMusicStream(Music music) for (int i = 0; i < MAX_STREAM_BUFFERS; i++) { - - //UpdateAudioStream(music->stream, pcm, AUDIO_BUFFER_SIZE); // Update one buffer at a time alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate); } @@ -853,7 +855,7 @@ void UpdateMusicStream(Music music) if (processed > 0) { - bool active = true; + bool streamEnding = false; // NOTE: Using dynamic allocation because it could require more than 16KB void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, 1); @@ -898,7 +900,7 @@ void UpdateMusicStream(Music music) if (music->samplesLeft <= 0) { - active = false; + streamEnding = true; break; } } @@ -907,7 +909,7 @@ void UpdateMusicStream(Music music) free(pcm); // Reset audio stream for looping - if (!active) + if (streamEnding) { StopMusicStream(music); // Stop music (and reset) -- cgit v1.2.3