| 9 | |
| 10 | |
| 11 | int 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 |
nothing calls this directly
no test coverage detected