Watch
2
0
Fork
You've already forked raylib-cs
0

chore: run dotnet format scoped default (was previously scoped to just 'style')

This commit is contained in:
tiger tiger tiger 2026-07-30 15:07:59 +02:00
commit c06874f14a
No known key found for this signature in database
23 changed files with 749 additions and 485 deletions

View file

@ -176,41 +176,42 @@ public unsafe partial class AmpEnvelope : IExample
switch (env.State) switch (env.State)
{ {
case ADSRState.Attack: case ADSRState.Attack:
{
env.CurrentValue += (1.0f / env.AttackTime) * sampleTime;
if (env.CurrentValue >= 1.0f)
{ {
env.CurrentValue = 1.0f; env.CurrentValue += (1.0f / env.AttackTime) * sampleTime;
env.State = ADSRState.Decay; if (env.CurrentValue >= 1.0f)
{
env.CurrentValue = 1.0f;
env.State = ADSRState.Decay;
}
} }
} break;
break;
case ADSRState.Decay: case ADSRState.Decay:
{ {
env.CurrentValue -= ((1.0f - env.SustainLevel) / env.DecayTime) * sampleTime; env.CurrentValue -= ((1.0f - env.SustainLevel) / env.DecayTime) * sampleTime;
if (env.CurrentValue <= env.SustainLevel) if (env.CurrentValue <= env.SustainLevel)
{
env.CurrentValue = env.SustainLevel;
env.State = ADSRState.Sustain;
}
}
break;
case ADSRState.Sustain:
{ {
env.CurrentValue = env.SustainLevel; env.CurrentValue = env.SustainLevel;
env.State = ADSRState.Sustain;
} }
} break;
break;
case ADSRState.Sustain:
{
env.CurrentValue = env.SustainLevel;
}
break;
case ADSRState.Release: 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.CurrentValue -= (env.SustainLevel / env.ReleaseTime) * sampleTime;
env.State = ADSRState.Idle; if (env.CurrentValue <= 0.001f) // Use a small threshold to avoid infinite tail
{
env.CurrentValue = 0.0f;
env.State = ADSRState.Idle;
}
} }
} break;
break; default:
default: break; break;
} }
} }

View file

@ -88,10 +88,18 @@ public unsafe partial class StreamCallback : IExample
{ {
switch (waveType) switch (waveType)
{ {
case WaveType.Sine: SetAudioStreamCallback(stream, &SineCallback); break; case WaveType.Sine:
case WaveType.Square: SetAudioStreamCallback(stream, &SquareCallback); break; SetAudioStreamCallback(stream, &SineCallback);
case WaveType.Triangle: SetAudioStreamCallback(stream, &TriangleCallback); break; break;
case WaveType.Sawtooth: SetAudioStreamCallback(stream, &SawtoothCallback); break; case WaveType.Square:
SetAudioStreamCallback(stream, &SquareCallback);
break;
case WaveType.Triangle:
SetAudioStreamCallback(stream, &TriangleCallback);
break;
case WaveType.Sawtooth:
SetAudioStreamCallback(stream, &SawtoothCallback);
break;
} }
} }

View file

@ -243,13 +243,19 @@ public partial class Camera3dFps : IExample
// Clamp view up // Clamp view up
float maxAngleUp = Vector3Angle(up, yaw); float maxAngleUp = Vector3Angle(up, yaw);
maxAngleUp -= 0.001f; // Avoid numerical errors maxAngleUp -= 0.001f; // Avoid numerical errors
if (-(lookRotation.Y) > maxAngleUp) { lookRotation.Y = -maxAngleUp; } if (-(lookRotation.Y) > maxAngleUp)
{
lookRotation.Y = -maxAngleUp;
}
// Clamp view down // Clamp view down
float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw); float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw);
maxAngleDown *= -1.0f; // Downwards angle is negative maxAngleDown *= -1.0f; // Downwards angle is negative
maxAngleDown += 0.001f; // Avoid numerical errors maxAngleDown += 0.001f; // Avoid numerical errors
if (-(lookRotation.Y) < maxAngleDown) { lookRotation.Y = -maxAngleDown; } if (-(lookRotation.Y) < maxAngleDown)
{
lookRotation.Y = -maxAngleDown;
}
// Up and down // Up and down
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up)); Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));

View file

