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


C# ContextHandle类代码示例

本文整理汇总了C#中ContextHandle的典型用法代码示例。如果您正苦于以下问题:C# ContextHandle类的具体用法?C# ContextHandle怎么用?C# ContextHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreateGLContext

 public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
 {
     WinWindowInfo winWindowInfo = (WinWindowInfo) window;
       IntPtr display = this.GetDisplay(winWindowInfo.DeviceContext);
       EglWindowInfo window1 = new EglWindowInfo(winWindowInfo.WindowHandle, display);
       return (IGraphicsContext) new EglContext(handle, window1, shareContext, major, minor, flags);
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:7,代码来源:EglWinPlatformFactory.cs

示例2: CreateGLContext

 public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
 {
     X11WindowInfo x11_win = (X11WindowInfo)window;
     //EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(x11_win.WindowHandle, Egl.GetDisplay(x11_win.Display));
     EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(x11_win.WindowHandle, Egl.GetDisplay(new IntPtr(0)));
     return new EglContext(handle, egl_win, shareContext, major, minor, flags);
 }
开发者ID:dellis1972,项目名称:opentk,代码行数:7,代码来源:EglX11PlatformFactory.cs

示例3: InitialSetup

 public static void InitialSetup()
 {
     // FOR THE LOVE OF GOD PLEASE LET THIS WORK
     AudioDevice = Alc.OpenDevice (null); // Default device
     if (AudioDevice != null) {
         AudioCtx = Alc.CreateContext(AudioDevice, (int[])null);
         if(AudioCtx != ContextHandle.Zero)
         {
             Alc.GetError(AudioDevice);
             if(Alc.MakeContextCurrent( AudioCtx ))
             {
                 //LoadWaveFile ("camprespite_loop", "camprespite_loop.wav");
                 LoadWaveFile ("last_human_loop", "last_human_loop_limited.wav");//.DurationAdjust(0.01);
                 LoadWaveFile ("induction_loop", "induction_loop.wav");
                 LoadWaveFile ("sfx_bullet_impact", "sfx_bullet_impact.wav");
                 LoadWaveFile ("sfx_player_land_two_feet", "sfx_player_land_two_feet.wav");
                 LoadWaveFile ("sfx_shoot_gun", "sfx_shoot_gun.wav");
                 LoadWaveFile ("win", "win.wav");
             }
             else
                 throw new Exception("Failed to set current audio context");
         }
         else
             throw new Exception("Failed to create audio context.");
     }
     else
         throw new Exception("Failed to open default audio device.");
 }
开发者ID:qwook,项目名称:hungry,代码行数:28,代码来源:Sound.cs

示例4: CreateContext

        public void CreateContext(bool direct, IGLContext source)
        {
            Debug.WriteLine(String.Format("OpenGL context is bound to handle: {0}", this.windowInfo.Handle));

            Debug.Write("Creating render context... ");
            // Do not rely on OpenTK.Platform.Windows.Wgl - the context is not ready yet,
            // and Wgl extensions will fail to load.
            renderContext = new ContextHandle(Wgl.Imports.CreateContext(deviceContext));
            if (renderContext == IntPtr.Zero)
                throw new ApplicationException("Could not create OpenGL render context (Wgl.CreateContext() return 0).");
            
            Debug.WriteLine(String.Format("done! (id: {0})", renderContext));

            Wgl.Imports.MakeCurrent(deviceContext, renderContext);
            Wgl.LoadAll();
            GL.LoadAll();
            Glu.LoadAll();

            vsync_supported = Wgl.Arb.SupportsExtension(this.deviceContext, "WGL_EXT_swap_control") &&
                Wgl.Load("wglGetSwapIntervalEXT") && Wgl.Load("wglSwapIntervalEXT");

            if (source != null)
            {
                Debug.Print("Sharing state with context {0}", (source as IGLContextInternal).Context);
                Wgl.Imports.ShareLists(renderContext, (source as IGLContextInternal).Context);
            }
        }
开发者ID:nebenjamin,项目名称:cpsc-431-project,代码行数:27,代码来源:WinGLContext.cs

示例5: CreateGLContext

 public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
 {
     WinWindowInfo win_win = (WinWindowInfo)window;
     IntPtr egl_display = GetDisplay(win_win.DeviceContext);
     EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(win_win.WindowHandle, egl_display);
     return new EglContext(handle, egl_win, shareContext, major, minor, flags);
 }
开发者ID:challal,项目名称:scallion,代码行数:7,代码来源:EglWinPlatformFactory.cs

示例6: WinGLContext

        static WinGLContext()
        {
            // Dynamically load the OpenGL32.dll in order to use the extension loading capabilities of Wgl.
            if (opengl32Handle == IntPtr.Zero)
            {
                opengl32Handle = Functions.LoadLibrary(opengl32Name);
                if (opengl32Handle == IntPtr.Zero)
                    throw new ApplicationException(String.Format("LoadLibrary(\"{0}\") call failed with code {1}",
                                                                 opengl32Name, Marshal.GetLastWin32Error()));
                Debug.WriteLine(String.Format("Loaded opengl32.dll: {0}", opengl32Handle));
            }

            // We need to create a temp context in order to load
            // wgl extensions (e.g. for multisampling or GL3).
            // We cannot rely on OpenTK.Platform.Wgl until we
            // create the context and call Wgl.LoadAll().
            Debug.Print("Creating temporary context for wgl extensions.");
            using (INativeWindow native = new NativeWindow())
            {
                // Create temporary context and load WGL entry points
                WinWindowInfo window = native.WindowInfo as WinWindowInfo;
                ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext));
                Wgl.Imports.MakeCurrent(window.DeviceContext, temp_context.Handle);
                Wgl.LoadAll();

                // Query graphics modes
                ModeSelector = new WinGraphicsMode(temp_context, window.DeviceContext);
                
                // Destroy temporary context
                Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
                Wgl.Imports.DeleteContext(temp_context.Handle);
                wgl_loaded = true;
            }
        }
