Merge branch 'master' into rcore_platform_split
This commit is contained in:
commit
b4d2928f20
12 changed files with 13015 additions and 12701 deletions
|
|
@ -55,9 +55,7 @@
|
|||
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
|
||||
//#define SUPPORT_BUSY_WAIT_LOOP 1
|
||||
// Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy
|
||||
#define SUPPORT_PARTIALBUSY_WAIT_LOOP
|
||||
// Wait for events passively (sleeping while no events) instead of polling them actively every frame
|
||||
//#define SUPPORT_EVENTS_WAITING 1
|
||||
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1
|
||||
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
||||
#define SUPPORT_SCREEN_CAPTURE 1
|
||||
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
||||
|
|
|
|||
22009
src/external/miniaudio.h
vendored
22009
src/external/miniaudio.h
vendored
File diff suppressed because it is too large
Load diff
10
src/external/msf_gif.h
vendored
10
src/external/msf_gif.h
vendored
|
|
@ -256,16 +256,16 @@ static void msf_cook_frame(MsfCookedFrame * frame, uint8_t * raw, uint8_t * used
|
|||
int width, int height, int pitch, int depth)
|
||||
{ MsfTimeFunc
|
||||
//bit depth for each channel
|
||||
const static int rdepthsArray[17] = { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5 };
|
||||
const static int gdepthsArray[17] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6 };
|
||||
const static int bdepthsArray[17] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5 };
|
||||
static const int rdepthsArray[17] = { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5 };
|
||||
static const int gdepthsArray[17] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6 };
|
||||
static const int bdepthsArray[17] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5 };
|
||||
//this extra level of indirection looks unnecessary but we need to explicitly decay the arrays to pointers
|
||||
//in order to be able to swap them because of C's annoying not-quite-pointers, not-quite-value-types stack arrays.
|
||||
const int * rdepths = msf_gif_bgra_flag? bdepthsArray : rdepthsArray;
|
||||
const int * gdepths = gdepthsArray;
|
||||
const int * bdepths = msf_gif_bgra_flag? rdepthsArray : bdepthsArray;
|
||||
|
||||
const static int ditherKernel[16] = {
|
||||
static const int ditherKernel[16] = {
|
||||
0 << 12, 8 << 12, 2 << 12, 10 << 12,
|
||||
12 << 12, 4 << 12, 14 << 12, 6 << 12,
|
||||
3 << 12, 11 << 12, 1 << 12, 9 << 12,
|
||||
|
|
@ -404,7 +404,7 @@ static MsfGifBuffer * msf_compress_frame(void * allocContext, int width, int hei
|
|||
MsfGifBuffer * buffer = (MsfGifBuffer *) MSF_GIF_MALLOC(allocContext, maxBufSize);
|
||||
if (!buffer) { return NULL; }
|
||||
uint8_t * writeHead = buffer->data;
|
||||
MsfStridedList lzw = { lzwMem };
|
||||
MsfStridedList lzw = { lzwMem, 0, 0 };
|
||||
|
||||
//allocate tlb
|
||||
int totalBits = frame.rbits + frame.gbits + frame.bbits;
|
||||
|
|
|
|||
20
src/raudio.c
20
src/raudio.c
|
|
@ -474,6 +474,16 @@ void InitAudioDevice(void)
|
|||
return;
|
||||
}
|
||||
|
||||
// Mixing happens on a separate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may
|
||||
// want to look at something a bit smarter later on to keep everything real-time, if that's necessary.
|
||||
if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing");
|
||||
ma_device_uninit(&AUDIO.System.device);
|
||||
ma_context_uninit(&AUDIO.System.context);
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep the device running the whole time. May want to consider doing something a bit smarter and only have the device running
|
||||
// while there's at least one sound being played.
|
||||
result = ma_device_start(&AUDIO.System.device);
|
||||
|
|
@ -485,16 +495,6 @@ void InitAudioDevice(void)
|
|||
return;
|
||||
}
|
||||
|
||||
// Mixing happens on a separate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may
|
||||
// want to look at something a bit smarter later on to keep everything real-time, if that's necessary.
|
||||
if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing");
|
||||
ma_device_uninit(&AUDIO.System.device);
|
||||
ma_context_uninit(&AUDIO.System.context);
|
||||
return;
|
||||
}
|
||||
|
||||
TRACELOG(LOG_INFO, "AUDIO: Device initialized successfully");
|
||||
TRACELOG(LOG_INFO, " > Backend: miniaudio / %s", ma_get_backend_name(AUDIO.System.context.backend));
|
||||
TRACELOG(LOG_INFO, " > Format: %s -> %s", ma_get_format_name(AUDIO.System.device.playback.format), ma_get_format_name(AUDIO.System.device.playback.internalFormat));
|
||||
|
|
|
|||
12
src/raylib.h
12
src/raylib.h
|
|
@ -938,8 +938,8 @@ extern "C" { // Prevents name mangling of functions
|
|||
|
||||
// Window-related functions
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked)
|
||||
RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully
|
||||
RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen
|
||||
RLAPI bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP)
|
||||
|
|
@ -1163,7 +1163,7 @@ RLAPI int GetTouchPointCount(void); // Get number of t
|
|||
// Gestures and Touch Handling Functions (Module: rgestures)
|
||||
//------------------------------------------------------------------------------------
|
||||
RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
|
||||
RLAPI bool IsGestureDetected(int gesture); // Check if a gesture have been detected
|
||||
RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected
|
||||
RLAPI int GetGestureDetected(void); // Get latest detected gesture
|
||||
RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
|
||||
RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector
|
||||
|
|
@ -1331,7 +1331,7 @@ RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout);
|
|||
RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
|
||||
RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready
|
||||
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
|
||||
RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
|
||||
RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
|
||||
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
|
||||
|
|
@ -1379,7 +1379,7 @@ RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileDat
|
|||
RLAPI bool IsFontReady(Font font); // Check if a font is ready
|
||||
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use
|
||||
RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
|
||||
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
|
||||
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
|
||||
RLAPI void UnloadFont(Font font); // Unload font from GPU memory (VRAM)
|
||||
RLAPI bool ExportFontAsCode(Font font, const char *fileName); // Export font as code file, returns true on success
|
||||
|
||||
|
|
@ -1541,7 +1541,7 @@ RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileDat
|
|||
RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
||||
RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data
|
||||
RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data
|
||||
RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready
|
||||
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
|
|
@ -1598,7 +1598,7 @@ RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set vol
|
|||
RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
|
||||
RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered)
|
||||
RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
|
||||
RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data
|
||||
RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data
|
||||
|
||||
RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as <float>s
|
||||
RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream
|
||||
|
|
|
|||
|
|
@ -214,6 +214,10 @@ RMAPI float Wrap(float value, float min, float max)
|
|||
// Check whether two given floats are almost equal
|
||||
RMAPI int FloatEquals(float x, float y)
|
||||
{
|
||||
#if !defined(EPSILON)
|
||||
#define EPSILON 0.000001f
|
||||
#endif
|
||||
|
||||
int result = (fabsf(x - y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(x), fabsf(y))));
|
||||
|
||||
return result;
|
||||
|
|
@ -506,6 +510,10 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
|
|||
// Check whether two given vectors are almost equal
|
||||
RMAPI int Vector2Equals(Vector2 p, Vector2 q)
|
||||
{
|
||||
#if !defined(EPSILON)
|
||||
#define EPSILON 0.000001f
|
||||
#endif
|
||||
|
||||
int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
||||
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y)))));
|
||||
|
||||
|
|
@ -1090,6 +1098,10 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
|
|||
// Check whether two given vectors are almost equal
|
||||
RMAPI int Vector3Equals(Vector3 p, Vector3 q)
|
||||
{
|
||||
#if !defined(EPSILON)
|
||||
#define EPSILON 0.000001f
|
||||
#endif
|
||||
|
||||
int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
||||
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
|
||||
((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z)))));
|
||||
|
|
@ -1846,6 +1858,10 @@ RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
|||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
#if !defined(EPSILON)
|
||||
#define EPSILON 0.000001f
|
||||
#endif
|
||||
|
||||
float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w;
|
||||
|
||||
if (cosHalfTheta < 0)
|
||||
|
|
@ -2153,6 +2169,10 @@ RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat)
|
|||
// Check whether two given quaternions are almost equal
|
||||
RMAPI int QuaternionEquals(Quaternion p, Quaternion q)
|
||||
{
|
||||
#if !defined(EPSILON)
|
||||
#define EPSILON 0.000001f
|
||||
#endif
|
||||
|
||||
int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
||||
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
|
||||
((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&
|
||||
|
|
|
|||
|
|
@ -46,6 +46,20 @@
|
|||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
// Function specifiers definition
|
||||
|
||||
// Function specifiers in case library is build/used as a shared library (Windows)
|
||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||
#if defined(_WIN32)
|
||||
#if defined(BUILD_LIBTYPE_SHARED)
|
||||
#if defined(__TINYC__)
|
||||
#define __declspec(x) __attribute__((x))
|
||||
#endif
|
||||
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
||||
#elif defined(USE_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef RLAPI
|
||||
#define RLAPI // Functions defined as 'extern' by default (implicit specifiers)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ void SetGesturesEnabled(unsigned int flags)
|
|||
}
|
||||
|
||||
// Check if a gesture have been detected
|
||||
bool IsGestureDetected(int gesture)
|
||||
bool IsGestureDetected(unsigned int gesture)
|
||||
{
|
||||
if ((GESTURES.enabledFlags & GESTURES.current) == gesture) return true;
|
||||
else return false;
|
||||
|
|
|
|||
31
src/rlgl.h
31
src/rlgl.h
|
|
@ -2997,7 +2997,10 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
|
|||
|
||||
int mipWidth = width;
|
||||
int mipHeight = height;
|
||||
int mipOffset = 0; // Mipmap data offset
|
||||
int mipOffset = 0; // Mipmap data offset, only used for tracelog
|
||||
|
||||
// NOTE: Added pointer math separately from function to avoid UBSAN complaining
|
||||
unsigned char *dataPtr = (unsigned char *)data;
|
||||
|
||||
// Load the different mipmap levels
|
||||
for (int i = 0; i < mipmapCount; i++)
|
||||
|
|
@ -3009,11 +3012,11 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
|
|||
|
||||
TRACELOGD("TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset);
|
||||
|
||||
if (glInternalFormat != -1)
|
||||
if (glInternalFormat != 0)
|
||||
{
|
||||
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, (unsigned char *)data + mipOffset);
|
||||
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, dataPtr);
|
||||
#if !defined(GRAPHICS_API_OPENGL_11)
|
||||
else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, (unsigned char *)data + mipOffset);
|
||||
else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, dataPtr);
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
|
|
@ -3036,7 +3039,8 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
|
|||
|
||||
mipWidth /= 2;
|
||||
mipHeight /= 2;
|
||||
mipOffset += mipSize;
|
||||
mipOffset += mipSize; // Increment offset position to next mipmap
|
||||
dataPtr += mipSize; // Increment data pointer to next mipmap
|
||||
|
||||
// Security check for NPOT textures
|
||||
if (mipWidth < 1) mipWidth = 1;
|
||||
|
|
@ -3162,7 +3166,7 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
|
|||
unsigned int glInternalFormat, glFormat, glType;
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
|
||||
|
||||
if (glInternalFormat != -1)
|
||||
if (glInternalFormat != 0)
|
||||
{
|
||||
// Load cubemap faces
|
||||
for (unsigned int i = 0; i < 6; i++)
|
||||
|
|
@ -3230,7 +3234,7 @@ void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int h
|
|||
unsigned int glInternalFormat, glFormat, glType;
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
|
||||
|
||||
if ((glInternalFormat != -1) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB))
|
||||
if ((glInternalFormat != 0) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB))
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, offsetX, offsetY, width, height, glFormat, glType, data);
|
||||
}
|
||||
|
|
@ -3374,7 +3378,7 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
|||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
|
||||
unsigned int size = rlGetPixelDataSize(width, height, format);
|
||||
|
||||
if ((glInternalFormat != -1) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB))
|
||||
if ((glInternalFormat != 0) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB))
|
||||
{
|
||||
pixels = RL_MALLOC(size);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels);
|
||||
|
|
@ -3537,11 +3541,14 @@ bool rlFramebufferComplete(unsigned int id)
|
|||
void rlUnloadFramebuffer(unsigned int id)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
|
||||
// Query depth attachment to automatically delete texture/renderbuffer
|
||||
int depthType = 0, depthId = 0;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id); // Bind framebuffer to query depth texture type
|
||||
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &depthType);
|
||||
|
||||
// TODO: Review warning retrieving object name in WebGL
|
||||
// WARNING: WebGL: INVALID_ENUM: getFramebufferAttachmentParameter: invalid parameter name
|
||||
// https://registry.khronos.org/webgl/specs/latest/1.0/
|
||||
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &depthId);
|
||||
|
||||
unsigned int depthIdU = (unsigned int)depthId;
|
||||
|
|
@ -3690,7 +3697,7 @@ void rlDrawVertexArrayElements(int offset, int count, const void *buffer)
|
|||
// NOTE: Added pointer math separately from function to avoid UBSAN complaining
|
||||
unsigned short *bufferPtr = (unsigned short *)buffer;
|
||||
if (offset > 0) bufferPtr += offset;
|
||||
|
||||
|
||||
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)bufferPtr);
|
||||
}
|
||||
|
||||
|
|
@ -3709,7 +3716,7 @@ void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffe
|
|||
// NOTE: Added pointer math separately from function to avoid UBSAN complaining
|
||||
unsigned short *bufferPtr = (unsigned short *)buffer;
|
||||
if (offset > 0) bufferPtr += offset;
|
||||
|
||||
|
||||
glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)bufferPtr, instances);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -4241,7 +4248,7 @@ void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool re
|
|||
unsigned int glInternalFormat = 0, glFormat = 0, glType = 0;
|
||||
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
|
||||
glBindImageTexture(index, id, 0, 0, 0, readonly ? GL_READ_ONLY : GL_READ_WRITE, glInternalFormat);
|
||||
glBindImageTexture(index, id, 0, 0, 0, readonly? GL_READ_ONLY : GL_READ_WRITE, glInternalFormat);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1202,7 +1202,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
|||
// NOTE: Vertex attributes must be uploaded considering default locations points and available vertex data
|
||||
|
||||
// Enable vertex attributes: position (shader-location = 0)
|
||||
void *vertices = mesh->animVertices != NULL ? mesh->animVertices : mesh->vertices;
|
||||
void *vertices = (mesh->animVertices != NULL)? mesh->animVertices : mesh->vertices;
|
||||
mesh->vboId[0] = rlLoadVertexBuffer(vertices, mesh->vertexCount*3*sizeof(float), dynamic);
|
||||
rlSetVertexAttribute(0, 3, RL_FLOAT, 0, 0, 0);
|
||||
rlEnableVertexAttribute(0);
|
||||
|
|
@ -1218,7 +1218,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
|||
if (mesh->normals != NULL)
|
||||
{
|
||||
// Enable vertex attributes: normals (shader-location = 2)
|
||||
void *normals = mesh->animNormals != NULL ? mesh->animNormals : mesh->normals;
|
||||
void *normals = (mesh->animNormals != NULL)? mesh->animNormals : mesh->normals;
|
||||
mesh->vboId[2] = rlLoadVertexBuffer(normals, mesh->vertexCount*3*sizeof(float), dynamic);
|
||||
rlSetVertexAttribute(2, 3, RL_FLOAT, 0, 0, 0);
|
||||
rlEnableVertexAttribute(2);
|
||||
|
|
@ -5246,7 +5246,7 @@ static bool GetPoseAtTimeGLTF(cgltf_accessor *input, cgltf_accessor *output, flo
|
|||
float tend = 0.0f;
|
||||
int keyframe = 0; // Defaults to first pose
|
||||
|
||||
for (int i = 0; i < input->count - 1; i++)
|
||||
for (int i = 0; i < (int)input->count - 1; i++)
|
||||
{
|
||||
cgltf_bool r1 = cgltf_accessor_read_float(input, i, &tstart, 1);
|
||||
if (!r1) return false;
|
||||
|
|
@ -5585,7 +5585,7 @@ static Model LoadM3D(const char *fileName)
|
|||
|
||||
if (!m3d || M3D_ERR_ISFATAL(m3d->errcode))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load M3D data, error code %d", fileName, m3d ? m3d->errcode : -2);
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load M3D data, error code %d", fileName, m3d? m3d->errcode : -2);
|
||||
if (m3d) m3d_free(m3d);
|
||||
UnloadFileData(fileData);
|
||||
return model;
|
||||
|
|
@ -5614,6 +5614,20 @@ static Model LoadM3D(const char *fileName)
|
|||
// We always need a default material, so we add +1
|
||||
model.materialCount++;
|
||||
|
||||
// WARNING: Sorting is not needed, valid M3D model files should already be sorted
|
||||
// faces should already by grouped by material
|
||||
// Just keeping the sorting function for reference (Check PR #3363)
|
||||
/*
|
||||
static int m3d_compare_faces(const void *a, const void *b)
|
||||
{
|
||||
m3df_t *fa = (m3df_t *)a;
|
||||
m3df_t *fb = (m3df_t *)b;
|
||||
return (fa->materialid - fb->materialid);
|
||||
}
|
||||
|
||||
qsort(m3d->face, m3d->numface, sizeof(m3df_t), m3d_compare_faces);
|
||||
*/
|
||||
|
||||
model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh));
|
||||
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
|
||||
model.materials = (Material *)RL_CALLOC(model.materialCount + 1, sizeof(Material));
|
||||
|
|
@ -5680,7 +5694,7 @@ static Model LoadM3D(const char *fileName)
|
|||
model.meshes[k].vertices[l*9 + 7] = m3d->vertex[m3d->face[i].vertex[2]].y*m3d->scale;
|
||||
model.meshes[k].vertices[l*9 + 8] = m3d->vertex[m3d->face[i].vertex[2]].z*m3d->scale;
|
||||
|
||||
// without vertex color (full transparency), we use the default color
|
||||
// Without vertex color (full transparency), we use the default color
|
||||
if (model.meshes[k].colors != NULL)
|
||||
{
|
||||
if (m3d->vertex[m3d->face[i].vertex[0]].color & 0xFF000000)
|
||||
|
|
@ -5722,7 +5736,7 @@ static Model LoadM3D(const char *fileName)
|
|||
int skinid = m3d->vertex[m3d->face[i].vertex[n]].skinid;
|
||||
|
||||
// Check if there is a skin for this mesh, should be, just failsafe
|
||||
if (skinid != M3D_UNDEF && skinid < (int)m3d->numskin)
|
||||
if ((skinid != M3D_UNDEF) && (skinid < (int)m3d->numskin))
|
||||
{
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
|
|
@ -5896,7 +5910,7 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCou
|
|||
|
||||
if (!m3d || M3D_ERR_ISFATAL(m3d->errcode))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load M3D data, error code %d", fileName, m3d ? m3d->errcode : -2);
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load M3D data, error code %d", fileName, m3d? m3d->errcode : -2);
|
||||
UnloadFileData(fileData);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ Image LoadImageSvg(const char *fileNameOrString, int width, int height)
|
|||
|
||||
#if defined(SUPPORT_FILEFORMAT_SVG)
|
||||
bool isSvgStringValid = false;
|
||||
|
||||
|
||||
// Validate fileName or string
|
||||
if (fileNameOrString != NULL)
|
||||
{
|
||||
|
|
@ -355,7 +355,7 @@ Image LoadImageSvg(const char *fileNameOrString, int width, int height)
|
|||
if (isSvgStringValid)
|
||||
{
|
||||
struct NSVGimage *svgImage = nsvgParse(fileData, "px", 96.0f);
|
||||
|
||||
|
||||
unsigned char *img = RL_MALLOC(width*height*4);
|
||||
|
||||
// Calculate scales for both the width and the height
|
||||
|
|
|
|||
27
src/utils.c
27
src/utils.c
|
|
@ -200,7 +200,7 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
|
|||
// WARNING: On binary streams SEEK_END could not be found,
|
||||
// using fseek() and ftell() could not work in some (rare) cases
|
||||
fseek(file, 0, SEEK_END);
|
||||
int size = ftell(file);
|
||||
int size = ftell(file); // WARNING: ftell() returns 'long int', maximum size returned is INT_MAX (2147483647 bytes)
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if (size > 0)
|
||||
|
|
@ -210,11 +210,24 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
|
|||
if (data != NULL)
|
||||
{
|
||||
// NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements]
|
||||
unsigned int count = (unsigned int)fread(data, sizeof(unsigned char), size, file);
|
||||
*dataSize = count;
|
||||
size_t count = fread(data, sizeof(unsigned char), size, file);
|
||||
|
||||
// WARNING: fread() returns a size_t value, usually 'unsigned int' (32bit compilation) and 'unsigned long long' (64bit compilation)
|
||||
// dataSize is unified along raylib as a 'int' type, so, for file-sizes > INT_MAX (2147483647 bytes) we have a limitation
|
||||
if (count > 2147483647)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "FILEIO: [%s] File is bigger than 2147483647 bytes, avoid using LoadFileData()", fileName);
|
||||
|
||||
RL_FREE(data);
|
||||
data = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dataSize = (int)count;
|
||||
|
||||
if (count != size) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially loaded", fileName);
|
||||
else TRACELOG(LOG_INFO, "FILEIO: [%s] File loaded successfully", fileName);
|
||||
if ((*dataSize) != size) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially loaded (%i bytes out of %i)", fileName, dataSize, count);
|
||||
else TRACELOG(LOG_INFO, "FILEIO: [%s] File loaded successfully", fileName);
|
||||
}
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to allocated memory for file reading", fileName);
|
||||
}
|
||||
|
|
@ -254,7 +267,9 @@ bool SaveFileData(const char *fileName, void *data, int dataSize)
|
|||
|
||||
if (file != NULL)
|
||||
{
|
||||
unsigned int count = (unsigned int)fwrite(data, sizeof(unsigned char), dataSize, file);
|
||||
// WARNING: fwrite() returns a size_t value, usually 'unsigned int' (32bit compilation) and 'unsigned long long' (64bit compilation)
|
||||
// and expects a size_t input value but as dataSize is limited to INT_MAX (2147483647 bytes), there shouldn't be a problem
|
||||
int count = (int)fwrite(data, sizeof(unsigned char), dataSize, file);
|
||||
|
||||
if (count == 0) TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to write file", fileName);
|
||||
else if (count != dataSize) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially written", fileName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue