Update C sources, add new functions and rename package to

This commit is contained in:
Milan Nikolic 2018-10-08 18:56:34 +02:00
parent 391c25482d
commit 08aa518a46
156 changed files with 34542 additions and 19573 deletions

View file

@ -4,21 +4,10 @@
*
* CONFIGURATION:
*
* #define SUPPORT_SAVE_PNG (defined by default)
* Support saving image data as PNG fileformat
* NOTE: Requires stb_image_write library
*
* #define SUPPORT_SAVE_BMP
* Support saving image data as BMP fileformat
* NOTE: Requires stb_image_write library
*
* #define SUPPORT_TRACELOG
* Show TraceLog() output messages
* NOTE: By default LOG_DEBUG traces not shown
*
* DEPENDENCIES:
* stb_image_write - BMP/PNG writting functions
*
*
* LICENSE: zlib/libpng
*
@ -57,10 +46,10 @@
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
#include <string.h> // Required for: strlen(), strrchr(), strcmp()
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "external/stb_image_write.h" // Required for: stbi_write_bmp(), stbi_write_png()
#endif
/* This should be in <stdio.h>, but Travis doesn't find it... */
FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int),
int (*writefn)(void *, const char *, int),
fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));
//----------------------------------------------------------------------------------
// Global Variables Definition
@ -68,6 +57,7 @@
// Log types messages supported flags (bit based)
static unsigned char logTypeFlags = LOG_INFO | LOG_WARNING | LOG_ERROR;
static TraceLogCallback logCallback = NULL;
#if defined(PLATFORM_ANDROID)
AAssetManager *assetManager;
@ -93,11 +83,26 @@ void SetTraceLog(unsigned char types)
logTypeFlags = types;
}
// Set a trace log callback to enable custom logging bypassing raylib's one
void SetTraceLogCallback(TraceLogCallback callback)
{
logCallback = callback;
}
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int msgType, const char *text, ...)
{
#if defined(SUPPORT_TRACELOG)
static char buffer[128];
va_list args;
va_start(args, text);
if (logCallback)
{
logCallback(msgType, text, args);
va_end(args);
return;
}
switch(msgType)
{
@ -111,9 +116,6 @@ void TraceLog(int msgType, const char *text, ...)
strcat(buffer, text);
strcat(buffer, "\n");
va_list args;
va_start(args, text);
#if defined(PLATFORM_ANDROID)
switch(msgType)
{
@ -137,32 +139,10 @@ void TraceLog(int msgType, const char *text, ...)
va_end(args);
if (msgType == LOG_ERROR) exit(1); // If LOG_ERROR message, exit program
#endif // SUPPORT_TRACELOG
}
#if defined(SUPPORT_SAVE_BMP)
// Creates a BMP image file from an array of pixel data
void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
{
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
stbi_write_bmp(fileName, width, height, compSize, imgData);
TraceLog(LOG_INFO, "BMP Image saved: %s", fileName);
#endif
}
#endif
#if defined(SUPPORT_SAVE_PNG)
// Creates a PNG image file from an array of pixel data
void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
{
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
stbi_write_png(fileName, width, height, compSize, imgData, width*compSize);
TraceLog(LOG_INFO, "PNG Image saved: %s", fileName);
#endif
}
#endif
// Keep track of memory allocated
// NOTE: mallocType defines the type of data allocated
/*