diff --git a/src/core.c b/src/core.c index 9bf9837b..41ef4b4f 100644 --- a/src/core.c +++ b/src/core.c @@ -1953,7 +1953,7 @@ void BeginDrawing(void) void EndDrawing(void) { rlDrawRenderBatchActive(); // Update and draw internal render batch - + #if defined(SUPPORT_MOUSE_CURSOR_POINT) // Draw a small rectangle on mouse position for user reference if (!CORE.Input.Mouse.cursorHidden) @@ -2021,7 +2021,7 @@ void EndDrawing(void) #if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) SwapScreenBuffer(); // Copy back buffer to front buffer (screen) - + // Frame time control system CORE.Time.current = GetTime(); CORE.Time.draw = CORE.Time.current - CORE.Time.previous; @@ -2043,7 +2043,7 @@ void EndDrawing(void) PollInputEvents(); // Poll user events #endif - + #if defined(SUPPORT_EVENTS_AUTOMATION) // Events recording and playing logic if (eventsRecording) RecordAutomationEvent(CORE.Time.frameCounter); @@ -2642,8 +2642,8 @@ void SetTargetFPS(int fps) int GetFPS(void) { int fps = 0; - -#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) + +#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) #define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures #define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 millisecondes #define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT) @@ -2663,7 +2663,7 @@ int GetFPS(void) history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT; average += history[index]; } - + fps = (int)roundf(1.0f/average); #endif @@ -5102,19 +5102,22 @@ static void ErrorCallback(int error, const char *description) { TRACELOG(LOG_WARNING, "GLFW: Error: %i Description: %s", error, description); } + #if defined(PLATFORM_WEB) -EM_JS(int, CanvasGetWidth, (), { return canvas.clientWidth; }); -EM_JS(int, CanvasGetHeight, (), { return canvas.clientHeight; }); +EM_JS(int, GetCanvasWidth, (), { return canvas.clientWidth; }); +EM_JS(int, GetCanvasHeight, (), { return canvas.clientHeight; }); + static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *e, void *userData) { // Don't resize non-resizeable windows if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0) return true; - // This event is called whenever the window changes sizes, so the size of - // the canvas object is explicitly retrieved below - int width = CanvasGetWidth(); - int height = CanvasGetHeight(); + + // This event is called whenever the window changes sizes, + // so the size of the canvas object is explicitly retrieved below + int width = GetCanvasWidth(); + int height = GetCanvasHeight(); emscripten_set_canvas_element_size("#canvas",width,height); - + SetupViewport(width, height); // Reset viewport and projection matrix for new size CORE.Window.currentFbo.width = width; @@ -5126,9 +5129,11 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent * // Set current screen size CORE.Window.screen.width = width; CORE.Window.screen.height = height; + // NOTE: Postprocessing texture is not scaled to new size } -#endif +#endif + // GLFW3 WindowSize Callback, runs when window is resizedLastFrame // NOTE: Window resizing not allowed by default static void WindowSizeCallback(GLFWwindow *window, int width, int height) @@ -6875,7 +6880,7 @@ static void LoadAutomationEvents(const char *fileName) { sscanf(buffer, "e %d %d %d %d %d", &events[count].frame, &events[count].type, &events[count].params[0], &events[count].params[1], &events[count].params[2]); - + count++; } diff --git a/src/raylib.h b/src/raylib.h index 51565421..020af527 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -222,7 +222,7 @@ typedef struct Color { // Rectangle, 4 components typedef struct Rectangle { - float x; // Rectangle top-left corner position x + float x; // Rectangle top-left corner position x float y; // Rectangle top-left corner position y float width; // Rectangle width float height; // Rectangle height diff --git a/src/shapes.c b/src/shapes.c index 788c3c83..98852bc8 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -1645,7 +1645,7 @@ bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshol if (fabsf(dxl) >= fabsf(dyl)) collision = (dxl > 0)? ((p1.x <= point.x) && (point.x <= p2.x)) : ((p2.x <= point.x) && (point.x <= p1.x)); else collision = (dyl > 0)? ((p1.y <= point.y) && (point.y <= p2.y)) : ((p2.y <= point.y) && (point.y <= p1.y)); } - + return collision; } diff --git a/src/text.c b/src/text.c index a5e87121..65460d80 100644 --- a/src/text.c +++ b/src/text.c @@ -929,10 +929,9 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f float glyphWidth = 0; if (codepoint != '\n') { - glyphWidth = (font.chars[index].advanceX == 0) ? font.recs[index].width * scaleFactor : font.chars[index].advanceX * scaleFactor; - - if (i + 1 < length) - glyphWidth = glyphWidth + spacing; + glyphWidth = (font.chars[index].advanceX == 0) ? font.recs[index].width*scaleFactor : font.chars[index].advanceX*scaleFactor; + + if (i + 1 < length) glyphWidth = glyphWidth + spacing; } // NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container @@ -979,7 +978,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f { if (!wordWrap) { - textOffsetY += (font.baseSize + font.baseSize / 2) * scaleFactor; + textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor; textOffsetX = 0; } } @@ -987,7 +986,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f { if (!wordWrap && ((textOffsetX + glyphWidth) > rec.width)) { - textOffsetY += (font.baseSize + font.baseSize / 2) * scaleFactor; + textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor; textOffsetX = 0; } @@ -998,7 +997,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f bool isGlyphSelected = false; if ((selectStart >= 0) && (k >= selectStart) && (k < (selectStart + selectLength))) { - DrawRectangleRec((Rectangle){ rec.x + textOffsetX - 1, rec.y + textOffsetY, glyphWidth, (float)font.baseSize * scaleFactor }, selectBackTint); + DrawRectangleRec((Rectangle){ rec.x + textOffsetX - 1, rec.y + textOffsetY, glyphWidth, (float)font.baseSize*scaleFactor }, selectBackTint); isGlyphSelected = true; } @@ -1011,7 +1010,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f if (wordWrap && (i == endLine)) { - textOffsetY += (font.baseSize + font.baseSize / 2) * scaleFactor; + textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor; textOffsetX = 0; startLine = endLine; endLine = -1;