Author: rloach
Date: 2007-01-12 11:29:18 -0500 (Fri, 12 Jan 2007)
New Revision: 70929

Added:
   trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerState.cs
   trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerStateCollection.cs
Modified:
   trunk/Mono.Xna/src/Microsoft.Xna.Framework.Game/Game.cs
   trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/GraphicsDevice.cs
   trunk/Mono.Xna/src/Microsoft.Xna.Framework/Input/Enums.cs
Log:
Implement GraphicsDevice.Clear(), stub out SamplerState and 
SamplerStateCollection, fix Game.Tick, uncomment some GraphicsDevice functions, 
use SDL.NET enumeration keys explicitly.

Modified: trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/GraphicsDevice.cs
===================================================================
--- trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/GraphicsDevice.cs       
2007-01-12 16:17:43 UTC (rev 70928)
+++ trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/GraphicsDevice.cs       
2007-01-12 16:29:18 UTC (rev 70929)
@@ -5,6 +5,8 @@
 http://www.taoframework.com
 All rights reserved.
 
+Authors: Rob Loach (http://www.robloach.net)
+
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
@@ -27,6 +29,7 @@
 
 using Microsoft.Xna.Framework;
 using System;
+using Tao.OpenGl;
 
 namespace Microsoft.Xna.Framework.Graphics
 {
@@ -99,29 +102,23 @@
 
         public RenderState RenderState { get { throw new 
NotImplementedException(); } }
 
-        // TODO
-        //public SamplerStateCollection SamplerStates { get{ throw new 
NotImplementedException(); } }
+        public SamplerStateCollection SamplerStates { get{ throw new 
NotImplementedException(); } }
 
         public Rectangle ScissorRectangle { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
 
         public bool SoftwareVertexProcessing { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
 
-        // TODO
-        //public TextureCollection Textures { get{ throw new 
NotImplementedException(); } }
+        public TextureCollection Textures { get{ throw new 
NotImplementedException(); } }
 
-        // TODO
-        //public VertexDeclaration VertexDeclaration { get{ throw new 
NotImplementedException(); } set{ throw new NotImplementedException(); } }
+        public VertexDeclaration VertexDeclaration { get{ throw new 
NotImplementedException(); } set{ throw new NotImplementedException(); } }
 
-        // TODO
-        //public SamplerStateCollection VertexSamplerStates { get{ throw new 
NotImplementedException(); } }
+        public SamplerStateCollection VertexSamplerStates { get{ throw new 
NotImplementedException(); } }
 
         public VertexShader VertexShader { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
 
-        // TODO
-        //public TextureCollection VertexTextures { get{ throw new 
NotImplementedException(); } }
+        public TextureCollection VertexTextures { get{ throw new 
NotImplementedException(); } }
 
-        // TODO
-        //public VertexStreamCollection Vertices { get { throw new 
NotImplementedException(); } }
+        public VertexStreamCollection Vertices { get { throw new 
NotImplementedException(); } }
 
         public Viewport Viewport { get { throw new NotImplementedException(); 
} set { throw new NotImplementedException(); } }
 
@@ -141,7 +138,9 @@
 
         public void Clear(Color color) 
         {
-            // Todo: Fill in the colour
+            // TODO: Find a better way to do it with just one call to glClear.
+            Gl.glClearColor((float)color.R / 255f, (float)color.G / 255f, 
(float)color.B / 255f, (float)color.A / 255f);
+            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
         }
 
         public void Clear(ClearOptions options, Color color, float depth, int 
stencil) { throw new NotImplementedException(); }

