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

Function main

deps/LLGL/examples/Cpp/MultiRenderer/Example.cpp:282–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280 */
281
282int main(int argc, char* argv[])
283{
284 try
285 {
286 // Create main window
287 const LLGL::Extent2D resolution{ 800, 600 };
288
289 LLGL::WindowDescriptor mainWindowDesc;
290 {
291 mainWindowDesc.title = L"LLGL Example: Multi Renderer ( OpenGL, Vulkan, Direct3D 11, Direct3D 12 )";
292 mainWindowDesc.size = resolution;
293 mainWindowDesc.centered = true;
294 }
295 auto mainWindow = LLGL::Window::Create(mainWindowDesc);
296
297 // Create renderers
298 const int halfWidth = static_cast<int>(resolution.width/2);
299 const int halfHeight = static_cast<int>(resolution.height/2);
300
301 MyRenderer myRenderers[4] =
302 {
303 { "Vulkan", *mainWindow, { 0, 0 }, LLGL::Viewport{ { 0, 0 }, resolution } },
304 { "OpenGL", *mainWindow, { halfWidth, 0 }, LLGL::Viewport{ { -halfWidth, 0 }, resolution } },
305 { "Direct3D11", *mainWindow, { 0, halfHeight }, LLGL::Viewport{ { 0, -halfHeight }, resolution } },
306 { "Direct3D12", *mainWindow, { halfWidth, halfHeight }, LLGL::Viewport{ { -halfWidth, -halfHeight }, resolution } },
307 };
308
309 mainWindow->Show();
310
311 // Create resources
312 auto cubeVertices = GenerateTexturedCubeVertices();
313 auto cubeIndices = GenerateTexturedCubeTriangleIndices();
314
315 for (auto& renderer : myRenderers)
316 renderer.CreateResources(cubeVertices, cubeIndices);
317
318 auto input = std::make_shared<LLGL::Input>();
319 mainWindow->AddEventListener(input);
320
321 // Initialize matrices (OpenGL needs a unit-cube NDC-space)
322 const float aspectRatio = static_cast<float>(mainWindowDesc.size.width) / static_cast<float>(mainWindowDesc.size.height);
323 const float nearPlane = 0.1f;
324 const float farPlane = 100.0f;
325 const float fieldOfView = 45.0f;
326
327 Gs::Matrix4f projMatrices[4];
328 for (int i = 0; i < 4; ++i)
329 {
330 projMatrices[i] = myRenderers[i].BuildPerspectiveProjection(aspectRatio, nearPlane, farPlane, fieldOfView);
331 myRenderers[i].GetSubWindow().AddEventListener(input);
332 }
333
334 Gs::Matrix4f viewMatrix, worldMatrix;
335 Gs::Translate(viewMatrix, Gs::Vector3f(0, 0, 5));
336
337 // Enter main loop
338 while (mainWindow->ProcessEvents() && !input->KeyDown(LLGL::Key::Escape))
339 {

Callers

nothing calls this directly

Calls 11

CreateResourcesMethod · 0.80
KeyDownMethod · 0.80
KeyPressedMethod · 0.80
RenderMethod · 0.80
ShowMethod · 0.45
AddEventListenerMethod · 0.45
ProcessEventsMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected