Exemple #1
0
        /// <summary>
        /// The actual cleanup method for <see cref="Graphics"/>.
        /// </summary>
        private void Shutdown()
        {
            camera = null;

            if(model.SafeDispose()) model = null;
            if(shader.SafeDispose()) shader = null;
            if(directXDevice.SafeDispose()) directXDevice = null;
        }
Exemple #2
0
        /// <summary>
        /// Initializes the current <see cref="Graphics"/> object.
        /// </summary>
        /// <param name="height">The height of the window.</param>
        /// <param name="width">The width of the window.</param>
        /// <param name="hwnd">The pointer to the current <see cref="RenderForm"/>.</param>
        /// <returns>True if initialization is successful.</returns>
        public bool Initialize(int height, int width, IntPtr hwnd)
        {
            VSync = true;
            FullScreen = false;
            ScreenDepth = 1000.1f;
            ScreenNear = 0.1f;
            Hwnd = hwnd;

            directXDevice = new D3D();
            if(directXDevice == null)
                return false;

            if(!directXDevice.Initialize(height, width, 1000f, 0.1f, Hwnd))
            {
                MessageBox.Show("Could not initialize Direct3D");
                return false;
            }

            camera = new Camera {Position = new Vector3(0f, 0f, -2.5f)};

            model = new Model();
            if(!model.Initialize(directXDevice.Device))
            {
                MessageBox.Show("Could not initialize model buffers.");
                return false;
            }

            shader = new TextureShader();
            if(!shader.Initialize(directXDevice.Device))
            {
                MessageBox.Show("Could not initialize shader");
                return false;
            }

            return true;
        }