本文整理汇总了C#中OpenTK.GameWindow.MakeCurrent方法的典型用法代码示例。如果您正苦于以下问题:C# GameWindow.MakeCurrent方法的具体用法?C# GameWindow.MakeCurrent怎么用?C# GameWindow.MakeCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenTK.GameWindow
的用法示例。
在下文中一共展示了GameWindow.MakeCurrent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
private void Initialize()
{
GraphicsContext.ShareContexts = true;
window = new OpenTK.GameWindow();
window.RenderFrame += OnRenderFrame;
window.UpdateFrame += OnUpdateFrame;
window.Closing += new EventHandler<CancelEventArgs>(OpenTkGameWindow_Closing);
window.Resize += OnResize;
window.Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
window.Keyboard.KeyUp += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
#if LINUX
window.WindowBorder = WindowBorder.Resizable;
#endif
#if WINDOWS
window.MouseEnter += OnMouseEnter;
window.MouseLeave += OnMouseLeave;
#endif
window.KeyPress += OnKeyPress;
// Set the window icon.
window.Icon = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location);
updateClientBounds = false;
clientBounds = new Rectangle(window.ClientRectangle.X, window.ClientRectangle.Y,
window.ClientRectangle.Width, window.ClientRectangle.Height);
windowState = window.WindowState;
#if WINDOWS
{
var windowInfoType = window.WindowInfo.GetType();
var propertyInfo = windowInfoType.GetProperty("WindowHandle");
_windowHandle = (IntPtr)propertyInfo.GetValue(window.WindowInfo, null);
}
#endif
// Provide the graphics context for background loading
Threading.BackgroundContext = new GraphicsContext(GraphicsMode.Default, window.WindowInfo);
Threading.WindowInfo = window.WindowInfo;
keys = new List<Keys>();
// Make the foreground context the current context
if (GraphicsContext.CurrentContext == null || !GraphicsContext.CurrentContext.IsCurrent)
window.MakeCurrent();
// mouse
// TODO review this when opentk 1.1 is released
#if WINDOWS || LINUX
Mouse.setWindows(window);
#else
Mouse.UpdateMouseInfo(window.Mouse);
#endif
//Default no resizing
AllowUserResizing = false;
}
示例2: Init
public void Init(GameWindow gamewindow)
{
renderer = new Gwen.Renderer.OpenTK();
skin = new Gwen.Skin.TexturedBase (renderer, "DefaultSkin.png");
canvas = new Gwen.Control.Canvas (skin);
canvas.SetSize (gamewindow.Width, gamewindow.Height);
canvas.ShouldDrawBackground = true;
canvas.BackgroundColor = System.Drawing.Color.FromArgb (255, 225, 225, 225);
input = new Gwen.Input.OpenTK (gamewindow);
input.Initialize (canvas);
gamewindow.Keyboard.KeyDown += (s, e) =>
{
input.ProcessKeyDown (e);
};
gamewindow.Keyboard.KeyUp += (s, e) =>
{
input.ProcessKeyUp (e);
};
gamewindow.Mouse.ButtonDown += (s, e) =>
{
input.ProcessMouseMessage (e);
};
gamewindow.Mouse.ButtonUp += (s, e) =>
{
input.ProcessMouseMessage (e);
};
gamewindow.Mouse.Move += (s, e) =>
{
input.ProcessMouseMessage (e);
};
gamewindow.Mouse.WheelChanged += (s, e) =>
{
input.ProcessMouseMessage (e);
};
gamewindow.Load += (s, e) =>
{
PreLoad();
gamewindow.VSync = VSyncMode.On;
PostLoad();
};
gamewindow.Resize += (s, e) =>
{
GL.Viewport (0, 0, gamewindow.Width, gamewindow.Height);
GL.MatrixMode (MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho (0, gamewindow.Width, gamewindow.Height, 0, -1, 1);
canvas.SetSize (gamewindow.Width, gamewindow.Height);
};
gamewindow.UpdateFrame += (s, e) =>
{
PreUpdate();
if (renderer.TextCacheSize > 1000)
renderer.FlushTextCache();
PostUpdate();
};
gamewindow.RenderFrame += (s, e) =>
{
gamewindow.MakeCurrent();
PreRender();
canvas.RenderCanvas();
PostRender();
gamewindow.SwapBuffers();
};
}
示例3: SimpleUserInterface
public SimpleUserInterface()
{
GameWindow=new GameWindow(512,512);
GameWindow.Visible = true;
GameWindow.ProcessEvents();
GameWindow.MakeCurrent();
Renderer=new SimpleRenderer();
Renderer.Init();
}