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


C# GameWindow.MakeCurrent方法代码示例

本文整理汇总了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;
        }
开发者ID:bwfox,项目名称:MonoGame,代码行数:57,代码来源:OpenTKGameWindow.cs

示例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();
        };
    }
开发者ID:ming4883,项目名称:gwen-dotnet,代码行数:80,代码来源:ExampleBase.cs

示例3: SimpleUserInterface

 public SimpleUserInterface()
 {
     GameWindow=new GameWindow(512,512);
     GameWindow.Visible = true;
     GameWindow.ProcessEvents();
     GameWindow.MakeCurrent();
     Renderer=new SimpleRenderer();
     Renderer.Init();
 }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:9,代码来源:Gl1Renderer.cs


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