Axiom.RenderSystems.OpenGL.OpenTKWindow.Create C# (CSharp) Метод

Create() публичный Метод

Creates & displays the new window.
public Create ( string name, int width, int height, bool fullScreen, NamedParameterList miscParams ) : void
name string
width int The width of the window in pixels.
height int The height of the window in pixels.
fullScreen bool If true, the window fills the screen, with no title bar or border.
miscParams NamedParameterList A variable number of platform-specific arguments. /// The actual requirements must be defined by the implementing subclasses.
Результат void
		public override void Create( string name, int width, int height, bool fullScreen, NamedParameterList miscParams )
		{
			string title = name;
			bool vsync = false;
			int depthBuffer = GraphicsMode.Default.Depth;
			float displayFrequency = 60f;
			string border = "resizable";

			this.name = name;
			this.width = width;
			this.height = height;
			this.colorDepth = 32;
			this.fullScreen = fullScreen;
			displayDevice = DisplayDevice.Default;

			#region Parameter Handling

			if ( miscParams != null )
			{
				foreach ( KeyValuePair<string, object> entry in miscParams )
				{
					switch ( entry.Key )
					{
						case "title":
							title = entry.Value.ToString();
							break;
						case "left":
							left = Int32.Parse( entry.Value.ToString() );
							break;
						case "top":
							top = Int32.Parse( entry.Value.ToString() );
							break;
						case "fsaa":
							fsaa = Int32.Parse( entry.Value.ToString() );
							break;
						case "colourDepth":
						case "colorDepth":
							colorDepth = Int32.Parse( entry.Value.ToString() );
							break;
						case "vsync":
							vsync = entry.Value.ToString() == "No" ? false : true;
							break;
						case "displayFrequency":
							displayFrequency = Int32.Parse( entry.Value.ToString() );
							break;
						case "depthBuffer":
							depthBuffer = Int32.Parse( entry.Value.ToString() );
							break;
						case "border":
							border = entry.Value.ToString().ToLower();
							break;

						case "externalWindowInfo":
							glContext = new OpenTKGLContext( (OpenTK.Platform.IWindowInfo)entry.Value );
							break;

						case "externalWindowHandle":
							object handle = entry.Value;
							IntPtr ptr = IntPtr.Zero;
							if ( handle.GetType() == typeof( IntPtr ) )
							{
								ptr = (IntPtr)handle;
							}
							else if ( handle.GetType() == typeof( System.Int32 ) )
							{
								ptr = new IntPtr( (int)handle );
							}
							//glContext = new OpenTKGLContext(Control.FromHandle(ptr), Control.FromHandle(ptr).Parent);

							WindowEventMonitor.Instance.RegisterWindow( this );
							fullScreen = false;
							IsActive = true;
							break;

						case "externalWindow":
							//glContext = new OpenTKGLContext((Control)entry.Value, ((Control)entry.Value).Parent);
							WindowEventMonitor.Instance.RegisterWindow( this );
							fullScreen = false;
							IsActive = true;
							break;

						default:
							break;
					}
				}
			}

			#endregion Parameter Handling

			if ( glContext == null )
			{
				// create window
				_window = new NativeWindow( width, height, title, GameWindowFlags.Default, new GraphicsMode( GraphicsMode.Default.ColorFormat, depthBuffer, GraphicsMode.Default.Stencil, FSAA ), displayDevice );
				glContext = new OpenTKGLContext( _window.WindowInfo );

				FileSystem.FileInfoList ico = ResourceGroupManager.Instance.FindResourceFileInfo( ResourceGroupManager.DefaultResourceGroupName, "AxiomIcon.ico" );
				if ( ico.Count != 0 )
				{
					_window.Icon = System.Drawing.Icon.ExtractAssociatedIcon( ico[ 0 ].Filename );
				}

				if ( fullScreen )
				{
					displayDevice.ChangeResolution( width, height, ColorDepth, displayFrequency );
					_window.WindowState = WindowState.Fullscreen;
					IsFullScreen = true;
				}
				else
				{
					_window.WindowState = WindowState.Normal;

					if ( border == "fixed" )
						_window.WindowBorder = WindowBorder.Fixed;
					else if ( border == "resizable" )
						_window.WindowBorder = WindowBorder.Resizable;
					else if ( border == "none" )
						_window.WindowBorder = WindowBorder.Hidden;
				}

				_window.Title = title;

				WindowEventMonitor.Instance.RegisterWindow( this );

				// lets get active!
				IsActive = true;
				glContext.VSync = vsync;
				_window.Visible = true;
			}
		}

Usage Example

Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="fullScreen"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="depthBuffer"></param>
        /// <param name="vsync"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public override RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            var window = new OpenTKWindow();

            window.Create(name, width, height, fullScreen, miscParams);
            return(window);
        }
All Usage Examples Of Axiom.RenderSystems.OpenGL.OpenTKWindow::Create