static void Main(string[] args) { // TEST Test test = new Test(); float[] flArray = test.GenerateArray(); for (int i = 0; i < flArray.Length; i++ ) { Console.WriteLine(flArray[i] + " i = " + i); } int width = 1280; int height = 720; Window window = new Window(width, height); DeviceManager deviceManager = new DeviceManager(); if (!deviceManager.Init(window)) { Console.WriteLine("Could not create DeviceManager"); } Renderer renderer = new Renderer(deviceManager); if (!renderer.Init()) { Console.WriteLine("Could not create renderer"); } // Wtf? why must i first poll the state twice before it actually gives back the real result? KeyboardState kbState = new KeyboardState(window); kbState.IsKeyDown(27); kbState.IsKeyDown(27); // camera Camera camera = new Camera(); camera.SetCameraProjection(50.0f, (float) width / (float) height, 0.25f, 250.0f); // load default shader ShaderObject shaderObject = new ShaderObject("path", deviceManager); // load sponza GeometryLoader gLoader = new GeometryLoader(); Mesh[] meshes = gLoader.LoadOBJX("resources/sponza_custom.mh"); FPSCounter fpsCounter = new FPSCounter(); bool running = true; while (window.IsAlive() && running) { window.UpdateWindow(); renderer.ClearD3D(deviceManager); for (int i = 0; i < meshes.Length; i++) { Mesh mesh = meshes[i]; renderer.RenderMesh(mesh, deviceManager, camera, shaderObject); } renderer.Present(deviceManager); // update camera.UpdateRotation(); camera.UpdateViewMatrix(); // Update Keyboard kbState = new KeyboardState(window); if (kbState.IsKeyDown(27)) { running = false; } // FPS // fpsCounter.GetFPS(); } // Close Program for (int i = 0; i < meshes.Length; i++) { meshes[i].Destroy(); } shaderObject.Destroy(); deviceManager.Destroy(); renderer.Destroy(); }
public void RenderMesh(Mesh mesh, DeviceManager deviceManager, Camera camera, ShaderObject shaderObject) { Render(mesh.GetHandle(), deviceManager.GetDeviceManagerHandle(), camera.GetHandle(), shaderObject.GetHandle()); }