MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / main

Function main

deps/LLGL/examples/Cpp/MultiContext/Example.cpp:11–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11int main(int argc, char* argv[])
12{
13 try
14 {
15 // Set report callback to standard output
16 LLGL::Log::SetReportCallbackStd();
17
18 // Load render system module
19 LLGL::RenderingDebugger debugger;
20 auto renderer = LLGL::RenderSystem::Load(GetSelectedRendererModule(argc, argv), nullptr, &debugger);
21
22 std::cout << "LLGL Renderer: " << renderer->GetName() << std::endl;
23
24 // Create two render contexts
25 LLGL::RenderContextDescriptor contextDesc;
26 {
27 contextDesc.videoMode.resolution = { 640, 480 };
28 contextDesc.vsync.enabled = true;
29 contextDesc.samples = 8;
30 }
31 auto context1 = renderer->CreateRenderContext(contextDesc);
32 auto context2 = renderer->CreateRenderContext(contextDesc);
33
34 // Get command queue and create command buffer
35 auto commandQueue = renderer->GetCommandQueue();
36 auto commands = renderer->CreateCommandBuffer();
37
38 // Create input handler
39 auto input = std::make_shared<LLGL::Input>();
40
41 auto& window1 = static_cast<LLGL::Window&>(context1->GetSurface());
42 auto& window2 = static_cast<LLGL::Window&>(context2->GetSurface());
43
44 window1.AddEventListener(input);
45 window2.AddEventListener(input);
46
47 // Set window titles
48 window1.SetTitle(L"LLGL Example: Multi Context (1)");
49 window2.SetTitle(L"LLGL Example: Multi Context (2)");
50
51 // Set window positions
52 LLGL::Extent2D desktopResolution;
53 if (auto display = LLGL::Display::InstantiatePrimary())
54 desktopResolution = display->GetDisplayMode().resolution;
55
56 const LLGL::Offset2D desktopCenter
57 {
58 static_cast<int>(desktopResolution.width)/2,
59 static_cast<int>(desktopResolution.height)/2
60 };
61
62 window1.SetPosition({ desktopCenter.x - 700, desktopCenter.y - 480/2 });
63 window2.SetPosition({ desktopCenter.x + 700 - 640, desktopCenter.y - 480/2 });
64
65 // Show windows
66 window1.Show();
67 window2.Show();
68

Callers

nothing calls this directly

Calls 15

SetReportCallbackStdFunction · 0.85
findFunction · 0.85
GetSurfaceMethod · 0.80
AppendAttributeMethod · 0.80
KeyPressedMethod · 0.80
KeyDownMethod · 0.80
GetNameMethod · 0.45
CreateRenderContextMethod · 0.45
GetCommandQueueMethod · 0.45
CreateCommandBufferMethod · 0.45
AddEventListenerMethod · 0.45

Tested by

no test coverage detected