commit
4419ee9802
@ -24,10 +24,52 @@
|
||||
********************************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_WIN32)
|
||||
#include <conio.h> // Windows only, no stardard library
|
||||
|
||||
#endif
|
||||
#include "audio.h"
|
||||
|
||||
#if defined(__linux)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateOculusTracking();
|
||||
UpdateOculusTracking(&camera);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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 <sys/time.h> // Required for: timespec
|
||||
#include <time.h> // Required for: clock_gettime()
|
||||
#include <stdint.h>
|
||||
#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;
|
||||
|
17
src/raylib.h
17
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user