Added: trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerState.cs
===================================================================
--- trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerState.cs 
2007-01-12 16:17:43 UTC (rev 70928)
+++ trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerState.cs 
2007-01-12 16:29:18 UTC (rev 70929)
@@ -0,0 +1,59 @@
+#region License
+/*
+MIT License
+Copyright � 2006 The Mono.Xna Team
+http://www.taoframework.com
+All rights reserved.
+
+Authors: Rob Loach (http://www.robloach.net)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+#endregion License
+
+using System;
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+    /// <summary>
+    /// Contains sampler states for the device.
+    /// </summary>
+    public sealed class SamplerState
+    {
+        public TextureAddressMode AddressU { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+
+        public TextureAddressMode AddressV { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+
+        public TextureAddressMode AddressW { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+
+        public Color BorderColor { get { throw new NotImplementedException(); 
} set { throw new NotImplementedException(); } }
+
+        public TextureFilter MagFilter { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+
+        public int MaxAnisotropy { get { throw new NotImplementedException(); 
} set { throw new NotImplementedException(); } }
+
+        public int MaxMipLevel { get { throw new NotImplementedException(); } 
set { throw new NotImplementedException(); } }
+
+        public TextureFilter MinFilter { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+
+        public TextureFilter MipFilter { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+
+        public float MipMapLevelOfDetailBias { get { throw new 
NotImplementedException(); } set { throw new NotImplementedException(); } }
+    }
+}

Added: 
trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerStateCollection.cs
===================================================================
--- 
trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerStateCollection.cs   
    2007-01-12 16:17:43 UTC (rev 70928)
+++ 
trunk/Mono.Xna/src/Microsoft.Xna.Framework/Graphics/SamplerStateCollection.cs   
    2007-01-12 16:29:18 UTC (rev 70929)
@@ -0,0 +1,39 @@
+#region License
+/*
+MIT License
+Copyright � 2006 The Mono.Xna Team
+http://www.taoframework.com
+All rights reserved.
+
+Authors: Rob Loach (http://www.robloach.net)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+#endregion License
+
+using System;
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+    /// <summary>Collection of SamplerState objects.</summary>
+    public sealed class SamplerStateCollection
+    {
+        public SamplerState this[int index] { get { throw new 
NotImplementedException(); } }
+    }
+}

Modified: trunk/Mono.Xna/src/Microsoft.Xna.Framework/Input/Enums.cs
===================================================================
--- trunk/Mono.Xna/src/Microsoft.Xna.Framework/Input/Enums.cs   2007-01-12 
16:17:43 UTC (rev 70928)
+++ trunk/Mono.Xna/src/Microsoft.Xna.Framework/Input/Enums.cs   2007-01-12 
16:29:18 UTC (rev 70929)
@@ -26,8 +26,7 @@
 #endregion License
 
 using System;
-using System.Collections.Generic;
-using System.Text;
+using SdlDotNet.Input;
 
 namespace Microsoft.Xna.Framework.Input
 {
@@ -74,32 +73,32 @@
         None=0
     }
     /// <summary>
-    /// 
+    /// Identifies a particular key on a keyboard.
     /// </summary>
     public enum Keys
     {
         None = 0,
         Back = 8,
-        Tab = 9,
-        Enter = 13,
-        CapsLock = 20,
-        Escape = 27,
-        Space = 32,
-        PageUp = 33,
-        PageDown = 34,
-        End = 35,
-        Home = 36,
-        Left = 37,
-        Up = 38,
-        Right = 39,
-        Down = 40,
+        Tab = Key.Tab,
+        Enter = Key.Return,
+        CapsLock = Key.CapsLock,
+        Escape = Key.Escape,
+        Space = Key.Space,
+        PageUp = Key.PageUp,
+        PageDown = Key.PageDown,
+        End = Key.End,
+        Home = Key.Home,
+        Left = Key.LeftArrow,
+        Up = Key.UpArrow,
+        Right = Key.RightArrow,
+        Down = Key.DownArrow,
         Select = 41,
         Print = 42,
         Execute = 43,
-        PrintScreen = 44,
-        Insert = 45,
-        Delete = 46,
-        Help = 47,
+        PrintScreen = Key.Print,
+        Insert = Key.Insert,
+        Delete = Key.Delete,
+        Help = Key.Help,
         D0 = 48,
         D1 = 49,
         D2 = 50,
@@ -110,67 +109,67 @@
         D7 = 55,
         D8 = 56,
         D9 = 57,
-        A = 65,
-        B = 66,
-        C = 67,
-        D = 68,
-        E = 69,
-        F = 70,
-        G = 71,
-        H = 72,
-        I = 73,
-        J = 74,
-        K = 75,
-        L = 76,
-        M = 77,
-        N = 78,
-        O = 79,
-        P = 80,
-        Q = 81,
-        R = 82,
-        S = 83,
-        T = 84,
-        U = 85,
-        V = 86,
-        W = 87,
-        X = 88,
-        Y = 89,
-        Z = 90,
-        LeftWindows = 91,
-        RightWindows = 92,
+        A = Key.A,
+        B = Key.B,
+        C = Key.C,
+        D = Key.D,
+        E = Key.E,
+        F = Key.F,
+        G = Key.G,
+        H = Key.H,
+        I = Key.I,
+        J = Key.J,
+        K = Key.K,
+        L = Key.L,
+        M = Key.M,
+        N = Key.N,
+        O = Key.O,
+        P = Key.P,
+        Q = Key.Q,
+        R = Key.R,
+        S = Key.S,
+        T = Key.T,
+        U = Key.U,
+        V = Key.V,
+        W = Key.W,
+        X = Key.X,
+        Y = Key.Y,
+        Z = Key.Z,
+        LeftWindows = Key.LeftWindows,
+        RightWindows = Key.RightWindows,
         Apps = 93,
         Sleep = 95,
-        NumPad0 = 96,
-        NumPad1 = 97,
-        NumPad2 = 98,
-        NumPad3 = 99,
-        NumPad4 = 100,
-        NumPad5 = 101,
-        NumPad6 = 102,
-        NumPad7 = 103,
-        NumPad8 = 104,
-        NumPad9 = 105,
-        Multiply = 106,
-        Add = 107,
+        NumPad0 = Key.Keypad0,
+        NumPad1 = Key.Keypad1,
+        NumPad2 = Key.Keypad2,
+        NumPad3 = Key.Keypad3,
+        NumPad4 = Key.Keypad4,
+        NumPad5 = Key.Keypad5,
+        NumPad6 = Key.Keypad6,
+        NumPad7 = Key.Keypad7,
+        NumPad8 = Key.Keypad8,
+        NumPad9 = Key.Keypad9,
+        Multiply = Key.KeypadMultiply,
+        Add = Key.KeypadPlus,
         Separator = 108,
-        Subtract = 109,
-        Decimal = 110,
-        Divide = 111,
-        F1 = 112,
-        F2 = 113,
-        F3 = 114,
-        F4 = 115,
-        F5 = 116,
-        F6 = 117,
-        F7 = 118,
-        F8 = 119,
-        F9 = 120,
-        F10 = 121,
-        F11 = 122,
-        F12 = 123,
-        F13 = 124,
-        F14 = 125,
-        F15 = 126,
+        Subtract = Key.Minus,
+        Decimal = Key.Period,
+        Divide = Key.KeypadDivide,
+        F1 = Key.F1,
+        F2 = Key.F2,
+        F3 = Key.F3,
+        F4 = Key.F4,
+        F5 = Key.F5,
+        F6 = Key.F6,
+        F7 = Key.F7,
+        F8 = Key.F8,
+        F9 = Key.F9,
+        F10 = Key.F10,
+        F11 = Key.F11,
+        F12 = Key.F12,
+        F13 = Key.F13,
+        F14 = Key.F14,
+        F15 = Key.F15,
         F16 = 127,
         F17 = 128,
         F18 = 129,
@@ -180,14 +179,14 @@
         F22 = 133,
         F23 = 134,
         F24 = 135,
-        NumLock = 144,
-        Scroll = 145,
-        LeftShift = 160,
-        RightShift = 161,
-        LeftControl = 162,
-        RightControl = 163,
-        LeftAlt = 164,
-        RightAlt = 165,
+        NumLock = Key.NumLock,
+        Scroll = Key.ScrollLock,
+        LeftShift = Key.LeftShift,
+        RightShift = Key.RightShift,
+        LeftControl = Key.LeftControl,
+        RightControl = Key.RightControl,
+        LeftAlt = Key.LeftAlt,
+        RightAlt = Key.RightAlt,
         BrowserBack = 166,
         BrowserForward = 167,
         BrowserRefresh = 168,

Modified: trunk/Mono.Xna/src/Microsoft.Xna.Framework.Game/Game.cs
===================================================================
--- trunk/Mono.Xna/src/Microsoft.Xna.Framework.Game/Game.cs     2007-01-12 
16:17:43 UTC (rev 70928)
+++ trunk/Mono.Xna/src/Microsoft.Xna.Framework.Game/Game.cs     2007-01-12 
16:29:18 UTC (rev 70929)
@@ -229,8 +229,12 @@
                {
             if (this.exitRequested)
                 return;
+
+            // The program isn't active, so be nice to other applications
             if (!this.isActive)
                 
System.Threading.Thread.Sleep((int)this.inactiveSleepTime.TotalMilliseconds);
+
+            // Step the clock forward
             this.clock.Step();
             this.elapsedRealTime = this.clock.ElapsedTime;
             if (this.elapsedRealTime < TimeSpan.Zero)
@@ -240,65 +244,78 @@
             this.gameTime.TotalRealTime = this.clock.CurrentTime;
             this.gameTime.ElapsedRealTime = this.elapsedRealTime;
             this.drawRunningSlowly = false;
+            bool finishTickAndDraw = false;
+
             if (this.isFixedTimeStep)
             {
                 this.accumulatedElapsedGameTime += this.elapsedRealTime;
-                long num1 = this.accumulatedElapsedGameTime.Ticks / 
this.targetElapsedTime.Ticks;
+                long time = this.accumulatedElapsedGameTime.Ticks / 
this.targetElapsedTime.Ticks;
                 this.accumulatedElapsedGameTime = 
TimeSpan.FromTicks(this.accumulatedElapsedGameTime.Ticks % 
this.targetElapsedTime.Ticks);
                 this.lastFrameElapsedGameTime = TimeSpan.Zero;
-                TimeSpan span1 = this.targetElapsedTime;
-                if (num1 <= 0)
+                if (time <= 0)
+                    finishTickAndDraw = true;
+                else
+                    finishTickAndDraw = 
PerformTimeStep(this.targetElapsedTime, time);
+            }
+            if (finishTickAndDraw == false)
+            {
+                TimeSpan span2 = this.elapsedRealTime;
+                try
                 {
-                    goto FinishTickAndDraw;
+                    this.gameTime.ElapsedGameTime = 
this.lastFrameElapsedGameTime = span2;
+                    this.gameTime.TotalGameTime = this.totalGameTime;
+                    this.Update(this.gameTime);
                 }
-                while (num1 > 1)
+                finally
                 {
-                    this.gameTime.IsRunningSlowly = this.drawRunningSlowly = 
true;
-                    num1--;
-                    try
-                    {
-                        this.gameTime.ElapsedGameTime = span1;
-                        this.gameTime.TotalGameTime = this.totalGameTime;
-                        this.Update(this.gameTime);
-                        continue;
-                    }
-                    finally
-                    {
-                        this.lastFrameElapsedGameTime += span1;
-                        this.totalGameTime += span1;
-                    }
+                    this.totalGameTime += span2;
                 }
-                this.gameTime.IsRunningSlowly = false;
+            }
+            if (!this.exitRequested)
+                this.DrawFrame();
+               }
+
+        /// <summary>
+        /// Performs a controled time step.
+        /// </summary>
+        /// <param name="elapsedTime"></param>
+        /// <param name="time"></param>
+        /// <returns></returns>
+        /// <remarks>Used by Game.Tick().</remarks>
+        private bool PerformTimeStep(TimeSpan elapsedTime, long time)
+        {
+            while (time > 1)
+            {
+                this.gameTime.IsRunningSlowly = this.drawRunningSlowly = true;
+                time--;
                 try
                 {
-                    this.gameTime.ElapsedGameTime = span1;
+                    this.gameTime.ElapsedGameTime = elapsedTime;
                     this.gameTime.TotalGameTime = this.totalGameTime;
                     this.Update(this.gameTime);
-                    goto FinishTickAndDraw;
+                    continue;
                 }
                 finally
                 {
-                    this.lastFrameElapsedGameTime += span1;
-                    this.totalGameTime += span1;
+                    this.lastFrameElapsedGameTime += elapsedTime;
+                    this.totalGameTime += elapsedTime;
                 }
             }
-            TimeSpan span2 = this.elapsedRealTime;
+            this.gameTime.IsRunningSlowly = false;
             try
             {
-                this.gameTime.ElapsedGameTime = this.lastFrameElapsedGameTime 
= span2;
+                this.gameTime.ElapsedGameTime = elapsedTime;
                 this.gameTime.TotalGameTime = this.totalGameTime;
                 this.Update(this.gameTime);
+                return true;
             }
             finally
             {
-                this.totalGameTime += span2;
+                this.lastFrameElapsedGameTime += elapsedTime;
+                this.totalGameTime += elapsedTime;
             }
-        FinishTickAndDraw:
-            if (!this.exitRequested)
-            {
-                this.DrawFrame();
-            }
-               }
+            return false;
+        }
 
                #endregion Public methods
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to