开发者ID:BrainSlugs83,项目名称:opentk,代码行数:34,代码来源:WinGLContext.cs

示例7: iPhoneOSGraphicsContext

        internal iPhoneOSGraphicsContext(ContextHandle handle, IWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags)
        {
            // ignore mode, window

            iPhoneOSGraphicsContext shared = sharedContext as iPhoneOSGraphicsContext;

            EAGLRenderingAPI version = 0;
            if (major == 1 && minor == 1)
                version = EAGLRenderingAPI.OpenGLES1;
            else if (major == 2 && minor == 0)
                version = EAGLRenderingAPI.OpenGLES2;
            else if (major == 3 && minor == 0)
                version = EAGLRenderingAPI.OpenGLES3;
            else
                throw new ArgumentException (string.Format("Unsupported GLES version {0}.{1}.", major, minor));

            if (handle.Handle == IntPtr.Zero) {
                EAGLContext = shared != null && shared.EAGLContext != null
                    ? new EAGLContext(version, shared.EAGLContext.ShareGroup)
                    : new EAGLContext(version);
                contextHandle = new ContextHandle(EAGLContext.Handle);
            } else {
                EAGLContext = (EAGLContext) Runtime.GetNSObject (handle.Handle);
                contextHandle = handle;
            }
        }
开发者ID:renanyoy,项目名称:mono-opentk,代码行数:26,代码来源:iPhoneOSGraphicsContext.cs

