Esempio n. 1
0
        /// <summary>
        /// The device has been created.  Resources that are not lost on
        /// Reset() can be created here
        /// </summary>
        public void InitializeDeviceObjects()
        {
            Pool vertexBufferPool;
            Caps caps;

            // Initialize the font's internal textures
            font = new Font(device, new System.Drawing.Font("Arial",
                                                            12.0f, System.Drawing.FontStyle.Bold));

            // Load the main file object
            if (airplane == null)
            {
                airplane = new GraphicsMesh();
            }

            airplane.Create(device,
                            "StencilBufferShadowVolume.Content.", "air2.md3dm",
                            System.Reflection.Assembly.GetExecutingAssembly());

            // Load the terrain
            if (terrainObject == null)
            {
                terrainObject = new GraphicsMesh();
            }

            terrainObject.Create(device,
                                 "StencilBufferShadowVolume.Content.", "seafloor.md3dm",
                                 System.Reflection.Assembly.GetExecutingAssembly());

            // Set a reasonable vertex type
            terrainObject.SetVertexFormat(MeshVertex.Format);
            airplane.SetVertexFormat(MeshVertex.Format);

            // Get the device capabilities

            caps = device.DeviceCaps;

            if (caps.SurfaceCaps.SupportsVidVertexBuffer)
            {
                vertexBufferPool = Pool.VideoMemory;
            }
            else
            {
                vertexBufferPool = Pool.SystemMemory;
            }

            // Create a big square for rendering the mirror, we don't
            // need to recreate this every time, if the VertexBuffer
            // is destroyed (by a call to Reset for example), it will
            // automatically be recreated and the 'Created' event fired.
            squareVertexBuffer = new VertexBuffer(typeof(ShadowVertex), 4,
                                                  device, Usage.WriteOnly, ShadowVertex.Format,
                                                  vertexBufferPool);
            squareVertexBuffer.Created += new System.EventHandler(
                this.ShadowCreated);

            // Manually fire the created event the first time
            this.ShadowCreated(squareVertexBuffer, null);
        }
Esempio n. 2
0
        /// <summary>
        /// The device has been created.  Resources that are not lost on
        /// Reset() can be created here.
        /// </summary>
        public void InitializeDeviceObjects()
        {
            // Load the skybox
            skyBoxMesh.Create(device, "Billboard.Content.", "skybox2.md3dm",
                              System.Reflection.Assembly.GetExecutingAssembly());

            // Load the terrain
            terrainMesh.Create(device, "Billboard.Content.", "seafloor.md3dm",
                               System.Reflection.Assembly.GetExecutingAssembly());

            fpsTimer = new FpsTimerTool(device);
        }