public bool Initialize(Device device, DeviceContext deviceContext, IntPtr windowHandle, int screanWidth, int screenHeight, Matrix baseViewMatrix) { // Store the screen width and height. ScreenWidth = screanWidth; ScreenHeight = screenHeight; // Store the base view matrix. BaseViewMatrix = baseViewMatrix; // Create the font object. Font = new Font(); // Initialize the font object. if (!Font.Initialize(device, "fontdata.txt", "font.dds")) return false; // Create the font shader object. FontShader = new FontShader(); // Initialize the font shader object. if (!FontShader.Initialize(device, windowHandle)) return false; // Initialize the first sentence. if (!InitializeSentence(out sentences[0], 32, device)) return false; // Now update the sentence vertex buffer with the new string information. if (!UpdateSentece(ref sentences[0], "Render Count:", 20, 20, 1, 1, 1, deviceContext)) return false; return true; }
public bool Initialize(Device device, DeviceContext deviceContext, IntPtr windowHandle, int screanWidth, int screenHeight, Matrix baseViewMatrix) { // Store the screen width and height. ScreenWidth = screanWidth; ScreenHeight = screenHeight; // Store the base view matrix. BaseViewMatrix = baseViewMatrix; // Create the font object. Font = new Font(); // Initialize the font object. if (!Font.Initialize(device, "fontdata.txt", "font.dds")) return false; // Create the font shader object. FontShader = new FontShader(); // Initialize the font shader object. if (!FontShader.Initialize(device, windowHandle)) return false; // Initialize the sentences. if (!InitializeSentence(out sentences[0], 150, device)) return false; if (!InitializeSentence(out sentences[1], 32, device)) return false; if (!InitializeSentence(out sentences[2], 16, device)) return false; if (!InitializeSentence(out sentences[3], 16, device)) return false; if (!InitializeSentence(out sentences[4], 16, device)) return false; if (!InitializeSentence(out sentences[5], 16, device)) return false; if (!InitializeSentence(out sentences[6], 16, device)) return false; if (!InitializeSentence(out sentences[7], 16, device)) return false; if (!InitializeSentence(out sentences[8], 16, device)) return false; if (!InitializeSentence(out sentences[9], 16, device)) return false; if (!InitializeSentence(out sentences[10], 32, device)) return false; return true; }
public bool Initialize(SystemConfiguration configuration, IntPtr windowHandle) { if (Input == null) { Input = new InputClass(); if (!Input.Initialize(configuration, windowHandle)) { MessageBox.Show("Could not initialize input object", "Error", MessageBoxButtons.OK); return false; } } // Create the Direct3D object. D3D = new DX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { MessageBox.Show("Could not initialize Direct3D", "Error", MessageBoxButtons.OK); return false; } // Create the camera object Camera = new Camera(); // Initialize a base view matrix the camera for 2D user interface rendering. Camera.SetPosition(0, 0, -1); Camera.Render(); var baseViewMatrix = Camera.ViewMatrix; // Set the initial position of the camera. var cameraX = 50f; var cameraY = 2f; var cameraZ = -7f; Camera.SetPosition(cameraX, cameraY, cameraZ); // Create the terrain object. Terrain = new Terrain(); // Initialize the terrain object. if (!Terrain.Initialize(D3D.Device)) { MessageBox.Show("Could not initialize the terrain object", "Error", MessageBoxButtons.OK); return false; } // Create the light shader object. ColorShader = new ColorShader(); // Initialize the light shader object. if (!ColorShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the light shader", "Error", MessageBoxButtons.OK); return false; } // Create and initialize Timer. Timer = new Timer(); if (!Timer.Initialize()) { MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK); return false; } // Create the position object. Position = new Position(); // Set the initial position of the viewer to the same as the initial camera position. Position.SetPosition(new Vector3(cameraX, cameraY, cameraZ)); // Create and initialize the FPS object. FPS = new FPS(); FPS.Initialize(); // Create and initialize the CPU. CPU = new CPU(); CPU.Initialize(); // Create the font shader object. FontShader = new FontShader(); // Initialize the font shader object. if (!FontShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize font shader object", "Error", MessageBoxButtons.OK); return false; } // Create the text object. Text = new Text(); if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix)) { MessageBox.Show("Could not initialize the text object", "Error", MessageBoxButtons.OK); return false; } if (!Text.SetVideoCard(D3D.VideoCardDescription, D3D.VideoCardMemory, D3D.DeviceContext)) { MessageBox.Show("Could not set video card into the text object", "Error", MessageBoxButtons.OK); return false; } return true; }
public bool Initialize(SystemConfiguration configuration, IntPtr windowHandle) { if (Input == null) { Input = new InputClass(); if (!Input.Initialize(configuration, windowHandle)) { MessageBox.Show("Could not initialize input object", "Error", MessageBoxButtons.OK); return false; } } // Create the Direct3D object. D3D = new DX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { MessageBox.Show("Could not initialize Direct3D", "Error", MessageBoxButtons.OK); return false; } // Create the camera object Camera = new Camera(); // Initialize a base view matrix the camera for 2D user interface rendering. Camera.SetPosition(0, 0, -1); Camera.Render(); var baseViewMatrix = Camera.ViewMatrix; // Set the initial position of the camera. var cameraX = 50f; var cameraY = 18f; var cameraZ = -7f; Camera.SetPosition(cameraX, cameraY, cameraZ); // Create the terrain object. Terrain = new HeightMapTerrain(); // Initialize the terrain object. if (!(Terrain as HeightMapTerrain).Initialize(D3D.Device, "heightMap01.bmp", "dirt02.dds")) { MessageBox.Show("Could not initialize the terrain object", "Error", MessageBoxButtons.OK); return false; } // Create and initialize Timer. Timer = new Timer(); if (!Timer.Initialize()) { MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK); return false; } // Create the position object. Position = new Position(); // Set the initial position of the viewer to the same as the initial camera position. Position.SetPosition(new Vector3(cameraX, cameraY, cameraZ)); // Create and initialize the FPS object. FPS = new FPS(); FPS.Initialize(); // Create and initialize the CPU. CPU = new CPU(); CPU.Initialize(); // Create the font shader object. FontShader = new FontShader(); // Initialize the font shader object. if (!FontShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize font shader object", "Error", MessageBoxButtons.OK); return false; } // Create the text object. Text = new Text(); if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix)) { MessageBox.Show("Could not initialize the text object", "Error", MessageBoxButtons.OK); return false; } // Set the video card information in the text object. if (!Text.SetVideoCard(D3D.VideoCardDescription, D3D.VideoCardMemory, D3D.DeviceContext)) { MessageBox.Show("Could not set video card into the text object", "Error", MessageBoxButtons.OK); return false; } // Create the height map terrain shader object. HeightMapTerrainShader = new HeightMapTerrainShader(); // Initialize the height map terrain shader object. if (!HeightMapTerrainShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the height map terrain shader", "Error", MessageBoxButtons.OK); return false; } // Create the light object. Light = new Light(); // Initialize the light object Light.SetAmbientColor(0.5f, 0.5f, 0.5f, 1f); Light.SetDiffuseColor(1f, 1f, 1f, 1f); Light.SetDirection(0f, 0f, 0.75f); // Create the frustum object. Frustum = new Frustum(); // Create the quad tree object. QuadTree = new QuadTree(); // Initialize the quad tree object. if (!QuadTree.Initialize(D3D.Device, Terrain)) { MessageBox.Show("Could not initialize the quad tree object", "Error", MessageBoxButtons.OK); return false; } return true; }