示例8: Initialize

		// initialize
		internal static void Initialize() {
			// openal
			OpenAlDevice = Alc.OpenDevice(null);
			if (OpenAlDevice != IntPtr.Zero) {
                OpenAlContext = Alc.CreateContext(OpenAlDevice, (int[])null);
				if (OpenAlContext != ContextHandle.Zero) {
					Alc.MakeContextCurrent(OpenAlContext);
					AL.SpeedOfSound(343.0f);
					AL.DistanceModel(ALDistanceModel.None);
				} else {
					Alc.CloseDevice(OpenAlDevice);
					OpenAlDevice = IntPtr.Zero;
					System.Windows.Forms.MessageBox.Show("The sound device could be opened, but the sound context could not be created.", "openBVE", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
				}
			} else {
				OpenAlContext = ContextHandle.Zero;
				System.Windows.Forms.MessageBox.Show("The sound device could not be opened.", "openBVE", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
			}
			// outer radius
			switch (Interface.CurrentOptions.SoundRange) {
				case Interface.SoundRange.Low:
					OuterRadiusFactorMinimum = 2.0;
					OuterRadiusFactorMaximum = 8.0;
					break;
				case Interface.SoundRange.Medium:
					OuterRadiusFactorMinimum = 4.0;
					OuterRadiusFactorMaximum = 16.0;
					break;
				case Interface.SoundRange.High:
					OuterRadiusFactorMinimum = 8.0;
					OuterRadiusFactorMaximum = 32.0;
					break;
			}
			OuterRadiusFactor = OuterRadiusFactorMaximum;
		}
开发者ID:leezer3,项目名称:OpenBVE,代码行数:36,代码来源:SoundManager.cs

示例9: OpenALSoundController

		private OpenALSoundController ()
		{
			alcMacOSXMixerOutputRate(PREFERRED_MIX_RATE);
			_device = Alc.OpenDevice (string.Empty);
			CheckALError ("Could not open AL device");
			if (_device != IntPtr.Zero) {
				int[] attribute = new int[0];
				_context = Alc.CreateContext (_device, attribute);
				CheckALError ("Could not open AL context");

				if (_context != ContextHandle.Zero) {
					Alc.MakeContextCurrent (_context);
					CheckALError ("Could not make AL context current");
				}
			} else {
				return;
			}

			allSourcesArray = new int[MAX_NUMBER_OF_SOURCES];
			AL.GenSources (allSourcesArray);

			availableSourcesCollection = new HashSet<int> ();
			inUseSourcesCollection = new HashSet<OALSoundBuffer> ();
			playingSourcesCollection = new HashSet<OALSoundBuffer> ();


			for (int x=0; x < MAX_NUMBER_OF_SOURCES; x++) {
				availableSourcesCollection.Add (allSourcesArray [x]);
			}
		}
开发者ID:ValXp,项目名称:MonoGame,代码行数:30,代码来源:OpenALSoundController.cs

示例10: EglContext

 public EglContext(ContextHandle handle, EglWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags)
 {
     if (handle == ContextHandle.Zero)
     throw new ArgumentException("handle");
       if (window == null)
     throw new ArgumentNullException("window");
       this.Handle = handle;
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:8,代码来源:EglContext.cs

示例11: GraphicsContext

 // Necessary to allow creation of dummy GraphicsContexts (see CreateDummyContext static method).
 GraphicsContext(ContextHandle handle)
 {
     implementation = new OpenTK.Platform.Dummy.DummyGLContext(handle);
     lock (SyncRoot)
     {
         available_contexts.Add((implementation as IGraphicsContextInternal).Context, new WeakReference(this));
     }
 }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:9,代码来源:GraphicsContext.cs

示例12: CreateContext

 public void CreateContext(bool direct, IGraphicsContext source)
 {
     if (Handle == ContextHandle.Zero)
     {
         ++handle_count;
         Handle = new ContextHandle((IntPtr)handle_count);
     }
 }
开发者ID:Munk801,项目名称:Journey-to-the-West-Video-Game,代码行数:8,代码来源:DummyGLContext.cs

示例13: GraphicsContext

        // Necessary to allow creation of dummy GraphicsContexts (see CreateDummyContext static method).
        GraphicsContext(ContextHandle handle)
        {
            implementation = new OpenTK.Platform.Dummy.DummyGLContext(handle);

            lock (SyncRoot)
            {
                AddContext(this);
            }
        }
开发者ID:shahid-pk,项目名称:opentk,代码行数:10,代码来源:GraphicsContext.cs

示例14: AglContext

 public AglContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext)
 {
     if (handle == ContextHandle.Zero)
     throw new ArgumentException("handle");
       if (window == null)
     throw new ArgumentNullException("window");
       this.Handle = handle;
       this.carbonWindow = (CarbonWindowInfo) window;
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:9,代码来源:AglContext.cs

示例15: SDL2GLContext

        public SDL2GLContext(IntPtr ctxhandle, IWindowInfo windowInfo)
        {
			Console.WriteLine("WARNING! Creating context in a way we don't quite understand.");
            SDL2WindowInfo currentWindow = (SDL2WindowInfo)windowInfo;
			window = currentWindow.WindowHandle;
			context = ctxhandle;
			Handle = new ContextHandle(context);
			MakeCurrent(windowInfo);
        }
开发者ID:sulix,项目名称:opentk-sdl2,代码行数:9,代码来源:SDL2GLContext.cs


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