diff --git a/src/external/jar_xm.h b/src/external/jar_xm.h index ea7a32831..82170f54d 100644 --- a/src/external/jar_xm.h +++ b/src/external/jar_xm.h @@ -75,7 +75,7 @@ struct jar_xm_context_s; typedef struct jar_xm_context_s jar_xm_context_t; #ifdef __cplusplus -extern "C" { +extern "C" { #endif //** Create a XM context. @@ -363,7 +363,7 @@ struct jar_xm_sample_s { uint16_t num_patterns; uint16_t num_instruments; uint16_t linear_interpolation; - uint16_t ramping; + uint16_t ramping; jar_xm_frequency_type_t frequency_type; uint8_t pattern_table[PATTERN_ORDER_TABLE_LENGTH]; @@ -457,7 +457,7 @@ struct jar_xm_sample_s { uint16_t default_tempo; // Number of ticks per row uint16_t default_bpm; float default_global_volume; - + uint16_t tempo; // Number of ticks per row uint16_t bpm; float global_volume; @@ -708,7 +708,7 @@ int jar_xm_check_sanity_postload(jar_xm_context_t* ctx) { if(ctx->module.pattern_table[i] >= ctx->module.num_patterns) { if(i+1 == ctx->module.length && ctx->module.length > 1) { DEBUG("trimming invalid POT at pos %X", i); - --ctx->module.length; + --ctx->module.length; } else { DEBUG("module has invalid POT, pos %X references nonexistent pattern %X", i, ctx->module.pattern_table[i]); return 1; @@ -823,7 +823,7 @@ char* jar_xm_load_module(jar_xm_context_t* ctx, const char* moddata, size_t modd pat->slots = (jar_xm_pattern_slot_t*)mempool; mempool += mod->num_channels * pat->num_rows * sizeof(jar_xm_pattern_slot_t); offset += READ_U32(offset); /* Pattern header length */ - + if(packed_patterndata_size == 0) { /* No pattern data is present */ memset(pat->slots, 0, sizeof(jar_xm_pattern_slot_t) * pat->num_rows * mod->num_channels); } else { @@ -1236,7 +1236,7 @@ static void jar_xm_post_pattern_change(jar_xm_context_t* ctx) { /* Loop if necessary */ if(ctx->current_table_index >= ctx->module.length) { ctx->current_table_index = ctx->module.restart_position; - ctx->tempo =ctx->default_tempo; // reset to file default value + ctx->tempo =ctx->default_tempo; // reset to file default value ctx->bpm = ctx->default_bpm; // reset to file default value ctx->global_volume = ctx->default_global_volume; // reset to file default value } @@ -1586,7 +1586,7 @@ static void jar_xm_trigger_note(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch->sample_position = 0.f; ch->ping = true; }; - + if (!(flags & jar_xm_TRIGGER_KEEP_VOLUME)) { if(ch->sample != NULL) { ch->volume = ch->sample->volume; @@ -1665,7 +1665,7 @@ static void jar_xm_row(jar_xm_context_t* ctx) { /* No E6y loop is in effect (or we are in the first pass) */ ctx->loop_count = (ctx->row_loop_count[MAX_NUM_ROWS * ctx->current_table_index + ctx->current_row]++); } - + /// Move to next row ctx->current_row++; /* uint8 warning: can increment from 255 to 0, in which case it is still necessary to go the next pattern. */ if (!ctx->position_jump && !ctx->pattern_break && (ctx->current_row >= cur->num_rows || ctx->current_row == 0)) { @@ -1721,7 +1721,7 @@ static void jar_xm_tick(jar_xm_context_t* ctx) { if(ctx->current_tick == 0) { jar_xm_row(ctx); // We have processed all ticks and we run the row } - + jar_xm_module_t* mod = &(ctx->module); for(uint8_t i = 0; i < ctx->module.num_channels; ++i) { jar_xm_channel_context_t* ch = ctx->channels + i; @@ -1885,7 +1885,7 @@ static void jar_xm_tick(jar_xm_context_t* ctx) { } break; case 16: /* Fxy: Set tempo/BPM */ - break; + break; case 17: /* Hxy: Global volume slide */ if(ctx->current_tick == 0) break; if((ch->global_volume_slide_param & 0xF0) && (ch->global_volume_slide_param & 0x0F)) { break; }; /* Invalid state */ @@ -1904,7 +1904,7 @@ static void jar_xm_tick(jar_xm_context_t* ctx) { if(ctx->current_tick == ch->current->effect_param) { jar_xm_key_off(ch); }; break; case 21: /* Lxx: Set envelope position */ - break; + break; case 25: /* Pxy: Panning slide */ if(ctx->current_tick == 0) break; jar_xm_panning_slide(ch, ch->panning_slide_param); @@ -2105,7 +2105,7 @@ static void jar_xm_next_of_sample(jar_xm_context_t* ctx, jar_xm_channel_context_ // gather all channel audio into stereo float static void jar_xm_mixdown(jar_xm_context_t* ctx, float* left, float* right) { jar_xm_module_t* mod = &(ctx->module); - + if(ctx->remaining_samples_in_tick <= 0) { jar_xm_tick(ctx); }; @@ -2142,7 +2142,7 @@ static void jar_xm_mixdown(jar_xm_context_t* ctx, float* left, float* right) { // apply brick wall limiter when audio goes beyond bounderies if(*left < -1.0) {*left = -1.0;} else if(*left > 1.0) {*left = 1.0;}; - if(*right < -1.0) {*right = -1.0;} else if(*right > 1.0) {*right = 1.0;}; + if(*right < -1.0) {*right = -1.0;} else if(*right > 1.0) {*right = 1.0;}; }; void jar_xm_generate_samples(jar_xm_context_t* ctx, float* output, size_t numsamples) { @@ -2244,7 +2244,7 @@ int jar_xm_create_context_from_file(jar_xm_context_t** ctx, uint32_t rate, const return 6; break; } - + return 0; } @@ -2256,7 +2256,7 @@ void jar_xm_reset(jar_xm_context_t* ctx) { ctx->current_row = 0; ctx->current_table_index = 0; ctx->current_tick = 0; - ctx->tempo =ctx->default_tempo; // reset to file default value + ctx->tempo =ctx->default_tempo; // reset to file default value ctx->bpm = ctx->default_bpm; // reset to file default value ctx->global_volume = ctx->default_global_volume; // reset to file default value } @@ -2282,7 +2282,7 @@ void jar_xm_table_jump(jar_xm_context_t* ctx, int table_ptr) { } else { ctx->current_table_index = 0; ctx->module.restart_position = 0; // The reason to jump is to start a new loop or track - ctx->tempo =ctx->default_tempo; // reset to file default value + ctx->tempo =ctx->default_tempo; // reset to file default value ctx->bpm = ctx->default_bpm; // reset to file default value ctx->global_volume = ctx->default_global_volume; // reset to file default value }; @@ -2383,31 +2383,31 @@ void jar_xm_debug(jar_xm_context_t *ctx) { y += size; DrawText(TextFormat("LCT = %i", ctx->loop_count), x, y, size, WHITE); y += size; DrawText(TextFormat("MAX LCT = %i", ctx->max_loop_count), x, y, size, WHITE); x = size * 12; y = 0; - + y += size; DrawText(TextFormat("CUR TCK = %i", ctx->current_tick), x, y, size, WHITE); y += size; DrawText(TextFormat("XTR TCK = %i", ctx->extra_ticks), x, y, size, WHITE); y += size; DrawText(TextFormat("TCK/ROW = %i", ctx->tempo), x, y, size, ORANGE); y += size; DrawText(TextFormat("SPL TCK = %f", ctx->remaining_samples_in_tick), x, y, size, WHITE); y += size; DrawText(TextFormat("GEN SPL = %i", ctx->generated_samples), x, y, size, WHITE); y += size * 7; - + x = 0; size=16; // TIMELINE OF MODULE for (int i=0; i < ctx->module.length; i++) { if (i == ctx->jump_dest) { if (ctx->position_jump) { - DrawRectangle(i * size * 2, y - size, size * 2, size, GOLD); + DrawRectangle(i * size * 2, y - size, size * 2, size, GOLD); } else { - DrawRectangle(i * size * 2, y - size, size * 2, size, BROWN); + DrawRectangle(i * size * 2, y - size, size * 2, size, BROWN); }; }; if (i == ctx->current_table_index) { // DrawText(TextFormat("%02X", ctx->current_tick), i * size * 2, y - size, size, WHITE); - DrawRectangle(i * size * 2, y, size * 2, size, RED); + DrawRectangle(i * size * 2, y, size * 2, size, RED); DrawText(TextFormat("%02X", ctx->current_row), i * size * 2, y - size, size, YELLOW); } else { - DrawRectangle(i * size * 2, y, size * 2, size, ORANGE); + DrawRectangle(i * size * 2, y, size * 2, size, ORANGE); }; DrawText(TextFormat("%02X", ctx->module.pattern_table[i]), i * size * 2, y, size, WHITE); }; @@ -2426,19 +2426,19 @@ void jar_xm_debug(jar_xm_context_t *ctx) { DrawText("FX", x + size * 6, y, size, YELLOW); x += 9 * size; }; - x += size; + x += size; for (int j=(ctx->current_row - 14); j<(ctx->current_row + 15); j++) { y += size; x = 0; if (j >=0 && j < (cur->num_rows)) { - DrawRectangle(x, y, size * 2, size, BROWN); + DrawRectangle(x, y, size * 2, size, BROWN); DrawText(TextFormat("%02X",j), x, y, size, WHITE); x += 2 * size; for(uint8_t i = 0; i < ctx->module.num_channels; i++) { if (j==(ctx->current_row)) { - DrawRectangle(x, y, 8 * size, size, DARKGREEN); + DrawRectangle(x, y, 8 * size, size, DARKGREEN); } else { - DrawRectangle(x, y, 8 * size, size, DARKGRAY); + DrawRectangle(x, y, 8 * size, size, DARKGRAY); }; jar_xm_pattern_slot_t *s = cur->slots + j * ctx->module.num_channels + i; // jar_xm_channel_context_t *ch = ctx->channels + i; diff --git a/src/models.c b/src/models.c index fd7daee6f..bd200d5f7 100644 --- a/src/models.c +++ b/src/models.c @@ -828,16 +828,16 @@ void UnloadModelKeepMeshes(Model model) BoundingBox GetModelBoundingBox(Model model) { BoundingBox bounds = { 0 }; - + if (model.meshCount > 0) - { + { Vector3 temp = { 0 }; bounds = GetMeshBoundingBox(model.meshes[0]); - + for (int i = 1; i < model.meshCount; i++) { BoundingBox tempBounds = GetMeshBoundingBox(model.meshes[i]); - + temp.x = (bounds.min.x < tempBounds.min.x)? bounds.min.x : tempBounds.min.x; temp.y = (bounds.min.y < tempBounds.min.y)? bounds.min.y : tempBounds.min.y; temp.z = (bounds.min.z < tempBounds.min.z)? bounds.min.z : tempBounds.min.z; @@ -849,7 +849,7 @@ BoundingBox GetModelBoundingBox(Model model) bounds.max = temp; } } - + return bounds; } @@ -1105,7 +1105,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins // transforms[0]: model transformation provided (includes DrawModel() params combined with model.transform) // rlGetMatrixTransform(): rlgl internal transform matrix due to push/pop matrix stack matModel = MatrixMultiply(transforms[0], rlGetMatrixTransform()); - + // Get model-view matrix matModelView = MatrixMultiply(matModel, matView); } @@ -1376,7 +1376,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount) // Set materials shader to default (DIFFUSE, SPECULAR, NORMAL) if (materials != NULL) { - for (unsigned int i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) { materials[i].shader.id = rlGetShaderIdDefault(); materials[i].shader.locs = rlGetShaderLocsDefault(); @@ -1396,7 +1396,7 @@ Material LoadMaterialDefault(void) // Using rlgl default shader material.shader.id = rlGetShaderIdDefault(); material.shader.locs = rlGetShaderLocsDefault(); - + // Using rlgl default texture (1x1 pixel, UNCOMPRESSED_R8G8B8A8, 1 mipmap) material.maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; //material.maps[MATERIAL_MAP_NORMAL].texture; // NOTE: By default, not set @@ -2825,7 +2825,7 @@ void GenMeshTangents(Mesh *mesh) RL_FREE(tan2); if (mesh->vboId != NULL) - { + { if (mesh->vboId[SHADER_LOC_VERTEX_TANGENT] != 0) { // Upate existing vertex buffer @@ -2834,15 +2834,15 @@ void GenMeshTangents(Mesh *mesh) else { // Load a new tangent attributes buffer - mesh->vboId[SHADER_LOC_VERTEX_TANGENT] = rlLoadVertexBuffer(mesh->tangents, mesh->vertexCount*4*sizeof(float), false); + mesh->vboId[SHADER_LOC_VERTEX_TANGENT] = rlLoadVertexBuffer(mesh->tangents, mesh->vertexCount*4*sizeof(float), false); } - + rlEnableVertexArray(mesh->vaoId); rlSetVertexAttribute(4, 4, RL_FLOAT, 0, 0, 0); rlEnableVertexAttribute(4); rlDisableVertexArray(); } - + TRACELOG(LOG_INFO, "MESH: Tangents data computed and uploaded for provided mesh"); } @@ -3370,7 +3370,7 @@ static Model LoadOBJ(const char *fileName) if (ret != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load OBJ data", fileName); else TRACELOG(LOG_INFO, "MODEL: [%s] OBJ data loaded successfully: %i meshes/%i materials", fileName, meshCount, materialCount); - model.meshCount = materialCount; + model.meshCount = materialCount; // Init model materials array if (materialCount > 0) @@ -3468,7 +3468,7 @@ static Model LoadOBJ(const char *fileName) // Get default texture, in case no texture is defined // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 - model.materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; + model.materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; if (materials[m].diffuse_texname != NULL) model.materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = LoadTexture(materials[m].diffuse_texname); //char *diffuse_texname; // map_Kd diff --git a/src/raudio.c b/src/raudio.c index 072dc5d33..f48888a98 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1733,7 +1733,7 @@ void UpdateMusicStream(Music music) } UpdateAudioStream(music.stream, pcm, frameCountToStream); - + framesLeft -= frameCountToStream; if (framesLeft <= 0) diff --git a/src/raymath.h b/src/raymath.h index 0909eb7e5..3addc25de 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -1432,7 +1432,7 @@ RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) { Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z); - + if (axisLength != 0.0f) { angle *= 0.5f; diff --git a/src/rlgl.h b/src/rlgl.h index 9b705473f..7d9b8d140 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -41,7 +41,7 @@ * #define SUPPORT_GL_DETAILS_INFO * Show OpenGL extensions and capabilities detailed logs on init * -* rlgl capabilities could be customized just defining some internal +* rlgl capabilities could be customized just defining some internal * values before library inclusion (default values listed): * * #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits @@ -54,7 +54,7 @@ * #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance * #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance * -* When loading a shader, the following vertex attribute and uniform +* When loading a shader, the following vertex attribute and uniform * location names are tried to be set automatically: * * #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0 @@ -246,11 +246,11 @@ //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -typedef enum { - OPENGL_11 = 1, - OPENGL_21, - OPENGL_33, - OPENGL_ES_20 +typedef enum { + OPENGL_11 = 1, + OPENGL_21, + OPENGL_33, + OPENGL_ES_20 } rlGlVersion; typedef enum { @@ -1025,7 +1025,7 @@ void rlLoadIdentity(void) // Multiply the current matrix by a translation matrix void rlTranslatef(float x, float y, float z) { - Matrix matTranslation = { + Matrix matTranslation = { 1.0f, 0.0f, 0.0f, x, 0.0f, 1.0f, 0.0f, y, 0.0f, 0.0f, 1.0f, z, @@ -1041,7 +1041,7 @@ void rlTranslatef(float x, float y, float z) void rlRotatef(float angle, float x, float y, float z) { Matrix matRotation = rlMatrixIdentity(); - + // Axis vector (x, y, z) normalization float lengthSquared = x*x + y*y + z*z; if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f)) @@ -1051,7 +1051,7 @@ void rlRotatef(float angle, float x, float y, float z) y *= inverseLength; z *= inverseLength; } - + // Rotation matrix generation float sinres = sinf(DEG2RAD*angle); float cosres = cosf(DEG2RAD*angle); @@ -1084,11 +1084,11 @@ void rlRotatef(float angle, float x, float y, float z) // Multiply the current matrix by a scaling matrix void rlScalef(float x, float y, float z) { - Matrix matScale = { + Matrix matScale = { x, 0.0f, 0.0f, 0.0f, 0.0f, y, 0.0f, 0.0f, 0.0f, 0.0f, z, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f + 0.0f, 0.0f, 0.0f, 1.0f }; // NOTE: We transpose matrix with multiplication order @@ -1145,7 +1145,7 @@ void rlOrtho(double left, double right, double bottom, double top, double znear, // NOTE: If left-right and top-botton values are equal it could create a division by zero, // response to it is platform/compiler dependant Matrix matOrtho = { 0 }; - + float rl = (float)(right - left); float tb = (float)(top - bottom); float fn = (float)(zfar - znear); @@ -1558,11 +1558,11 @@ void rlActiveDrawBuffers(int count) // it can be queried with glGet*() but it must be at least 8 //GLint maxDrawBuffers = 0; //glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); - + if (count > 0) { if (count > 8) TRACELOG(LOG_WARNING, "GL: Max color buffers limited to 8"); - else + else { unsigned int buffers[8] = { GL_COLOR_ATTACHMENT0, @@ -2399,10 +2399,10 @@ void rlDrawRenderBatch(rlRenderBatch *batch) // Create modelview-projection matrix and upload to shader Matrix matMVP = rlMatrixMultiply(RLGL.State.modelview, RLGL.State.projection); - float matMVPfloat[16] = { - matMVP.m0, matMVP.m1, matMVP.m2, matMVP.m3, - matMVP.m4, matMVP.m5, matMVP.m6, matMVP.m7, - matMVP.m8, matMVP.m9, matMVP.m10, matMVP.m11, + float matMVPfloat[16] = { + matMVP.m0, matMVP.m1, matMVP.m2, matMVP.m3, + matMVP.m4, matMVP.m5, matMVP.m6, matMVP.m7, + matMVP.m8, matMVP.m9, matMVP.m10, matMVP.m11, matMVP.m12, matMVP.m13, matMVP.m14, matMVP.m15 }; glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MVP], 1, false, matMVPfloat); @@ -3431,7 +3431,7 @@ unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode) if (vsCode != NULL) vertexShaderId = rlCompileShader(vsCode, GL_VERTEX_SHADER); if (fsCode != NULL) fragmentShaderId = rlCompileShader(fsCode, GL_FRAGMENT_SHADER); - + if ((vertexShaderId == RLGL.State.defaultVShaderId) && (fragmentShaderId == RLGL.State.defaultFShaderId)) id = RLGL.State.defaultShaderId; else { @@ -3582,13 +3582,13 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId) program = 0; } - else + else { // Get the size of compiled shader program (not available on OpenGL ES 2.0) // NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero. //GLint binarySize = 0; //glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize); - + TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Program shader loaded successfully", program); } #endif @@ -3670,10 +3670,10 @@ void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType void rlSetUniformMatrix(int locIndex, Matrix mat) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - float matfloat[16] = { - mat.m0, mat.m1, mat.m2, mat.m3, - mat.m4, mat.m5, mat.m6, mat.m7, - mat.m8, mat.m9, mat.m10, mat.m11, + float matfloat[16] = { + mat.m0, mat.m1, mat.m2, mat.m3, + mat.m4, mat.m5, mat.m6, mat.m7, + mat.m8, mat.m9, mat.m10, mat.m11, mat.m12, mat.m13, mat.m14, mat.m15 }; glUniformMatrix4fv(locIndex, 1, false, matfloat); diff --git a/src/text.c b/src/text.c index 9d336f218..66a08eb19 100644 --- a/src/text.c +++ b/src/text.c @@ -899,9 +899,9 @@ void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, rlTranslatef(position.x, position.y, 0.0f); rlRotatef(rotation, 0.0f, 0.0f, 1.0f); rlTranslatef(-origin.x, -origin.y, 0.0f); - + DrawTextEx(font, text, (Vector2){ 0.0f, 0.0f }, fontSize, spacing, tint); - + rlPopMatrix(); } @@ -1002,7 +1002,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing } // Get index position for a unicode character on font -// NOTE: If codepoint is not found in the font it fallbacks to '?' +// NOTE: If codepoint is not found in the font it fallbacks to '?' int GetGlyphIndex(Font font, int codepoint) { #ifndef GLYPH_NOTFOUND_CHAR_FALLBACK @@ -1030,24 +1030,24 @@ int GetGlyphIndex(Font font, int codepoint) } // Get glyph font info data for a codepoint (unicode character) -// NOTE: If codepoint is not found in the font it fallbacks to '?' +// NOTE: If codepoint is not found in the font it fallbacks to '?' GlyphInfo GetGlyphInfo(Font font, int codepoint) { GlyphInfo info = { 0 }; - + info = font.chars[GetGlyphIndex(font, codepoint)]; - + return info; } // Get glyph rectangle in font atlas for a codepoint (unicode character) -// NOTE: If codepoint is not found in the font it fallbacks to '?' +// NOTE: If codepoint is not found in the font it fallbacks to '?' Rectangle GetGlyphAtlasRec(Font font, int codepoint) { Rectangle rec = { 0 }; - + rec = font.recs[GetGlyphIndex(font, codepoint)]; - + return rec; } diff --git a/src/textures.c b/src/textures.c index 2480bcfcc..6d5c2c5f4 100644 --- a/src/textures.c +++ b/src/textures.c @@ -382,7 +382,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i if (image.data != NULL) TRACELOG(LOG_INFO, "IMAGE: Data loaded successfully (%ix%i | %s | %i mipmaps)", image.width, image.height, rlGetPixelFormatName(image.format), image.mipmaps); else TRACELOG(LOG_WARNING, "IMAGE: Failed to load image data"); - + return image; } @@ -2419,28 +2419,28 @@ void ImageDrawPixelV(Image *dst, Vector2 position, Color color) // Draw line within an image void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color) { - // Using Bresenham's algorithm as described in + // Using Bresenham's algorithm as described in // Drawing Lines with Pixels - Joshua Scott - March 2012 // https://classic.csunplugged.org/wp-content/uploads/2014/12/Lines.pdf - + int changeInX = (endPosX - startPosX); int absChangeInX = (changeInX < 0)? -changeInX : changeInX; int changeInY = (endPosY - startPosY); int absChangeInY = (changeInY < 0)? -changeInY : changeInY; - + int startU, startV, endU, stepV; // Substitutions, either U = X, V = Y or vice versa. See loop at end of function //int endV; // Not needed but left for better understanding, check code below int A, B, P; // See linked paper above, explained down in the main loop int reversedXY = (absChangeInY < absChangeInX); - - if (reversedXY) + + if (reversedXY) { A = 2*absChangeInY; B = A - 2*absChangeInX; P = A - absChangeInX; if (changeInX > 0) - { + { startU = startPosX; startV = startPosY; endU = endPosX; @@ -2452,23 +2452,23 @@ void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int en startV = endPosY; endU = startPosX; //endV = startPosY; - + // Since start and end are reversed changeInX = -changeInX; changeInY = -changeInY; } - + stepV = (changeInY < 0)? -1 : 1; - + ImageDrawPixel(dst, startU, startV, color); // At this point they are correctly ordered... } else { - A = 2*absChangeInX; + A = 2*absChangeInX; B = A - 2*absChangeInY; P = A - absChangeInY; - - if (changeInY > 0) + + if (changeInY > 0) { startU = startPosY; startV = startPosX; @@ -2481,21 +2481,21 @@ void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int en startV = endPosX; endU = startPosY; //endV = startPosX; - + // Since start and end are reversed changeInX = -changeInX; changeInY = -changeInY; } - + stepV = (changeInX < 0)? -1 : 1; - + ImageDrawPixel(dst, startV, startU, color); // ... but need to be reversed here. Repeated in the main loop below - } - + } + // We already drew the start point. If we started at startU + 0, the line would be crooked and too short - for (int u = startU + 1, v = startV; u <= endU; u++) + for (int u = startU + 1, v = startV; u <= endU; u++) { - if (P >= 0) + if (P >= 0) { v += stepV; // Adjusts whenever we stray too far from the direct line. Details in the linked paper above P += B; // Remembers that we corrected our path