當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。