diff --git a/src/raudio.c b/src/raudio.c index 2d41b2385..ccd156c1e 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1407,7 +1407,7 @@ Music LoadMusicStream(const char *fileName) // Load music stream from memory buffer, fileType refers to extension: i.e. ".wav" // WARNING: File extension must be provided in lower-case -Music LoadMusicStreamFromMemory(const char *fileType, unsigned char *data, int dataSize) +Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize) { Music music = { 0 }; bool musicLoaded = false; diff --git a/src/raylib.h b/src/raylib.h index b7217bf95..1604ecc1c 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1059,10 +1059,10 @@ RLAPI void ClearDroppedFiles(void); // Clear dropp RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time) // Compression/Encoding functionality -RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm) -RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm) -RLAPI char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLength); // Encode data to Base64 string -RLAPI unsigned char *DecodeDataBase64(unsigned char *data, int *outputLength); // Decode Base64 string data +RLAPI unsigned char *CompressData(const unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm) +RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm) +RLAPI char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLength); // Encode data to Base64 string +RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputLength); // Decode Base64 string data // Persistent storage management RLAPI bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success @@ -1338,7 +1338,7 @@ RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color co RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation) RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint) -RLAPI void DrawTextCodepoints(Font font, int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint) +RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint) // Text font info functions RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font @@ -1353,7 +1353,7 @@ RLAPI void UnloadCodepoints(int *codepoints); // Unload RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string RLAPI int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure RLAPI const char *CodepointToUTF8(int codepoint, int *byteSize); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) -RLAPI char *TextCodepointsToUTF8(int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) +RLAPI char *TextCodepointsToUTF8(const int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) // Text strings management functions (no UTF-8 strings, only byte chars) // NOTE: Some strings allocate memory internally for returned strings, just be careful! @@ -1423,7 +1423,7 @@ RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, // Mesh management functions RLAPI void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids -RLAPI void UpdateMeshBuffer(Mesh mesh, int index, void *data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index +RLAPI void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index RLAPI void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU RLAPI void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform RLAPI void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances); // Draw multiple mesh instances with material and different transforms @@ -1511,7 +1511,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload // Music management functions RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file -RLAPI Music LoadMusicStreamFromMemory(const char *fileType, unsigned char *data, int dataSize); // Load music stream from data +RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data RLAPI void UnloadMusicStream(Music music); // Unload music stream RLAPI void PlayMusicStream(Music music); // Start music playing RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing diff --git a/src/rcore.c b/src/rcore.c index 2b0164ee2..fc781219a 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3181,7 +3181,7 @@ long GetFileModTime(const char *fileName) } // Compress data (DEFLATE algorythm) -unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength) +unsigned char *CompressData(const unsigned char *data, int dataLength, int *compDataLength) { #define COMPRESSION_QUALITY_DEFLATE 8 @@ -3201,7 +3201,7 @@ unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLe } // Decompress data (DEFLATE algorythm) -unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength) +unsigned char *DecompressData(const unsigned char *compData, int compDataLength, int *dataLength) { unsigned char *data = NULL; @@ -3259,7 +3259,7 @@ char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLen } // Decode Base64 string data -unsigned char *DecodeDataBase64(unsigned char *data, int *outputLength) +unsigned char *DecodeDataBase64(const unsigned char *data, int *outputLength) { static const unsigned char base64decodeTable[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/rlgl.h b/src/rlgl.h index f3977e670..8513998cb 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -620,23 +620,24 @@ RLAPI void rlSetTexture(unsigned int id); // Set current texture for r // Vertex buffers management RLAPI unsigned int rlLoadVertexArray(void); // Load vertex array (vao) if supported -RLAPI unsigned int rlLoadVertexBuffer(void *buffer, int size, bool dynamic); // Load a vertex buffer attribute -RLAPI unsigned int rlLoadVertexBufferElement(void *buffer, int size, bool dynamic); // Load a new attributes element buffer -RLAPI void rlUpdateVertexBuffer(unsigned int bufferId, void *data, int dataSize, int offset); // Update GPU buffer with new data +RLAPI unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic); // Load a vertex buffer attribute +RLAPI unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic); // Load a new attributes element buffer +RLAPI void rlUpdateVertexBuffer(unsigned int bufferId, const void *data, int dataSize, int offset); // Update GPU buffer with new data +RLAPI void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset); // Update vertex buffer elements with new data RLAPI void rlUnloadVertexArray(unsigned int vaoId); RLAPI void rlUnloadVertexBuffer(unsigned int vboId); -RLAPI void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, void *pointer); +RLAPI void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer); RLAPI void rlSetVertexAttributeDivisor(unsigned int index, int divisor); RLAPI void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count); // Set vertex attribute default value RLAPI void rlDrawVertexArray(int offset, int count); -RLAPI void rlDrawVertexArrayElements(int offset, int count, void *buffer); +RLAPI void rlDrawVertexArrayElements(int offset, int count, const void *buffer); RLAPI void rlDrawVertexArrayInstanced(int offset, int count, int instances); -RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, void *buffer, int instances); +RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances); // Textures management -RLAPI unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount); // Load texture in GPU +RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount); // Load texture in GPU RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) -RLAPI unsigned int rlLoadTextureCubemap(void *data, int size, int format); // Load texture cubemap +RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format); // Load texture cubemap RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data); // Update GPU texture with new data RLAPI void rlGetGlTextureFormats(int format, int *glInternalFormat, int *glFormat, int *glType); // Get OpenGL internal formats RLAPI const char *rlGetPixelFormatName(unsigned int format); // Get name string for pixel format @@ -2682,7 +2683,7 @@ bool rlCheckRenderBatchLimit(int vCount) // Textures data management //----------------------------------------------------------------------------------------- // Convert image data to OpenGL texture (returns OpenGL valid Id) -unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount) +unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount) { glBindTexture(GL_TEXTURE_2D, 0); // Free any old binding @@ -2884,7 +2885,7 @@ unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer) // Load texture cubemap // NOTE: Cubemap data is expected to be 6 images in a single data array (one after the other), // expected the following convention: +X, -X, +Y, -Y, +Z, -Z -unsigned int rlLoadTextureCubemap(void *data, int size, int format) +unsigned int rlLoadTextureCubemap(const void *data, int size, int format) { unsigned int id = 0; @@ -3319,7 +3320,7 @@ void rlUnloadFramebuffer(unsigned int id) // Vertex data management //----------------------------------------------------------------------------------------- // Load a new attributes buffer -unsigned int rlLoadVertexBuffer(void *buffer, int size, bool dynamic) +unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic) { unsigned int id = 0; @@ -3333,7 +3334,7 @@ unsigned int rlLoadVertexBuffer(void *buffer, int size, bool dynamic) } // Load a new attributes element buffer -unsigned int rlLoadVertexBufferElement(void *buffer, int size, bool dynamic) +unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic) { unsigned int id = 0; @@ -3380,7 +3381,7 @@ void rlDisableVertexBufferElement(void) // Update vertex buffer with new data // NOTE: dataSize and offset must be provided in bytes -void rlUpdateVertexBuffer(unsigned int id, void *data, int dataSize, int offset) +void rlUpdateVertexBuffer(unsigned int id, const void *data, int dataSize, int offset) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) glBindBuffer(GL_ARRAY_BUFFER, id); @@ -3390,7 +3391,7 @@ void rlUpdateVertexBuffer(unsigned int id, void *data, int dataSize, int offset) // Update vertex buffer elements with new data // NOTE: dataSize and offset must be provided in bytes -void rlUpdateVertexBufferElements(unsigned int id, void *data, int dataSize, int offset) +void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); @@ -3443,9 +3444,9 @@ void rlDrawVertexArray(int offset, int count) } // Draw vertex array elements -void rlDrawVertexArrayElements(int offset, int count, void *buffer) +void rlDrawVertexArrayElements(int offset, int count, const void *buffer) { - glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (unsigned short *)buffer + offset); + glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)buffer + offset); } // Draw vertex array instanced @@ -3457,10 +3458,10 @@ void rlDrawVertexArrayInstanced(int offset, int count, int instances) } // Draw vertex array elements instanced -void rlDrawVertexArrayElementsInstanced(int offset, int count, void *buffer, int instances) +void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (unsigned short *)buffer + offset, instances); + glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)buffer + offset, instances); #endif } @@ -3501,7 +3502,7 @@ unsigned int rlLoadVertexArray(void) } // Set vertex attribute -void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, void *pointer) +void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) glVertexAttribPointer(index, compSize, type, normalized, stride, pointer); diff --git a/src/rmodels.c b/src/rmodels.c index 4fb6465e1..f60d1f621 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1174,7 +1174,7 @@ void UploadMesh(Mesh *mesh, bool dynamic) } // Update mesh vertex data in GPU for a specific buffer index -void UpdateMeshBuffer(Mesh mesh, int index, void *data, int dataSize, int offset) +void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset) { rlUpdateVertexBuffer(mesh.vboId[index], data, dataSize, offset); } diff --git a/src/rtext.c b/src/rtext.c index 0a8af79e1..8c5366333 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1092,7 +1092,7 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz } // Draw multiple character (codepoints) -void DrawTextCodepoints(Font font, int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint) +void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint) { int textOffsetY = 0; // Offset between lines (on line break '\n') float textOffsetX = 0.0f; // Offset X to next character to draw @@ -1605,7 +1605,7 @@ const char *TextToPascal(const char *text) // Encode text codepoint into UTF-8 text // REQUIRES: memcpy() // WARNING: Allocated memory should be manually freed -char *TextCodepointsToUTF8(int *codepoints, int length) +char *TextCodepointsToUTF8(const int *codepoints, int length) { // We allocate enough memory fo fit all possible codepoints // NOTE: 5 bytes for every codepoint should be enough