@ -237,112 +237,218 @@ public partial class KeyboardTestbed : IExample
{ {
switch ((KeyboardKey)key) switch ((KeyboardKey)key)
{ {
case KeyboardKey.Apostrophe: return "'"; // Key: ' case KeyboardKey.Apostrophe:
case KeyboardKey.Comma: return ","; // Key: , return "'"; // Key: '
case KeyboardKey.Minus: return "-"; // Key: - case KeyboardKey.Comma:
case KeyboardKey.Period: return "."; // Key: . return ","; // Key: ,
case KeyboardKey.Slash: return "/"; // Key: / case KeyboardKey.Minus:
case KeyboardKey.Zero: return "0"; // Key: 0 return "-"; // Key: -
case KeyboardKey.One: return "1"; // Key: 1 case KeyboardKey.Period:
case KeyboardKey.Two: return "2"; // Key: 2 return "."; // Key: .
case KeyboardKey.Three: return "3"; // Key: 3 case KeyboardKey.Slash:
case KeyboardKey.Four: return "4"; // Key: 4 return "/"; // Key: /
case KeyboardKey.Five: return "5"; // Key: 5 case KeyboardKey.Zero:
case KeyboardKey.Six: return "6"; // Key: 6 return "0"; // Key: 0
case KeyboardKey.Seven: return "7"; // Key: 7 case KeyboardKey.One:
case KeyboardKey.Eight: return "8"; // Key: 8 return "1"; // Key: 1
case KeyboardKey.Nine: return "9"; // Key: 9 case KeyboardKey.Two:
case KeyboardKey.Semicolon: return ";"; // Key: ; return "2"; // Key: 2
case KeyboardKey.Equal: return "="; // Key: = case KeyboardKey.Three:
case KeyboardKey.A: return "A"; // Key: A | a return "3"; // Key: 3
case KeyboardKey.B: return "B"; // Key: B | b case KeyboardKey.Four:
case KeyboardKey.C: return "C"; // Key: C | c return "4"; // Key: 4
case KeyboardKey.D: return "D"; // Key: D | d case KeyboardKey.Five:
case KeyboardKey.E: return "E"; // Key: E | e return "5"; // Key: 5
case KeyboardKey.F: return "F"; // Key: F | f case KeyboardKey.Six:
case KeyboardKey.G: return "G"; // Key: G | g return "6"; // Key: 6
case KeyboardKey.H: return "H"; // Key: H | h case KeyboardKey.Seven:
case KeyboardKey.I: return "I"; // Key: I | i return "7"; // Key: 7
case KeyboardKey.J: return "J"; // Key: J | j case KeyboardKey.Eight:
case KeyboardKey.K: return "K"; // Key: K | k return "8"; // Key: 8
case KeyboardKey.L: return "L"; // Key: L | l case KeyboardKey.Nine:
case KeyboardKey.M: return "M"; // Key: M | m return "9"; // Key: 9
case KeyboardKey.N: return "N"; // Key: N | n case KeyboardKey.Semicolon:
case KeyboardKey.O: return "O"; // Key: O | o return ";"; // Key: ;
case KeyboardKey.P: return "P"; // Key: P | p case KeyboardKey.Equal:
case KeyboardKey.Q: return "Q"; // Key: Q | q return "="; // Key: =
case KeyboardKey.R: return "R"; // Key: R | r case KeyboardKey.A:
case KeyboardKey.S: return "S"; // Key: S | s return "A"; // Key: A | a
case KeyboardKey.T: return "T"; // Key: T | t case KeyboardKey.B:
case KeyboardKey.U: return "U"; // Key: U | u return "B"; // Key: B | b
case KeyboardKey.V: return "V"; // Key: V | v case KeyboardKey.C:
case KeyboardKey.W: return "W"; // Key: W | w return "C"; // Key: C | c
case KeyboardKey.X: return "X"; // Key: X | x case KeyboardKey.D:
case KeyboardKey.Y: return "Y"; // Key: Y | y return "D"; // Key: D | d
case KeyboardKey.Z: return "Z"; // Key: Z | z case KeyboardKey.E:
case KeyboardKey.LeftBracket: return "["; // Key: [ return "E"; // Key: E | e
case KeyboardKey.Backslash: return "\\"; // Key: '\' case KeyboardKey.F:
case KeyboardKey.RightBracket: return "]"; // Key: ] return "F"; // Key: F | f
case KeyboardKey.Grave: return "`"; // Key: ` case KeyboardKey.G:
case KeyboardKey.Space: return "SPACE"; // Key: Space return "G"; // Key: G | g
case KeyboardKey.Escape: return "ESC"; // Key: Esc case KeyboardKey.H:
case KeyboardKey.Enter: return "ENTER"; // Key: Enter return "H"; // Key: H | h
case KeyboardKey.Tab: return "TAB"; // Key: Tab case KeyboardKey.I:
case KeyboardKey.Backspace: return "BACK"; // Key: Backspace return "I"; // Key: I | i
case KeyboardKey.Insert: return "INS"; // Key: Ins case KeyboardKey.J:
case KeyboardKey.Delete: return "DEL"; // Key: Del return "J"; // Key: J | j
case KeyboardKey.Right: return "RIGHT"; // Key: Cursor right case KeyboardKey.K:
case KeyboardKey.Left: return "LEFT"; // Key: Cursor left return "K"; // Key: K | k
case KeyboardKey.Down: return "DOWN"; // Key: Cursor down case KeyboardKey.L:
case KeyboardKey.Up: return "UP"; // Key: Cursor up return "L"; // Key: L | l
case KeyboardKey.PageUp: return "PGUP"; // Key: Page up case KeyboardKey.M:
case KeyboardKey.PageDown: return "PGDOWN"; // Key: Page down return "M"; // Key: M | m
case KeyboardKey.Home: return "HOME"; // Key: Home case KeyboardKey.N:
case KeyboardKey.End: return "END"; // Key: End return "N"; // Key: N | n
case KeyboardKey.CapsLock: return "CAPS"; // Key: Caps lock case KeyboardKey.O:
case KeyboardKey.ScrollLock: return "LOCK"; // Key: Scroll down return "O"; // Key: O | o
case KeyboardKey.NumLock: return "NUMLOCK"; // Key: Num lock case KeyboardKey.P:
case KeyboardKey.PrintScreen: return "PRINTSCR"; // Key: Print screen return "P"; // Key: P | p
case KeyboardKey.Pause: return "PAUSE"; // Key: Pause case KeyboardKey.Q:
case KeyboardKey.F1: return "F1"; // Key: F1 return "Q"; // Key: Q | q
case KeyboardKey.F2: return "F2"; // Key: F2 case KeyboardKey.R:
case KeyboardKey.F3: return "F3"; // Key: F3 return "R"; // Key: R | r
case KeyboardKey.F4: return "F4"; // Key: F4 case KeyboardKey.S:
case KeyboardKey.F5: return "F5"; // Key: F5 return "S"; // Key: S | s
case KeyboardKey.F6: return "F6"; // Key: F6 case KeyboardKey.T:
case KeyboardKey.F7: return "F7"; // Key: F7 return "T"; // Key: T | t
case KeyboardKey.F8: return "F8"; // Key: F8 case KeyboardKey.U:
case KeyboardKey.F9: return "F9"; // Key: F9 return "U"; // Key: U | u
case KeyboardKey.F10: return "F10"; // Key: F10 case KeyboardKey.V:
case KeyboardKey.F11: return "F11"; // Key: F11 return "V"; // Key: V | v
case KeyboardKey.F12: return "F12"; // Key: F12 case KeyboardKey.W:
case KeyboardKey.LeftShift: return "LSHIFT"; // Key: Shift left return "W"; // Key: W | w
case KeyboardKey.LeftControl: return "LCTRL"; // Key: Control left case KeyboardKey.X:
case KeyboardKey.LeftAlt: return "LALT"; // Key: Alt left return "X"; // Key: X | x
case KeyboardKey.LeftSuper: return "WIN"; // Key: Super left case KeyboardKey.Y:
case KeyboardKey.RightShift: return "RSHIFT"; // Key: Shift right return "Y"; // Key: Y | y
case KeyboardKey.RightControl: return "RCTRL"; // Key: Control right case KeyboardKey.Z:
case KeyboardKey.RightAlt: return "ALTGR"; // Key: Alt right return "Z"; // Key: Z | z
case KeyboardKey.RightSuper: return "RSUPER"; // Key: Super right case KeyboardKey.LeftBracket:
case KeyboardKey.KeyboardMenu: return "KBMENU"; // Key: KB menu return "["; // Key: [
case KeyboardKey.Kp0: return "KP0"; // Key: Keypad 0 case KeyboardKey.Backslash:
case KeyboardKey.Kp1: return "KP1"; // Key: Keypad 1 return "\\"; // Key: '\'
case KeyboardKey.Kp2: return "KP2"; // Key: Keypad 2 case KeyboardKey.RightBracket:
case KeyboardKey.Kp3: return "KP3"; // Key: Keypad 3 return "]"; // Key: ]
case KeyboardKey.Kp4: return "KP4"; // Key: Keypad 4 case KeyboardKey.Grave:
case KeyboardKey.Kp5: return "KP5"; // Key: Keypad 5 return "`"; // Key: `
case KeyboardKey.Kp6: return "KP6"; // Key: Keypad 6 case KeyboardKey.Space:
case KeyboardKey.Kp7: return "KP7"; // Key: Keypad 7 return "SPACE"; // Key: Space
case KeyboardKey.Kp8: return "KP8"; // Key: Keypad 8 case KeyboardKey.Escape:
case KeyboardKey.Kp9: return "KP9"; // Key: Keypad 9 return "ESC"; // Key: Esc
case KeyboardKey.KpDecimal: return "KPDEC"; // Key: Keypad . case KeyboardKey.Enter:
case KeyboardKey.KpDivide: return "KPDIV"; // Key: Keypad / return "ENTER"; // Key: Enter
case KeyboardKey.KpMultiply: return "KPMUL"; // Key: Keypad * case KeyboardKey.Tab:
case KeyboardKey.KpSubtract: return "KPSUB"; // Key: Keypad - return "TAB"; // Key: Tab
case KeyboardKey.KpAdd: return "KPADD"; // Key: Keypad + case KeyboardKey.Backspace:
case KeyboardKey.KpEnter: return "KPENTER"; // Key: Keypad Enter return "BACK"; // Key: Backspace
case KeyboardKey.KpEqual: return "KPEQU"; // Key: Keypad = case KeyboardKey.Insert:
default: return ""; 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 "";
} }
} }

