From 9d3ad52160a0e32271a8e3d76d9ea95e9bd0684a Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 15 Nov 2016 19:15:25 +0100 Subject: Removed byte typedef --- src/raylib.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/raylib.h') diff --git a/src/raylib.h b/src/raylib.h index f6243304..2e3112cf 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -305,9 +305,6 @@ #endif #endif -// byte type -typedef unsigned char byte; - // Vector2 type typedef struct Vector2 { float x; -- cgit v1.2.3 From 6d1b712a9678a7e1d57d994ab51afafbe06ec5fb Mon Sep 17 00:00:00 2001 From: raysan5 Date: Wed, 16 Nov 2016 18:46:13 +0100 Subject: Reviewed modules comments --- src/audio.c | 19 ++++++++++++------- src/audio.h | 16 +++++++++------- src/core.c | 25 +++++++++++++------------ src/external/stb_image.h | 4 ++-- src/models.c | 9 +++++++-- src/raylib.h | 34 ++++++++++++++++++---------------- src/rlgl.c | 29 ++++++++++++++++++++++++----- src/rlgl.h | 26 +++++++++++++++++++++----- src/shapes.c | 10 ++++++++-- src/text.c | 8 +++++++- src/textures.c | 10 +++++++--- src/utils.c | 14 ++++++++++---- src/utils.h | 6 ++---- 13 files changed, 140 insertions(+), 70 deletions(-) (limited to 'src/raylib.h') diff --git a/src/audio.c b/src/audio.c index 3684e10a..3ddbf0ce 100644 --- a/src/audio.c +++ b/src/audio.c @@ -2,18 +2,22 @@ * * raylib.audio * -* Basic functions to manage Audio: +* This module provides basic functionality to work with audio: * Manage audio device (init/close) -* Load and Unload audio files +* Load and Unload audio files (WAV, OGG, FLAC, XM, MOD) * Play/Stop/Pause/Resume loaded audio * Manage mixing channels * Manage raw audio context * -* Uses external lib: -* OpenAL Soft - Audio device management lib (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 +* External libs: +* 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 +* +* Module Configuration Flags: +* AUDIO_STANDALONE - Use this module as standalone library (independently of raylib) * * Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: * XM audio module support (jar_xm) @@ -21,6 +25,7 @@ * Mixing channels support * Raw audio context support * +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event diff --git a/src/audio.h b/src/audio.h index 923492ca..5de8f613 100644 --- a/src/audio.h +++ b/src/audio.h @@ -2,18 +2,19 @@ * * raylib.audio * -* Basic functions to manage Audio: +* This module provides basic functionality to work with audio: * Manage audio device (init/close) -* Load and Unload audio files +* Load and Unload audio files (WAV, OGG, FLAC, XM, MOD) * Play/Stop/Pause/Resume loaded audio * Manage mixing channels * Manage raw audio context * -* Uses external lib: -* OpenAL Soft - Audio device management lib (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 +* External libs: +* 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 * * Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: * XM audio module support (jar_xm) @@ -21,6 +22,7 @@ * Mixing channels support * Raw audio context support * +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event diff --git a/src/core.c b/src/core.c index 8e15eb96..991dd4a0 100644 --- a/src/core.c +++ b/src/core.c @@ -4,24 +4,25 @@ * * Basic functions to manage windows, OpenGL context and input on multiple platforms * -* The following platforms are supported: -* PLATFORM_DESKTOP - Windows, Linux, Mac (OSX) -* PLATFORM_ANDROID - Only OpenGL ES 2.0 devices -* PLATFORM_RPI - Rapsberry Pi (tested on Raspbian) -* PLATFORM_WEB - Emscripten, HTML5 -* Oculus Rift CV1 (with desktop mirror) - View [rlgl] module to enable it +* The following platforms are supported: Windows, Linux, Mac (OSX), Android, Raspberry Pi, HTML5, Oculus Rift CV1 * -* On PLATFORM_DESKTOP, the external lib GLFW3 (www.glfw.com) is used to manage graphic -* device, OpenGL context and input on multiple operating systems (Windows, Linux, OSX). -* -* On PLATFORM_ANDROID, graphic device is managed by EGL and input system by Android activity. -* -* On PLATFORM_RPI, graphic device is managed by EGL and input system is coded in raw mode. +* External libs: +* GLFW3 - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX) +* raymath - 3D math functionality (Vector3, Matrix, Quaternion) +* camera - Multiple 3D camera modes (free, orbital, 1st person, 3rd person) +* gestures - Gestures system for touch-ready devices (or simulated from mouse inputs) * * Module Configuration Flags: +* PLATFORM_DESKTOP - Windows, Linux, Mac (OSX) +* PLATFORM_ANDROID - Android (only OpenGL ES 2.0 devices), graphic device is managed by EGL and input system by Android activity. +* PLATFORM_RPI - Rapsberry Pi (tested on Raspbian), graphic device is managed by EGL and input system is coded in raw mode. +* PLATFORM_WEB - HTML5 (using emscripten compiler) * * RL_LOAD_DEFAULT_FONT - Use external module functions to load default raylib font (module: text) * +* NOTE: Oculus Rift CV1 requires PLATFORM_DESKTOP for render mirror - View [rlgl] module to enable it +* +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event diff --git a/src/external/stb_image.h b/src/external/stb_image.h index ce87646d..5572a880 100644 --- a/src/external/stb_image.h +++ b/src/external/stb_image.h @@ -390,7 +390,7 @@ publish, and distribute this file as you see fit. #define STBI_NO_HDR // RaySan: not required by raylib -#define STBI_NO_SIMD // RaySan: issues when compiling with GCC 4.7.2 +//#define STBI_NO_SIMD // RaySan: issues when compiling with GCC 4.7.2 #ifndef STBI_NO_STDIO #include @@ -398,7 +398,7 @@ publish, and distribute this file as you see fit. // NOTE: Added to work with raylib on Android #if defined(PLATFORM_ANDROID) - #include "utils.h" // Android fopen function map + #include "utils.h" // RaySan: Android fopen function map #endif #define STBI_VERSION 1 diff --git a/src/models.c b/src/models.c index b7e36b8a..4275f89e 100644 --- a/src/models.c +++ b/src/models.c @@ -4,6 +4,12 @@ * * Basic functions to draw 3d shapes and load/draw 3d models (.OBJ) * +* External libs: +* rlgl - raylib OpenGL abstraction layer +* +* Module Configuration Flags: +* ... +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event @@ -34,8 +40,7 @@ #include // Required for: strcmp() #include // Required for: sin(), cos() -#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 -#include "raymath.h" // Matrix data type and Matrix functions +#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 //---------------------------------------------------------------------------------- // Defines and Macros diff --git a/src/raylib.h b/src/raylib.h index 2e3112cf..ef393f63 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -6,37 +6,39 @@ * * Features: * Library written in plain C code (C99) -* Uses C# PascalCase/camelCase notation +* Uses PascalCase/camelCase notation * Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0) * Unique OpenGL abstraction layer (usable as standalone module): [rlgl] * Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF) * Multiple textures support, including compressed formats and mipmaps generation * Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps * Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support -* Powerful math module for Vector, Matrix and Quaternion operations [raymath] -* Audio loading and playing with streaming support and mixing channels (WAV, OGG, XM, MOD) +* Powerful math module for Vector, Matrix and Quaternion operations: [raymath] +* Audio loading and playing with streaming support and mixing channels [audio] * VR stereo rendering support with configurable HMD device parameters * Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi, HTML5 and Oculus Rift CV1 * Custom color palette for fancy visuals on raywhite background * Minimal external dependencies (GLFW3, OpenGL, OpenAL) +* Complete binding for LUA [rlua] * -* Used external libs: -* GLFW3 (www.glfw.org) for window/context management and input -* GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) -* stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA, PSD, GIF, HDR, PIC) -* stb_image_write (Sean Barret) for image writting (PNG) -* stb_vorbis (Sean Barret) for ogg audio loading -* stb_truetype (Sean Barret) for ttf fonts loading -* jar_xm (Joshua Reisenauer) for XM audio module loading -* jar_mod (Joshua Reisenauer) for MOD audio module loading -* OpenAL Soft for audio device/context management -* tinfl for data decompression (DEFLATE algorithm) +* External libs: +* GLFW3 (www.glfw.org) for window/context management and input [core] +* GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl] +* stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures] +* stb_image_write (Sean Barret) for image writting (PNG) [utils] +* stb_truetype (Sean Barret) for ttf fonts loading [text] +* stb_vorbis (Sean Barret) for ogg audio loading [audio] +* jar_xm (Joshua Reisenauer) for XM audio module loading [audio] +* jar_mod (Joshua Reisenauer) for MOD audio module loading [audio] +* dr_flac (David Reid) for FLAC audio file loading [audio] +* OpenAL Soft for audio device/context management [audio] +* tinfl for data decompression (DEFLATE algorithm) [utils] * * Some design decisions: * 32bit Colors - All defined color are always RGBA (struct Color is 4 byte) -* One custom default font is loaded automatically when InitWindow() +* One custom default font could be loaded automatically when InitWindow() [core] * If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads -* If using OpenGL 3.3 or ES2, two default shaders are loaded automatically (internally defined) +* If using OpenGL 3.3 or ES2, two default shaders could be loaded automatically (internally defined) * * -- LICENSE -- * diff --git a/src/rlgl.c b/src/rlgl.c index d3bba07b..28dc5171 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -2,11 +2,30 @@ * * rlgl - raylib OpenGL abstraction layer * -* raylib now uses OpenGL 1.1 style functions (rlVertex) that are mapped to selected OpenGL version: -* OpenGL 1.1 - Direct map rl* -> gl* -* OpenGL 2.1 - Vertex data is stored in VBOs, call rlglDraw() to render -* OpenGL 3.3 - Vertex data is stored in VAOs, call rlglDraw() to render -* OpenGL ES 2 - Vertex data is stored in VBOs or VAOs (when available), call rlglDraw() to render +* 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). +* +* 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: +* rlglInit() - Initialize internal buffers and auxiliar resources +* rlglDraw() - Process internal buffers and send required draw calls +* rlglClose() - De-initialize internal buffers data and other auxiliar resources +* +* External libs: +* 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) +* RLGL_NO_STANDARD_SHADER - Avoid standard shader (shader_standard.h) inclusion +* RLGL_NO_DISTORTION_SHADER - Avoid stereo rendering distortion sahder (shader_distortion.h) inclusion +* RLGL_OCULUS_SUPPORT - Enable Oculus Rift CV1 functionality +* * * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * diff --git a/src/rlgl.h b/src/rlgl.h index 78ea6727..e4d40714 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -2,11 +2,27 @@ * * rlgl - raylib OpenGL abstraction layer * -* raylib now uses OpenGL 1.1 style functions (rlVertex) that are mapped to selected OpenGL version: -* OpenGL 1.1 - Direct map rl* -> gl* -* OpenGL 2.1 - Vertex data is stored in VBOs, call rlglDraw() to render -* OpenGL 3.3 - Vertex data is stored in VAOs, call rlglDraw() to render -* OpenGL ES 2 - Vertex data is stored in VBOs or VAOs (when available), call rlglDraw() to render +* 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). +* +* 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: +* rlglInit() - Initialize internal buffers and auxiliar resources +* rlglDraw() - Process internal buffers and send required draw calls +* rlglClose() - De-initialize internal buffers data and other auxiliar resources +* +* External libs: +* 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) +* * * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * diff --git a/src/shapes.c b/src/shapes.c index 79cf567a..70aad59a 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -4,6 +4,12 @@ * * Basic functions to draw 2d Shapes and check collisions * +* External libs: +* rlgl - raylib OpenGL abstraction layer +* +* Module Configuration Flags: +* ... +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event @@ -25,11 +31,11 @@ #include "raylib.h" +#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 + #include // Required for: abs() #include // Required for: sinf(), cosf(), sqrtf() -#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 - //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- diff --git a/src/text.c b/src/text.c index 72d273d4..d752f1cb 100644 --- a/src/text.c +++ b/src/text.c @@ -4,6 +4,12 @@ * * Basic functions to load SpriteFonts and draw Text * +* External libs: +* stb_truetype - Load TTF file and rasterize characters data +* +* Module Configuration Flags: +* ... +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event @@ -33,7 +39,7 @@ #include "utils.h" // Required for: GetExtension(), GetNextPOT() // Following libs are used on LoadTTF() -//#define STBTT_STATIC +#define STBTT_STATIC // Define stb_truetype functions static to this module #define STB_TRUETYPE_IMPLEMENTATION #include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() diff --git a/src/textures.c b/src/textures.c index 5354a74f..af59d035 100644 --- a/src/textures.c +++ b/src/textures.c @@ -4,9 +4,13 @@ * * Basic functions to load and draw Textures (2d) * -* Uses external lib: -* stb_image - Multiple formats image loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC) -* NOTE: stb_image has been slightly modified, original library: https://github.com/nothings/stb +* External libs: +* stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC) +* NOTE: stb_image has been slightly modified to support Android platform. +* stb_image_resize - Multiple image resize algorythms +* +* Module Configuration Flags: +* ... * * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * diff --git a/src/utils.c b/src/utils.c index b96e2c70..640c5720 100644 --- a/src/utils.c +++ b/src/utils.c @@ -2,12 +2,16 @@ * * raylib.utils * -* Utils Functions Definitions +* Some utility functions * -* Uses external libs: -* tinfl - zlib DEFLATE algorithm decompression lib +* External libs: +* tinfl - zlib DEFLATE algorithm decompression * stb_image_write - PNG writting functions * +* Module Configuration Flags: +* DO_NOT_TRACE_DEBUG_MSGS - Avoid showing DEBUG TraceLog() messages +* +* * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event @@ -46,7 +50,9 @@ #endif #include "external/tinfl.c" // Required for: tinfl_decompress_mem_to_mem() - // NOTE: Deflate algorythm data decompression + // NOTE: DEFLATE algorythm data decompression + +#define DO_NOT_TRACE_DEBUG_MSGS // Avoid DEBUG messages tracing //---------------------------------------------------------------------------------- // Global Variables Definition diff --git a/src/utils.h b/src/utils.h index 899cf583..045b0692 100644 --- a/src/utils.h +++ b/src/utils.h @@ -2,9 +2,9 @@ * * raylib.utils * -* Some utility functions: rRES files data decompression +* Some utility functions * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2016 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. @@ -34,8 +34,6 @@ //---------------------------------------------------------------------------------- // Some basic Defines //---------------------------------------------------------------------------------- -#define DO_NOT_TRACE_DEBUG_MSGS // Use this define to avoid DEBUG tracing - #if defined(PLATFORM_ANDROID) #define fopen(name, mode) android_fopen(name, mode) #endif -- cgit v1.2.3 From bee283b12b348b054bde2eae1a449c363ac26fd7 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 17 Nov 2016 12:55:30 +0100 Subject: Some tweaks around --- src/Makefile | 5 +++++ src/core.c | 4 ++-- src/models.c | 12 ++++++------ src/raylib.h | 16 ++++++++-------- src/rlgl.c | 4 ++-- src/rlgl.h | 3 ++- 6 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/raylib.h') diff --git a/src/Makefile b/src/Makefile index feadc424..2433428f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -41,6 +41,11 @@ SHARED ?= NO # define NO to use OpenAL Soft as static library (or shared by default) SHARED_OPENAL ?= NO +# on PLATFORM_WEB force OpenAL Soft shared library +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL ?= YES +endif + # determine if the file has root access (only for installing raylib) # "whoami" prints the name of the user that calls him (so, if it is the root # user, "whoami" prints "root"). diff --git a/src/core.c b/src/core.c index 991dd4a0..4807b7f6 100644 --- a/src/core.c +++ b/src/core.c @@ -668,7 +668,7 @@ void Begin3dMode(Camera camera) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) - if (IsVrDeviceReady()) BeginVrDrawing(); + if (IsVrDeviceReady() || IsVrSimulator()) BeginVrDrawing(); rlMatrixMode(RL_PROJECTION); // Switch to projection matrix @@ -698,7 +698,7 @@ void End3dMode(void) { rlglDraw(); // Process internal buffers (update + draw) - if (IsVrDeviceReady()) EndVrDrawing(); + if (IsVrDeviceReady() || IsVrSimulator()) EndVrDrawing(); rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlPopMatrix(); // Restore previous matrix (PROJECTION) from matrix stack diff --git a/src/models.c b/src/models.c index 4275f89e..be0e6ea4 100644 --- a/src/models.c +++ b/src/models.c @@ -81,11 +81,11 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color) } // Draw a circle in 3D world space -void DrawCircle3D(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color) +void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color) { rlPushMatrix(); rlTranslatef(center.x, center.y, center.z); - rlRotatef(rotationAngle, rotation.x, rotation.y, rotation.z); + rlRotatef(rotationAngle, rotationAxis.x, rotationAxis.y, rotationAxis.z); rlBegin(RL_LINES); for (int i = 0; i < 360; i += 10) @@ -584,9 +584,9 @@ void DrawLight(Light light) { DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY)); - DrawCircle3D(light->position, light->radius, 0.0f, (Vector3){ 0, 0, 0 }, (light->enabled ? light->diffuse : GRAY)); - DrawCircle3D(light->position, light->radius, 90.0f, (Vector3){ 1, 0, 0 }, (light->enabled ? light->diffuse : GRAY)); - DrawCircle3D(light->position, light->radius, 90.0f, (Vector3){ 0, 1, 0 }, (light->enabled ? light->diffuse : GRAY)); + DrawCircle3D(light->position, light->radius, (Vector3){ 0, 0, 0 }, 0.0f, (light->enabled ? light->diffuse : GRAY)); + DrawCircle3D(light->position, light->radius, (Vector3){ 1, 0, 0 }, 90.0f, (light->enabled ? light->diffuse : GRAY)); + DrawCircle3D(light->position, light->radius, (Vector3){ 0, 1, 0 },90.0f, (light->enabled ? light->diffuse : GRAY)); } break; case LIGHT_DIRECTIONAL: { @@ -602,7 +602,7 @@ void DrawLight(Light light) Vector3 dir = VectorSubtract(light->target, light->position); VectorNormalize(&dir); - DrawCircle3D(light->position, 0.5f, 0.0f, dir, (light->enabled ? light->diffuse : GRAY)); + DrawCircle3D(light->position, 0.5f, dir, 0.0f, (light->enabled ? light->diffuse : GRAY)); //DrawCylinderWires(light->position, 0.0f, 0.3f*light->coneAngle/50, 0.6f, 5, (light->enabled ? light->diffuse : GRAY)); DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY)); diff --git a/src/raylib.h b/src/raylib.h index ef393f63..6d67051e 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -724,7 +724,7 @@ RLAPI float GetGesturePinchAngle(void); // Get gesture pin //------------------------------------------------------------------------------------ // Camera System Functions (Module: camera) //------------------------------------------------------------------------------------ -RLAPI void SetCameraMode(Camera, int mode); // Set camera mode (multiple camera modes available) +RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera) @@ -835,7 +835,7 @@ RLAPI const char *SubText(const char *text, int position, int length); // Basic 3d Shapes Drawing Functions (Module: models) //------------------------------------------------------------------------------------ RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space -RLAPI void DrawCircle3D(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color); // Draw a circle in 3D world space +RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires @@ -850,7 +850,7 @@ RLAPI void DrawRay(Ray ray, Color color); RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo RLAPI void DrawLight(Light light); // Draw light in 3D world -//DrawTorus(), DrawTeapot() are useless... +//DrawTorus(), DrawTeapot() could be useful? //------------------------------------------------------------------------------------ // Model 3d Loading and Drawing Functions (Module: models) @@ -917,7 +917,7 @@ RLAPI void DestroyLight(Light light); // Des //------------------------------------------------------------------------------------ RLAPI void InitVrDevice(int vdDevice); // Init VR device RLAPI void CloseVrDevice(void); // Close VR device -RLAPI bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready +RLAPI bool IsVrDeviceReady(void); // Detect if VR device is ready RLAPI bool IsVrSimulator(void); // Detect if VR simulator is running RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) @@ -926,7 +926,7 @@ RLAPI void ToggleVrMode(void); // Enable/Disable VR experienc // Audio Loading and Playing Functions (Module: audio) //------------------------------------------------------------------------------------ RLAPI void InitAudioDevice(void); // Initialize audio device and context -RLAPI void CloseAudioDevice(void); // Close the audio device and context (and music stream) +RLAPI void CloseAudioDevice(void); // Close the audio device and context RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully RLAPI Wave LoadWave(const char *fileName); // Load wave data from file into RAM @@ -950,9 +950,9 @@ RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file RLAPI void UnloadMusicStream(Music music); // Unload music stream -RLAPI void PlayMusicStream(Music music); // Start music playing (open stream) +RLAPI void PlayMusicStream(Music music); // Start music playing RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming -RLAPI void StopMusicStream(Music music); // Stop music playing (close stream) +RLAPI void StopMusicStream(Music music); // Stop music playing RLAPI void PauseMusicStream(Music music); // Pause music playing RLAPI void ResumeMusicStream(Music music); // Resume playing paused music RLAPI bool IsMusicPlaying(Music music); // Check if music is playing @@ -963,7 +963,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, - unsigned int channels); // Init audio stream (to stream audio pcm data) + unsigned int channels); // Init audio stream (to stream raw audio pcm data) RLAPI void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill diff --git a/src/rlgl.c b/src/rlgl.c index 28dc5171..b567f8fd 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -2786,13 +2786,13 @@ void CloseVrDevice(void) // Detect if VR device is available bool IsVrDeviceReady(void) { - return (vrDeviceReady || vrSimulator) && vrEnabled; + return (vrDeviceReady && vrEnabled); } // Detect if VR simulator is running bool IsVrSimulator(void) { - return vrSimulator; + return (vrSimulator && vrEnabled); } // Enable/Disable VR experience (device or simulator) diff --git a/src/rlgl.h b/src/rlgl.h index e4d40714..7d328a52 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -423,7 +423,8 @@ float *MatrixToFloat(Matrix mat); void InitVrDevice(int vrDevice); // Init VR device void CloseVrDevice(void); // Close VR device -bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready +bool IsVrDeviceReady(void); // Detect if VR device is ready +bool IsVrSimulator(void); // Detect if VR simulator is running void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) -- cgit v1.2.3 From f1bcfc1352f73b9da98601f6b67cd15853b1cb8f Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 22 Nov 2016 12:14:55 +0100 Subject: Corrected bug on GenTextureMipmaps() texture.mipmaps value needs to be updated, so, texture must be passed by reference instead of by value --- src/raylib.h | 2 +- src/rlgl.c | 30 ++++++++++++++++++------------ src/rlgl.h | 2 +- src/textures.c | 8 ++++---- 4 files changed, 24 insertions(+), 18 deletions(-) (limited to 'src/raylib.h') diff --git a/src/raylib.h b/src/raylib.h index 6d67051e..d28b07a3 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -802,7 +802,7 @@ RLAPI void ImageColorInvert(Image *image); RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) -RLAPI void GenTextureMipmaps(Texture2D texture); // Generate GPU mipmaps for a texture +RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode diff --git a/src/rlgl.c b/src/rlgl.c index b567f8fd..629d7967 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1719,15 +1719,15 @@ void rlglUpdateTexture(unsigned int id, int width, int height, int format, void } // Generate mipmap data for selected texture -void rlglGenerateMipmaps(Texture2D texture) +void rlglGenerateMipmaps(Texture2D *texture) { - glBindTexture(GL_TEXTURE_2D, texture.id); + glBindTexture(GL_TEXTURE_2D, texture->id); // Check if texture is power-of-two (POT) bool texIsPOT = false; - if (((texture.width > 0) && ((texture.width & (texture.width - 1)) == 0)) && - ((texture.height > 0) && ((texture.height & (texture.height - 1)) == 0))) texIsPOT = true; + if (((texture->width > 0) && ((texture->width & (texture->width - 1)) == 0)) && + ((texture->height > 0) && ((texture->height & (texture->height - 1)) == 0))) texIsPOT = true; if ((texIsPOT) || (npotSupported)) { @@ -1737,13 +1737,13 @@ void rlglGenerateMipmaps(Texture2D texture) // NOTE: data size is reallocated to fit mipmaps data // NOTE: CPU mipmap generation only supports RGBA 32bit data - int mipmapCount = GenerateMipmaps(data, texture.width, texture.height); + int mipmapCount = GenerateMipmaps(data, texture->width, texture->height); - int size = texture.width*texture.height*4; // RGBA 32bit only + int size = texture->width*texture->height*4; // RGBA 32bit only int offset = size; - int mipWidth = texture.width/2; - int mipHeight = texture.height/2; + int mipWidth = texture->width/2; + int mipHeight = texture->height/2; // Load the mipmaps for (int level = 1; level < mipmapCount; level++) @@ -1757,23 +1757,29 @@ void rlglGenerateMipmaps(Texture2D texture) mipHeight /= 2; } - TraceLog(WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture.id); + TraceLog(WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture->id); // NOTE: Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data free(data); + texture->mipmaps = mipmapCount + 1; #endif #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically - TraceLog(INFO, "[TEX ID %i] Mipmaps generated automatically", texture.id); + TraceLog(INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps (must be available) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps + + #define MIN(a,b) (((a)<(b))?(a):(b)) + #define MAX(a,b) (((a)>(b))?(a):(b)) + + texture->mipmaps = 1 + floor(log2(MAX(texture->width, texture->height))); #endif } - else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture.id); + else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id); glBindTexture(GL_TEXTURE_2D, 0); } diff --git a/src/rlgl.h b/src/rlgl.h index 7d328a52..bc12db0f 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -371,7 +371,7 @@ void rlglLoadExtensions(void *loader); // Load OpenGL extensions unsigned int rlglLoadTexture(void *data, int width, int height, int textureFormat, int mipmapCount); // Load texture in GPU RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments) void rlglUpdateTexture(unsigned int id, int width, int height, int format, void *data); // Update GPU texture with new data -void rlglGenerateMipmaps(Texture2D texture); // Generate mipmap data for selected texture +void rlglGenerateMipmaps(Texture2D *texture); // Generate mipmap data for selected texture void rlglLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids void rlglUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer) diff --git a/src/textures.c b/src/textures.c index af59d035..126adad3 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1516,14 +1516,14 @@ void ImageColorBrightness(Image *image, int brightness) } // Generate GPU mipmaps for a texture -void GenTextureMipmaps(Texture2D texture) +void GenTextureMipmaps(Texture2D *texture) { #if PLATFORM_WEB - int potWidth = GetNextPOT(texture.width); - int potHeight = GetNextPOT(texture.height); + int potWidth = GetNextPOT(texture->width); + int potHeight = GetNextPOT(texture->height); // Check if texture is POT - if ((potWidth != texture.width) || (potHeight != texture.height)) + if ((potWidth != texture->width) || (potHeight != texture->height)) { TraceLog(WARNING, "Limited NPOT support, no mipmaps available for NPOT textures"); } -- cgit v1.2.3