OSDN Git Service

Added anti-aliasing control
authorLatif Khalifa <latifer@streamgrid.net>
Tue, 17 May 2011 17:45:26 +0000 (17:45 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Tue, 17 May 2011 17:45:26 +0000 (17:45 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@866 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Dialogs/PrimWorkshop.Designer.cs
Radegast/GUI/Dialogs/PrimWorkshop.cs

index f1b60aa..c77d62b 100644 (file)
@@ -67,6 +67,7 @@ namespace Radegast
             this.gbZoom = new System.Windows.Forms.GroupBox();
             this.label2 = new System.Windows.Forms.Label();
             this.btnResetView = new System.Windows.Forms.Button();
+            this.cbAA = new System.Windows.Forms.CheckBox();
             this.chkWireFrame = new System.Windows.Forms.CheckBox();
             this.label1 = new System.Windows.Forms.Label();
             this.ctxObjects = new System.Windows.Forms.ContextMenuStrip(this.components);
@@ -123,6 +124,7 @@ namespace Radegast
             // 
             this.gbZoom.Controls.Add(this.label2);
             this.gbZoom.Controls.Add(this.btnResetView);
+            this.gbZoom.Controls.Add(this.cbAA);
             this.gbZoom.Controls.Add(this.chkWireFrame);
             this.gbZoom.Controls.Add(this.label1);
             this.gbZoom.Controls.Add(this.scrollZoom);
@@ -156,6 +158,16 @@ namespace Radegast
             this.btnResetView.UseVisualStyleBackColor = true;
             this.btnResetView.Click += new System.EventHandler(this.btnReset_Click);
             // 
+            // cbAA
+            // 
+            this.cbAA.AutoSize = true;
+            this.cbAA.Location = new System.Drawing.Point(89, 32);
+            this.cbAA.Name = "cbAA";
+            this.cbAA.Size = new System.Drawing.Size(82, 17);
+            this.cbAA.TabIndex = 21;
+            this.cbAA.Text = "Anti-aliasing";
+            this.cbAA.UseVisualStyleBackColor = true;
+            // 
             // chkWireFrame
             // 
             this.chkWireFrame.AutoSize = true;
@@ -186,46 +198,46 @@ namespace Radegast
             this.returnToolStripMenuItem,
             this.deleteToolStripMenuItem});
             this.ctxObjects.Name = "ctxObjects";
-            this.ctxObjects.Size = new System.Drawing.Size(153, 142);
+            this.ctxObjects.Size = new System.Drawing.Size(110, 120);
             this.ctxObjects.Opening += new System.ComponentModel.CancelEventHandler(this.ctxObjects_Opening);
             // 
             // touchToolStripMenuItem
             // 
             this.touchToolStripMenuItem.Name = "touchToolStripMenuItem";
-            this.touchToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.touchToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
             this.touchToolStripMenuItem.Text = "Touch";
             this.touchToolStripMenuItem.Click += new System.EventHandler(this.touchToolStripMenuItem_Click);
             // 
             // sitToolStripMenuItem
             // 
             this.sitToolStripMenuItem.Name = "sitToolStripMenuItem";
-            this.sitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.sitToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
             this.sitToolStripMenuItem.Text = "Sit";
             this.sitToolStripMenuItem.Click += new System.EventHandler(this.sitToolStripMenuItem_Click);
             // 
             // toolStripMenuItem1
             // 
             this.toolStripMenuItem1.Name = "toolStripMenuItem1";
-            this.toolStripMenuItem1.Size = new System.Drawing.Size(149, 6);
+            this.toolStripMenuItem1.Size = new System.Drawing.Size(106, 6);
             // 
             // takeToolStripMenuItem
             // 
             this.takeToolStripMenuItem.Name = "takeToolStripMenuItem";
-            this.takeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.takeToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
             this.takeToolStripMenuItem.Text = "Take";
             this.takeToolStripMenuItem.Click += new System.EventHandler(this.takeToolStripMenuItem_Click);
             // 
             // returnToolStripMenuItem
             // 
             this.returnToolStripMenuItem.Name = "returnToolStripMenuItem";
-            this.returnToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.returnToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
             this.returnToolStripMenuItem.Text = "Return";
             this.returnToolStripMenuItem.Click += new System.EventHandler(this.returnToolStripMenuItem_Click);
             // 
             // deleteToolStripMenuItem
             // 
             this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
-            this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.deleteToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
             this.deleteToolStripMenuItem.Text = "Delete";
             this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
             // 