View file

@ -314,13 +314,26 @@ public partial class ViewportScaling : IExample
switch (viewportType) switch (viewportType)
{ {
case ViewportType.KeepAspectInteger: KeepAspectCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; case ViewportType.KeepAspectInteger:
case ViewportType.KeepHeightInteger: KeepHeightCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; KeepAspectCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect);
case ViewportType.KeepWidthInteger: KeepWidthCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; break;
case ViewportType.KeepAspect: KeepAspectCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; case ViewportType.KeepHeightInteger:
case ViewportType.KeepHeight: KeepHeightCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; KeepHeightCenteredInteger(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect);
case ViewportType.KeepWidth: KeepWidthCentered(screenWidth, screenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect); break; break;
default: 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); UnloadRenderTexture(target);

View file

@ -8,7 +8,10 @@ namespace Examples;
public sealed class ExcludeFromBrowserAttribute : Attribute public sealed class ExcludeFromBrowserAttribute : Attribute
{ {
/// <summary>Why the example cannot run in the browser.</summary> /// <summary>Why the example cannot run in the browser.</summary>
public string Reason { get; } public string Reason
{
get;
}
public ExcludeFromBrowserAttribute(string reason = null) public ExcludeFromBrowserAttribute(string reason = null)
{ {

View file

@ -14,10 +14,16 @@ namespace Examples;
public interface IExample public interface IExample
{ {
/// <summary>Display name shown in the navigation dropdown.</summary> /// <summary>Display name shown in the navigation dropdown.</summary>
string Name { get; } string Name
{
get;
}
/// <summary>Window title, matching the example's standalone <c>Main()</c>.</summary> /// <summary>Window title, matching the example's standalone <c>Main()</c>.</summary>
string Title { get; } string Title
{
get;
}
/// <summary>Desktop window size, matching the standalone <c>Main()</c>. The browser canvas is fixed at 800x450.</summary> /// <summary>Desktop window size, matching the standalone <c>Main()</c>. The browser canvas is fixed at 800x450.</summary>
int Width => 800; int Width => 800;

View file

@ -423,8 +423,12 @@ public partial class Decals : IExample
nV3 = ClipSegment(inMesh[i + 1], nV1, planes[face], s); nV3 = ClipSegment(inMesh[i + 1], nV1, planes[face], s);
nV4 = ClipSegment(inMesh[i + 1], nV2, planes[face], s); nV4 = ClipSegment(inMesh[i + 1], nV2, planes[face], s);
outMesh.Add(nV3); outMesh.Add(nV2); outMesh.Add(nV1); outMesh.Add(nV3);
outMesh.Add(nV2); outMesh.Add(nV3); outMesh.Add(nV4); outMesh.Add(nV2);
outMesh.Add(nV1);
outMesh.Add(nV2);
outMesh.Add(nV3);
outMesh.Add(nV4);
} }
else else
{ {
@ -443,8 +447,12 @@ public partial class Decals : IExample
nV4 = ClipSegment(inMesh[i + 2], nV2, planes[face], s); nV4 = ClipSegment(inMesh[i + 2], nV2, planes[face], s);
} }
outMesh.Add(nV1); outMesh.Add(nV2); outMesh.Add(nV3); outMesh.Add(nV1);
outMesh.Add(nV4); outMesh.Add(nV3); outMesh.Add(nV2); outMesh.Add(nV2);
outMesh.Add(nV3);
outMesh.Add(nV4);
outMesh.Add(nV3);
outMesh.Add(nV2);
} }
break; break;
case 2: case 2:
@ -454,7 +462,9 @@ public partial class Decals : IExample
nV1 = inMesh[i]; nV1 = inMesh[i];
nV2 = ClipSegment(nV1, inMesh[i + 1], planes[face], s); nV2 = ClipSegment(nV1, inMesh[i + 1], planes[face], s);
nV3 = ClipSegment(nV1, inMesh[i + 2], 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) if (!v2Out)
@ -462,7 +472,9 @@ public partial class Decals : IExample
nV1 = inMesh[i + 1]; nV1 = inMesh[i + 1];
nV2 = ClipSegment(nV1, inMesh[i + 2], planes[face], s); nV2 = ClipSegment(nV1, inMesh[i + 2], planes[face], s);
nV3 = ClipSegment(nV1, inMesh[i], 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) if (!v3Out)
@ -470,7 +482,9 @@ public partial class Decals : IExample
nV1 = inMesh[i + 2]; nV1 = inMesh[i + 2];
nV2 = ClipSegment(nV1, inMesh[i], planes[face], s); nV2 = ClipSegment(nV1, inMesh[i], planes[face], s);
nV3 = ClipSegment(nV1, inMesh[i + 1], 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; break;
default: // The entire face lies outside of the plane, so let's discard the corresponding vertices default: // The entire face lies outside of the plane, so let's discard the corresponding vertices

View file

@ -209,10 +209,22 @@ public partial class DeferredRendering : IExample
); );
// Check key inputs to enable/disable lights // Check key inputs to enable/disable lights
if (IsKeyPressed(KeyboardKey.Y)) { lights[0].Enabled = !lights[0].Enabled; } if (IsKeyPressed(KeyboardKey.Y))
if (IsKeyPressed(KeyboardKey.R)) { lights[1].Enabled = !lights[1].Enabled; } {
if (IsKeyPressed(KeyboardKey.G)) { lights[2].Enabled = !lights[2].Enabled; } lights[0].Enabled = !lights[0].Enabled;
if (IsKeyPressed(KeyboardKey.B)) { lights[3].Enabled = !lights[3].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 // Check key inputs to switch between G-buffer textures
if (IsKeyPressed(KeyboardKey.One)) if (IsKeyPressed(KeyboardKey.One))
@ -277,40 +289,40 @@ public partial class DeferredRendering : IExample
switch (mode) switch (mode)
{ {
case DeferredMode.Shading: 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); 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)); DrawSphereWires(lights[i].Position, 0.2f, 8, 8, ColorAlpha(lights[i].Color, 0.3f));
} }
} }
Rlgl.DisableShader(); Rlgl.DisableShader();
EndMode3D(); EndMode3D();
DrawText("FINAL RESULT", 10, screenHeight - 30, 20, Color.DarkGreen); DrawText("FINAL RESULT", 10, screenHeight - 30, 20, Color.DarkGreen);
} }
break; break;
case DeferredMode.Position: case DeferredMode.Position:
{ {
DrawTextureRec( DrawTextureRec(
new Texture2D { Id = gBuffer.PositionTextureId, Width = screenWidth, Height = screenHeight }, new Texture2D { Id = gBuffer.PositionTextureId, Width = screenWidth, Height = screenHeight },
new Rectangle(0, 0, screenWidth, -screenHeight), new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero, Vector2.Zero,
Color.RayWhite Color.RayWhite
); );
DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen);
} }
break; break;
case DeferredMode.Normal: case DeferredMode.Normal:
{ {
DrawTextureRec( DrawTextureRec(
new Texture2D { Id = gBuffer.NormalTextureId, Width = screenWidth, Height = screenHeight }, new Texture2D { Id = gBuffer.NormalTextureId, Width = screenWidth, Height = screenHeight },
new Rectangle(0, 0, screenWidth, -screenHeight), new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero, Vector2.Zero,
Color.RayWhite Color.RayWhite
); );
DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen);
} }
break; break;
case DeferredMode.Albedo: case DeferredMode.Albedo:
{ {
DrawTextureRec( DrawTextureRec(
new Texture2D { Id = gBuffer.AlbedoSpecTextureId, Width = screenWidth, Height = screenHeight }, new Texture2D { Id = gBuffer.AlbedoSpecTextureId, Width = screenWidth, Height = screenHeight },
new Rectangle(0, 0, screenWidth, -screenHeight), new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero, Vector2.Zero,
Color.RayWhite Color.RayWhite
); );
DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen); DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, Color.DarkGreen);
} }
break; break;
default: break; default:
break;
} }
DrawText("Toggle lights keys: [Y][R][G][B]", 10, 40, 20, Color.DarkGray); DrawText("Toggle lights keys: [Y][R][G][B]", 10, 40, 20, Color.DarkGray);

