Selaa lähdekoodia

Review defines

pull/669/head
Ray 6 vuotta sitten
vanhempi
commit
b8b8936cd7
4 muutettua tiedostoa jossa 27 lisäystä ja 27 poistoa
  1. +1
    -1
      src/audio.c
  2. +16
    -16
      src/core.c
  3. +4
    -4
      src/raylib.h
  4. +6
    -6
      src/rlgl.h

+ 1
- 1
src/audio.c Näytä tiedosto

@ -132,7 +132,7 @@
#include "external/dr_mp3.h" // MP3 loading functions #include "external/dr_mp3.h" // MP3 loading functions
#endif #endif
#ifdef _MSC_VER
#if defined(_MSC_VER)
#undef bool #undef bool
#endif #endif

+ 16
- 16
src/core.c Näytä tiedosto

@ -125,7 +125,7 @@
#include <ctype.h> // Required for: tolower() [Used in IsFileExtension()] #include <ctype.h> // Required for: tolower() [Used in IsFileExtension()]
#include <sys/stat.h> // Required for stat() [Used in GetLastWriteTime()] #include <sys/stat.h> // Required for stat() [Used in GetLastWriteTime()]
#if defined(_MSC_VER)
#if defined(_WIN32) && defined(_MSC_VER)
#include "external/dirent.h" // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()] #include "external/dirent.h" // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()]
#else #else
#include <dirent.h> // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()] #include <dirent.h> // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()]
@ -1465,6 +1465,21 @@ void TakeScreenshot(const char *fileName)
#endif #endif
} }
// Check if the file exists
bool FileExists(const char *fileName)
{
bool result = false;
#if defined(_WIN32)
if (_access(fileName, 0) != -1)
#else
if (access(fileName, F_OK) != -1)
#endif
result = true;
return result;
}
// Check file extension // Check file extension
bool IsFileExtension(const char *fileName, const char *ext) bool IsFileExtension(const char *fileName, const char *ext)
{ {
@ -1515,21 +1530,6 @@ static const char *strprbrk(const char *s, const char *charset)
return latestMatch; return latestMatch;
} }
// Return true if the file exists
bool FileExists(const char *fileName)
{
bool result = false;
#if defined(_WIN32)
if (_access(fileName, 0) != -1)
#else
if (access(fileName, F_OK) != -1)
#endif
result = true;
return result;
}
// Get pointer to filename for a path string // Get pointer to filename for a path string
const char *GetFileName(const char *filePath) const char *GetFileName(const char *filePath)
{ {

+ 4
- 4
src/raylib.h Näytä tiedosto

@ -311,7 +311,7 @@
// NOTE: MSC C++ compiler does not support compound literals (C99 feature) // NOTE: MSC C++ compiler does not support compound literals (C99 feature)
// Plain structures in C++ (without constructors) can be initialized from { } initializers. // Plain structures in C++ (without constructors) can be initialized from { } initializers.
#ifdef __cplusplus
#if defined(__cplusplus)
#define CLITERAL #define CLITERAL
#else #else
#define CLITERAL (Color) #define CLITERAL (Color)
@ -786,7 +786,7 @@ typedef enum {
// Callbacks to be implemented by users // Callbacks to be implemented by users
typedef void (*TraceLogCallback)(int msgType, const char *text, va_list args); typedef void (*TraceLogCallback)(int msgType, const char *text, va_list args);
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" { // Prevents name mangling of functions extern "C" { // Prevents name mangling of functions
#endif #endif
@ -868,9 +868,9 @@ RLAPI void TakeScreenshot(const char *fileName); // Takes a scr
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
// Files management functions // Files management functions
RLAPI bool FileExists(const char *fileName); // Check if file exists
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
RLAPI const char *GetExtension(const char *fileName); // Get pointer to extension for a filename string RLAPI const char *GetExtension(const char *fileName); // Get pointer to extension for a filename string
RLAPI bool FileExists(const char *fileName); // Return true if file exists
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (memory should be freed) RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (memory should be freed)
RLAPI const char *GetDirectoryPath(const char *fileName); // Get full path for a given fileName (uses static string) RLAPI const char *GetDirectoryPath(const char *fileName); // Get full path for a given fileName (uses static string)
@ -1277,7 +1277,7 @@ RLAPI void StopAudioStream(AudioStream stream); // Stop au
RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level) RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)
RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level) RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
#ifdef __cplusplus
#if defined(__cplusplus)
} }
#endif #endif

+ 6
- 6
src/rlgl.h Näytä tiedosto

@ -378,7 +378,7 @@ typedef unsigned char byte;
} VrDevice; } VrDevice;
#endif #endif
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" { // Prevents name mangling of functions extern "C" { // Prevents name mangling of functions
#endif #endif
@ -516,7 +516,7 @@ void TraceLog(int msgType, const char *text, ...); // Show trace log messag
int GetPixelDataSize(int width, int height, int format);// Get pixel data size in bytes (image or texture) int GetPixelDataSize(int width, int height, int format);// Get pixel data size in bytes (image or texture)
#endif #endif
#ifdef __cplusplus
#if defined(__cplusplus)
} }
#endif #endif
@ -553,7 +553,7 @@ int GetPixelDataSize(int width, int height, int format);// Get pixel data size i
#else #else
// APIENTRY for OpenGL function pointer declarations is required // APIENTRY for OpenGL function pointer declarations is required
#ifndef APIENTRY #ifndef APIENTRY
#ifdef _WIN32
#if defined(_WIN32)
#define APIENTRY __stdcall #define APIENTRY __stdcall
#else #else
#define APIENTRY #define APIENTRY
@ -1620,7 +1620,7 @@ void rlglInit(int width, int height)
// NOTE: We don't need to check again supported extensions but we do (GLAD already dealt with that) // NOTE: We don't need to check again supported extensions but we do (GLAD already dealt with that)
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt); glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
#ifdef _MSC_VER
#if defined(_MSC_VER)
const char **extList = malloc(sizeof(const char *)*numExt); const char **extList = malloc(sizeof(const char *)*numExt);
#else #else
const char *extList[numExt]; const char *extList[numExt];
@ -3803,7 +3803,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);
#ifdef _MSC_VER
#if defined(_MSC_VER)
char *log = malloc(maxLength); char *log = malloc(maxLength);
#else #else
char log[maxLength]; char log[maxLength];
@ -3812,7 +3812,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
TraceLog(LOG_INFO, "%s", log); TraceLog(LOG_INFO, "%s", log);
#ifdef _MSC_VER
#if defined(_MSC_VER)
free(log); free(log);
#endif #endif
glDeleteProgram(program); glDeleteProgram(program);

Ladataan…
Peruuta
Tallenna