From c06874f14a9db1059be3cdcd0b0b6c892b1c0abb Mon Sep 17 00:00:00 2001 From: tiger tiger tiger Date: Thu, 30 Jul 2026 15:07:59 +0200 Subject: [PATCH] chore: run dotnet format scoped default (was previously scoped to just 'style') --- Examples/Audio/AmpEnvelope.cs | 53 ++-- Examples/Audio/StreamCallback.cs | 16 +- Examples/Core/Camera3dFps.cs | 10 +- Examples/Core/KeyboardTestbed.cs | 318 ++++++++++++++++-------- Examples/Core/ViewportScaling.cs | 27 +- Examples/ExcludeFromBrowserAttribute.cs | 5 +- Examples/IExample.cs | 10 +- Examples/Models/Decals.cs | 28 ++- Examples/Shaders/DeferredRendering.cs | 159 ++++++------ Examples/Shaders/LightmapRendering.cs | 12 +- Examples/Shapes/BallPhysics.cs | 46 ++-- Examples/Shapes/BulletHell.cs | 112 ++++----- Examples/Shapes/DashedLine.cs | 26 +- Examples/Shapes/DigitalClock.cs | 43 +++- Examples/Shapes/DoublePendulum.cs | 13 +- Examples/Shapes/HilbertCurve.cs | 36 +-- Examples/Shapes/LinesDrawing.cs | 24 +- Examples/Shapes/MathAngleRotation.cs | 76 +++--- Examples/Shapes/MouseTrail.cs | 36 +-- Examples/Shapes/PenroseTile.cs | 23 +- Examples/Shapes/RectangleAdvanced.cs | 24 +- Examples/Shapes/SimpleParticles.cs | 86 ++++--- Examples/Text/Text3D.cs | 35 ++- 23 files changed, 741 insertions(+), 477 deletions(-) diff --git a/Examples/Audio/AmpEnvelope.cs b/Examples/Audio/AmpEnvelope.cs index 2c1df4b..6efc7ba 100644 --- a/Examples/Audio/AmpEnvelope.cs +++ b/Examples/Audio/AmpEnvelope.cs @@ -176,41 +176,42 @@ public unsafe partial class AmpEnvelope : IExample switch (env.State) { case ADSRState.Attack: - { - env.CurrentValue += (1.0f / env.AttackTime) * sampleTime; - if (env.CurrentValue >= 1.0f) { - env.CurrentValue = 1.0f; - env.State = ADSRState.Decay; + env.CurrentValue += (1.0f / env.AttackTime) * sampleTime; + if (env.CurrentValue >= 1.0f) + { + env.CurrentValue = 1.0f; + env.State = ADSRState.Decay; + } } - } - break; + break; case ADSRState.Decay: - { - env.CurrentValue -= ((1.0f - env.SustainLevel) / env.DecayTime) * sampleTime; - if (env.CurrentValue <= env.SustainLevel) + { + env.CurrentValue -= ((1.0f - env.SustainLevel) / env.DecayTime) * sampleTime; + if (env.CurrentValue <= env.SustainLevel) + { + env.CurrentValue = env.SustainLevel; + env.State = ADSRState.Sustain; + } + } + break; + case ADSRState.Sustain: { env.CurrentValue = env.SustainLevel; - env.State = ADSRState.Sustain; } - } - break; - case ADSRState.Sustain: - { - env.CurrentValue = env.SustainLevel; - } - break; + break; case ADSRState.Release: - { - env.CurrentValue -= (env.SustainLevel / env.ReleaseTime) * sampleTime; - if (env.CurrentValue <= 0.001f) // Use a small threshold to avoid infinite tail { - env.CurrentValue = 0.0f; - env.State = ADSRState.Idle; + env.CurrentValue -= (env.SustainLevel / env.ReleaseTime) * sampleTime; + if (env.CurrentValue <= 0.001f) // Use a small threshold to avoid infinite tail + { + env.CurrentValue = 0.0f; + env.State = ADSRState.Idle; + } } - } - break; - default: break; + break; + default: + break; } } diff --git a/Examples/Audio/StreamCallback.cs b/Examples/Audio/StreamCallback.cs index f146f9f..b92a72a 100644 --- a/Examples/Audio/StreamCallback.cs +++ b/Examples/Audio/StreamCallback.cs @@ -88,10 +88,18 @@ public unsafe partial class StreamCallback : IExample { switch (waveType) { - case WaveType.Sine: SetAudioStreamCallback(stream, &SineCallback); break; - case WaveType.Square: SetAudioStreamCallback(stream, &SquareCallback); break; - case WaveType.Triangle: SetAudioStreamCallback(stream, &TriangleCallback); break; - case WaveType.Sawtooth: SetAudioStreamCallback(stream, &SawtoothCallback); break; + case WaveType.Sine: + SetAudioStreamCallback(stream, &SineCallback); + break; + case WaveType.Square: + SetAudioStreamCallback(stream, &SquareCallback); + break; + case WaveType.Triangle: + SetAudioStreamCallback(stream, &TriangleCallback); + break; + case WaveType.Sawtooth: + SetAudioStreamCallback(stream, &SawtoothCallback); + break; } } diff --git a/Examples/Core/Camera3dFps.cs b/Examples/Core/Camera3dFps.cs index cd24279..cc68b72 100644 --- a/Examples/Core/Camera3dFps.cs +++ b/Examples/Core/Camera3dFps.cs @@ -243,13 +243,19 @@ public partial class Camera3dFps : IExample // Clamp view up float maxAngleUp = Vector3Angle(up, yaw); maxAngleUp -= 0.001f; // Avoid numerical errors - if (-(lookRotation.Y) > maxAngleUp) { lookRotation.Y = -maxAngleUp; } + if (-(lookRotation.Y) > maxAngleUp) + { + lookRotation.Y = -maxAngleUp; + } // Clamp view down float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw); maxAngleDown *= -1.0f; // Downwards angle is negative maxAngleDown += 0.001f; // Avoid numerical errors - if (-(lookRotation.Y) < maxAngleDown) { lookRotation.Y = -maxAngleDown; } + if (-(lookRotation.Y) < maxAngleDown) + { + lookRotation.Y = -maxAngleDown; + } // Up and down Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up)); diff --git a/Examples/Core/KeyboardTestbed.cs b/Examples/Core/KeyboardTestbed.cs index d01bf64..019a736 100644 --- a/Examples/Core/KeyboardTestbed.cs +++ b/Examples/Core/KeyboardTestbed.cs @@ -237,112 +237,218 @@ public partial class KeyboardTestbed : IExample { switch ((KeyboardKey)key) { - case KeyboardKey.Apostrophe: return "'"; // Key: ' - case KeyboardKey.Comma: return ","; // Key: , - case KeyboardKey.Minus: return "-"; // Key: - - case KeyboardKey.Period: return "."; // Key: . - case KeyboardKey.Slash: return "/"; // Key: / - case KeyboardKey.Zero: return "0"; // Key: 0 - case KeyboardKey.One: return "1"; // Key: 1 - case KeyboardKey.Two: return "2"; // Key: 2 - case KeyboardKey.Three: return "3"; // Key: 3 - case KeyboardKey.Four: return "4"; // Key: 4 - case KeyboardKey.Five: return "5"; // Key: 5 - case KeyboardKey.Six: return "6"; // Key: 6 - case KeyboardKey.Seven: return "7"; // Key: 7 - case KeyboardKey.Eight: return "8"; // Key: 8 - case KeyboardKey.Nine: return "9"; // Key: 9 - case KeyboardKey.Semicolon: return ";"; // Key: ; - case KeyboardKey.Equal: return "="; // Key: = - case KeyboardKey.A: return "A"; // Key: A | a - case KeyboardKey.B: return "B"; // Key: B | b - case KeyboardKey.C: return "C"; // Key: C | c - case KeyboardKey.D: return "D"; // Key: D | d - case KeyboardKey.E: return "E"; // Key: E | e - case KeyboardKey.F: return "F"; // Key: F | f - case KeyboardKey.G: return "G"; // Key: G | g - case KeyboardKey.H: return "H"; // Key: H | h - case KeyboardKey.I: return "I"; // Key: I | i - case KeyboardKey.J: return "J"; // Key: J | j - case KeyboardKey.K: return "K"; // Key: K | k - case KeyboardKey.L: return "L"; // Key: L | l - case KeyboardKey.M: return "M"; // Key: M | m - case KeyboardKey.N: return "N"; // Key: N | n - case KeyboardKey.O: return "O"; // Key: O | o - case KeyboardKey.P: return "P"; // Key: P | p - case KeyboardKey.Q: return "Q"; // Key: Q | q - case KeyboardKey.R: return "R"; // Key: R | r - case KeyboardKey.S: return "S"; // Key: S | s - case KeyboardKey.T: return "T"; // Key: T | t - case KeyboardKey.U: return "U"; // Key: U | u - case KeyboardKey.V: return "V"; // Key: V | v - case KeyboardKey.W: return "W"; // Key: W | w - case KeyboardKey.X: return "X"; // Key: X | x - case KeyboardKey.Y: return "Y"; // Key: Y | y - case KeyboardKey.Z: return "Z"; // Key: Z | z - case KeyboardKey.LeftBracket: return "["; // Key: [ - case KeyboardKey.Backslash: return "\\"; // Key: '\' - case KeyboardKey.RightBracket: return "]"; // Key: ] - case KeyboardKey.Grave: return "`"; // Key: ` - case KeyboardKey.Space: return "SPACE"; // Key: Space - case KeyboardKey.Escape: return "ESC"; // Key: Esc - case KeyboardKey.Enter: return "ENTER"; // Key: Enter - case KeyboardKey.Tab: return "TAB"; // Key: Tab - case KeyboardKey.Backspace: return "BACK"; // Key: Backspace - case KeyboardKey.Insert: return "INS"; // Key: Ins - case KeyboardKey.Delete: return "DEL"; // Key: Del - case KeyboardKey.Right: return "RIGHT"; // Key: Cursor right - case KeyboardKey.Left: return "LEFT"; // Key: Cursor left - case KeyboardKey.Down: return "DOWN"; // Key: Cursor down - case KeyboardKey.Up: return "UP"; // Key: Cursor up - case KeyboardKey.PageUp: return "PGUP"; // Key: Page up - case KeyboardKey.PageDown: return "PGDOWN"; // Key: Page down - case KeyboardKey.Home: return "HOME"; // Key: Home - case KeyboardKey.End: return "END"; // Key: End - case KeyboardKey.CapsLock: return "CAPS"; // Key: Caps lock - case KeyboardKey.ScrollLock: return "LOCK"; // Key: Scroll down - case KeyboardKey.NumLock: return "NUMLOCK"; // Key: Num lock - case KeyboardKey.PrintScreen: return "PRINTSCR"; // Key: Print screen - case KeyboardKey.Pause: return "PAUSE"; // Key: Pause - case KeyboardKey.F1: return "F1"; // Key: F1 - case KeyboardKey.F2: return "F2"; // Key: F2 - case KeyboardKey.F3: return "F3"; // Key: F3 - case KeyboardKey.F4: return "F4"; // Key: F4 - case KeyboardKey.F5: return "F5"; // Key: F5 - case KeyboardKey.F6: return "F6"; // Key: F6 - case KeyboardKey.F7: return "F7"; // Key: F7 - case KeyboardKey.F8: return "F8"; // Key: F8 - case KeyboardKey.F9: return "F9"; // Key: F9 - case KeyboardKey.F10: return "F10"; // Key: F10 - case KeyboardKey.F11: return "F11"; // Key: F11 - case KeyboardKey.F12: return "F12"; // Key: F12 - case KeyboardKey.LeftShift: return "LSHIFT"; // Key: Shift left - case KeyboardKey.LeftControl: return "LCTRL"; // Key: Control left - case KeyboardKey.LeftAlt: return "LALT"; // Key: Alt left - case KeyboardKey.LeftSuper: return "WIN"; // Key: Super left - case KeyboardKey.RightShift: return "RSHIFT"; // Key: Shift right - case KeyboardKey.RightControl: return "RCTRL"; // Key: Control right - case KeyboardKey.RightAlt: return "ALTGR"; // Key: Alt right - case KeyboardKey.RightSuper: return "RSUPER"; // Key: Super right - case KeyboardKey.KeyboardMenu: return "KBMENU"; // Key: KB menu - case KeyboardKey.Kp0: return "KP0"; // Key: Keypad 0 - case KeyboardKey.Kp1: return "KP1"; // Key: Keypad 1 - case KeyboardKey.Kp2: return "KP2"; // Key: Keypad 2 - case KeyboardKey.Kp3: return "KP3"; // Key: Keypad 3 - case KeyboardKey.Kp4: return "KP4"; // Key: Keypad 4 - case KeyboardKey.Kp5: return "KP5"; // Key: Keypad 5 - case KeyboardKey.Kp6: return "KP6"; // Key: Keypad 6 - case KeyboardKey.Kp7: return "KP7"; // Key: Keypad 7 - case KeyboardKey.Kp8: return "KP8"; // Key: Keypad 8 - case KeyboardKey.Kp9: return "KP9"; // Key: Keypad 9 - case KeyboardKey.KpDecimal: return "KPDEC"; // Key: Keypad . - case KeyboardKey.KpDivide: return "KPDIV"; // Key: Keypad / - case KeyboardKey.KpMultiply: return "KPMUL"; // Key: Keypad * - case KeyboardKey.KpSubtract: return "KPSUB"; // Key: Keypad - - case KeyboardKey.KpAdd: return "KPADD"; // Key: Keypad + - case KeyboardKey.KpEnter: return "KPENTER"; // Key: Keypad Enter - case KeyboardKey.KpEqual: return "KPEQU"; // Key: Keypad = - default: return ""; + case KeyboardKey.Apostrophe: + return "'"; // Key: ' + case KeyboardKey.Comma: + return ","; // Key: , + case KeyboardKey.Minus: + return "-"; // Key: - + case KeyboardKey.Period: + return "."; // Key: . + case KeyboardKey.Slash: + return "/"; // Key: / + case KeyboardKey.Zero: + return "0"; // Key: 0 + case KeyboardKey.One: + return "1"; // Key: 1 + case KeyboardKey.Two: + return "2"; // Key: 2 + case KeyboardKey.Three: + return "3"; // Key: 3 + case KeyboardKey.Four: + return "4"; // Key: 4 + case KeyboardKey.Five: + return "5"; // Key: 5 + case KeyboardKey.Six: + return "6"; // Key: 6 + case KeyboardKey.Seven: + return "7"; // Key: 7 + case KeyboardKey.Eight: + return "8"; // Key: 8 + case KeyboardKey.Nine: + return "9"; // Key: 9 + case KeyboardKey.Semicolon: + return ";"; // Key: ; + case KeyboardKey.Equal: + return "="; // Key: = + case KeyboardKey.A: + return "A"; // Key: A | a + case KeyboardKey.B: + return "B"; // Key: B | b + case KeyboardKey.C: + return "C"; // Key: C | c + case KeyboardKey.D: + return "D"; // Key: D | d + case KeyboardKey.E: + return "E"; // Key: E | e + case KeyboardKey.F: + return "F"; // Key: F | f + case KeyboardKey.G: + return "G"; // Key: G | g + case KeyboardKey.H: + return "H"; // Key: H | h + case KeyboardKey.I: + return "I"; // Key: I | i + case KeyboardKey.J: + return "J"; // Key: J | j + case KeyboardKey.K: + return "K"; // Key: K | k + case KeyboardKey.L: + return "L"; // Key: L | l + case KeyboardKey.M: + return "M"; // Key: M | m + case KeyboardKey.N: + return "N"; // Key: N | n + case KeyboardKey.O: + return "O"; // Key: O | o + case KeyboardKey.P: + return "P"; // Key: P | p + case KeyboardKey.Q: + return "Q"; // Key: Q | q + case KeyboardKey.R: + return "R"; // Key: R | r + case KeyboardKey.S: + return "S"; // Key: S | s + case KeyboardKey.T: + return "T"; // Key: T | t + case KeyboardKey.U: + return "U"; // Key: U | u + case KeyboardKey.V: + return "V"; // Key: V | v + case KeyboardKey.W: + return "W"; // Key: W | w + case KeyboardKey.X: + return "X"; // Key: X | x + case KeyboardKey.Y: + return "Y"; // Key: Y | y + case KeyboardKey.Z: + return "Z"; // Key: Z | z + case KeyboardKey.LeftBracket: + return "["; // Key: [ + case KeyboardKey.Backslash: + return "\\"; // Key: '\' + case KeyboardKey.RightBracket: + return "]"; // Key: ] + case KeyboardKey.Grave: + return "`"; // Key: ` + case KeyboardKey.Space: + return "SPACE"; // Key: Space + case KeyboardKey.Escape: + return "ESC"; // Key: Esc + case KeyboardKey.Enter: + return "ENTER"; // Key: Enter + case KeyboardKey.Tab: + return "TAB"; // Key: Tab + case KeyboardKey.Backspace: + return "BACK"; // Key: Backspace + case KeyboardKey.Insert: + return "INS"; // Key: Ins + case KeyboardKey.Delete: + return "DEL"; // Key: Del + case KeyboardKey.Right: + return "RIGHT"; // Key: Cursor right + case KeyboardKey.Left: + return "LEFT"; // Key: Cursor left + case KeyboardKey.Down: + return "DOWN"; // Key: Cursor down + case KeyboardKey.Up: + return "UP"; // Key: Cursor up + case KeyboardKey.PageUp: + return "PGUP"; // Key: Page up + case KeyboardKey.PageDown: + return "PGDOWN"; // Key: Page down + case KeyboardKey.Home: + return "HOME"; // Key: Home + case KeyboardKey.End: + return "END"; // Key: End + case KeyboardKey.CapsLock: + return "CAPS"; // Key: Caps lock + case KeyboardKey.ScrollLock: + return "LOCK"; // Key: Scroll down + case KeyboardKey.NumLock: + return "NUMLOCK"; // Key: Num lock + case KeyboardKey.PrintScreen: + return "PRINTSCR"; // Key: Print screen + case KeyboardKey.Pause: + return "PAUSE"; // Key: Pause + case KeyboardKey.F1: + return "F1"; // Key: F1 + case KeyboardKey.F2: + return "F2"; // Key: F2 + case KeyboardKey.F3: + return "F3"; // Key: F3 + case KeyboardKey.F4: + return "F4"; // Key: F4 + case KeyboardKey.F5: + return "F5"; // Key: F5 + case KeyboardKey.F6: + return "F6"; // Key: F6 + case KeyboardKey.F7: + return "F7"; // Key: F7 + case KeyboardKey.F8: + return "F8"; // Key: F8 + case KeyboardKey.F9: + return "F9"; // Key: F9 + case KeyboardKey.F10: + return "F10"; // Key: F10 + case KeyboardKey.F11: + return "F11"; // Key: F11 + case KeyboardKey.F12: + return "F12"; // Key: F12 + case KeyboardKey.LeftShift: + return "LSHIFT"; // Key: Shift left + case KeyboardKey.LeftControl: + return "LCTRL"; // Key: Control left + case KeyboardKey.LeftAlt: + return "LALT"; // Key: Alt left + case KeyboardKey.LeftSuper: + return "WIN"; // Key: Super left + case KeyboardKey.RightShift: + return "RSHIFT"; // Key: Shift right + case KeyboardKey.RightControl: + return "RCTRL"; // Key: Control right + case KeyboardKey.RightAlt: + return "ALTGR"; // Key: Alt right + case KeyboardKey.RightSuper: + return "RSUPER"; // Key: Super right + case KeyboardKey.KeyboardMenu: + return "KBMENU"; // Key: KB menu + case KeyboardKey.Kp0: + return "KP0"; // Key: Keypad 0 + case KeyboardKey.Kp1: + return "KP1"; // Key: Keypad 1 + case KeyboardKey.Kp2: + return "KP2"; // Key: Keypad 2 + case KeyboardKey.Kp3: + return "KP3"; // Key: Keypad 3 + case KeyboardKey.Kp4: + return "KP4"; // Key: Keypad 4 + case KeyboardKey.Kp5: + return "KP5"; // Key: Keypad 5 + case KeyboardKey.Kp6: + return "KP6"; // Key: Keypad 6 + case KeyboardKey.Kp7: + return "KP7"; // Key: Keypad 7 + case KeyboardKey.Kp8: + return "KP8"; // Key: Keypad 8 + case KeyboardKey.Kp9: + return "KP9"; // Key: Keypad 9 + case KeyboardKey.KpDecimal: + return "KPDEC"; // Key: Keypad . + case KeyboardKey.KpDivide: + return "KPDIV"; // Key: Keypad / + case KeyboardKey.KpMultiply: + return "KPMUL"; // Key: Keypad * + case KeyboardKey.KpSubtract: + return "KPSUB"; // Key: Keypad - + case KeyboardKey.KpAdd: + return "KPADD"; // Key: Keypad + + case KeyboardKey.KpEnter: + return "KPENTER"; // Key: Keypad Enter + case KeyboardKey.KpEqual: + return "KPEQU"; // Key: Keypad = + default: + return ""; } } diff --git a/Examples/Core/ViewportScaling.cs b/Examples/Core/ViewportScaling.cs index 615b832..46f2cbf 100644 --- a/Examples/Core/ViewportScaling.cs +++ b/Examples/Core/ViewportScaling.cs @@ -314,13 +314,26 @@ public partial class ViewportScaling : IExample switch (viewportType) { - case ViewportType.KeepAspectInteger: KeepAspectCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; - case ViewportType.KeepHeightInteger: KeepHeightCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; - case ViewportType.KeepWidthInteger: KeepWidthCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; - case ViewportType.KeepAspect: KeepAspectCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; - case ViewportType.KeepHeight: KeepHeightCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; - case ViewportType.KeepWidth: KeepWidthCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; - default: break; + case ViewportType.KeepAspectInteger: + KeepAspectCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); + break; + case ViewportType.KeepHeightInteger: + KeepHeightCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); + break; + case ViewportType.KeepWidthInteger: + KeepWidthCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); + break; + case ViewportType.KeepAspect: + KeepAspectCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); + break; + case ViewportType.KeepHeight: + KeepHeightCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); + break; + case ViewportType.KeepWidth: + KeepWidthCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); + break; + default: + break; } UnloadRenderTexture(target); diff --git a/Examples/ExcludeFromBrowserAttribute.cs b/Examples/ExcludeFromBrowserAttribute.cs index e2224c7..9034669 100644 --- a/Examples/ExcludeFromBrowserAttribute.cs +++ b/Examples/ExcludeFromBrowserAttribute.cs @@ -8,7 +8,10 @@ namespace Examples; public sealed class ExcludeFromBrowserAttribute : Attribute { /// Why the example cannot run in the browser. - public string Reason { get; } + public string Reason + { + get; + } public ExcludeFromBrowserAttribute(string reason = null) { diff --git a/Examples/IExample.cs b/Examples/IExample.cs index f2100d9..e589691 100644 --- a/Examples/IExample.cs +++ b/Examples/IExample.cs @@ -14,10 +14,16 @@ namespace Examples; public interface IExample { /// Display name shown in the navigation dropdown. - string Name { get; } + string Name + { + get; + } /// Window title, matching the example's standalone Main(). - string Title { get; } + string Title + { + get; + } /// Desktop window size, matching the standalone Main(). The browser canvas is fixed at 800x450. int Width => 800; diff --git a/Examples/Models/Decals.cs b/Examples/Models/Decals.cs index 461f5ac..d72ef89 100644 --- a/Examples/Models/Decals.cs +++ b/Examples/Models/Decals.cs @@ -423,8 +423,12 @@ public partial class Decals : IExample nV3 = ClipSegment(inMesh[i + 1], nV1, planes[face], s); nV4 = ClipSegment(inMesh[i + 1], nV2, planes[face], s); - outMesh.Add(nV3); outMesh.Add(nV2); outMesh.Add(nV1); - outMesh.Add(nV2); outMesh.Add(nV3); outMesh.Add(nV4); + outMesh.Add(nV3); + outMesh.Add(nV2); + outMesh.Add(nV1); + outMesh.Add(nV2); + outMesh.Add(nV3); + outMesh.Add(nV4); } else { @@ -443,8 +447,12 @@ public partial class Decals : IExample nV4 = ClipSegment(inMesh[i + 2], nV2, planes[face], s); } - outMesh.Add(nV1); outMesh.Add(nV2); outMesh.Add(nV3); - outMesh.Add(nV4); outMesh.Add(nV3); outMesh.Add(nV2); + outMesh.Add(nV1); + outMesh.Add(nV2); + outMesh.Add(nV3); + outMesh.Add(nV4); + outMesh.Add(nV3); + outMesh.Add(nV2); } break; case 2: @@ -454,7 +462,9 @@ public partial class Decals : IExample nV1 = inMesh[i]; nV2 = ClipSegment(nV1, inMesh[i + 1], planes[face], s); nV3 = ClipSegment(nV1, inMesh[i + 2], planes[face], s); - outMesh.Add(nV1); outMesh.Add(nV2); outMesh.Add(nV3); + outMesh.Add(nV1); + outMesh.Add(nV2); + outMesh.Add(nV3); } if (!v2Out) @@ -462,7 +472,9 @@ public partial class Decals : IExample nV1 = inMesh[i + 1]; nV2 = ClipSegment(nV1, inMesh[i + 2], planes[face], s); nV3 = ClipSegment(nV1, inMesh[i], planes[face], s); - outMesh.Add(nV1); outMesh.Add(nV2); outMesh.Add(nV3); + outMesh.Add(nV1); + outMesh.Add(nV2); + outMesh.Add(nV3); } if (!v3Out) @@ -470,7 +482,9 @@ public partial class Decals : IExample nV1 = inMesh[i + 2]; nV2 = ClipSegment(nV1, inMesh[i], planes[face], s); nV3 = ClipSegment(nV1, inMesh[i + 1], planes[face], s); - outMesh.Add(nV1); outMesh.Add(nV2); outMesh.Add(nV3); + outMesh.Add(nV1); + outMesh.Add(nV2); + outMesh.Add(nV3); } break; default: // The entire face lies outside of the plane, so let's discard the corresponding vertices diff --git a/Examples/Shaders/DeferredRendering.cs b/Examples/Shaders/DeferredRendering.cs index 93ff23f..1602df1 100644 --- a/Examples/Shaders/DeferredRendering.cs +++ b/Examples/Shaders/DeferredRendering.cs @@ -209,10 +209,22 @@ public partial class DeferredRendering : IExample ); // Check key inputs to enable/disable lights - if (IsKeyPressed(KeyboardKey.Y)) { lights[0].Enabled = !lights[0].Enabled; } - if (IsKeyPressed(KeyboardKey.R)) { lights[1].Enabled = !lights[1].Enabled; } - if (IsKeyPressed(KeyboardKey.G)) { lights[2].Enabled = !lights[2].Enabled; } - if (IsKeyPressed(KeyboardKey.B)) { lights[3].Enabled = !lights[3].Enabled; } + if (IsKeyPressed(KeyboardKey.Y)) + { + lights[0].Enabled = !lights[0].Enabled; + } + if (IsKeyPressed(KeyboardKey.R)) + { + lights[1].Enabled = !lights[1].Enabled; + } + if (IsKeyPressed(KeyboardKey.G)) + { + lights[2].Enabled = !lights[2].Enabled; + } + if (IsKeyPressed(KeyboardKey.B)) + { + lights[3].Enabled = !lights[3].Enabled; + } // Check key inputs to switch between G-buffer textures if (IsKeyPressed(KeyboardKey.One)) @@ -277,40 +289,40 @@ public partial class DeferredRendering : IExample switch (mode) { case DeferredMode.Shading: - { - BeginMode3D(camera); - Rlgl.DisableColorBlend(); - Rlgl.EnableShader(deferredShader.Id); - // Bind our g-buffer textures - // We are binding them to locations that we earlier set in sampler2D uniforms `gPosition`, `gNormal`, - // and `gAlbedoSpec` - Rlgl.ActiveTextureSlot(TexUnitPosition); - Rlgl.EnableTexture(gBuffer.PositionTextureId); - Rlgl.ActiveTextureSlot(TexUnitNormal); - Rlgl.EnableTexture(gBuffer.NormalTextureId); - Rlgl.ActiveTextureSlot(TexUnitAlbedoSpec); - Rlgl.EnableTexture(gBuffer.AlbedoSpecTextureId); - - // Finally, we draw a fullscreen quad to our default framebufferId - // This will now be shaded using our deferred shader - Rlgl.LoadDrawQuad(); - Rlgl.DisableShader(); - Rlgl.EnableColorBlend(); - EndMode3D(); - - // As a last step, we now copy over the depth buffer from our g-buffer to the default framebufferId - Rlgl.BindFramebuffer(RlReadFramebuffer, gBuffer.FramebufferId); - Rlgl.BindFramebuffer(RlDrawFramebuffer, 0); - Rlgl.BlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, GlDepthBufferBit); - Rlgl.DisableFramebuffer(); - - // Since our shader is now done and disabled, we can draw spheres - // that represent light positions in default forward rendering - BeginMode3D(camera); - Rlgl.EnableShader(Rlgl.GetShaderIdDefault()); - for (var i = 0; i < MaxLights; i++) { - if (lights[i].Enabled) + BeginMode3D(camera); + Rlgl.DisableColorBlend(); + Rlgl.EnableShader(deferredShader.Id); + // Bind our g-buffer textures + // We are binding them to locations that we earlier set in sampler2D uniforms `gPosition`, `gNormal`, + // and `gAlbedoSpec` + Rlgl.ActiveTextureSlot(TexUnitPosition); + Rlgl.EnableTexture(gBuffer.PositionTextureId); + Rlgl.ActiveTextureSlot(TexUnitNormal); + Rlgl.EnableTexture(gBuffer.NormalTextureId); + Rlgl.ActiveTextureSlot(TexUnitAlbedoSpec); + Rlgl.EnableTexture(gBuffer.AlbedoSpecTextureId); + + // Finally, we draw a fullscreen quad to our default framebufferId + // This will now be shaded using our deferred shader + Rlgl.LoadDrawQuad(); + Rlgl.DisableShader(); + Rlgl.EnableColorBlend(); + EndMode3D(); + + // As a last step, we now copy over the depth buffer from our g-buffer to the default framebufferId + Rlgl.BindFramebuffer(RlReadFramebuffer, gBuffer.FramebufferId); + Rlgl.BindFramebuffer(RlDrawFramebuffer, 0); + Rlgl.BlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, GlDepthBufferBit); + Rlgl.DisableFramebuffer(); + + // Since our shader is now done and disabled, we can draw spheres + // that represent light positions in default forward rendering + BeginMode3D(camera); + Rlgl.EnableShader(Rlgl.GetShaderIdDefault()); + for (var i = 0; i < MaxLights; i++) + { + if (lights[i].Enabled) { DrawSphereEx(lights[i].Position, 0.2f, 8, 8, lights[i].Color); } @@ -319,49 +331,50 @@ public partial class DeferredRendering : IExample DrawSphereWires(lights[i].Position, 0.2f, 8, 8, ColorAlpha(lights[i].Color, 0.3f)); } } - Rlgl.DisableShader(); - EndMode3D(); + Rlgl.DisableShader(); + EndMode3D(); - DrawText("FINAL RESULT", 10, screenHeight - 30, 20, Color.DarkGreen); - } - break; + DrawText("FINAL RESULT", 10, screenHeight - 30, 20, Color.DarkGreen); + } + break; case DeferredMode.Position: - { - DrawTextureRec( - new Texture2D { Id = gBuffer.PositionTextureId, Width = screenWidth, Height = screenHeight }, - new Rectangle(0, 0, screenWidth, -screenHeight), - Vector2.Zero, - Color.RayWhite - ); + { + DrawTextureRec( + new Texture2D { Id = gBuffer.PositionTextureId, Width = screenWidth, Height = screenHeight }, + new Rectangle(0, 0, screenWidth, -screenHeight), + Vector2.Zero, + Color.RayWhite + ); - DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); - } - break; + DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); + } + break; case DeferredMode.Normal: - { - DrawTextureRec( - new Texture2D { Id = gBuffer.NormalTextureId, Width = screenWidth, Height = screenHeight }, - new Rectangle(0, 0, screenWidth, -screenHeight), - Vector2.Zero, - Color.RayWhite - ); + { + DrawTextureRec( + new Texture2D { Id = gBuffer.NormalTextureId, Width = screenWidth, Height = screenHeight }, + new Rectangle(0, 0, screenWidth, -screenHeight), + Vector2.Zero, + Color.RayWhite + ); - DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); - } - break; + DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); + } + break; case DeferredMode.Albedo: - { - DrawTextureRec( - new Texture2D { Id = gBuffer.AlbedoSpecTextureId, Width = screenWidth, Height = screenHeight }, - new Rectangle(0, 0, screenWidth, -screenHeight), - Vector2.Zero, - Color.RayWhite - ); + { + DrawTextureRec( + new Texture2D { Id = gBuffer.AlbedoSpecTextureId, Width = screenWidth, Height = screenHeight }, + new Rectangle(0, 0, screenWidth, -screenHeight), + Vector2.Zero, + Color.RayWhite + ); - DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); - } - break; - default: break; + DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); + } + break; + default: + break; } DrawText("Toggle lights keys: [Y][R][G][B]", 10, 40, 20, Color.DarkGray); diff --git a/Examples/Shaders/LightmapRendering.cs b/Examples/Shaders/LightmapRendering.cs index 32bb7cf..c4774d7 100644 --- a/Examples/Shaders/LightmapRendering.cs +++ b/Examples/Shaders/LightmapRendering.cs @@ -67,10 +67,14 @@ public partial class LightmapRendering : IExample mesh.AllocTexCoords2(); // X // Y - mesh.TexCoords2[0] = 0.0f; mesh.TexCoords2[1] = 0.0f; - mesh.TexCoords2[2] = 1.0f; mesh.TexCoords2[3] = 0.0f; - mesh.TexCoords2[4] = 0.0f; mesh.TexCoords2[5] = 1.0f; - mesh.TexCoords2[6] = 1.0f; mesh.TexCoords2[7] = 1.0f; + mesh.TexCoords2[0] = 0.0f; + mesh.TexCoords2[1] = 0.0f; + mesh.TexCoords2[2] = 1.0f; + mesh.TexCoords2[3] = 0.0f; + mesh.TexCoords2[4] = 0.0f; + mesh.TexCoords2[5] = 1.0f; + mesh.TexCoords2[6] = 1.0f; + mesh.TexCoords2[7] = 1.0f; // Load a new texcoords2 attributes buffer mesh.VboId[(int)ShaderLocationIndex.VertexTexcoord02] = diff --git a/Examples/Shapes/BallPhysics.cs b/Examples/Shapes/BallPhysics.cs index cfbe66e..4b66f97 100644 --- a/Examples/Shapes/BallPhysics.cs +++ b/Examples/Shapes/BallPhysics.cs @@ -62,7 +62,7 @@ public partial class BallPhysics : IExample // Init first ball in the array balls[0] = new Ball { - position = new Vector2(GetScreenWidth()/2.0f, GetScreenHeight()/2.0f), + position = new Vector2(GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f), speed = new Vector2(200, 200), prevPosition = new Vector2(0, 0), radius = 40, @@ -98,7 +98,7 @@ public partial class BallPhysics : IExample // If the distance between the ball position and the mouse press position // is less than or equal to the ball radius, the event occurred inside the ball - if (MathF.Sqrt(pressOffset.X*pressOffset.X + pressOffset.Y*pressOffset.Y) <= balls[i].radius) + if (MathF.Sqrt(pressOffset.X * pressOffset.X + pressOffset.Y * pressOffset.Y) <= balls[i].radius) { balls[i].grabbed = true; grabbedBallIndex = i; @@ -163,7 +163,7 @@ public partial class BallPhysics : IExample } // Changes gravity - gravity += GetMouseWheelMove()*5; + gravity += GetMouseWheelMove() * 5; // Updates each ball state for (int i = 0; i < ballCount; i++) @@ -179,31 +179,31 @@ public partial class BallPhysics : IExample if ((balls[i].position.X + balls[i].radius) >= screenWidth) { balls[i].position.X = screenWidth - balls[i].radius; // Ball repositioning - balls[i].speed.X = -balls[i].speed.X*balls[i].elasticity; // Elasticity makes the ball lose 10% of its velocity on hit + balls[i].speed.X = -balls[i].speed.X * balls[i].elasticity; // Elasticity makes the ball lose 10% of its velocity on hit } // Does the ball hit the screen left boundary? else if ((balls[i].position.X - balls[i].radius) <= 0) { balls[i].position.X = balls[i].radius; - balls[i].speed.X = -balls[i].speed.X*balls[i].elasticity; + balls[i].speed.X = -balls[i].speed.X * balls[i].elasticity; } // The same for y axis if ((balls[i].position.Y + balls[i].radius) >= screenHeight) { balls[i].position.Y = screenHeight - balls[i].radius; - balls[i].speed.Y = -balls[i].speed.Y*balls[i].elasticity; + balls[i].speed.Y = -balls[i].speed.Y * balls[i].elasticity; } else if ((balls[i].position.Y - balls[i].radius) <= 0) { balls[i].position.Y = balls[i].radius; - balls[i].speed.Y = -balls[i].speed.Y*balls[i].elasticity; + balls[i].speed.Y = -balls[i].speed.Y * balls[i].elasticity; } // Friction makes the ball lose 1% of its velocity each frame - balls[i].speed.X = balls[i].speed.X*balls[i].friction; + balls[i].speed.X = balls[i].speed.X * balls[i].friction; // Gravity affects only the y axis - balls[i].speed.Y = balls[i].speed.Y*balls[i].friction + gravity; + balls[i].speed.Y = balls[i].speed.Y * balls[i].friction + gravity; } else { @@ -212,8 +212,8 @@ public partial class BallPhysics : IExample balls[i].position.Y = mousePos.Y - pressOffset.Y; // While the ball is grabbed, recalculates its velocity - balls[i].speed.X = (balls[i].position.X - balls[i].prevPosition.X)/delta; - balls[i].speed.Y = (balls[i].position.Y - balls[i].prevPosition.Y)/delta; + balls[i].speed.X = (balls[i].position.X - balls[i].prevPosition.X) / delta; + balls[i].speed.Y = (balls[i].position.Y - balls[i].prevPosition.Y) / delta; balls[i].prevPosition = balls[i].position; } } @@ -225,20 +225,20 @@ public partial class BallPhysics : IExample //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(Color.RayWhite); + ClearBackground(Color.RayWhite); - for (int i = 0; i < ballCount; i++) - { - DrawCircleV(balls[i].position, balls[i].radius, balls[i].color); - DrawCircleLinesV(balls[i].position, balls[i].radius, Color.Black); - } + for (int i = 0; i < ballCount; i++) + { + DrawCircleV(balls[i].position, balls[i].radius, balls[i].color); + DrawCircleLinesV(balls[i].position, balls[i].radius, Color.Black); + } - DrawText("grab a ball by pressing with the mouse and throw it by releasing", 10, 10, 10, Color.DarkGray); - DrawText("right click to create new balls (keep left control pressed to create a lot)", 10, 30, 10, Color.DarkGray); - DrawText("use mouse wheel to change gravity", 10, 50, 10, Color.DarkGray); - DrawText("middle click to shake", 10, 70, 10, Color.DarkGray); - DrawText($"BALL COUNT: {ballCount}", 10, GetScreenHeight() - 70, 20, Color.Black); - DrawText($"GRAVITY: {gravity:F2}", 10, GetScreenHeight() - 40, 20, Color.Black); + DrawText("grab a ball by pressing with the mouse and throw it by releasing", 10, 10, 10, Color.DarkGray); + DrawText("right click to create new balls (keep left control pressed to create a lot)", 10, 30, 10, Color.DarkGray); + DrawText("use mouse wheel to change gravity", 10, 50, 10, Color.DarkGray); + DrawText("middle click to shake", 10, 70, 10, Color.DarkGray); + DrawText($"BALL COUNT: {ballCount}", 10, GetScreenHeight() - 70, 20, Color.Black); + DrawText($"GRAVITY: {gravity:F2}", 10, GetScreenHeight() - 40, 20, Color.Black); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/Examples/Shapes/BulletHell.cs b/Examples/Shapes/BulletHell.cs index 09660f9..01931aa 100644 --- a/Examples/Shapes/BulletHell.cs +++ b/Examples/Shapes/BulletHell.cs @@ -88,8 +88,8 @@ public partial class BulletHell : IExample // Draw circle to bullet texture, then draw bullet using DrawTexture() // NOTE: This is done to improve the performance, since DrawCircle() is very slow BeginTextureMode(bulletTexture); - DrawCircle(12, 12, (float)bulletRadius, Color.White); - DrawCircleLines(12, 12, (float)bulletRadius, Color.Black); + DrawCircle(12, 12, (float)bulletRadius, Color.White); + DrawCircleLines(12, 12, (float)bulletRadius, Color.Black); EndTextureMode(); drawInPerformanceMode = true; @@ -113,16 +113,16 @@ public partial class BulletHell : IExample spawnCooldownTimer = spawnCooldown; // Spawn bullets - float degreesPerRow = 360.0f/bulletRows; + float degreesPerRow = 360.0f / bulletRows; for (int row = 0; row < bulletRows; row++) { if (bulletCount < MAX_BULLETS) { - bullets[bulletCount].position = new Vector2((float)screenWidth/2, (float)screenHeight/2); + bullets[bulletCount].position = new Vector2((float)screenWidth / 2, (float)screenHeight / 2); bullets[bulletCount].disabled = false; - bullets[bulletCount].color = bulletColor[row%2]; + bullets[bulletCount].color = bulletColor[row % 2]; - float bulletDirection = baseDirection + (degreesPerRow*row); + float bulletDirection = baseDirection + (degreesPerRow * row); // Bullet speed*bullet direction, this will determine how much pixels will be incremented/decremented // from the bullet position every frame. Since the bullets doesn't change its direction and speed, @@ -130,8 +130,8 @@ public partial class BulletHell : IExample // 0 degrees = right, 90 degrees = down, 180 degrees = left and 270 degrees = up, basically clockwise // Case you want it to be anti-clockwise, add "* -1" at the y acceleration bullets[bulletCount].acceleration = new Vector2( - bulletSpeed*MathF.Cos(bulletDirection*DEG2RAD), - bulletSpeed*MathF.Sin(bulletDirection*DEG2RAD) + bulletSpeed * MathF.Cos(bulletDirection * DEG2RAD), + bulletSpeed * MathF.Sin(bulletDirection * DEG2RAD) ); bulletCount++; @@ -151,10 +151,10 @@ public partial class BulletHell : IExample bullets[i].position.Y += bullets[i].acceleration.Y; // Disable bullet if out of screen - if ((bullets[i].position.X < -bulletRadius*2) || - (bullets[i].position.X > screenWidth + bulletRadius*2) || - (bullets[i].position.Y < -bulletRadius*2) || - (bullets[i].position.Y > screenHeight + bulletRadius*2)) + if ((bullets[i].position.X < -bulletRadius * 2) || + (bullets[i].position.X > screenWidth + bulletRadius * 2) || + (bullets[i].position.Y < -bulletRadius * 2) || + (bullets[i].position.Y > screenHeight + bulletRadius * 2)) { bullets[i].disabled = true; bulletDisabledCount++; @@ -214,60 +214,60 @@ public partial class BulletHell : IExample // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(Color.RayWhite); + ClearBackground(Color.RayWhite); - // Draw magic circle - magicCircleRotation++; - DrawRectanglePro(new Rectangle((float)screenWidth/2, (float)screenHeight/2, 120, 120), - new Vector2(60.0f, 60.0f), magicCircleRotation, Color.Purple); - DrawRectanglePro(new Rectangle((float)screenWidth/2, (float)screenHeight/2, 120, 120), - new Vector2(60.0f, 60.0f), magicCircleRotation + 45, Color.Purple); - DrawCircleLines(screenWidth/2, screenHeight/2, 70, Color.Black); - DrawCircleLines(screenWidth/2, screenHeight/2, 50, Color.Black); - DrawCircleLines(screenWidth/2, screenHeight/2, 30, Color.Black); + // Draw magic circle + magicCircleRotation++; + DrawRectanglePro(new Rectangle((float)screenWidth / 2, (float)screenHeight / 2, 120, 120), + new Vector2(60.0f, 60.0f), magicCircleRotation, Color.Purple); + DrawRectanglePro(new Rectangle((float)screenWidth / 2, (float)screenHeight / 2, 120, 120), + new Vector2(60.0f, 60.0f), magicCircleRotation + 45, Color.Purple); + DrawCircleLines(screenWidth / 2, screenHeight / 2, 70, Color.Black); + DrawCircleLines(screenWidth / 2, screenHeight / 2, 50, Color.Black); + DrawCircleLines(screenWidth / 2, screenHeight / 2, 30, Color.Black); - // Draw bullets - if (drawInPerformanceMode) + // Draw bullets + if (drawInPerformanceMode) + { + // Draw bullets using pre-rendered texture containing circle + for (int i = 0; i < bulletCount; i++) { - // Draw bullets using pre-rendered texture containing circle - for (int i = 0; i < bulletCount; i++) + // Do not draw disabled bullets (out of screen) + if (!bullets[i].disabled) { - // Do not draw disabled bullets (out of screen) - if (!bullets[i].disabled) - { - DrawTexture(bulletTexture.Texture, - (int)(bullets[i].position.X - bulletTexture.Texture.Width*0.5f), - (int)(bullets[i].position.Y - bulletTexture.Texture.Height*0.5f), - bullets[i].color); - } + DrawTexture(bulletTexture.Texture, + (int)(bullets[i].position.X - bulletTexture.Texture.Width * 0.5f), + (int)(bullets[i].position.Y - bulletTexture.Texture.Height * 0.5f), + bullets[i].color); } } - else + } + else + { + // Draw bullets using DrawCircle(), less performant + for (int i = 0; i < bulletCount; i++) { - // Draw bullets using DrawCircle(), less performant - for (int i = 0; i < bulletCount; i++) + // Do not draw disabled bullets (out of screen) + if (!bullets[i].disabled) { - // Do not draw disabled bullets (out of screen) - if (!bullets[i].disabled) - { - DrawCircleV(bullets[i].position, (float)bulletRadius, bullets[i].color); - DrawCircleLinesV(bullets[i].position, (float)bulletRadius, Color.Black); - } + DrawCircleV(bullets[i].position, (float)bulletRadius, bullets[i].color); + DrawCircleLinesV(bullets[i].position, (float)bulletRadius, Color.Black); } } + } - // Draw UI - DrawRectangle(10, 10, 280, 150, new Color(0, 0, 0, 200)); - DrawText("Controls:", 20, 20, 10, Color.LightGray); - DrawText("- Right/Left or A/D: Change rows number", 40, 40, 10, Color.LightGray); - DrawText("- Up/Down or W/S: Change bullet speed", 40, 60, 10, Color.LightGray); - DrawText("- Z or X: Change spawn cooldown", 40, 80, 10, Color.LightGray); - DrawText("- Space (Hold): Change the angle increment", 40, 100, 10, Color.LightGray); - DrawText("- Enter: Switch draw method (Performance)", 40, 120, 10, Color.LightGray); - DrawText("- C: Clear bullets", 40, 140, 10, Color.LightGray); + // Draw UI + DrawRectangle(10, 10, 280, 150, new Color(0, 0, 0, 200)); + DrawText("Controls:", 20, 20, 10, Color.LightGray); + DrawText("- Right/Left or A/D: Change rows number", 40, 40, 10, Color.LightGray); + DrawText("- Up/Down or W/S: Change bullet speed", 40, 60, 10, Color.LightGray); + DrawText("- Z or X: Change spawn cooldown", 40, 80, 10, Color.LightGray); + DrawText("- Space (Hold): Change the angle increment", 40, 100, 10, Color.LightGray); + DrawText("- Enter: Switch draw method (Performance)", 40, 120, 10, Color.LightGray); + DrawText("- C: Clear bullets", 40, 140, 10, Color.LightGray); - DrawRectangle(610, 10, 170, 30, new Color(0, 0, 0, 200)); - if (drawInPerformanceMode) + DrawRectangle(610, 10, 170, 30, new Color(0, 0, 0, 200)); + if (drawInPerformanceMode) { DrawText("Draw method: DrawTexture(*)", 620, 20, 10, Color.Green); } @@ -277,8 +277,8 @@ public partial class BulletHell : IExample } DrawRectangle(135, 410, 530, 30, new Color(0, 0, 0, 200)); - DrawText($"[ FPS: {GetFPS()}, Bullets: {bulletCount - bulletDisabledCount}, Rows: {bulletRows}, Bullet speed: {bulletSpeed:F2}, Angle increment per frame: {angleIncrement}, Cooldown: {spawnCooldown:F0} ]", - 155, 420, 10, Color.Green); + DrawText($"[ FPS: {GetFPS()}, Bullets: {bulletCount - bulletDisabledCount}, Rows: {bulletRows}, Bullet speed: {bulletSpeed:F2}, Angle increment per frame: {angleIncrement}, Cooldown: {spawnCooldown:F0} ]", + 155, 420, 10, Color.Green); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/Examples/Shapes/DashedLine.cs b/Examples/Shapes/DashedLine.cs index 30eb773..fc3e804 100644 --- a/Examples/Shapes/DashedLine.cs +++ b/Examples/Shapes/DashedLine.cs @@ -80,7 +80,7 @@ public partial class DashedLine : IExample // Cycle through colors ('C' key) if (IsKeyPressed(KeyboardKey.C)) { - colorIndex = (colorIndex + 1)%lineColors.Length; + colorIndex = (colorIndex + 1) % lineColors.Length; } //---------------------------------------------------------------------------------- @@ -88,23 +88,23 @@ public partial class DashedLine : IExample //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(Color.RayWhite); + ClearBackground(Color.RayWhite); - // Draw the dashed line with the current properties - DrawLineDashed(lineStartPosition, lineEndPosition, (int)dashLength, (int)blankLength, lineColors[colorIndex]); + // Draw the dashed line with the current properties + DrawLineDashed(lineStartPosition, lineEndPosition, (int)dashLength, (int)blankLength, lineColors[colorIndex]); - // Draw UI and Instructions - DrawRectangle(5, 5, 265, 95, Fade(Color.SkyBlue, 0.5f)); - DrawRectangleLines(5, 5, 265, 95, Color.Blue); + // Draw UI and Instructions + DrawRectangle(5, 5, 265, 95, Fade(Color.SkyBlue, 0.5f)); + DrawRectangleLines(5, 5, 265, 95, Color.Blue); - DrawText("CONTROLS:", 15, 15, 10, Color.Black); - DrawText("UP/DOWN: Change Dash Length", 15, 35, 10, Color.Black); - DrawText("LEFT/RIGHT: Change Space Length", 15, 55, 10, Color.Black); - DrawText("C: Cycle Color", 15, 75, 10, Color.Black); + DrawText("CONTROLS:", 15, 15, 10, Color.Black); + DrawText("UP/DOWN: Change Dash Length", 15, 35, 10, Color.Black); + DrawText("LEFT/RIGHT: Change Space Length", 15, 55, 10, Color.Black); + DrawText("C: Cycle Color", 15, 75, 10, Color.Black); - DrawText($"Dash: {dashLength:F0} | Space: {blankLength:F0}", 15, 115, 10, Color.DarkGray); + DrawText($"Dash: {dashLength:F0} | Space: {blankLength:F0}", 15, 115, 10, Color.DarkGray); - DrawFPS(screenWidth - 80, 10); + DrawFPS(screenWidth - 80, 10); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/Examples/Shapes/DigitalClock.cs b/Examples/Shapes/DigitalClock.cs index b213f03..28e0a74 100644 --- a/Examples/Shapes/DigitalClock.cs +++ b/Examples/Shapes/DigitalClock.cs @@ -213,17 +213,38 @@ public partial class DigitalClock : IExample { switch (value) { - case 0: Draw7SDisplay(position, 0b00111111, colorOn, colorOff); break; - case 1: Draw7SDisplay(position, 0b00000110, colorOn, colorOff); break; - case 2: Draw7SDisplay(position, 0b01011011, colorOn, colorOff); break; - case 3: Draw7SDisplay(position, 0b01001111, colorOn, colorOff); break; - case 4: Draw7SDisplay(position, 0b01100110, colorOn, colorOff); break; - case 5: Draw7SDisplay(position, 0b01101101, colorOn, colorOff); break; - case 6: Draw7SDisplay(position, 0b01111101, colorOn, colorOff); break; - case 7: Draw7SDisplay(position, 0b00000111, colorOn, colorOff); break; - case 8: Draw7SDisplay(position, 0b01111111, colorOn, colorOff); break; - case 9: Draw7SDisplay(position, 0b01101111, colorOn, colorOff); break; - default: break; + case 0: + Draw7SDisplay(position, 0b00111111, colorOn, colorOff); + break; + case 1: + Draw7SDisplay(position, 0b00000110, colorOn, colorOff); + break; + case 2: + Draw7SDisplay(position, 0b01011011, colorOn, colorOff); + break; + case 3: + Draw7SDisplay(position, 0b01001111, colorOn, colorOff); + break; + case 4: + Draw7SDisplay(position, 0b01100110, colorOn, colorOff); + break; + case 5: + Draw7SDisplay(position, 0b01101101, colorOn, colorOff); + break; + case 6: + Draw7SDisplay(position, 0b01111101, colorOn, colorOff); + break; + case 7: + Draw7SDisplay(position, 0b00000111, colorOn, colorOff); + break; + case 8: + Draw7SDisplay(position, 0b01111111, colorOn, colorOff); + break; + case 9: + Draw7SDisplay(position, 0b01101111, colorOn, colorOff); + break; + default: + break; } } diff --git a/Examples/Shapes/DoublePendulum.cs b/Examples/Shapes/DoublePendulum.cs index 7013781..200dae5 100644 --- a/Examples/Shapes/DoublePendulum.cs +++ b/Examples/Shapes/DoublePendulum.cs @@ -68,8 +68,14 @@ public partial class DoublePendulum : IExample public void Init() { // Simulation Parameters - l1 = 15.0f; m1 = 0.2f; theta1 = DEG2RAD * 170; w1 = 0; - l2 = 15.0f; m2 = 0.1f; theta2 = DEG2RAD * 0; w2 = 0; + l1 = 15.0f; + m1 = 0.2f; + theta1 = DEG2RAD * 170; + w1 = 0; + l2 = 15.0f; + m2 = 0.1f; + theta2 = DEG2RAD * 0; + w2 = 0; lengthScaler = 0.1f; totalM = m1 + m2; @@ -82,7 +88,8 @@ public partial class DoublePendulum : IExample L2 = l2 * lengthScaler; // Draw parameters - lineThick = 20; trailThick = 2; + lineThick = 20; + trailThick = 2; fateAlpha = 0.01f; // Create framebuffer diff --git a/Examples/Shapes/HilbertCurve.cs b/Examples/Shapes/HilbertCurve.cs index 3e1f31c..9fc8cee 100644 --- a/Examples/Shapes/HilbertCurve.cs +++ b/Examples/Shapes/HilbertCurve.cs @@ -162,24 +162,30 @@ public partial class HilbertCurve : IExample switch (hilbertIndex) { case 0: - { - temp = vect.X; - vect.X = vect.Y; - vect.Y = temp; - } break; + { + temp = vect.X; + vect.X = vect.Y; + vect.Y = temp; + } + break; case 2: - { - vect.X += len; + { + vect.X += len; + vect.Y += len; + } + break; + case 1: vect.Y += len; - } break; - case 1: vect.Y += len; break; + break; case 3: - { - temp = len - 1 - vect.X; - vect.X = 2 * len - 1 - vect.Y; - vect.Y = temp; - } break; - default: break; + { + temp = len - 1 - vect.X; + vect.X = 2 * len - 1 - vect.Y; + vect.Y = temp; + } + break; + default: + break; } } diff --git a/Examples/Shapes/LinesDrawing.cs b/Examples/Shapes/LinesDrawing.cs index c700bcb..df146da 100644 --- a/Examples/Shapes/LinesDrawing.cs +++ b/Examples/Shapes/LinesDrawing.cs @@ -60,7 +60,7 @@ public partial class LinesDrawing : IExample // Clear the canvas to the background color BeginTextureMode(canvas); - ClearBackground(Color.RayWhite); + ClearBackground(Color.RayWhite); EndTextureMode(); } @@ -78,7 +78,7 @@ public partial class LinesDrawing : IExample if (IsMouseButtonPressed(MouseButton.Middle)) { BeginTextureMode(canvas); - ClearBackground(Color.RayWhite); + ClearBackground(Color.RayWhite); EndTextureMode(); } @@ -94,7 +94,7 @@ public partial class LinesDrawing : IExample if (leftButtonDown) { // Increase the hue value by the distance our cursor has moved since the last frame (divided by 3) - lineHue += Vector2Distance(mousePositionPrevious, GetMousePosition())/3.0f; + lineHue += Vector2Distance(mousePositionPrevious, GetMousePosition()) / 3.0f; // While the hue is >=360, subtract it to bring it down into the range 0-360 // This is more visually accurate than resetting to zero @@ -113,10 +113,10 @@ public partial class LinesDrawing : IExample // Draw the line onto the canvas BeginTextureMode(canvas); - // Circles act as "caps", smoothing corners - DrawCircleV(mousePositionPrevious, lineThickness/2.0f, drawColor); - DrawCircleV(GetMousePosition(), lineThickness/2.0f, drawColor); - DrawLineEx(mousePositionPrevious, GetMousePosition(), lineThickness, drawColor); + // Circles act as "caps", smoothing corners + DrawCircleV(mousePositionPrevious, lineThickness / 2.0f, drawColor); + DrawCircleV(GetMousePosition(), lineThickness / 2.0f, drawColor); + DrawLineEx(mousePositionPrevious, GetMousePosition(), lineThickness, drawColor); EndTextureMode(); } @@ -132,13 +132,13 @@ public partial class LinesDrawing : IExample //---------------------------------------------------------------------------------- BeginDrawing(); - // Draw the render texture to the screen, flipped vertically to make it appear top-side up - DrawTextureRec(canvas.Texture, new Rectangle(0.0f, 0.0f, (float)canvas.Texture.Width, (float)-canvas.Texture.Height), Vector2Zero(), Color.White); + // Draw the render texture to the screen, flipped vertically to make it appear top-side up + DrawTextureRec(canvas.Texture, new Rectangle(0.0f, 0.0f, (float)canvas.Texture.Width, (float)-canvas.Texture.Height), Vector2Zero(), Color.White); - // Draw the preview circle - if (!leftButtonDown) + // Draw the preview circle + if (!leftButtonDown) { - DrawCircleLinesV(GetMousePosition(), lineThickness/2.0f, new Color(127, 127, 127, 127)); + DrawCircleLinesV(GetMousePosition(), lineThickness / 2.0f, new Color(127, 127, 127, 127)); } // Draw the hint text diff --git a/Examples/Shapes/MathAngleRotation.cs b/Examples/Shapes/MathAngleRotation.cs index 20c091f..81b2697 100644 --- a/Examples/Shapes/MathAngleRotation.cs +++ b/Examples/Shapes/MathAngleRotation.cs @@ -41,7 +41,7 @@ public partial class MathAngleRotation : IExample public void Init() { - center = new Vector2(screenWidth/2.0f, screenHeight/2.0f); + center = new Vector2(screenWidth / 2.0f, screenHeight / 2.0f); // Predefined angles for fixed lines angles = new[] { 0, 30, 60, 90 }; @@ -64,44 +64,54 @@ public partial class MathAngleRotation : IExample // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(Color.White); + ClearBackground(Color.White); - DrawText("Fixed angles + rotating line", 10, 10, 20, Color.LightGray); + DrawText("Fixed angles + rotating line", 10, 10, 20, Color.LightGray); - // Draw fixed-angle lines with colorful gradient - for (int i = 0; i < numAngles; i++) + // Draw fixed-angle lines with colorful gradient + for (int i = 0; i < numAngles; i++) + { + float rad = angles[i] * DEG2RAD; + Vector2 end = new Vector2(center.X + MathF.Cos(rad) * lineLength, + center.Y + MathF.Sin(rad) * lineLength); + + // Gradient color from green → cyan → blue → magenta + Color col; + switch (i) { - float rad = angles[i]*DEG2RAD; - Vector2 end = new Vector2(center.X + MathF.Cos(rad)*lineLength, - center.Y + MathF.Sin(rad)*lineLength); - - // Gradient color from green → cyan → blue → magenta - Color col; - switch(i) - { - case 0: col = Color.Green; break; - case 1: col = Color.Orange; break; - case 2: col = Color.Blue; break; - case 3: col = Color.Magenta; break; - default: col = Color.White; break; - } - - DrawLineEx(center, end, 5.0f, col); - - // Draw angle label slightly offset along the line - Vector2 textPos = new Vector2(center.X + MathF.Cos(rad)*(lineLength + 20), - center.Y + MathF.Sin(rad)*(lineLength + 20)); - DrawText($"{angles[i]}°", (int)textPos.X, (int)textPos.Y, 20, col); + case 0: + col = Color.Green; + break; + case 1: + col = Color.Orange; + break; + case 2: + col = Color.Blue; + break; + case 3: + col = Color.Magenta; + break; + default: + col = Color.White; + break; } - // Draw animated rotating line with changing color - float animRad = totalAngle*DEG2RAD; - Vector2 animEnd = new Vector2(center.X + MathF.Cos(animRad)*lineLength, - center.Y + MathF.Sin(animRad)*lineLength); + DrawLineEx(center, end, 5.0f, col); - // Cycle through HSV colors for animated line - Color animCol = ColorFromHSV(totalAngle % 360.0f, 0.8f, 0.9f); - DrawLineEx(center, animEnd, 5.0f, animCol); + // Draw angle label slightly offset along the line + Vector2 textPos = new Vector2(center.X + MathF.Cos(rad) * (lineLength + 20), + center.Y + MathF.Sin(rad) * (lineLength + 20)); + DrawText($"{angles[i]}°", (int)textPos.X, (int)textPos.Y, 20, col); + } + + // Draw animated rotating line with changing color + float animRad = totalAngle * DEG2RAD; + Vector2 animEnd = new Vector2(center.X + MathF.Cos(animRad) * lineLength, + center.Y + MathF.Sin(animRad) * lineLength); + + // Cycle through HSV colors for animated line + Color animCol = ColorFromHSV(totalAngle % 360.0f, 0.8f, 0.9f); + DrawLineEx(center, animEnd, 5.0f, animCol); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/Examples/Shapes/MouseTrail.cs b/Examples/Shapes/MouseTrail.cs index 7878640..c0d881f 100644 --- a/Examples/Shapes/MouseTrail.cs +++ b/Examples/Shapes/MouseTrail.cs @@ -59,32 +59,32 @@ public partial class MouseTrail : IExample //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(Color.Black); + ClearBackground(Color.Black); - // Draw the trail by looping through the history array - for (int i = 0; i < MAX_TRAIL_LENGTH; i++) + // Draw the trail by looping through the history array + for (int i = 0; i < MAX_TRAIL_LENGTH; i++) + { + // Ensure we skip drawing if the array hasn't been fully filled on startup + if ((trailPositions[i].X != 0.0f) || (trailPositions[i].Y != 0.0f)) { - // Ensure we skip drawing if the array hasn't been fully filled on startup - if ((trailPositions[i].X != 0.0f) || (trailPositions[i].Y != 0.0f)) - { - // Calculate relative trail strength (ratio is near 1.0 for new, near 0.0 for old) - float ratio = (float)(MAX_TRAIL_LENGTH - i)/MAX_TRAIL_LENGTH; + // Calculate relative trail strength (ratio is near 1.0 for new, near 0.0 for old) + float ratio = (float)(MAX_TRAIL_LENGTH - i) / MAX_TRAIL_LENGTH; - // Fade effect: oldest positions are more transparent - // Fade (color, alpha) - alpha is 0.5 to 1.0 based on ratio - Color trailColor = Fade(Color.SkyBlue, ratio*0.5f + 0.5f); + // Fade effect: oldest positions are more transparent + // Fade (color, alpha) - alpha is 0.5 to 1.0 based on ratio + Color trailColor = Fade(Color.SkyBlue, ratio * 0.5f + 0.5f); - // Size effect: oldest positions are smaller - float trailRadius = 15.0f*ratio; + // Size effect: oldest positions are smaller + float trailRadius = 15.0f * ratio; - DrawCircleV(trailPositions[i], trailRadius, trailColor); - } + DrawCircleV(trailPositions[i], trailRadius, trailColor); } + } - // Draw a distinct white circle for the current mouse position (Index 0) - DrawCircleV(mousePosition, 15.0f, Color.White); + // Draw a distinct white circle for the current mouse position (Index 0) + DrawCircleV(mousePosition, 15.0f, Color.White); - DrawText("Move the mouse to see the trail effect!", 10, screenHeight - 30, 20, Color.LightGray); + DrawText("Move the mouse to see the trail effect!", 10, screenHeight - 30, 20, Color.LightGray); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/Examples/Shapes/PenroseTile.cs b/Examples/Shapes/PenroseTile.cs index ab02a50..7f56a5b 100644 --- a/Examples/Shapes/PenroseTile.cs +++ b/Examples/Shapes/PenroseTile.cs @@ -194,17 +194,26 @@ public partial class PenroseTile : IExample char step = production[i]; switch (step) { - case 'W': newProduction.Append(ls.ruleW); break; - case 'X': newProduction.Append(ls.ruleX); break; - case 'Y': newProduction.Append(ls.ruleY); break; - case 'Z': newProduction.Append(ls.ruleZ); break; + case 'W': + newProduction.Append(ls.ruleW); + break; + case 'X': + newProduction.Append(ls.ruleX); + break; + case 'Y': + newProduction.Append(ls.ruleY); + break; + case 'Z': + newProduction.Append(ls.ruleZ); + break; default: - { - if (step != 'F') + { + if (step != 'F') { newProduction.Append(step); } - } break; + } + break; } } diff --git a/Examples/Shapes/RectangleAdvanced.cs b/Examples/Shapes/RectangleAdvanced.cs index 1b2c94b..1a0bed5 100644 --- a/Examples/Shapes/RectangleAdvanced.cs +++ b/Examples/Shapes/RectangleAdvanced.cs @@ -162,10 +162,26 @@ public partial class RectangleAdvanced : IExample { Color color = new Color(0, 0, 0, 0); float radius = 0.0f; - if (k == 0) { color = left; radius = radiusLeft; } // [1] Upper Left Corner - if (k == 1) { color = right; radius = radiusRight; } // [3] Upper Right Corner - if (k == 2) { color = right; radius = radiusRight; } // [5] Lower Right Corner - if (k == 3) { color = left; radius = radiusLeft; } // [7] Lower Left Corner + if (k == 0) + { + color = left; + radius = radiusLeft; + } // [1] Upper Left Corner + if (k == 1) + { + color = right; + radius = radiusRight; + } // [3] Upper Right Corner + if (k == 2) + { + color = right; + radius = radiusRight; + } // [5] Lower Right Corner + if (k == 3) + { + color = left; + radius = radiusLeft; + } // [7] Lower Left Corner float angle = angles[k]; Vector2 center = centers[k]; diff --git a/Examples/Shapes/SimpleParticles.cs b/Examples/Shapes/SimpleParticles.cs index 2ae1b4e..3927a73 100644 --- a/Examples/Shapes/SimpleParticles.cs +++ b/Examples/Shapes/SimpleParticles.cs @@ -190,22 +190,26 @@ public partial class SimpleParticles : IExample switch (type) { case ParticleType.Water: - { - newParticle.radius = 5.0f; - newParticle.color = Color.Blue; - } break; + { + newParticle.radius = 5.0f; + newParticle.color = Color.Blue; + } + break; case ParticleType.Smoke: - { - newParticle.radius = 7.0f; - newParticle.color = Color.Gray; - } break; + { + newParticle.radius = 7.0f; + newParticle.color = Color.Gray; + } + break; case ParticleType.Fire: - { - newParticle.radius = 10.0f; - newParticle.color = Color.Yellow; - speed /= 10.0f; - } break; - default: break; + { + newParticle.radius = 10.0f; + newParticle.color = Color.Yellow; + speed /= 10.0f; + } + break; + default: + break; } float direction = (float)(random.Next(360)); @@ -238,41 +242,45 @@ public partial class SimpleParticles : IExample switch (buffer[i].type) { case ParticleType.Water: - { - buffer[i].position.X += buffer[i].velocity.X; - buffer[i].velocity.Y += 0.2f; // Gravity - buffer[i].position.Y += buffer[i].velocity.Y; - } break; + { + buffer[i].position.X += buffer[i].velocity.X; + buffer[i].velocity.Y += 0.2f; // Gravity + buffer[i].position.Y += buffer[i].velocity.Y; + } + break; case ParticleType.Smoke: - { - buffer[i].position.X += buffer[i].velocity.X; - buffer[i].velocity.Y -= 0.05f; // Upwards - buffer[i].position.Y += buffer[i].velocity.Y; - buffer[i].radius += 0.5f; // Increment radius: smoke expands - buffer[i].color.A -= 4; // Decrement alpha: smoke fades + { + buffer[i].position.X += buffer[i].velocity.X; + buffer[i].velocity.Y -= 0.05f; // Upwards + buffer[i].position.Y += buffer[i].velocity.Y; + buffer[i].radius += 0.5f; // Increment radius: smoke expands + buffer[i].color.A -= 4; // Decrement alpha: smoke fades - // If alpha transparent, particle dies - if (buffer[i].color.A < 4) + // If alpha transparent, particle dies + if (buffer[i].color.A < 4) { buffer[i].alive = false; } - } break; + } + break; case ParticleType.Fire: - { - // Add a little horizontal oscillation to fire particles - buffer[i].position.X += buffer[i].velocity.X + MathF.Cos(buffer[i].lifeTime * 215.0f); - buffer[i].velocity.Y -= 0.05f; // Upwards - buffer[i].position.Y += buffer[i].velocity.Y; - buffer[i].radius -= 0.15f; // Decrement radius: fire shrinks - buffer[i].color.G -= 3; // Decrement green: fire turns reddish starting from yellow + { + // Add a little horizontal oscillation to fire particles + buffer[i].position.X += buffer[i].velocity.X + MathF.Cos(buffer[i].lifeTime * 215.0f); + buffer[i].velocity.Y -= 0.05f; // Upwards + buffer[i].position.Y += buffer[i].velocity.Y; + buffer[i].radius -= 0.15f; // Decrement radius: fire shrinks + buffer[i].color.G -= 3; // Decrement green: fire turns reddish starting from yellow - // If radius too small, particle dies - if (buffer[i].radius <= 0.02f) + // If radius too small, particle dies + if (buffer[i].radius <= 0.02f) { buffer[i].alive = false; } - } break; - default: break; + } + break; + default: + break; } // Disable particle when out of screen diff --git a/Examples/Text/Text3D.cs b/Examples/Text/Text3D.cs index f734a9a..3d4e2e0 100644 --- a/Examples/Text/Text3D.cs +++ b/Examples/Text/Text3D.cs @@ -135,7 +135,8 @@ public partial class Text3D : IExample layerDistance = 0.01f; wcfg = new WaveTextConfig(); - wcfg.WaveSpeed.X = wcfg.WaveSpeed.Y = 3.0f; wcfg.WaveSpeed.Z = 0.5f; + wcfg.WaveSpeed.X = wcfg.WaveSpeed.Y = 3.0f; + wcfg.WaveSpeed.Z = 0.5f; wcfg.WaveOffset.X = wcfg.WaveOffset.Y = wcfg.WaveOffset.Z = 0.35f; wcfg.WaveRange.X = wcfg.WaveRange.Y = wcfg.WaveRange.Z = 0.45f; @@ -230,12 +231,16 @@ public partial class Text3D : IExample } // Handle text layers changes - if (IsKeyPressed(KeyboardKey.Home)) { if (layers > 1) + if (IsKeyPressed(KeyboardKey.Home)) + { + if (layers > 1) { --layers; } } - else if (IsKeyPressed(KeyboardKey.End)) { if (layers < TextMaxLayers) + else if (IsKeyPressed(KeyboardKey.End)) + { + if (layers < TextMaxLayers) { ++layers; } @@ -559,19 +564,27 @@ public partial class Text3D : IExample // Front Face Rlgl.Normal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up - Rlgl.TexCoord2f(tx, ty); Rlgl.Vertex3f(x, y, z); // Top Left Of The Texture and Quad - Rlgl.TexCoord2f(tx, th); Rlgl.Vertex3f(x, y, z + height); // Bottom Left Of The Texture and Quad - Rlgl.TexCoord2f(tw, th); Rlgl.Vertex3f(x + width, y, z + height); // Bottom Right Of The Texture and Quad - Rlgl.TexCoord2f(tw, ty); Rlgl.Vertex3f(x + width, y, z); // Top Right Of The Texture and Quad + Rlgl.TexCoord2f(tx, ty); + Rlgl.Vertex3f(x, y, z); // Top Left Of The Texture and Quad + Rlgl.TexCoord2f(tx, th); + Rlgl.Vertex3f(x, y, z + height); // Bottom Left Of The Texture and Quad + Rlgl.TexCoord2f(tw, th); + Rlgl.Vertex3f(x + width, y, z + height); // Bottom Right Of The Texture and Quad + Rlgl.TexCoord2f(tw, ty); + Rlgl.Vertex3f(x + width, y, z); // Top Right Of The Texture and Quad if (backface) { // Back Face Rlgl.Normal3f(0.0f, -1.0f, 0.0f); // Normal Pointing Down - Rlgl.TexCoord2f(tx, ty); Rlgl.Vertex3f(x, y, z); // Top Right Of The Texture and Quad - Rlgl.TexCoord2f(tw, ty); Rlgl.Vertex3f(x + width, y, z); // Top Left Of The Texture and Quad - Rlgl.TexCoord2f(tw, th); Rlgl.Vertex3f(x + width, y, z + height); // Bottom Left Of The Texture and Quad - Rlgl.TexCoord2f(tx, th); Rlgl.Vertex3f(x, y, z + height); // Bottom Right Of The Texture and Quad + Rlgl.TexCoord2f(tx, ty); + Rlgl.Vertex3f(x, y, z); // Top Right Of The Texture and Quad + Rlgl.TexCoord2f(tw, ty); + Rlgl.Vertex3f(x + width, y, z); // Top Left Of The Texture and Quad + Rlgl.TexCoord2f(tw, th); + Rlgl.Vertex3f(x + width, y, z + height); // Bottom Left Of The Texture and Quad + Rlgl.TexCoord2f(tx, th); + Rlgl.Vertex3f(x, y, z + height); // Bottom Right Of The Texture and Quad } Rlgl.End(); Rlgl.PopMatrix();