Repository navigation
Player release: Linux/macOS natives, DMD without colorization #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b661acb
unity: Ship the Linux natives in Linux players.
freezy 3c20683
unity: Import settings for the macOS natives, per CPU, without the ve…
freezy c3f1ecf
dmd: Offer one frame format per uncolorized source, so frames reach t…
freezy 03bbbea
test: Uncolorized frames through a real render graph reach every-form…
freezy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| // Visual Pinball Engine | ||
| // Copyright (C) 2026 freezy and VPE Team | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
| // Licensed under MIT. See https://opensource.org/license/mit. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using LibDmd; | ||
| using LibDmd.Frame; | ||
| using LibDmd.Output; | ||
| using NUnit.Framework; | ||
| using VisualPinball.Engine.DMD.Unity; | ||
| using VisualPinball.Unity; | ||
|
|
||
| namespace VisualPinball.Engine.DMD.Tests | ||
| { | ||
| /// <summary> | ||
| /// Frames from an uncolorized source go through a real render graph, into a destination taking | ||
| /// every format (like the in-scene DMD) and one taking RGB only (like the presentation output). | ||
| /// </summary> | ||
| public sealed class VpeGleSourceTests | ||
| { | ||
| private const int Width = 4, Height = 2; | ||
|
|
||
| [TestCase(DisplayFrameFormat.Dmd2, 3)] | ||
| [TestCase(DisplayFrameFormat.Dmd4, 15)] | ||
| [TestCase(DisplayFrameFormat.Dmd8, 255)] | ||
| public void GrayFramesReachBothDestinations(DisplayFrameFormat format, int max) | ||
| { | ||
| var source = VpeGleSource.Create(new DisplayConfig("dmd0", Width, Height), colorize: false, rgb: false); | ||
| var everyFormat = new EveryFormatDestination("every format"); | ||
| var rgbOnly = new RgbOnlyDestination("rgb only"); | ||
| using (Render(source, everyFormat, rgbOnly)) { | ||
| var frame = new byte[Width * Height]; | ||
| frame[0] = (byte)max; | ||
| source.Push(format, frame, frame.Length); | ||
| } | ||
|
|
||
| Assert.That(everyFormat.Frames, Has.Count.EqualTo(1), "in-scene"); | ||
| Assert.That(everyFormat.Frames[0].Format, Is.EqualTo("Gray8")); | ||
| Assert.That(everyFormat.Frames[0].Data[0], Is.EqualTo(255)); | ||
| Assert.That(rgbOnly.Frames, Has.Count.EqualTo(1), "presentation"); | ||
| Assert.That(rgbOnly.Frames[0].Format, Is.EqualTo("Rgb24")); | ||
| } | ||
|
|
||
| [Test] | ||
| public void RgbFramesReachBothDestinations() | ||
| { | ||
| var source = VpeGleSource.Create(new DisplayConfig("dmd0", Width, Height), colorize: false, rgb: true); | ||
| var everyFormat = new EveryFormatDestination("every format"); | ||
| var rgbOnly = new RgbOnlyDestination("rgb only"); | ||
| using (Render(source, everyFormat, rgbOnly)) { | ||
| var frame = new byte[Width * Height * 3]; | ||
| frame[0] = 200; | ||
| source.Push(DisplayFrameFormat.Dmd24, frame, frame.Length); | ||
| } | ||
|
|
||
| Assert.That(everyFormat.Frames, Has.Count.EqualTo(1)); | ||
| Assert.That(everyFormat.Frames[0].Format, Is.EqualTo("Rgb24")); | ||
| Assert.That(everyFormat.Frames[0].Data[0], Is.EqualTo(200)); | ||
| Assert.That(rgbOnly.Frames, Has.Count.EqualTo(1)); | ||
| Assert.That(rgbOnly.Frames[0].Format, Is.EqualTo("Rgb24")); | ||
| } | ||
|
|
||
| private static IDisposable Render(VpeGleSource source, params IDestination[] destinations) | ||
| { | ||
| var graph = new RenderGraph(new UndisposedReferences(), runOnMainThread: true) { | ||
| Name = "test", | ||
| Source = source, | ||
| Destinations = new List<IDestination>(destinations), | ||
| }; | ||
| return graph.Init().StartRendering(null, error => Assert.Fail(error.ToString())); | ||
| } | ||
|
|
||
| private class RgbOnlyDestination : IRgb24Destination | ||
| { | ||
| internal readonly List<(string Format, byte[] Data)> Frames = new List<(string, byte[])>(); | ||
|
|
||
| internal RgbOnlyDestination(string name) => Name = name; | ||
|
|
||
| public string Name { get; } | ||
| public bool IsAvailable => true; | ||
| public bool NeedsDuplicateFrames => false; | ||
| public bool NeedsIdentificationFrames => false; | ||
|
|
||
| public void RenderRgb24(DmdFrame frame) => Record("Rgb24", frame); | ||
| public void SetColor(DmdColor color) { } | ||
| public void SetPalette(DmdColor[] colors) { } | ||
| public void ClearColor() { } | ||
| public void ClearPalette() { } | ||
| public void ClearDisplay() { } | ||
| public void Dispose() { } | ||
|
|
||
| protected void Record(string format, DmdFrame frame) => Frames.Add((format, (byte[])frame.Data.Clone())); | ||
| } | ||
|
|
||
| // the formats of the in-scene DMD | ||
| private sealed class EveryFormatDestination : RgbOnlyDestination, IGray2Destination, IGray4Destination, IGray8Destination, IRgb565Destination, IFixedSizeDestination | ||
| { | ||
| internal EveryFormatDestination(string name) : base(name) { } | ||
|
|
||
| public Dimensions FixedSize => new Dimensions(Width, Height); | ||
| public bool DmdAllowHdScaling => false; | ||
|
|
||
| public void RenderGray2(DmdFrame frame) => Record("Gray2", frame); | ||
| public void RenderGray4(DmdFrame frame) => Record("Gray4", frame); | ||
| public void RenderGray8(DmdFrame frame) => Record("Gray8", frame); | ||
| public void RenderRgb565(DmdFrame frame) => Record("Rgb565", frame); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Visual Pinball Engine | ||
| // Copyright (C) 2026 freezy and VPE Team | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
| // Licensed under MIT. See https://opensource.org/license/mit. | ||
|
|
||
| // The two VisualPinball.Unity types VpeGleSource uses, so it compiles here without Unity. Same | ||
| // members and values as in VisualPinball.Unity's IGamelogicEngine.cs. | ||
| namespace VisualPinball.Unity | ||
| { | ||
| public enum DisplayFrameFormat | ||
| { | ||
| Dmd2, | ||
| Dmd4, | ||
| Dmd8, | ||
| Dmd24, | ||
| Segment, | ||
| AlphaNumeric, | ||
| Numeric, | ||
| Video24 | ||
| } | ||
|
|
||
| public class DisplayConfig | ||
| { | ||
| public readonly string Id; | ||
| public readonly int Width; | ||
| public readonly int Height; | ||
|
|
||
| public DisplayConfig(string id, int width, int height) | ||
| { | ||
| Id = id; | ||
| Width = width; | ||
| Height = height; | ||
| } | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
VisualPinball.Engine.DMD.Unity/Plugins/linux-x64/libcargs.so.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
VisualPinball.Engine.DMD.Unity/Plugins/linux-x64/libserialport.so.0.1.1.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
VisualPinball.Engine.DMD.Unity/Plugins/linux-x64/libserialport.so.0.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.