From 5df10d824cc302bfdd765e1b28d293caaaeffcce Mon Sep 17 00:00:00 2001 From: Saggi Mizrahi Date: Thu, 22 Dec 2016 03:18:24 +0200 Subject: [PATCH 1/5] Fix bad call to oculus API Missing passing of &camera Signed-off-by: Saggi Mizrahi --- examples/rlgl_oculus_rift.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rlgl_oculus_rift.c b/examples/rlgl_oculus_rift.c index 39dee99e..30ef6f3b 100644 --- a/examples/rlgl_oculus_rift.c +++ b/examples/rlgl_oculus_rift.c @@ -144,7 +144,7 @@ int main(void) { // Update //---------------------------------------------------------------------------------- - UpdateOculusTracking(); + UpdateOculusTracking(&camera); //---------------------------------------------------------------------------------- // Draw From c394708c438440db1b756bfe7e86a15341a43cb7 Mon Sep 17 00:00:00 2001 From: Saggi Mizrahi Date: Thu, 22 Dec 2016 03:19:49 +0200 Subject: [PATCH 2/5] Change UpdateSound() to accept const void * The function means to accept a const * so let's declare it. Will allow passing const buffers in games. Also constness is next to godliness! Signed-off-by: Saggi Mizrahi --- src/audio.c | 2 +- src/audio.h | 2 +- src/raylib.h | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/audio.c b/src/audio.c index a9c07c39..aa89de02 100644 --- a/src/audio.c +++ b/src/audio.c @@ -342,7 +342,7 @@ void UnloadSound(Sound sound) // Update sound buffer with new data // NOTE: data must match sound.format -void UpdateSound(Sound sound, void *data, int numSamples) +void UpdateSound(Sound sound, const void *data, int numSamples) { ALint sampleRate, sampleSize, channels; alGetBufferi(sound.buffer, AL_FREQUENCY, &sampleRate); diff --git a/src/audio.h b/src/audio.h index 2b3c5933..db1bb694 100644 --- a/src/audio.h +++ b/src/audio.h @@ -115,7 +115,7 @@ Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, in Sound LoadSound(const char *fileName); // Load sound to memory Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource) -void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data +void UpdateSound(Sound sound, const void *data, int numSamples); // 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 diff --git a/src/raylib.h b/src/raylib.h index e7d2b74a..fff0c928 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -549,7 +549,7 @@ typedef enum { // Texture parameters: filter mode // NOTE 1: Filtering considers mipmaps if available in the texture // NOTE 2: Filter is accordingly set for minification and magnification -typedef enum { +typedef enum { FILTER_POINT = 0, // No filter, just pixel aproximation FILTER_BILINEAR, // Linear filtering FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps) @@ -581,12 +581,12 @@ typedef enum { } Gestures; // Camera system modes -typedef enum { - CAMERA_CUSTOM = 0, - CAMERA_FREE, - CAMERA_ORBITAL, - CAMERA_FIRST_PERSON, - CAMERA_THIRD_PERSON +typedef enum { + CAMERA_CUSTOM = 0, + CAMERA_FREE, + CAMERA_ORBITAL, + CAMERA_FIRST_PERSON, + CAMERA_THIRD_PERSON } CameraMode; // Head Mounted Display devices @@ -930,7 +930,8 @@ RLAPI Wave LoadWave(const char *fileName); // Load wa RLAPI Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from float array data (32bit) RLAPI Sound LoadSound(const char *fileName); // Load sound to memory RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data -RLAPI void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data +RLAPI void UpdateSound(Sound sound, const void *data, int numSamples);// Update sound buffer with new data +RLAPI Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource) RLAPI void UnloadWave(Wave wave); // Unload wave data RLAPI void UnloadSound(Sound sound); // Unload sound RLAPI void PlaySound(Sound sound); // Play a sound From b2d4cd66a72fd765daa64c27f6a8e529d3d18e2d Mon Sep 17 00:00:00 2001 From: Saggi Mizrahi Date: Thu, 22 Dec 2016 03:20:27 +0200 Subject: [PATCH 3/5] Fix warnings in lua binding Signed-off-by: Saggi Mizrahi --- src/rlua.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rlua.h b/src/rlua.h index 961ed1c1..10a75e3a 100644 --- a/src/rlua.h +++ b/src/rlua.h @@ -133,6 +133,7 @@ RLUADEF void CloseLuaDevice(void); // De-initialize Lua system #define LuaPush_AudioStream(L, aud) LuaPushOpaqueType(L, aud) #define LuaGetArgument_string luaL_checkstring +#define LuaGetArgument_ptr (void *)luaL_checkinteger #define LuaGetArgument_int (int)luaL_checkinteger #define LuaGetArgument_unsigned (unsigned)luaL_checkinteger #define LuaGetArgument_char (char)luaL_checkinteger @@ -1198,7 +1199,7 @@ int lua_GetGamepadName(lua_State* L) // TODO: Return gamepad name id int arg1 = LuaGetArgument_int(L, 1); - char * result = GetGamepadName(arg1); + const char * result = GetGamepadName(arg1); //lua_pushboolean(L, result); return 1; } @@ -2863,7 +2864,7 @@ int lua_LoadWaveEx(lua_State* L) { // TODO: Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, int channels); - int arg1 = 0; + float * arg1 = 0; int arg2 = LuaGetArgument_int(L, 2); int arg3 = LuaGetArgument_int(L, 3); int arg4 = LuaGetArgument_int(L, 4); @@ -2904,7 +2905,7 @@ int lua_UpdateSound(lua_State* L) Sound arg1 = LuaGetArgument_Sound(L, 1); const char * arg2 = LuaGetArgument_string(L, 2); - int * arg3 = LuaGetArgument_int(L, 3); + int arg3 = LuaGetArgument_int(L, 3); UpdateSound(arg1, arg2, arg3); return 0; } From 1aa775eca8d5fbacb3d5b19143ca08c6b9eca65d Mon Sep 17 00:00:00 2001 From: Saggi Mizrahi Date: Thu, 22 Dec 2016 03:21:04 +0200 Subject: [PATCH 4/5] Fix physac.h building on linux Signed-off-by: Saggi Mizrahi --- src/physac.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/physac.h b/src/physac.h index e807ffa6..d958c701 100644 --- a/src/physac.h +++ b/src/physac.h @@ -239,9 +239,10 @@ PHYSACDEF void ClosePhysics(void); // Functions required to query time on Windows int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); -#elif defined(__linux) +#elif defined(__linux) || defined(PLATFORM_WEB) #include // Required for: timespec #include // Required for: clock_gettime() + #include #endif //---------------------------------------------------------------------------------- @@ -266,7 +267,7 @@ PHYSACDEF void ClosePhysics(void); static unsigned int usedMemory = 0; // Total allocated dynamic memory static bool physicsThreadEnabled = false; // Physics thread enabled state static double currentTime = 0; // Current time in milliseconds -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) +#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux) || defined(PLATFORM_WEB) static double baseTime = 0; // Android and RPI platforms base time #endif static double startTime = 0; // Start time in milliseconds @@ -1942,7 +1943,7 @@ static double GetCurrentTime(void) { double time = 0; - #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) + #if defined(_WIN32) unsigned long long int clockFrequency, currentTime; QueryPerformanceFrequency(&clockFrequency); @@ -1951,7 +1952,7 @@ static double GetCurrentTime(void) time = (double)((double)currentTime/clockFrequency)*1000; #endif - #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) + #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux) || defined(PLATFORM_WEB) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); uint64_t temp = (uint64_t)ts.tv_sec*1000000000LLU + (uint64_t)ts.tv_nsec; From aaea2eb9a64ad97c54fe115f6fd132d6a00f76ef Mon Sep 17 00:00:00 2001 From: Saggi Mizrahi Date: Thu, 22 Dec 2016 03:22:09 +0200 Subject: [PATCH 5/5] Fix building audio_standalone example on linux Signed-off-by: Saggi Mizrahi --- examples/audio_standalone.c | 46 +++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/examples/audio_standalone.c b/examples/audio_standalone.c index 7688b881..d090bb83 100644 --- a/examples/audio_standalone.c +++ b/examples/audio_standalone.c @@ -24,10 +24,52 @@ ********************************************************************************************/ #include +#if defined(_WIN32) #include // Windows only, no stardard library - +#endif #include "audio.h" +#if defined(__linux) + +#include +#include +#include +#include + +static int kbhit(void) +{ + struct termios oldt, newt; + int ch; + int oldf; + + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + oldf = fcntl(STDIN_FILENO, F_GETFL, 0); + fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); + + ch = getchar(); + + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + fcntl(STDIN_FILENO, F_SETFL, oldf); + + if(ch != EOF) + { + ungetc(ch, stdin); + return 1; + } + + return 0; +} + +static char getch() +{ + return getchar(); +} + +#endif + #define KEY_ESCAPE 27 int main() @@ -78,4 +120,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +}