diff --git a/src/Makefile b/src/Makefile index f43a722f9..ac864680d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -147,13 +147,12 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_VERSION ?= 1.38.32 - CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit - PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64 - NODE_VERSION = 8.9.1_64bit - export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH) - EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) + EMSDK_PATH ?= C:/emsdk + EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten + CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin + PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 + NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin + export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) endif ifeq ($(PLATFORM),PLATFORM_ANDROID) @@ -278,7 +277,13 @@ endif # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers # -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing) -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing +CFLAGS += -Wall -D_DEFAULT_SOURCE -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing + +ifeq ($(PLATFORM), PLATFORM_WEB) + CFLAGS += -std=gnu99 +else + CFLAGS += -std=c99 +endif ifeq ($(PLATFORM_OS),LINUX) CFLAGS += -fPIC diff --git a/src/core.c b/src/core.c index fad2c485f..305eb33cf 100644 --- a/src/core.c +++ b/src/core.c @@ -2056,15 +2056,15 @@ unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLe } // Decompress data (DEFLATE algorythm) -char *DecompressData(char *compData, int compDataLength, int *dataLength) +unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength) { char *data = NULL; #if defined(SUPPORT_COMPRESSION_API) - data = stbi_zlib_decode_malloc(compData, compDataLength, dataLength); + data = stbi_zlib_decode_malloc((char *)compData, compDataLength, dataLength); #endif - return data; + return (unsigned char *)data; } // Save integer value to storage file (to defined position) @@ -3960,7 +3960,7 @@ static void WindowIconifyCallback(GLFWwindow *window, int iconified) } // GLFW3 Window Drop Callback, runs when drop files into window -// NOTE: Paths are stored in dinamic memory for further retrieval +// NOTE: Paths are stored in dynamic memory for further retrieval // Everytime new files are dropped, old ones are discarded static void WindowDropCallback(GLFWwindow *window, int count, const char **paths) { diff --git a/src/models.c b/src/models.c index ea7e5356d..bd79dbc47 100644 --- a/src/models.c +++ b/src/models.c @@ -2800,8 +2800,8 @@ static Model LoadOBJ(const char *fileName) model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material)); } - model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int)); + model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int)); /* // Multiple meshes data reference diff --git a/src/raylib.h b/src/raylib.h index f5fed9834..dc4b36013 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -956,8 +956,8 @@ RLAPI char **GetDroppedFiles(int *count); // Get dropped RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time) -RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorythm) -RLAPI char *DecompressData(char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm) +RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorythm) +RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm) // Persistent storage management RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position) diff --git a/src/textures.c b/src/textures.c index 56ff194ab..70e4a0e94 100644 --- a/src/textures.c +++ b/src/textures.c @@ -253,13 +253,10 @@ Image LoadImage(const char *fileName) FILE *imFile = fopen(fileName, "rb"); - stbi_set_flip_vertically_on_load(true); - // Load 32 bit per channel floats data + //stbi_set_flip_vertically_on_load(true); image.data = stbi_loadf_from_file(imFile, &image.width, &image.height, &imgBpp, 0); - stbi_set_flip_vertically_on_load(false); - fclose(imFile); image.mipmaps = 1; @@ -551,7 +548,7 @@ Color *GetImageData(Image image) pixels[i].a = 255; k += 3; - } + } break; case UNCOMPRESSED_R32G32B32A32: { pixels[i].r = (unsigned char)(((float *)image.data)[k]*255.0f); @@ -560,7 +557,7 @@ Color *GetImageData(Image image) pixels[i].a = (unsigned char)(((float *)image.data)[k]*255.0f); k += 4; - } + } break; default: break; } } @@ -1826,7 +1823,9 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color } Image srcCopy = ImageCopy(src); // Make a copy of source image to work with it - ImageCrop(&srcCopy, srcRec); // Crop source image to desired source rectangle + + // Crop source image to desired source rectangle (if required) + if ((src.width != (int)srcRec.width) && (src.height != (int)srcRec.height)) ImageCrop(&srcCopy, srcRec); // Scale source image in case destination rec size is different than source rec size if (((int)dstRec.width != (int)srcRec.width) || ((int)dstRec.height != (int)srcRec.height)) @@ -1856,7 +1855,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color dstRec.y = 0; } - if (dstRec.y > (dst->height - dstRec.height)) + if ((dstRec.y + dstRec.height) > dst->height) { ImageCrop(&srcCopy, (Rectangle) { 0, 0, dstRec.width, dst->height - dstRec.y }); dstRec.height = dst->height - dstRec.y;