View file

@ -67,10 +67,14 @@ public partial class LightmapRendering : IExample
mesh.AllocTexCoords2(); mesh.AllocTexCoords2();
// X // Y // X // Y
mesh.TexCoords2[0] = 0.0f; mesh.TexCoords2[1] = 0.0f; mesh.TexCoords2[0] = 0.0f;
mesh.TexCoords2[2] = 1.0f; mesh.TexCoords2[3] = 0.0f; mesh.TexCoords2[1] = 0.0f;
mesh.TexCoords2[4] = 0.0f; mesh.TexCoords2[5] = 1.0f; mesh.TexCoords2[2] = 1.0f;
mesh.TexCoords2[6] = 1.0f; mesh.TexCoords2[7] = 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 // Load a new texcoords2 attributes buffer
mesh.VboId[(int)ShaderLocationIndex.VertexTexcoord02] = mesh.VboId[(int)ShaderLocationIndex.VertexTexcoord02] =

View file

@ -62,7 +62,7 @@ public partial class BallPhysics : IExample
// Init first ball in the array // Init first ball in the array
balls[0] = new Ball 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), speed = new Vector2(200, 200),
prevPosition = new Vector2(0, 0), prevPosition = new Vector2(0, 0),
radius = 40, radius = 40,
@ -98,7 +98,7 @@ public partial class BallPhysics : IExample
// If the distance between the ball position and the mouse press position // 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 // 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; balls[i].grabbed = true;
grabbedBallIndex = i; grabbedBallIndex = i;
@ -163,7 +163,7 @@ public partial class BallPhysics : IExample
} }
// Changes gravity // Changes gravity
gravity += GetMouseWheelMove()*5; gravity += GetMouseWheelMove() * 5;
// Updates each ball state // Updates each ball state
for (int i = 0; i < ballCount; i++) 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) if ((balls[i].position.X + balls[i].radius) >= screenWidth)
{ {
balls[i].position.X = screenWidth - balls[i].radius; // Ball repositioning 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? // Does the ball hit the screen left boundary?
else if ((balls[i].position.X - balls[i].radius) <= 0) else if ((balls[i].position.X - balls[i].radius) <= 0)
{ {
balls[i].position.X = balls[i].radius; 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 // The same for y axis
if ((balls[i].position.Y + balls[i].radius) >= screenHeight) if ((balls[i].position.Y + balls[i].radius) >= screenHeight)
{ {
balls[i].position.Y = screenHeight - balls[i].radius; 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) else if ((balls[i].position.Y - balls[i].radius) <= 0)
{ {
balls[i].position.Y = balls[i].radius; 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 // 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 // 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 else
{ {
@ -212,8 +212,8 @@ public partial class BallPhysics : IExample
balls[i].position.Y = mousePos.Y - pressOffset.Y; balls[i].position.Y = mousePos.Y - pressOffset.Y;
// While the ball is grabbed, recalculates its velocity // While the ball is grabbed, recalculates its velocity
balls[i].speed.X = (balls[i].position.X - balls[i].prevPosition.X)/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].speed.Y = (balls[i].position.Y - balls[i].prevPosition.Y) / delta;
balls[i].prevPosition = balls[i].position; balls[i].prevPosition = balls[i].position;
} }
} }
@ -225,20 +225,20 @@ public partial class BallPhysics : IExample
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(Color.RayWhite); ClearBackground(Color.RayWhite);
for (int i = 0; i < ballCount; i++) for (int i = 0; i < ballCount; i++)
{ {
DrawCircleV(balls[i].position, balls[i].radius, balls[i].color); DrawCircleV(balls[i].position, balls[i].radius, balls[i].color);
DrawCircleLinesV(balls[i].position, balls[i].radius, Color.Black); 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("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("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("use mouse wheel to change gravity", 10, 50, 10, Color.DarkGray);
DrawText("middle click to shake", 10, 70, 10, Color.DarkGray); DrawText("middle click to shake", 10, 70, 10, Color.DarkGray);
DrawText($"BALL COUNT: {ballCount}", 10, GetScreenHeight() - 70, 20, Color.Black); DrawText($"BALL COUNT: {ballCount}", 10, GetScreenHeight() - 70, 20, Color.Black);
DrawText($"GRAVITY: {gravity:F2}", 10, GetScreenHeight() - 40, 20, Color.Black); DrawText($"GRAVITY: {gravity:F2}", 10, GetScreenHeight() - 40, 20, Color.Black);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -88,8 +88,8 @@ public partial class BulletHell : IExample
// Draw circle to bullet texture, then draw bullet using DrawTexture() // Draw circle to bullet texture, then draw bullet using DrawTexture()
// NOTE: This is done to improve the performance, since DrawCircle() is very slow // NOTE: This is done to improve the performance, since DrawCircle() is very slow
BeginTextureMode(bulletTexture); BeginTextureMode(bulletTexture);
DrawCircle(12, 12, (float)bulletRadius, Color.White); DrawCircle(12, 12, (float)bulletRadius, Color.White);
DrawCircleLines(12, 12, (float)bulletRadius, Color.Black); DrawCircleLines(12, 12, (float)bulletRadius, Color.Black);
EndTextureMode(); EndTextureMode();
drawInPerformanceMode = true; drawInPerformanceMode = true;
@ -113,16 +113,16 @@ public partial class BulletHell : IExample
spawnCooldownTimer = spawnCooldown; spawnCooldownTimer = spawnCooldown;
// Spawn bullets // Spawn bullets
float degreesPerRow = 360.0f/bulletRows; float degreesPerRow = 360.0f / bulletRows;
for (int row = 0; row < bulletRows; row++) for (int row = 0; row < bulletRows; row++)
{ {
if (bulletCount < MAX_BULLETS) 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].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 // 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, // 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 // 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 // Case you want it to be anti-clockwise, add "* -1" at the y acceleration
bullets[bulletCount].acceleration = new Vector2( bullets[bulletCount].acceleration = new Vector2(
bulletSpeed*MathF.Cos(bulletDirection*DEG2RAD), bulletSpeed * MathF.Cos(bulletDirection * DEG2RAD),
bulletSpeed*MathF.Sin(bulletDirection*DEG2RAD) bulletSpeed * MathF.Sin(bulletDirection * DEG2RAD)
); );
bulletCount++; bulletCount++;
@ -151,10 +151,10 @@ public partial class BulletHell : IExample
bullets[i].position.Y += bullets[i].acceleration.Y; bullets[i].position.Y += bullets[i].acceleration.Y;
// Disable bullet if out of screen // Disable bullet if out of screen
if ((bullets[i].position.X < -bulletRadius*2) || if ((bullets[i].position.X < -bulletRadius * 2) ||
(bullets[i].position.X > screenWidth + bulletRadius*2) || (bullets[i].position.X > screenWidth + bulletRadius * 2) ||
(bullets[i].position.Y < -bulletRadius*2) || (bullets[i].position.Y < -bulletRadius * 2) ||
(bullets[i].position.Y > screenHeight + bulletRadius*2)) (bullets[i].position.Y > screenHeight + bulletRadius * 2))
{ {
bullets[i].disabled = true; bullets[i].disabled = true;
bulletDisabledCount++; bulletDisabledCount++;
@ -214,60 +214,60 @@ public partial class BulletHell : IExample
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(Color.RayWhite); ClearBackground(Color.RayWhite);
// Draw magic circle // Draw magic circle
magicCircleRotation++; magicCircleRotation++;
DrawRectanglePro(new Rectangle((float)screenWidth/2, (float)screenHeight/2, 120, 120), DrawRectanglePro(new Rectangle((float)screenWidth / 2, (float)screenHeight / 2, 120, 120),
new Vector2(60.0f, 60.0f), magicCircleRotation, Color.Purple); new Vector2(60.0f, 60.0f), magicCircleRotation, Color.Purple);
DrawRectanglePro(new Rectangle((float)screenWidth/2, (float)screenHeight/2, 120, 120), DrawRectanglePro(new Rectangle((float)screenWidth / 2, (float)screenHeight / 2, 120, 120),
new Vector2(60.0f, 60.0f), magicCircleRotation + 45, Color.Purple); new Vector2(60.0f, 60.0f), magicCircleRotation + 45, Color.Purple);
DrawCircleLines(screenWidth/2, screenHeight/2, 70, Color.Black); DrawCircleLines(screenWidth / 2, screenHeight / 2, 70, Color.Black);
DrawCircleLines(screenWidth/2, screenHeight/2, 50, Color.Black); DrawCircleLines(screenWidth / 2, screenHeight / 2, 50, Color.Black);
DrawCircleLines(screenWidth/2, screenHeight/2, 30, Color.Black); DrawCircleLines(screenWidth / 2, screenHeight / 2, 30, Color.Black);
// Draw bullets // Draw bullets
if (drawInPerformanceMode) 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 // Do not draw disabled bullets (out of screen)
for (int i = 0; i < bulletCount; i++) if (!bullets[i].disabled)
{ {
// Do not draw disabled bullets (out of screen) DrawTexture(bulletTexture.Texture,
if (!bullets[i].disabled) (int)(bullets[i].position.X - bulletTexture.Texture.Width * 0.5f),
{ (int)(bullets[i].position.Y - bulletTexture.Texture.Height * 0.5f),
DrawTexture(bulletTexture.Texture, bullets[i].color);
(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 // Do not draw disabled bullets (out of screen)
for (int i = 0; i < bulletCount; i++) if (!bullets[i].disabled)
{ {
// Do not draw disabled bullets (out of screen) DrawCircleV(bullets[i].position, (float)bulletRadius, bullets[i].color);
if (!bullets[i].disabled) 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 // Draw UI
DrawRectangle(10, 10, 280, 150, new Color(0, 0, 0, 200)); DrawRectangle(10, 10, 280, 150, new Color(0, 0, 0, 200));
DrawText("Controls:", 20, 20, 10, Color.LightGray); DrawText("Controls:", 20, 20, 10, Color.LightGray);
DrawText("- Right/Left or A/D: Change rows number", 40, 40, 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("- 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("- Z or X: Change spawn cooldown", 40, 80, 10, Color.LightGray);
DrawText("- Space (Hold): Change the angle increment", 40, 100, 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("- Enter: Switch draw method (Performance)", 40, 120, 10, Color.LightGray);
DrawText("- C: Clear bullets", 40, 140, 10, Color.LightGray); DrawText("- C: Clear bullets", 40, 140, 10, Color.LightGray);
DrawRectangle(610, 10, 170, 30, new Color(0, 0, 0, 200)); DrawRectangle(610, 10, 170, 30, new Color(0, 0, 0, 200));
if (drawInPerformanceMode) if (drawInPerformanceMode)
{ {
DrawText("Draw method: DrawTexture(*)", 620, 20, 10, Color.Green); 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)); 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} ]", 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); 155, 420, 10, Color.Green);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -80,7 +80,7 @@ public partial class DashedLine : IExample
// Cycle through colors ('C' key) // Cycle through colors ('C' key)
if (IsKeyPressed(KeyboardKey.C)) if (IsKeyPressed(KeyboardKey.C))
{ {
colorIndex = (colorIndex + 1)%lineColors.Length; colorIndex = (colorIndex + 1) % lineColors.Length;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -88,23 +88,23 @@ public partial class DashedLine : IExample
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(Color.RayWhite); ClearBackground(Color.RayWhite);
// Draw the dashed line with the current properties // Draw the dashed line with the current properties
DrawLineDashed(lineStartPosition, lineEndPosition, (int)dashLength, (int)blankLength, lineColors[colorIndex]); DrawLineDashed(lineStartPosition, lineEndPosition, (int)dashLength, (int)blankLength, lineColors[colorIndex]);
// Draw UI and Instructions // Draw UI and Instructions
DrawRectangle(5, 5, 265, 95, Fade(Color.SkyBlue, 0.5f)); DrawRectangle(5, 5, 265, 95, Fade(Color.SkyBlue, 0.5f));
DrawRectangleLines(5, 5, 265, 95, Color.Blue); DrawRectangleLines(5, 5, 265, 95, Color.Blue);
DrawText("CONTROLS:", 15, 15, 10, Color.Black); DrawText("CONTROLS:", 15, 15, 10, Color.Black);
DrawText("UP/DOWN: Change Dash Length", 15, 35, 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("LEFT/RIGHT: Change Space Length", 15, 55, 10, Color.Black);
DrawText("C: Cycle Color", 15, 75, 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(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -213,17 +213,38 @@ public partial class DigitalClock : IExample
{ {
switch (value) switch (value)
{ {
case 0: Draw7SDisplay(position, 0b00111111, colorOn, colorOff); break; case 0:
case 1: Draw7SDisplay(position, 0b00000110, colorOn, colorOff); break; Draw7SDisplay(position, 0b00111111, colorOn, colorOff);
case 2: Draw7SDisplay(position, 0b01011011, colorOn, colorOff); break; break;
case 3: Draw7SDisplay(position, 0b01001111, colorOn, colorOff); break; case 1:
case 4: Draw7SDisplay(position, 0b01100110, colorOn, colorOff); break; Draw7SDisplay(position, 0b00000110, colorOn, colorOff);
case 5: Draw7SDisplay(position, 0b01101101, colorOn, colorOff); break; break;
case 6: Draw7SDisplay(position, 0b01111101, colorOn, colorOff); break; case 2:
case 7: Draw7SDisplay(position, 0b00000111, colorOn, colorOff); break; Draw7SDisplay(position, 0b01011011, colorOn, colorOff);
case 8: Draw7SDisplay(position, 0b01111111, colorOn, colorOff); break; break;
case 9: Draw7SDisplay(position, 0b01101111, colorOn, colorOff); break; case 3:
default: break; 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;
} }
} }

View file

@ -68,8 +68,14 @@ public partial class DoublePendulum : IExample
public void Init() public void Init()
{ {
// Simulation Parameters // Simulation Parameters
l1 = 15.0f; m1 = 0.2f; theta1 = DEG2RAD * 170; w1 = 0; l1 = 15.0f;
l2 = 15.0f; m2 = 0.1f; theta2 = DEG2RAD * 0; w2 = 0; m1 = 0.2f;
theta1 = DEG2RAD * 170;
w1 = 0;
l2 = 15.0f;
m2 = 0.1f;
theta2 = DEG2RAD * 0;
w2 = 0;
lengthScaler = 0.1f; lengthScaler = 0.1f;
totalM = m1 + m2; totalM = m1 + m2;
@ -82,7 +88,8 @@ public partial class DoublePendulum : IExample
L2 = l2 * lengthScaler; L2 = l2 * lengthScaler;
// Draw parameters // Draw parameters
lineThick = 20; trailThick = 2; lineThick = 20;
trailThick = 2;
fateAlpha = 0.01f; fateAlpha = 0.01f;
// Create framebuffer // Create framebuffer

View file

@ -162,24 +162,30 @@ public partial class HilbertCurve : IExample
switch (hilbertIndex) switch (hilbertIndex)
{ {
case 0: case 0:
{ {
temp = vect.X; temp = vect.X;
vect.X = vect.Y; vect.X = vect.Y;
vect.Y = temp; vect.Y = temp;
} break; }
break;
case 2: case 2:
{ {
vect.X += len; vect.X += len;
vect.Y += len;
}
break;
case 1:
vect.Y += len; vect.Y += len;
} break; break;
case 1: vect.Y += len; break;
case 3: case 3:
{ {
temp = len - 1 - vect.X; temp = len - 1 - vect.X;
vect.X = 2 * len - 1 - vect.Y; vect.X = 2 * len - 1 - vect.Y;
vect.Y = temp; vect.Y = temp;
} break; }
default: break; break;
default:
break;
} }
} }

View file

@ -60,7 +60,7 @@ public partial class LinesDrawing : IExample
// Clear the canvas to the background color // Clear the canvas to the background color
BeginTextureMode(canvas); BeginTextureMode(canvas);
ClearBackground(Color.RayWhite); ClearBackground(Color.RayWhite);
EndTextureMode(); EndTextureMode();
} }
@ -78,7 +78,7 @@ public partial class LinesDrawing : IExample
if (IsMouseButtonPressed(MouseButton.Middle)) if (IsMouseButtonPressed(MouseButton.Middle))
{ {
BeginTextureMode(canvas); BeginTextureMode(canvas);
ClearBackground(Color.RayWhite); ClearBackground(Color.RayWhite);
EndTextureMode(); EndTextureMode();
} }
@ -94,7 +94,7 @@ public partial class LinesDrawing : IExample
if (leftButtonDown) if (leftButtonDown)
{ {
// Increase the hue value by the distance our cursor has moved since the last frame (divided by 3) // 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 // 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 // This is more visually accurate than resetting to zero
@ -113,10 +113,10 @@ public partial class LinesDrawing : IExample
// Draw the line onto the canvas // Draw the line onto the canvas
BeginTextureMode(canvas); BeginTextureMode(canvas);
// Circles act as "caps", smoothing corners // Circles act as "caps", smoothing corners
DrawCircleV(mousePositionPrevious, lineThickness/2.0f, drawColor); DrawCircleV(mousePositionPrevious, lineThickness / 2.0f, drawColor);
DrawCircleV(GetMousePosition(), lineThickness/2.0f, drawColor); DrawCircleV(GetMousePosition(), lineThickness / 2.0f, drawColor);
DrawLineEx(mousePositionPrevious, GetMousePosition(), lineThickness, drawColor); DrawLineEx(mousePositionPrevious, GetMousePosition(), lineThickness, drawColor);
EndTextureMode(); EndTextureMode();
} }
@ -132,13 +132,13 @@ public partial class LinesDrawing : IExample
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
// Draw the render texture to the screen, flipped vertically to make it appear top-side up // 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); DrawTextureRec(canvas.Texture, new Rectangle(0.0f, 0.0f, (float)canvas.Texture.Width, (float)-canvas.Texture.Height), Vector2Zero(), Color.White);
// Draw the preview circle // Draw the preview circle
if (!leftButtonDown) 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 // Draw the hint text

View file

@ -41,7 +41,7 @@ public partial class MathAngleRotation : IExample
public void Init() 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 // Predefined angles for fixed lines
angles = new[] { 0, 30, 60, 90 }; angles = new[] { 0, 30, 60, 90 };
@ -64,44 +64,54 @@ public partial class MathAngleRotation : IExample
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); 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 // Draw fixed-angle lines with colorful gradient
for (int i = 0; i < numAngles; i++) 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; case 0:
Vector2 end = new Vector2(center.X + MathF.Cos(rad)*lineLength, col = Color.Green;
center.Y + MathF.Sin(rad)*lineLength); break;
case 1:
// Gradient color from green → cyan → blue → magenta col = Color.Orange;
Color col; break;
switch(i) case 2:
{ col = Color.Blue;
case 0: col = Color.Green; break; break;
case 1: col = Color.Orange; break; case 3:
case 2: col = Color.Blue; break; col = Color.Magenta;
case 3: col = Color.Magenta; break; break;
default: col = Color.White; 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);
} }
// Draw animated rotating line with changing color DrawLineEx(center, end, 5.0f, col);
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 // Draw angle label slightly offset along the line
Color animCol = ColorFromHSV(totalAngle % 360.0f, 0.8f, 0.9f); Vector2 textPos = new Vector2(center.X + MathF.Cos(rad) * (lineLength + 20),
DrawLineEx(center, animEnd, 5.0f, animCol); 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(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -59,32 +59,32 @@ public partial class MouseTrail : IExample
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(Color.Black); ClearBackground(Color.Black);
// Draw the trail by looping through the history array // Draw the trail by looping through the history array
for (int i = 0; i < MAX_TRAIL_LENGTH; i++) 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 // Calculate relative trail strength (ratio is near 1.0 for new, near 0.0 for old)
if ((trailPositions[i].X != 0.0f) || (trailPositions[i].Y != 0.0f)) 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 effect: oldest positions are more transparent
// Fade (color, alpha) - alpha is 0.5 to 1.0 based on ratio // Fade (color, alpha) - alpha is 0.5 to 1.0 based on ratio
Color trailColor = Fade(Color.SkyBlue, ratio*0.5f + 0.5f); Color trailColor = Fade(Color.SkyBlue, ratio * 0.5f + 0.5f);
// Size effect: oldest positions are smaller // Size effect: oldest positions are smaller
float trailRadius = 15.0f*ratio; 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) // Draw a distinct white circle for the current mouse position (Index 0)
DrawCircleV(mousePosition, 15.0f, Color.White); 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(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -194,17 +194,26 @@ public partial class PenroseTile : IExample
char step = production[i]; char step = production[i];
switch (step) switch (step)
{ {
case 'W': newProduction.Append(ls.ruleW); break; case 'W':
case 'X': newProduction.Append(ls.ruleX); break; newProduction.Append(ls.ruleW);
case 'Y': newProduction.Append(ls.ruleY); break; break;
case 'Z': newProduction.Append(ls.ruleZ); break; case 'X':
newProduction.Append(ls.ruleX);
break;
case 'Y':
newProduction.Append(ls.ruleY);
break;
case 'Z':
newProduction.Append(ls.ruleZ);
break;
default: default:
{ {
if (step != 'F') if (step != 'F')
{ {
newProduction.Append(step); newProduction.Append(step);
} }
} break; }
break;
} }
} }

View file

@ -162,10 +162,26 @@ public partial class RectangleAdvanced : IExample
{ {
Color color = new Color(0, 0, 0, 0); Color color = new Color(0, 0, 0, 0);
float radius = 0.0f; float radius = 0.0f;
if (k == 0) { color = left; radius = radiusLeft; } // [1] Upper Left Corner if (k == 0)
if (k == 1) { color = right; radius = radiusRight; } // [3] Upper Right Corner {
if (k == 2) { color = right; radius = radiusRight; } // [5] Lower Right Corner color = left;
if (k == 3) { color = left; radius = radiusLeft; } // [7] Lower Left Corner 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]; float angle = angles[k];
Vector2 center = centers[k]; Vector2 center = centers[k];

View file

@ -190,22 +190,26 @@ public partial class SimpleParticles : IExample
switch (type) switch (type)
{ {
case ParticleType.Water: case ParticleType.Water:
{ {
newParticle.radius = 5.0f; newParticle.radius = 5.0f;
newParticle.color = Color.Blue; newParticle.color = Color.Blue;
} break; }
break;
case ParticleType.Smoke: case ParticleType.Smoke:
{ {
newParticle.radius = 7.0f; newParticle.radius = 7.0f;
newParticle.color = Color.Gray; newParticle.color = Color.Gray;
} break; }
break;
case ParticleType.Fire: case ParticleType.Fire:
{ {
newParticle.radius = 10.0f; newParticle.radius = 10.0f;
newParticle.color = Color.Yellow; newParticle.color = Color.Yellow;
speed /= 10.0f; speed /= 10.0f;
} break; }
default: break; break;
default:
break;
} }
float direction = (float)(random.Next(360)); float direction = (float)(random.Next(360));
@ -238,41 +242,45 @@ public partial class SimpleParticles : IExample
switch (buffer[i].type) switch (buffer[i].type)
{ {
case ParticleType.Water: case ParticleType.Water:
{ {
buffer[i].position.X += buffer[i].velocity.X; buffer[i].position.X += buffer[i].velocity.X;
buffer[i].velocity.Y += 0.2f; // Gravity buffer[i].velocity.Y += 0.2f; // Gravity
buffer[i].position.Y += buffer[i].velocity.Y; buffer[i].position.Y += buffer[i].velocity.Y;
} break; }
break;
case ParticleType.Smoke: case ParticleType.Smoke:
{ {
buffer[i].position.X += buffer[i].velocity.X; buffer[i].position.X += buffer[i].velocity.X;
buffer[i].velocity.Y -= 0.05f; // Upwards buffer[i].velocity.Y -= 0.05f; // Upwards
buffer[i].position.Y += buffer[i].velocity.Y; buffer[i].position.Y += buffer[i].velocity.Y;
buffer[i].radius += 0.5f; // Increment radius: smoke expands buffer[i].radius += 0.5f; // Increment radius: smoke expands
buffer[i].color.A -= 4; // Decrement alpha: smoke fades buffer[i].color.A -= 4; // Decrement alpha: smoke fades
// If alpha transparent, particle dies // If alpha transparent, particle dies
if (buffer[i].color.A < 4) if (buffer[i].color.A < 4)
{ {
buffer[i].alive = false; buffer[i].alive = false;
} }
} break; }
break;
case ParticleType.Fire: case ParticleType.Fire:
{ {
// Add a little horizontal oscillation to fire particles // 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].position.X += buffer[i].velocity.X + MathF.Cos(buffer[i].lifeTime * 215.0f);
buffer[i].velocity.Y -= 0.05f; // Upwards buffer[i].velocity.Y -= 0.05f; // Upwards
buffer[i].position.Y += buffer[i].velocity.Y; buffer[i].position.Y += buffer[i].velocity.Y;
buffer[i].radius -= 0.15f; // Decrement radius: fire shrinks buffer[i].radius -= 0.15f; // Decrement radius: fire shrinks
buffer[i].color.G -= 3; // Decrement green: fire turns reddish starting from yellow buffer[i].color.G -= 3; // Decrement green: fire turns reddish starting from yellow
// If radius too small, particle dies // If radius too small, particle dies
if (buffer[i].radius <= 0.02f) if (buffer[i].radius <= 0.02f)
{ {
buffer[i].alive = false; buffer[i].alive = false;
} }
} break; }
default: break; break;
default:
break;
} }
// Disable particle when out of screen // Disable particle when out of screen

View file

@ -135,7 +135,8 @@ public partial class Text3D : IExample
layerDistance = 0.01f; layerDistance = 0.01f;
wcfg = new WaveTextConfig(); 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.WaveOffset.X = wcfg.WaveOffset.Y = wcfg.WaveOffset.Z = 0.35f;
wcfg.WaveRange.X = wcfg.WaveRange.Y = wcfg.WaveRange.Z = 0.45f; wcfg.WaveRange.X = wcfg.WaveRange.Y = wcfg.WaveRange.Z = 0.45f;
@ -230,12 +231,16 @@ public partial class Text3D : IExample
} }
// Handle text layers changes // Handle text layers changes
if (IsKeyPressed(KeyboardKey.Home)) { if (layers > 1) if (IsKeyPressed(KeyboardKey.Home))
{
if (layers > 1)
{ {
--layers; --layers;
} }
} }
else if (IsKeyPressed(KeyboardKey.End)) { if (layers < TextMaxLayers) else if (IsKeyPressed(KeyboardKey.End))
{
if (layers < TextMaxLayers)
{ {
++layers; ++layers;
} }
@ -559,19 +564,27 @@ public partial class Text3D : IExample
// Front Face // Front Face
Rlgl.Normal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up 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, ty);
Rlgl.TexCoord2f(tx, th); Rlgl.Vertex3f(x, y, z + height); // Bottom Left Of The Texture and Quad Rlgl.Vertex3f(x, y, z); // Top 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(tx, th);
Rlgl.TexCoord2f(tw, ty); Rlgl.Vertex3f(x + width, y, z); // Top Right Of The Texture and Quad 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) if (backface)
{ {
// Back Face // Back Face
Rlgl.Normal3f(0.0f, -1.0f, 0.0f); // Normal Pointing Down 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(tx, ty);
Rlgl.TexCoord2f(tw, ty); Rlgl.Vertex3f(x + width, y, z); // Top Left Of The Texture and Quad Rlgl.Vertex3f(x, y, z); // Top Right 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(tw, ty);
Rlgl.TexCoord2f(tx, th); Rlgl.Vertex3f(x, y, z + height); // Bottom Right Of The Texture and Quad 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.End();
Rlgl.PopMatrix(); Rlgl.PopMatrix();