MCPcopy Create free account
hub / github.com/LukasBanana/LLGL / Run

Method Run

examples/CSharp/ExampleBase/ExampleBase.cs:82–156  ·  view source on GitHub ↗
(string title, string[] args)

Source from the content-addressed store, hash-verified

80 }
81
82 public int Run(string title, string[] args)
83 {
84 // Configure example by input arguments
85 Func<string, bool> HasArgument = (string search) =>
86 {
87 foreach (string arg in args)
88 {
89 if (arg == search)
90 {
91 return true;
92 }
93 }
94 return false;
95 };
96
97 string rendererModule = ExampleBase.GetSelectedRendererModule(args);
98 if (HasArgument("-d") || HasArgument("--debug"))
99 {
100 Debugger = new LLGL.RenderingDebugger();
101 }
102
103 var report = new LLGL.Report();
104 Renderer = LLGL.RenderSystem.Load(new LLGL.RenderSystemDescriptor(rendererModule, debugger: Debugger), report);
105 if (Renderer == null)
106 {
107 Console.Write(report.ToString());
108 return 1;
109 }
110
111 var swapChainDesc = new LLGL.SwapChainDescriptor(resolution: initialResolution, samples: 8);
112 swapChainDesc.DebugName = "MySwapChain";
113 SwapChain = Renderer.CreateSwapChain(swapChainDesc);
114 SwapChain.SetVsyncInterval(1);
115
116 ExampleBase.PrintRendererInfo(Renderer.RendererInfo);
117
118 // Create command buffer
119 CmdBuffer = Renderer.CreateCommandBuffer(new LLGL.CommandBufferDescriptor() { Flags = LLGL.CommandBufferFlags.ImmediateSubmit });
120 CmdBuffer.DebugName = "MyCommandBuffer";
121
122 // Create resources
123 OnInitialize();
124
125 // Change window title and register event listener
126 var window = SwapChain.Surface.AsWindow();
127 window.AddEventListener(new MyEventListener(this));
128
129 window.Title = $"LLGL C# Example: {title} ( {Renderer.RendererInfo.RendererName} )";
130 window.Show();
131
132 // Main loop
133 while (LLGL.Surface.ProcessEvents() && !window.HasQuit)
134 {
135 if (profileNextFrame)
136 {
137 // Record frame timings
138 Debugger.TimeRecording = true;
139 OnDrawFrame();

Callers 1

MainMethod · 0.45

Calls 15

HasArgumentFunction · 0.85
OnDrawFrameFunction · 0.85
ToStringMethod · 0.80
CreateSwapChainMethod · 0.65
SetVsyncIntervalMethod · 0.65
CreateCommandBufferMethod · 0.65
PresentMethod · 0.65
FlushProfileMethod · 0.65
LoadMethod · 0.45
WriteMethod · 0.45
PrintRendererInfoMethod · 0.45

Tested by

no test coverage detected