Beispiel #1
0
 ///<summary>CAUTION: Runs slowly. May take minutes. Returns the string "invalid" if no suitable Direct X format can be found.</summary>
 public static string GetPreferredDirectXFormat(Form callingForm)
 {
     ToothChartDirectX.DirectXDeviceFormat[] possibleStandardFormats = ToothChartDirectX.GetStandardDeviceFormats();
     for (int i = 0; i < possibleStandardFormats.Length; i++)
     {
         if (TestDirectXFormat(callingForm, possibleStandardFormats[i].ToString()))
         {
             return(possibleStandardFormats[i].ToString());
         }
     }
     return("invalid");
 }
Beispiel #2
0
 ///<Summary>Get all formats for the grid based on the current filters.</Summary>
 private void RefreshFormats()
 {
     this.Cursor = Cursors.WaitCursor;
     gridFormats.Rows.Clear();
     gridFormats.Invalidate();
     textSelected.Text = "";
     Application.DoEvents();
     if (this.radioDirectXChart.Checked)
     {
         xformats = ToothChartDirectX.GetStandardDeviceFormats();
     }
     else if (this.radioOpenGLChart.Checked)
     {
         OpenGLWinFormsControl contextFinder = new OpenGLWinFormsControl();
         //Get raw formats.
         Gdi.PIXELFORMATDESCRIPTOR[] rawformats = OpenGLWinFormsControl.GetPixelFormats(contextFinder.GetHDC());
         if (checkAllFormats.Checked)
         {
             formats = new OpenGLWinFormsControl.PixelFormatValue[rawformats.Length];
             for (int i = 0; i < rawformats.Length; i++)
             {
                 formats[i] = new OpenGLWinFormsControl.PixelFormatValue();
                 formats[i].formatNumber = i + 1;
                 formats[i].pfd          = rawformats[i];
             }
         }
         else
         {
             //Prioritize formats as requested by the user.
             formats = OpenGLWinFormsControl.PrioritizePixelFormats(rawformats, checkDoubleBuffering.Checked, checkHardwareAccel.Checked);
         }
         contextFinder.Dispose();
     }
     //Update the format grid to reflect possible changes in formats.
     FillGrid();
     this.Cursor = Cursors.Default;
 }
Beispiel #3
0
        private void FillGrid()
        {
            int selectionIndex = -1;

            gridFormats.BeginUpdate();
            gridFormats.Rows.Clear();
            if (this.radioDirectXChart.Checked)
            {
                textSelected.Text = "";
                gridFormats.BeginUpdate();
                gridFormats.Columns.Clear();
                ODGridColumn col = new ODGridColumn(Lan.g(this, "FormatNum"), 80);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Adapter"), 60);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Accelerated"), 80);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Buffered"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "ColorBits"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "ColorFormat"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "DepthBits"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "DepthFormat"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Antialiasing"), 75);
                gridFormats.Columns.Add(col);
                gridFormats.EndUpdate();
                for (int i = 0; i < xformats.Length; i++)
                {
                    ODGridRow row = new ODGridRow();
                    row.Cells.Add((i + 1).ToString());
                    row.Cells.Add(xformats[i].adapterIndex.ToString());
                    row.Cells.Add(xformats[i].IsHardware?"Yes":"No");                                              //Supports hardware acceleration?
                    row.Cells.Add("Yes");                                                                          //Supports double-buffering. All DirectX devices support double-buffering as required.
                    row.Cells.Add(ToothChartDirectX.GetFormatBitCount(xformats[i].BackBufferFormat).ToString());   //Color bits.
                    row.Cells.Add(xformats[i].BackBufferFormat);
                    row.Cells.Add(ToothChartDirectX.GetFormatBitCount(xformats[i].DepthStencilFormat).ToString()); //Depth buffer bits.
                    row.Cells.Add(xformats[i].DepthStencilFormat);
                    row.Cells.Add(xformats[i].MultiSampleCount.ToString());
                    gridFormats.Rows.Add(row);
                    if (xformats[i].ToString() == selectedDirectXFormat)
                    {
                        selectionIndex    = i;
                        textSelected.Text = (i + 1).ToString();
                    }
                }
            }
            else if (this.radioOpenGLChart.Checked)
            {
                textSelected.Text = selectedFormatNum.ToString();
                gridFormats.BeginUpdate();
                gridFormats.Columns.Clear();
                ODGridColumn col = new ODGridColumn(Lan.g(this, "FormatNum"), 80);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "OpenGL"), 60);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Windowed"), 80);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Bitmapped"), 80);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Palette"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Accelerated"), 80);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "Buffered"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "ColorBits"), 75);
                gridFormats.Columns.Add(col);
                col = new ODGridColumn(Lan.g(this, "DepthBits"), 75);
                gridFormats.Columns.Add(col);
                gridFormats.EndUpdate();
                for (int i = 0; i < formats.Length; i++)
                {
                    ODGridRow row = new ODGridRow();
                    row.Cells.Add(formats[i].formatNumber.ToString());
                    row.Cells.Add(OpenGLWinFormsControl.FormatSupportsOpenGL(formats[i].pfd)?"Yes":"No");
                    row.Cells.Add(OpenGLWinFormsControl.FormatSupportsWindow(formats[i].pfd)?"Yes":"No");
                    row.Cells.Add(OpenGLWinFormsControl.FormatSupportsBitmap(formats[i].pfd)?"Yes":"No");
                    row.Cells.Add(OpenGLWinFormsControl.FormatUsesPalette(formats[i].pfd)?"Yes":"No");
                    row.Cells.Add(OpenGLWinFormsControl.FormatSupportsAcceleration(formats[i].pfd)?"Yes":"No");
                    row.Cells.Add(OpenGLWinFormsControl.FormatSupportsDoubleBuffering(formats[i].pfd)?"Yes":"No");
                    row.Cells.Add(formats[i].pfd.cColorBits.ToString());
                    row.Cells.Add(formats[i].pfd.cDepthBits.ToString());
                    gridFormats.Rows.Add(row);
                    if (formats[i].formatNumber == selectedFormatNum)
                    {
                        selectionIndex = i;
                    }
                }
            }
            gridFormats.EndUpdate();
            if (selectionIndex >= 0)
            {
                gridFormats.SetSelected(selectionIndex, true);
            }
        }