@@ -252,17 +264,18 @@ namespace Radegast
         public System.Windows.Forms.HScrollBar scrollYaw;
         public System.Windows.Forms.HScrollBar scrollZoom;
         public System.Windows.Forms.GroupBox gbZoom;
-        private System.Windows.Forms.CheckBox chkWireFrame;
-        private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Button btnResetView;
-        private System.Windows.Forms.Label label2;
         public System.Windows.Forms.ContextMenuStrip ctxObjects;
-        private System.Windows.Forms.ToolStripMenuItem touchToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem sitToolStripMenuItem;
-        private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
-        private System.Windows.Forms.ToolStripMenuItem takeToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem returnToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
+        public System.Windows.Forms.CheckBox cbAA;
+        public System.Windows.Forms.CheckBox chkWireFrame;
+        public System.Windows.Forms.Label label1;
+        public System.Windows.Forms.Button btnResetView;
+        public System.Windows.Forms.Label label2;
+        public System.Windows.Forms.ToolStripMenuItem touchToolStripMenuItem;
+        public System.Windows.Forms.ToolStripMenuItem sitToolStripMenuItem;
+        public System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
+        public System.Windows.Forms.ToolStripMenuItem takeToolStripMenuItem;
+        public System.Windows.Forms.ToolStripMenuItem returnToolStripMenuItem;
+        public System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
 
     }
 }
index 09c5ed7..bdafd16 100644 (file)
@@ -61,7 +61,7 @@ namespace Radegast
         /// <summary>
         /// Use multi sampling (anti aliasing)
         /// </summary>
-        public bool UseMultiSampling = false;
+        public bool UseMultiSampling = true;
 
         /// <summary>
         /// Is rendering engine ready and enabled
@@ -100,6 +100,8 @@ namespace Radegast
             InitializeComponent();
             Disposed += new EventHandler(frmPrimWorkshop_Disposed);
             AutoSavePosition = true;
+            UseMultiSampling = cbAA.Checked = instance.GlobalSettings["use_multi_sampling"];
+            cbAA.CheckedChanged += cbAA_CheckedChanged;
 
             this.instance = instance;
 
@@ -168,7 +170,7 @@ namespace Radegast
                 }
                 else
                 {
-                    for (int aa = 0; aa <= 8; aa += 2)
+                    for (int aa = 0; aa <= 4; aa += 2)
                     {
                         var testMode = new OpenTK.Graphics.GraphicsMode(OpenTK.DisplayDevice.Default.BitsPerPixel, 24, 8, aa);
                         if (testMode.Samples == aa)
@@ -183,23 +185,32 @@ namespace Radegast
                 GLMode = null;
             }
 
-            if (GLMode == null)
-            {
-                Logger.Log("Failed to initialize OpenGL control", Helpers.LogLevel.Error, Client);
-                return;
-            }
-
-            Logger.Log("Initializing OpenGL mode: " + GLMode.ToString(), Helpers.LogLevel.Info);
+            
             try
             {
-                glControl = new OpenTK.GLControl(GLMode);
+                if (GLMode == null)
+                {
+                    // Try default mode
+                    glControl = new OpenTK.GLControl();
+                }
+                else
+                {
+                    glControl = new OpenTK.GLControl(GLMode);
+                }
             }
-            catch
+            catch (Exception ex)
             {
+                Logger.Log(ex.Message, Helpers.LogLevel.Warning, Client);
                 glControl = null;
             }
 
-            if (glControl == null) return;
+            if (glControl == null)
+            {
+                Logger.Log("Failed to initialize OpenGL control, cannot continue", Helpers.LogLevel.Error, Client);
+                return;
+            }
+
+            Logger.Log("Initializing OpenGL mode: " + GLMode.ToString(), Helpers.LogLevel.Info);
 
             glControl.Paint += glControl_Paint;
             glControl.Resize += glControl_Resize;
@@ -1172,8 +1183,16 @@ namespace Radegast
                 }
             }
         }
+
+        private void cbAA_CheckedChanged(object sender, EventArgs e)
+        {
+            instance.GlobalSettings["use_multi_sampling"] = UseMultiSampling = cbAA.Checked;
+            SetupGLControl();
+        }
+
         #endregion Form controls handlers
 
+        #region Context menu
         private void ctxObjects_Opening(object sender, System.ComponentModel.CancelEventArgs e)
         {
             if (instance.State.IsSitting)
@@ -1246,6 +1265,8 @@ namespace Radegast
             }
             Close();
         }
+        #endregion Context menu
+
 
     }