当前位置: 首页>>代码示例>>C#>>正文


C# IGraphicsContext.LoadAll方法代码示例

本文整理汇总了C#中IGraphicsContext.LoadAll方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphicsContext.LoadAll方法的具体用法?C# IGraphicsContext.LoadAll怎么用?C# IGraphicsContext.LoadAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphicsContext的用法示例。


在下文中一共展示了IGraphicsContext.LoadAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GameWindow

 /// <summary>Constructs a new GameWindow with the specified attributes.</summary>
 /// <param name="width">The width of the GameWindow in pixels.</param>
 /// <param name="height">The height of the GameWindow in pixels.</param>
 /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
 /// <param name="title">The title of the GameWindow.</param>
 /// <param name="options">GameWindow options regarding window appearance and behavior.</param>
 /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
 public GameWindow(int width, int height, GraphicsMode mode, string title, bool nullContext,
     GameWindowFlags options, DisplayDevice device)
     : base(width, height, title, options, mode, device)
 {
     try {
         glContext = nullContext ? new NullContext() :
             Factory.Default.CreateGLContext(mode, WindowInfo);
         glContext.MakeCurrent(WindowInfo);
         glContext.LoadAll();
         VSync = true;
     } catch (Exception e) {
         Debug.Print(e.ToString());
         base.Dispose();
         throw;
     }
 }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:23,代码来源:GameWindow.cs

示例2: Initialize

        public void Initialize()
        {
            // <Rant>
            // OpenTK has a great fuckup in its design here. It's absolutly nohm it possible to create
            // a render context for offscreen rendering without creating an OpenTK window.
            // before.
            // Passing Utilities.CreateDummyWindowInfo() or anything else will cause an invalid cast exception
            // Using Utilities.CreateWindowsWindowInfo(IntPtr.Zero) binds the code to windows only
            // Really great, why do i need to have a window in order to render to memory? -_-
            //</Rant>

            _window = new NativeWindow { Visible = false };
            _context = new GraphicsContext(GraphicsMode.Default, _window.WindowInfo, 2, 0, GraphicsContextFlags.Default);
            _context.MakeCurrent(_window.WindowInfo);
            _context.LoadAll();

            // create offscreen rendertarget with high precision
            _rtt = new RenderToTexture(1, 1, false, 4, typeof(float));

            int precision;
            int range;
            GL.GetShaderPrecisionFormat(OpenTK.Graphics.OpenGL.ShaderType.FragmentShader, ShaderPrecisionType.HighFloat, out range, out precision);
            Debug.WriteLine("Precision: {0}, Range {1}", precision, range);

            // init SL#
            Bindings.OpenTK.SLSharp.Init();
        }
开发者ID:hach-que,项目名称:SLSharp,代码行数:27,代码来源:OpenTKTestRuntime.cs

示例3: InitSynchronizedOnce

		/// <summary>
		/// 
		/// </summary>
		/// <see cref="http://www.opentk.com/doc/graphics/graphicscontext"/>
		public override void InitSynchronizedOnce()
		{
			if (!AlreadyInitialized)
			{
				AlreadyInitialized = true;
				AutoResetEvent CompletedEvent = new AutoResetEvent(false);
				var CThread = new Thread(() =>
				{
					Thread.CurrentThread.CurrentCulture = new CultureInfo(PspConfig.ThreadCultureName);

					var UsedGraphicsMode = new GraphicsMode(
						color: new OpenTK.Graphics.ColorFormat(8, 8, 8, 8),
						depth: 16,
						stencil: 8,
						samples: 0,
						accum: new OpenTK.Graphics.ColorFormat(16, 16, 16, 16),
						//accum: new OpenTK.Graphics.ColorFormat(0, 0, 0, 0),
						buffers: 2,
						stereo: false
					);

					var UsedGameWindowFlags = GameWindowFlags.Default;

					//Console.Error.WriteLine(UsedGraphicsMode);
					//Console.ReadKey();
#if USE_GL_CONTROL
					GLControl = new GLControl(UsedGraphicsMode, 3, 0, GraphicsContextFlags.Default);
#else
					NativeWindow = new NativeWindow(512, 272, "PspGraphicEngine", UsedGameWindowFlags, UsedGraphicsMode, DisplayDevice.GetDisplay(DisplayIndex.Default));
#endif
					
#if SHOW_WINDOW
					NativeWindow.Visible = true;
#endif
					//Utilities.CreateWindowsWindowInfo(handle);

					GraphicsContext = new GraphicsContext(UsedGraphicsMode, WindowInfo);
					GraphicsContext.MakeCurrent(WindowInfo);
					{
						GraphicsContext.LoadAll();
						Initialize();
					}
					GraphicsContext.SwapInterval = 0;

#if true
					//Console.WriteLine("## {0}", UsedGraphicsMode);
					Console.WriteLine("## UsedGraphicsMode: {0}", UsedGraphicsMode);
					Console.WriteLine("## GraphicsContext.GraphicsMode: {0}", GraphicsContext.GraphicsMode);

					Console.WriteLine("## OpenGL Context Version: {0}.{1}", GlGetInteger(GetPName.MajorVersion), GlGetInteger(GetPName.MinorVersion));

					Console.WriteLine("## Depth Bits: {0}", GlGetInteger(GetPName.DepthBits));
					Console.WriteLine("## Stencil Bits: {0}", GlGetInteger(GetPName.StencilBits));
					Console.WriteLine("## Accum Bits: {0},{1},{2},{3}", GlGetInteger(GetPName.AccumRedBits), GlGetInteger(GetPName.AccumGreenBits), GlGetInteger(GetPName.AccumBlueBits), GlGetInteger(GetPName.AccumAlphaBits));

					if (GlGetInteger(GetPName.StencilBits) <= 0)
					{
						ConsoleUtils.SaveRestoreConsoleState(() =>
						{
							Console.ForegroundColor = ConsoleColor.Red;
							Console.Error.WriteLine("No stencil bits available!");
						});
					}

					/*
					GL.Enable(EnableCap.StencilTest);
					GL.StencilMask(0xFF);
					GL.ClearColor(new Color4(Color.FromArgb(0x11, 0x22, 0x33, 0x44)));
					GL.ClearStencil(0x7F);
					GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);

					var TestData = new uint[16 * 16];
					TestData[0] = 0x12345678;
					GL.ReadPixels(0, 0, 16, 16, PixelFormat.Rgba, PixelType.UnsignedInt8888Reversed, TestData);
					Console.WriteLine(GL.GetError());
					for (int n = 0; n < TestData.Length; n++) Console.Write("{0:X}", TestData[n]);
					*/
#endif

					GraphicsContext.MakeCurrent(null);
					CompletedEvent.Set();
					while (Running)
					{
#if !USE_GL_CONTROL
						NativeWindow.ProcessEvents();
#endif
						Thread.Sleep(1);
					}
					StopEvent.Set();
				});
				CThread.Name = "GpuImplEventHandling";
				CThread.IsBackground = true;
				CThread.Start();
				CompletedEvent.WaitOne();
			}
		}
