diff --git a/src/external/RGFW.h b/src/external/RGFW.h index 8bd9b5709ca5..7205bf9d8f7c 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -7727,8 +7727,8 @@ RGFW_bool RGFW_monitor_requestMode(RGFW_monitor mon, RGFW_monitorMode mode, RGFW dm.dmBitsPerPel = (DWORD)(mode.red + mode.green + mode.blue); } - if (ChangeDisplaySettingsEx(dd.DeviceName, &dm, NULL, CDS_TEST, NULL) == DISP_CHANGE_SUCCESSFUL) { - if (ChangeDisplaySettingsEx(dd.DeviceName, &dm, NULL, CDS_UPDATEREGISTRY, NULL) == DISP_CHANGE_SUCCESSFUL) + if (ChangeDisplaySettingsExA((LPCSTR)dd.DeviceName, (DEVMODE *)&dm, NULL, CDS_TEST, NULL) == DISP_CHANGE_SUCCESSFUL) { + if (ChangeDisplaySettingsExA((LPCSTR)dd.DeviceName, (DEVMODE *)&dm, NULL, CDS_UPDATEREGISTRY, NULL) == DISP_CHANGE_SUCCESSFUL) return RGFW_TRUE; return RGFW_FALSE; } else return RGFW_FALSE; diff --git a/src/external/glfw/src/context.c b/src/external/glfw/src/context.c index cc1fac4f395c..cfb1368bbcfa 100644 --- a/src/external/glfw/src/context.c +++ b/src/external/glfw/src/context.c @@ -359,7 +359,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, window->context.source = ctxconfig->source; window->context.client = GLFW_OPENGL_API; - previous = _glfwPlatformGetTls(&_glfw.contextSlot); + previous = (_GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot); glfwMakeContextCurrent((GLFWwindow*) window); if (_glfwPlatformGetTls(&_glfw.contextSlot) != window) return GLFW_FALSE; @@ -620,7 +620,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) _GLFW_REQUIRE_INIT(); - previous = _glfwPlatformGetTls(&_glfw.contextSlot); + previous = (_GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot); if (window && window->context.client == GLFW_NO_API) { @@ -642,7 +642,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) GLFWAPI GLFWwindow* glfwGetCurrentContext(void) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - return _glfwPlatformGetTls(&_glfw.contextSlot); + return (GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot); } GLFWAPI void glfwSwapBuffers(GLFWwindow* handle) @@ -668,7 +668,7 @@ GLFWAPI void glfwSwapInterval(int interval) _GLFW_REQUIRE_INIT(); - window = _glfwPlatformGetTls(&_glfw.contextSlot); + window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot); if (!window) { _glfwInputError(GLFW_NO_CURRENT_CONTEXT, @@ -686,7 +686,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension) _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - window = _glfwPlatformGetTls(&_glfw.contextSlot); + window = (_GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot); if (!window) { _glfwInputError(GLFW_NO_CURRENT_CONTEXT, @@ -752,7 +752,7 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - window = _glfwPlatformGetTls(&_glfw.contextSlot); + window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot); if (!window) { _glfwInputError(GLFW_NO_CURRENT_CONTEXT, @@ -762,4 +762,3 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname) return window->context.getProcAddress(procname); } - diff --git a/src/external/glfw/src/egl_context.c b/src/external/glfw/src/egl_context.c index ef65dd3504ad..5586d472ef58 100644 --- a/src/external/glfw/src/egl_context.c +++ b/src/external/glfw/src/egl_context.c @@ -118,10 +118,10 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, return GLFW_FALSE; } - nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig)); + nativeConfigs = (EGLConfig*)_glfw_calloc(nativeCount, sizeof(EGLConfig)); eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount); - usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = (_GLFWfbconfig *)_glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; for (i = 0; i < nativeCount; i++) @@ -308,7 +308,7 @@ static int extensionSupportedEGL(const char* extension) static GLFWglproc getProcAddressEGL(const char* procname) { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + _GLFWwindow* window = (_GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot); assert(window != NULL); if (window->context.egl.client) @@ -908,4 +908,3 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) return window->context.egl.surface; } - diff --git a/src/external/jar_mod.h b/src/external/jar_mod.h index 2a220f8afc2c..91348ac423c2 100644 --- a/src/external/jar_mod.h +++ b/src/external/jar_mod.h @@ -1148,7 +1148,7 @@ static bool jar_mod_load( jar_mod_context_t * modctx, void * mod_data, int mod_d { // 15 Samples modules support // Shift the whole datas to make it look likes a standard 4 channels mod. - memcopy(&(modctx->song.signature), "M.K.", 4); + memcopy(&(modctx->song.signature), (void*)"M.K.", 4); memcopy(&(modctx->song.length), &(modctx->song.samples[15]), 130); memclear(&(modctx->song.samples[15]), 0, 480); modmemory += 600; @@ -1535,7 +1535,7 @@ mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename) if(fsize && fsize < 32*1024*1024) { - modctx->modfile = JARMOD_MALLOC(fsize); + modctx->modfile = (muchar*) JARMOD_MALLOC(fsize); modctx->modfilesize = fsize; memset(modctx->modfile, 0, fsize); fread(modctx->modfile, fsize, 1, f); diff --git a/src/external/jar_xm.h b/src/external/jar_xm.h index 174c1704cafb..d9151e3f1980 100644 --- a/src/external/jar_xm.h +++ b/src/external/jar_xm.h @@ -123,7 +123,7 @@ void jar_xm_generate_samples(jar_xm_context_t* ctx, float* output, size_t numsam // * @param output buffer of 2*numsamples elements (A left and right value for each sample) // * @param numsamples number of samples to generate void jar_xm_generate_samples_16bit(jar_xm_context_t* ctx, short* output, size_t numsamples) { - float* musicBuffer = JARXM_MALLOC((2*numsamples)*sizeof(float)); + float* musicBuffer = (float*)JARXM_MALLOC((2*numsamples)*sizeof(float)); jar_xm_generate_samples(ctx, musicBuffer, numsamples); if(output){ @@ -136,7 +136,7 @@ void jar_xm_generate_samples_16bit(jar_xm_context_t* ctx, short* output, size_t // * @param output buffer of 2*numsamples elements (A left and right value for each sample) // * @param numsamples number of samples to generate void jar_xm_generate_samples_8bit(jar_xm_context_t* ctx, char* output, size_t numsamples) { - float* musicBuffer = JARXM_MALLOC((2*numsamples)*sizeof(float)); + float* musicBuffer = (float*)JARXM_MALLOC((2*numsamples)*sizeof(float)); jar_xm_generate_samples(ctx, musicBuffer, numsamples); if(output){ @@ -543,7 +543,7 @@ int jar_xm_create_context_safe(jar_xm_context_t** ctxp, const char* moddata, siz #endif bytes_needed = jar_xm_get_memory_needed_for_context(moddata, moddata_length); - mempool = JARXM_MALLOC(bytes_needed); + mempool = (char*)JARXM_MALLOC(bytes_needed); if(mempool == NULL && bytes_needed > 0) { /* JARXM_MALLOC() failed, trouble ahead */ DEBUG("call to JARXM_MALLOC() failed, returned %p", (void*)mempool); return 2; @@ -558,11 +558,11 @@ int jar_xm_create_context_safe(jar_xm_context_t** ctxp, const char* moddata, siz ctx->rate = rate; mempool = jar_xm_load_module(ctx, moddata, moddata_length, mempool); - mempool = ALIGN_PTR(mempool, 16); + mempool = (char*)ALIGN_PTR(mempool, 16); ctx->channels = (jar_xm_channel_context_t*)mempool; mempool += ctx->module.num_channels * sizeof(jar_xm_channel_context_t); - mempool = ALIGN_PTR(mempool, 16); + mempool = (char*)ALIGN_PTR(mempool, 16); ctx->default_global_volume = 1.f; ctx->global_volume = ctx->default_global_volume; @@ -583,7 +583,7 @@ int jar_xm_create_context_safe(jar_xm_context_t** ctxp, const char* moddata, siz ch->actual_panning = .5f; } - mempool = ALIGN_PTR(mempool, 16); + mempool = (char*)ALIGN_PTR(mempool, 16); ctx->row_loop_count = (uint8_t *)mempool; mempool += MAX_NUM_ROWS * sizeof(uint8_t); @@ -687,8 +687,8 @@ uint64_t jar_xm_get_latest_trigger_of_channel(jar_xm_context_t *ctx, uint16_t ch #define READ_MEMCPY(ptr, offset, length) memcpy_pad(ptr, length, moddata, moddata_length, offset) static void memcpy_pad(void *dst, size_t dst_len, const void *src, size_t src_len, size_t offset) { - uint8_t *dst_c = dst; - const uint8_t *src_c = src; + uint8_t *dst_c = (uint8_t *)dst; + const uint8_t *src_c = (uint8_t*)src; /* how many bytes can be copied without overrunning `src` */ size_t copy_bytes = (src_len >= offset) ? (src_len - offset) : 0; @@ -808,10 +808,10 @@ char* jar_xm_load_module(jar_xm_context_t* ctx, const char* moddata, size_t modd mod->linear_interpolation = 1; // Linear interpolation can be set after loading mod->ramping = 1; // ramping can be set after loading mempool += mod->num_patterns * sizeof(jar_xm_pattern_t); - mempool = ALIGN_PTR(mempool, 16); + mempool = (char*)ALIGN_PTR(mempool, 16); mod->instruments = (jar_xm_instrument_t*)mempool; mempool += mod->num_instruments * sizeof(jar_xm_instrument_t); - mempool = ALIGN_PTR(mempool, 16); + mempool = (char*)ALIGN_PTR(mempool, 16); uint16_t flags = READ_U32(offset + 14); mod->frequency_type = (flags & (1 << 0)) ? jar_xm_LINEAR_FREQUENCIES : jar_xm_AMIGA_FREQUENCIES; ctx->default_tempo = READ_U16(offset + 16); @@ -884,7 +884,7 @@ char* jar_xm_load_module(jar_xm_context_t* ctx, const char* moddata, size_t modd offset += packed_patterndata_size; } - mempool = ALIGN_PTR(mempool, 16); + mempool = (char*)ALIGN_PTR(mempool, 16); /* Read instruments */ for(uint16_t i = 0; i < ctx->module.num_instruments; ++i) { @@ -928,11 +928,11 @@ char* jar_xm_load_module(jar_xm_context_t* ctx, const char* moddata, size_t modd instr->panning_envelope.enabled = flags & (1 << 0); instr->panning_envelope.sustain_enabled = flags & (1 << 1); instr->panning_envelope.loop_enabled = flags & (1 << 2); - instr->vibrato_type = READ_U8(offset + 235); + instr->vibrato_type = (jar_xm_waveform_type_t )READ_U8(offset + 235); if(instr->vibrato_type == 2) { - instr->vibrato_type = 1; + instr->vibrato_type = (jar_xm_waveform_type_t)1; } else if(instr->vibrato_type == 1) { - instr->vibrato_type = 2; + instr->vibrato_type = (jar_xm_waveform_type_t)2; } instr->vibrato_sweep = READ_U8(offset + 236); instr->vibrato_depth = READ_U8(offset + 237); @@ -1475,7 +1475,7 @@ static void jar_xm_handle_note_and_instrument(jar_xm_context_t* ctx, jar_xm_chan jar_xm_pitch_slide(ctx, ch, ch->fine_portamento_down_param); break; case 4: /* E4y: Set vibrato control */ - ch->vibrato_waveform = s->effect_param & 3; + ch->vibrato_waveform = (jar_xm_waveform_type_t)(s->effect_param & 3); ch->vibrato_waveform_retrigger = !((s->effect_param >> 2) & 1); break; case 5: /* E5y: Set finetune */ @@ -1502,7 +1502,7 @@ static void jar_xm_handle_note_and_instrument(jar_xm_context_t* ctx, jar_xm_chan } break; case 7: /* E7y: Set tremolo control */ - ch->tremolo_waveform = s->effect_param & 3; + ch->tremolo_waveform = (jar_xm_waveform_type_t)(s->effect_param & 3); ch->tremolo_waveform_retrigger = !((s->effect_param >> 2) & 1); break; case 0xA: /* EAy: Fine volume slide up */ @@ -2223,7 +2223,7 @@ int jar_xm_create_context_from_file(jar_xm_context_t** ctx, uint32_t rate, const return 4; } - char* data = JARXM_MALLOC(size + 1); + char* data = (char*)JARXM_MALLOC(size + 1); if(!data || fread(data, 1, size, xmf) < size) { fclose(xmf); DEBUG_ERR(data ? "fread() failed" : "JARXM_MALLOC() failed"); diff --git a/src/external/qoa.h b/src/external/qoa.h index f0f44214d813..41be5bb11cdb 100644 --- a/src/external/qoa.h +++ b/src/external/qoa.h @@ -500,7 +500,7 @@ void *qoa_encode(const short *sample_data, qoa_desc *qoa, unsigned int *out_len) num_frames * QOA_LMS_LEN * 4 * qoa->channels + /* 4 * 4 bytes lms state per channel */ num_slices * 8 * qoa->channels; /* 8 byte slices */ - unsigned char *bytes = QOA_MALLOC(encoded_size); + unsigned char *bytes = (unsigned char *)QOA_MALLOC(encoded_size); for (unsigned int c = 0; c < qoa->channels; c++) { /* Set the initial LMS weights to {0, 0, -1, 2}. This helps with the @@ -657,7 +657,7 @@ short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *qoa) { /* Calculate the required size of the sample buffer and allocate */ int total_samples = qoa->samples * qoa->channels; - short *sample_data = QOA_MALLOC(total_samples * sizeof(short)); + short *sample_data = (short *)QOA_MALLOC(total_samples * sizeof(short)); unsigned int sample_index = 0; unsigned int frame_len; @@ -733,7 +733,7 @@ void *qoa_read(const char *filename, qoa_desc *qoa) { bytes_read = fread(data, 1, size, f); fclose(f); - sample_data = qoa_decode(data, bytes_read, qoa); + sample_data = qoa_decode((const unsigned char*)data, bytes_read, qoa); QOA_FREE(data); return sample_data; } diff --git a/src/external/qoaplay.c b/src/external/qoaplay.c index 4378e5ebdb16..0ac6f6c0662d 100644 --- a/src/external/qoaplay.c +++ b/src/external/qoaplay.c @@ -104,7 +104,7 @@ qoaplay_desc *qoaplay_open(const char *path) // + a buffer to hold one frame of encoded data unsigned int buffer_size = qoa_max_frame_size(&qoa); unsigned int sample_data_size = qoa.channels*QOA_FRAME_LEN*sizeof(short)*2; - qoaplay_desc *qoa_ctx = QOA_MALLOC(sizeof(qoaplay_desc) + buffer_size + sample_data_size); + qoaplay_desc *qoa_ctx = (qoaplay_desc *)QOA_MALLOC(sizeof(qoaplay_desc) + buffer_size + sample_data_size); memset(qoa_ctx, 0, sizeof(qoaplay_desc)); qoa_ctx->file = file; @@ -136,7 +136,7 @@ qoaplay_desc *qoaplay_open_memory(const unsigned char *data, int data_size) // + the sample data for one frame // + a buffer to hold one frame of encoded data unsigned int sample_data_size = qoa.channels*QOA_FRAME_LEN*sizeof(short)*2; - qoaplay_desc *qoa_ctx = QOA_MALLOC(sizeof(qoaplay_desc) + sample_data_size + data_size); + qoaplay_desc *qoa_ctx = (qoaplay_desc *)QOA_MALLOC(sizeof(qoaplay_desc) + sample_data_size + data_size); memset(qoa_ctx, 0, sizeof(qoaplay_desc)); qoa_ctx->file = NULL; diff --git a/src/external/tinyobj_loader_c.h b/src/external/tinyobj_loader_c.h index 55d595a69433..0c67535e0b11 100644 --- a/src/external/tinyobj_loader_c.h +++ b/src/external/tinyobj_loader_c.h @@ -454,7 +454,7 @@ static void parseFloat3(float *x, float *y, float *z, const char **token) { } static unsigned int my_strnlen(const char *s, unsigned int n) { - const char *p = memchr(s, 0, n); + const char *p = (const char*)memchr(s, 0, n); return p ? (unsigned int)(p - s) : n; } diff --git a/src/external/vox_loader.h b/src/external/vox_loader.h index 0d328c07875a..3709c43dcd16 100644 --- a/src/external/vox_loader.h +++ b/src/external/vox_loader.h @@ -151,7 +151,7 @@ void Vox_FreeArrays(VoxArray3D* voxarray); ///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// // Implementation -///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// #ifdef VOX_LOADER_IMPLEMENTATION @@ -165,7 +165,7 @@ void Vox_FreeArrays(VoxArray3D* voxarray); static void initArrayUShort(ArrayUShort* a, int initialSize) { - a->array = VOX_MALLOC(initialSize * sizeof(unsigned short)); + a->array = (unsigned short*)VOX_MALLOC(initialSize * sizeof(unsigned short)); a->used = 0; a->size = initialSize; } @@ -175,7 +175,7 @@ static void insertArrayUShort(ArrayUShort* a, unsigned short element) if (a->used == a->size) { a->size *= 2; - a->array = VOX_REALLOC(a->array, a->size * sizeof(unsigned short)); + a->array = (unsigned short *)VOX_REALLOC(a->array, a->size * sizeof(unsigned short)); } a->array[a->used++] = element; } @@ -194,7 +194,7 @@ static void freeArrayUShort(ArrayUShort* a) static void initArrayVector3(ArrayVector3* a, int initialSize) { - a->array = VOX_MALLOC(initialSize * sizeof(VoxVector3)); + a->array = (VoxVector3 *)VOX_MALLOC(initialSize * sizeof(VoxVector3)); a->used = 0; a->size = initialSize; } @@ -204,7 +204,7 @@ static void insertArrayVector3(ArrayVector3* a, VoxVector3 element) if (a->used == a->size) { a->size *= 2; - a->array = VOX_REALLOC(a->array, a->size * sizeof(VoxVector3)); + a->array = (VoxVector3 *)VOX_REALLOC(a->array, a->size * sizeof(VoxVector3)); } a->array[a->used++] = element; } @@ -222,7 +222,7 @@ static void freeArrayVector3(ArrayVector3* a) static void initArrayColor(ArrayColor* a, int initialSize) { - a->array = VOX_MALLOC(initialSize * sizeof(VoxColor)); + a->array = (VoxColor *)VOX_MALLOC(initialSize * sizeof(VoxColor)); a->used = 0; a->size = initialSize; } @@ -232,7 +232,7 @@ static void insertArrayColor(ArrayColor* a, VoxColor element) if (a->used == a->size) { a->size *= 2; - a->array = VOX_REALLOC(a->array, a->size * sizeof(VoxColor)); + a->array = (VoxColor *)VOX_REALLOC(a->array, a->size * sizeof(VoxColor)); } a->array[a->used++] = element; } @@ -327,7 +327,7 @@ static void Vox_AllocArray(VoxArray3D* pvoxarray, int _sx, int _sy, int _sz) // Alloc chunks array int size = sizeof(CubeChunk3D) * chx * chy * chz; - pvoxarray->m_arrayChunks = VOX_MALLOC(size); + pvoxarray->m_arrayChunks = (CubeChunk3D *)VOX_MALLOC(size); pvoxarray->arrayChunksSize = size; // Init chunks array @@ -366,7 +366,7 @@ static void Vox_SetVoxel(VoxArray3D* pvoxarray, int x, int y, int z, unsigned ch if (chunk->m_array == 0) { int size = CHUNKSIZE * CHUNKSIZE * CHUNKSIZE; - chunk->m_array = VOX_MALLOC(size); + chunk->m_array = (unsigned char*)VOX_MALLOC(size); chunk->arraySize = size; memset(chunk->m_array, 0, size); diff --git a/src/external/win32_clipboard.h b/src/external/win32_clipboard.h index 83285643269c..72edc95e04f2 100644 --- a/src/external/win32_clipboard.h +++ b/src/external/win32_clipboard.h @@ -96,9 +96,7 @@ typedef int WINBOOL; // typedef HANDLE HGLOBAL; -#ifndef HWND -#define HWND void* -#endif +typedef struct HWND__ *HWND; #if !defined(_WINUSER_) || !defined(WINUSER_ALREADY_INCLUDED) @@ -284,7 +282,7 @@ unsigned char* Win32GetClipboardImageData(int* width, int* height, unsigned long // This may be wrong since we might be allocating in a DLL and freeing from another module, the main application // that may cause heap corruption. We could create a FreeImage function // - bmpData = malloc(sizeof(bmpFileHeader) + clipDataSize); + bmpData = (BYTE*)malloc(sizeof(bmpFileHeader) + clipDataSize); // First we add the header for a bmp file memcpy(bmpData, &bmpFileHeader, sizeof(bmpFileHeader)); // Then we add the header for the bmp itself + the pixel data diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index cab497266ee9..82f54087166d 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1028,7 +1028,7 @@ Image GetClipboardImage(void) fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); - else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); + else image = LoadImageFromMemory(".bmp", (const unsigned char*)fileData, (int)dataSize); #else TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); #endif @@ -1350,8 +1350,8 @@ int InitPlatform(void) const GLFWallocator allocator = { .allocate = AllocateWrapper, - .deallocate = DeallocateWrapper, .reallocate = ReallocateWrapper, + .deallocate = DeallocateWrapper, .user = NULL, // RL_*ALLOC macros are not capable of handling user-provided data }; diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index f2e2a7407f3c..a78c75d4b9a0 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -80,10 +80,17 @@ void CloseWindow(void); #define CloseWindow CloseWindow_win32 #define ShowCursor __imp_ShowCursor #define _APISETSTRING_ - + #undef MAX_PATH +#if defined(__cplusplus) +extern "C" { +#endif __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar); +#if defined(__cplusplus) +} +#endif + #endif #if defined(__APPLE__) @@ -135,7 +142,6 @@ static bool RGFW_disableCursor = false; static const unsigned short keyMappingRGFW[] = { [RGFW_keyNULL] = KEY_NULL, [RGFW_return] = KEY_ENTER, - [RGFW_return] = KEY_ENTER, [RGFW_apostrophe] = KEY_APOSTROPHE, [RGFW_comma] = KEY_COMMA, [RGFW_minus] = KEY_MINUS, @@ -256,7 +262,7 @@ static int RGFW_gpConvTable[18] = { [RGFW_gamepadRight] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT, [RGFW_gamepadDown] = GAMEPAD_BUTTON_LEFT_FACE_DOWN, [RGFW_gamepadLeft] = GAMEPAD_BUTTON_LEFT_FACE_LEFT, - [RGFW_gamepadL3] = GAMEPAD_BUTTON_LEFT_THUMB, + [RGFW_gamepadL3] = GAMEPAD_BUTTON_LEFT_THUMB, [RGFW_gamepadR3] = GAMEPAD_BUTTON_RIGHT_THUMB, }; @@ -565,7 +571,7 @@ int RGFW_formatToChannels(int format) // Set icon for window void SetWindowIcon(Image image) { - RGFW_window_setIcon(platform.window, image.data, RGFW_AREA(image.width, image.height), RGFW_formatToChannels(image.format)); + RGFW_window_setIcon(platform.window, (u8*)image.data, RGFW_AREA(image.width, image.height), RGFW_formatToChannels(image.format)); } // Set icon for window @@ -586,8 +592,8 @@ void SetWindowIcons(Image *images, int count) if ((smallIcon == NULL) || ((images[i].width < smallIcon->width) && (images[i].height > smallIcon->height))) smallIcon = &images[i]; } - if (smallIcon != NULL) RGFW_window_setIconEx(platform.window, smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow); - if (bigIcon != NULL) RGFW_window_setIconEx(platform.window, bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar); + if (smallIcon != NULL) RGFW_window_setIconEx(platform.window, (u8*)smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow); + if (bigIcon != NULL) RGFW_window_setIconEx(platform.window, (u8*)bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar); } } @@ -806,7 +812,7 @@ Image GetClipboardImage(void) fileData = (void *)Win32GetClipboardImageData(&width, &height, &dataSize); if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data"); - else image = LoadImageFromMemory(".bmp", fileData, dataSize); + else image = LoadImageFromMemory(".bmp", (const unsigned char*)fileData, dataSize); #else TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement GetClipboardImage() for this OS"); #endif @@ -927,7 +933,7 @@ void PollInputEvents(void) // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); #endif - + // Reset keys/chars pressed registered CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0; @@ -1019,7 +1025,7 @@ void PollInputEvents(void) CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event->droppedFiles[i]); - + CORE.Window.dropFileCount++; } else if (CORE.Window.dropFileCount < 1024) @@ -1223,7 +1229,7 @@ void PollInputEvents(void) int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; int pressed = (value > 0.1f); CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed; - + if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; } @@ -1339,7 +1345,7 @@ int InitPlatform(void) // TODO: Is this needed by raylib now? // If so, rcore_desktop_sdl should be updated too //SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); - + if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1); RGFW_window_makeCurrent(platform.window); @@ -1419,7 +1425,7 @@ void ClosePlatform(void) // Keycode mapping static KeyboardKey ConvertScancodeToKey(u32 keycode) { - if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0; + if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return KEY_NULL; - return keyMappingRGFW[keycode]; + return (KeyboardKey)keyMappingRGFW[keycode]; } diff --git a/src/raudio.c b/src/raudio.c index 798c062e9e53..f3aa45ed35c0 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -575,7 +575,7 @@ AudioBuffer *LoadAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam return NULL; } - if (sizeInFrames > 0) audioBuffer->data = RL_CALLOC(sizeInFrames*channels*ma_get_bytes_per_sample(format), 1); + if (sizeInFrames > 0) audioBuffer->data = (unsigned char *)RL_CALLOC(sizeInFrames*channels*ma_get_bytes_per_sample(format), 1); // Audio data runs through a format converter ma_data_converter_config converterConfig = ma_data_converter_config_init(format, AUDIO_DEVICE_FORMAT, channels, AUDIO_DEVICE_CHANNELS, sampleRate, AUDIO.System.device.sampleRate); @@ -808,7 +808,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int wave.data = (short *)RL_MALLOC((size_t)wave.frameCount*wave.channels*sizeof(short)); // NOTE: We are forcing conversion to 16bit sample size on reading - drwav_read_pcm_frames_s16(&wav, wave.frameCount, wave.data); + drwav_read_pcm_frames_s16(&wav, wave.frameCount, (drwav_int16 *)wave.data); } else TRACELOG(LOG_WARNING, "WAVE: Failed to load WAV data"); @@ -1062,7 +1062,12 @@ bool ExportWave(Wave wave, const char *fileName) else if (IsFileExtension(fileName, ".wav")) { drwav wav = { 0 }; + #ifdef __cplusplus + drwav_data_format format = {}; + #else drwav_data_format format = { 0 }; + #endif + format.container = drwav_container_riff; if (wave.sampleSize == 32) format.format = DR_WAVE_FORMAT_IEEE_FLOAT; else format.format = DR_WAVE_FORMAT_PCM; @@ -1091,7 +1096,7 @@ bool ExportWave(Wave wave, const char *fileName) qoa.samplerate = wave.sampleRate; qoa.samples = wave.frameCount; - int bytesWritten = qoa_write(fileName, wave.data, &qoa); + int bytesWritten = qoa_write(fileName, (const short *)wave.data, &qoa); if (bytesWritten > 0) success = true; } else TRACELOG(LOG_WARNING, "AUDIO: Wave data must be 16 bit per sample for QOA format export"); @@ -2079,7 +2084,7 @@ float GetMusicTimePlayed(Music music) { uint64_t framesPlayed = 0; - jar_xm_get_position(music.ctxData, NULL, NULL, NULL, &framesPlayed); + jar_xm_get_position((jar_xm_context_t *)music.ctxData, NULL, NULL, NULL, &framesPlayed); secondsPlayed = (float)framesPlayed/music.stream.sampleRate; } else diff --git a/src/rcore.c b/src/rcore.c index b9098db02c8b..91daea9fd5fe 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -166,11 +166,17 @@ #define MAX_PATH 1025 #endif struct HINSTANCE__; +#if defined(__cplusplus) +extern "C" { +#endif __declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(struct HINSTANCE__ *hModule, char *lpFilename, unsigned long nSize); __declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(struct HINSTANCE__ *hModule, wchar_t *lpFilename, unsigned long nSize); __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); __declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod); __declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); +#if defined(__cplusplus) +} +#endif #elif defined(__linux__) #include #elif defined(__FreeBSD__) @@ -547,7 +553,6 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab // #endif #endif // SUPPORT_CLIPBOARD_IMAGE - // Include platform-specific submodules #if defined(PLATFORM_DESKTOP_GLFW) #include "platforms/rcore_desktop_glfw.c" @@ -2330,8 +2335,8 @@ const char *GetApplicationDirectory(void) int len = 0; #if defined(UNICODE) unsigned short widePath[MAX_PATH]; - len = GetModuleFileNameW(NULL, widePath, MAX_PATH); - len = WideCharToMultiByte(0, 0, widePath, len, appDir, MAX_PATH, NULL, NULL); + len = GetModuleFileNameW(NULL, (wchar_t*)widePath, MAX_PATH); + len = WideCharToMultiByte(0, 0, (wchar_t*)widePath, len, appDir, MAX_PATH, NULL, NULL); #else len = GetModuleFileNameA(NULL, appDir, MAX_PATH); #endif diff --git a/src/rmodels.c b/src/rmodels.c index 1e7599004d4d..d4e8ea87dc19 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -5174,7 +5174,7 @@ static cgltf_result LoadFileGLTFCallback(const struct cgltf_memory_options *memo // Release file data callback for cgltf static void ReleaseFileGLTFCallback(const struct cgltf_memory_options *memoryOptions, const struct cgltf_file_options *fileOptions, void *data) { - UnloadFileData(data); + UnloadFileData((unsigned char*)data); } // Load image from different glTF provided methods (uri, path, buffer_view) @@ -5208,7 +5208,11 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat int outSize = numberOfEncodedBits/8 ; // Actual encoded bytes void *data = NULL; + #ifdef __cplusplus + cgltf_options options = {}; + #else cgltf_options options = { 0 }; + #endif options.file.read = LoadFileGLTFCallback; options.file.release = ReleaseFileGLTFCallback; cgltf_result result = cgltf_load_buffer_base64(&options, outSize, cgltfImage->uri + i + 1, &data); @@ -5344,7 +5348,11 @@ static Model LoadGLTF(const char *fileName) if (fileData == NULL) return model; // glTF data loading + #ifdef __cplusplus + cgltf_options options = {}; + #else cgltf_options options = { 0 }; + #endif options.file.read = LoadFileGLTFCallback; options.file.release = ReleaseFileGLTFCallback; cgltf_data *data = NULL; @@ -6135,7 +6143,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_ float tmp[3] = { 0.0f }; cgltf_accessor_read_float(output, keyframe, tmp, 3); Vector3 v1 = {tmp[0], tmp[1], tmp[2]}; - Vector3 *r = data; + Vector3 *r = (Vector3 *)data; *r = v1; } break; @@ -6146,7 +6154,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_ Vector3 v1 = {tmp[0], tmp[1], tmp[2]}; cgltf_accessor_read_float(output, keyframe+1, tmp, 3); Vector3 v2 = {tmp[0], tmp[1], tmp[2]}; - Vector3 *r = data; + Vector3 *r = (Vector3*)data; *r = Vector3Lerp(v1, v2, t); } break; @@ -6161,7 +6169,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_ Vector3 v2 = {tmp[0], tmp[1], tmp[2]}; cgltf_accessor_read_float(output, 3*(keyframe+1), tmp, 3); Vector3 tangent2 = {tmp[0], tmp[1], tmp[2]}; - Vector3 *r = data; + Vector3 *r = (Vector3 *)data; *r = Vector3CubicHermite(v1, tangent1, v2, tangent2, t); } break; @@ -6178,7 +6186,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_ float tmp[4] = { 0.0f }; cgltf_accessor_read_float(output, keyframe, tmp, 4); Vector4 v1 = {tmp[0], tmp[1], tmp[2], tmp[3]}; - Vector4 *r = data; + Vector4 *r = (Vector4 *)data; *r = v1; } break; @@ -6189,7 +6197,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_ Vector4 v1 = {tmp[0], tmp[1], tmp[2], tmp[3]}; cgltf_accessor_read_float(output, keyframe+1, tmp, 4); Vector4 v2 = {tmp[0], tmp[1], tmp[2], tmp[3]}; - Vector4 *r = data; + Vector4 *r = (Vector4 *)data; *r = QuaternionSlerp(v1, v2, t); } break; @@ -6204,7 +6212,7 @@ static bool GetPoseAtTimeGLTF(cgltf_interpolation_type interpolationType, cgltf_ Vector4 v2 = {tmp[0], tmp[1], tmp[2], tmp[3]}; cgltf_accessor_read_float(output, 3*(keyframe+1), tmp, 4); Vector4 inTangent2 = {tmp[0], tmp[1], tmp[2], 0.0f}; - Vector4 *r = data; + Vector4 *r = (Vector4 *)data; v1 = QuaternionNormalize(v1); v2 = QuaternionNormalize(v2); @@ -6237,7 +6245,11 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo ModelAnimation *animations = NULL; // glTF data loading + #ifdef __cplusplus + cgltf_options options = {}; + #else cgltf_options options = { 0 }; + #endif options.file.read = LoadFileGLTFCallback; options.file.release = ReleaseFileGLTFCallback; cgltf_data *data = NULL; diff --git a/src/rtext.c b/src/rtext.c index ce9f381c46f3..852a75ad6bc7 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1731,7 +1731,7 @@ char *TextReplace(const char *text, const char *search, const char *replacement) // - 'text' points to the remainder of text after "end of replace" while (count--) { - insertPoint = strstr(text, search); + insertPoint = (char*)strstr(text, search); lastReplacePos = (int)(insertPoint - text); temp = strncpy(temp, text, lastReplacePos) + lastReplacePos; temp = strcpy(temp, replacement) + replaceLen; @@ -1887,7 +1887,7 @@ int TextFindIndex(const char *text, const char *search) { int position = -1; - char *ptr = strstr(text, search); + char *ptr = (char*)strstr(text, search); if (ptr != NULL) position = (int)(ptr - text); diff --git a/src/rtextures.c b/src/rtextures.c index a85467d8c9bf..250e67be3e49 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -1039,7 +1039,7 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float // We need to normalize the data from [-1..1] to [0..1] float np = (p + 1.0f)/2.0f; - int intensity = (int)(np*255.0f); + unsigned char intensity = (unsigned char)(np*255.0f); pixels[y*width + x] = (Color){ intensity, intensity, intensity, 255 }; } } @@ -1103,7 +1103,8 @@ Image GenImageCellular(int width, int height, int tileSize) int intensity = (int)(minDistance*256.0f/tileSize); if (intensity > 255) intensity = 255; - pixels[y*width + x] = (Color){ intensity, intensity, intensity, 255 }; + unsigned char intensityUC = (unsigned char)intensity; + pixels[y*width + x] = (Color){ intensityUC, intensityUC, intensityUC, 255 }; } } @@ -2405,7 +2406,7 @@ void ImageMipmaps(Image *image) image->data = temp; // Pointer to allocated memory point where store next mipmap level data - unsigned char *nextmip = image->data; + unsigned char *nextmip = (unsigned char*)image->data; mipWidth = image->width; mipHeight = image->height; diff --git a/src/utils.c b/src/utils.c index 5ccbc4fa9c01..93b24f039c48 100644 --- a/src/utils.c +++ b/src/utils.c @@ -374,7 +374,7 @@ char *LoadFileText(const char *fileName) // WARNING: \r\n is converted to \n on reading, so, // read bytes count gets reduced by the number of lines - if (count < size) text = RL_REALLOC(text, count + 1); + if (count < size) text = (char*)RL_REALLOC(text, count + 1); // Zero-terminate the string text[count] = '\0';