예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WorldViewProjection"/> class.
        /// </summary>
        /// <param name="graphics">The graphics interface to use.</param>
        public Light(GorgonGraphics graphics)
        {
            _lightData[0].Attenuation   = 6.0f;
            _lightData[0].LightColor    = GorgonColor.White;
            _lightData[0].LightPosition = Vector3.Zero;
            _lightData[0].SpecularColor = GorgonColor.White;
            _lightData[0].SpecularPower = 512.0f;

            _buffer = graphics.Buffers.CreateConstantBuffer("LightBuffer",
                                                            new GorgonConstantBufferSettings
            {
                SizeInBytes = LightData.Size * _lightData.Length,
                Usage       = BufferUsage.Default
            });

            _lightStore = new GorgonDataStream(_buffer.SizeInBytes);
            unsafe
            {
                DirectAccess.ZeroMemory(_lightStore.UnsafePointer, _buffer.SizeInBytes);
                var data = (LightData *)_lightStore.UnsafePointer;
                *   data = _lightData[0];
            }

            _buffer.Update(_lightStore);

            graphics.Shaders.PixelShader.ConstantBuffers[1] = _buffer;
        }
예제 #2
0
 /// <summary>
 /// Function to zero out the memory pointed to by this pointer.
 /// </summary>
 /// <param name="destination">Destination pointer to zero out.</param>
 /// <param name="size">Amount of memory to zero out.</param>
 /// <remarks>Since a pointer doesn't have a size associated with it, care must be taken to not overstep the bounds of the data pointed at by the pointer.</remarks>
 public static void ZeroMemory(this IntPtr destination, int size)
 {
     DirectAccess.ZeroMemory(destination, size);
 }