本文整理汇总了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);
}
示例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);
}
示例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.");
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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]);
}
}
示例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;
}
示例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));
}
}
示例12: CreateContext
public void CreateContext(bool direct, IGraphicsContext source)
{
if (Handle == ContextHandle.Zero)
{
++handle_count;
Handle = new ContextHandle((IntPtr)handle_count);
}
}
示例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);
}
}
示例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;
}
示例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);
}