本文整理汇总了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;
}
}
示例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();
}
示例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();
}
}
示例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;
}
}
示例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();
}