开发者ID:shin527,项目名称:cspspemu,代码行数:100,代码来源:OpenglGpuImpl.Init.cs

示例4: GameWindow

 /// <summary>Constructs a new GameWindow with the specified attributes.</summary>
 /// <param name="width">The width of the GameWindow in pixels.</param>
 /// <param name="height">The height of the GameWindow in pixels.</param>
 /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
 /// <param name="title">The title of the GameWindow.</param>
 /// <param name="options">GameWindow options regarding window appearance and behavior.</param>
 /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
 public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device)
     : base(width, height, title, options, mode == null ? GraphicsMode.Default : mode, device == null ? DisplayDevice.Default : device)
 {
     try {
         glContext = Factory.Default.CreateGLContext(mode == null ? GraphicsMode.Default : mode, WindowInfo);
         glContext.MakeCurrent(WindowInfo);
         glContext.LoadAll();
         VSync = true;
         //glWindow.WindowInfoChanged += delegate(object sender, EventArgs e) { OnWindowInfoChangedInternal(e); };
     } catch (Exception e) {
         Debug.Print(e.ToString());
         base.Dispose();
         throw;
     }
 }
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:22,代码来源:GameWindow.cs

示例5: GraphicsContext

        /// <summary>
        /// Initializes a new instance of the <see cref="OpenTK.Graphics.GraphicsContext"/> class using
        /// an external context handle that was created by a third-party library.
        /// </summary>
        /// <param name="handle">
        /// A valid, unique handle for an external OpenGL context, or <c>ContextHandle.Zero</c> to use the current context.
        /// It is an error to specify a handle that has been created through OpenTK or that has been passed to OpenTK before.
        /// </param>
        /// <param name="getAddress">
        /// A <c>GetAddressDelegate</c> instance that accepts the name of an OpenGL function and returns
        /// a valid function pointer, or <c>IntPtr.Zero</c> if that function is not supported. This delegate should be
        /// implemented using the same toolkit that created the OpenGL context (i.e. if the context was created with
        /// SDL_GL_CreateContext(), then this delegate should use SDL_GL_GetProcAddress() to retrieve function
        /// pointers.)
        /// </param>
        /// <param name="getCurrent">
        /// A <c>GetCurrentContextDelegate</c> instance that returns the handle of the current OpenGL context,
        /// or <c>IntPtr.Zero</c> if no context is current on the calling thread. This delegate should be implemented
        /// using the same toolkit that created the OpenGL context (i.e. if the context was created with
        /// SDL_GL_CreateContext(), then this delegate should use SDL_GL_GetCurrentContext() to retrieve
        /// the current context.)
        /// </param>
        public GraphicsContext(ContextHandle handle, GetAddressDelegate getAddress, GetCurrentContextDelegate getCurrent)
        {
            if (getAddress == null || getCurrent == null)
                throw new ArgumentNullException();

            // Make sure OpenTK has been initialized.
            // Fixes https://github.com/opentk/opentk/issues/52
            Toolkit.Init();

            lock (SyncRoot)
            {
                // Replace a zero-handle by the current context, if any
                if (handle == ContextHandle.Zero)
                {
                    handle = getCurrent();
                }

                // Make sure this handle corresponds to a valid, unique OpenGL context
                if (handle == ContextHandle.Zero)
                {
                    throw new GraphicsContextMissingException();
                }
                else if (available_contexts.ContainsKey(handle))
                {
                    throw new InvalidOperationException("Context handle has already been added");
                }

                // We have a valid handle for an external OpenGL context, wrap it into a
                // DummyGLContext instance.
                implementation = new Platform.Dummy.DummyGLContext(handle, getAddress);
                GetCurrentContext = getCurrent ?? GetCurrentContext;
                AddContext(this);
            }
            implementation.LoadAll();
        }
开发者ID:RetroAchievements,项目名称:opentk,代码行数:57,代码来源:GraphicsContext.cs


注:本文中的IGraphicsContext.LoadAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。