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


C# Window.ContextSettings类代码示例

本文整理汇总了C#中SFML.Window.ContextSettings的典型用法代码示例。如果您正苦于以下问题:C# ContextSettings类的具体用法?C# ContextSettings怎么用?C# ContextSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContextSettings类属于SFML.Window命名空间,在下文中一共展示了ContextSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Game

        public Game(uint width = 1365, uint height = 768)
        {
            if (!File.Exists(IniFileName))
            {
                MessageBox.Show(string.Format("Brak pliku {0}!", IniFileName));
                Environment.Exit(1);
            }

            ReadIniFile(IniFileName);

            Players = new Dictionary<int, PlayerInstance>();

            Width = width;
            Height = height;

            var settings = new ContextSettings { AntialiasingLevel = 8 };
            Window = new RenderWindow(new VideoMode(Width, Height), "Nano War", Styles.Close, settings);

            Window.Closed += (s, a) =>
                {
                    GameClient.GameClient.Dispose();
                    Window.Close();
                };
            Window.SetVerticalSyncEnabled(true);
            Window.SetKeyRepeatEnabled(false);

            StateMachine = new StateMachine();
            AudioManager = new AudioManager();
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:29,代码来源:Game.cs

示例2: Main

        private static void Main(string[] args)
        {
            var contextSettings = new ContextSettings {
                DepthBits = 32
            };
            var window = new RenderWindow(new VideoMode(640, 480), "JukeSaver spike: SFML Basic", Styles.Default, contextSettings);
            window.SetActive();

            window.Closed += OnClosed;
            window.KeyPressed += OnKeyPressed;

            int r = 0, g = 0, b = 0;
            var shape = new CircleShape() {
                Position = new Vector2f(320, 240),
            };

            while (window.IsOpen()) {
                window.DispatchEvents();
                window.Clear(new Color((byte)r, (byte)g, (byte)b));

                shape.Radius = (float)(80.0 + GetPulse() * 40.0);
                shape.Origin = new Vector2f(shape.Radius * 0.5f, shape.Radius * 0.5f);
                shape.Position = new Vector2f(320 - shape.Radius * 0.5f, 240 - shape.Radius * 0.5f);

                shape.FillColor = new Color(50, (byte)(160 + 80 * GetPulse()), (byte)(40 - (40 * GetPulse())));

                window.Draw(shape);
                window.Display();
            }
        }
开发者ID:nathanchere,项目名称:Spikes_JukeSaver,代码行数:30,代码来源:Program.cs

示例3: createDisplay

        public static void createDisplay(bool VSync = false,int FPSCap = 60)
        {
            try
            {
                //Configure the settings of the Window
                ContextSettings settings = new ContextSettings(24, 8, 4, 3, 2);
                window = new RenderWindow(new VideoMode(Convert.ToUInt32(WIDTH), Convert.ToUInt32(HEIGHT)), "OpenGL", Styles.Default, settings);
                Logger.Log(window.Settings.ToString(), Logger.Symbols.Warning);
                if (VSync)
                {
                    window.SetVerticalSyncEnabled(VSync);
                }else
                {
                    window.SetFramerateLimit(Convert.ToUInt32(FPSCap));
                }
                //Setup EventHandler
                window.Closed += new EventHandler(OnClosed);
                window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
                window.Resized += new EventHandler<SizeEventArgs>(OnResized);

                //Init OpenTK
                Toolkit.Init();
                OpenTK.Graphics.GraphicsContext context = new OpenTK.Graphics.GraphicsContext(new ContextHandle(IntPtr.Zero), null);
                GL.Viewport(0, 0, WIDTH, HEIGHT);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.StackTrace);
            }
        }
开发者ID:FelixKimmerle,项目名称:SFMLdotNetOpenGL,代码行数:30,代码来源:DisplayManager.cs

示例4: Init

        public static void Init()
        {
            ContextSettings settings = new ContextSettings (32, 8, 4, 3, 3);
              Styles windowStyle = Styles.Close;

              if (FULLSCREEN) {
            windowStyle = Styles.Fullscreen;
            Game.Width = FULLSCREEN_WIDTH;
            Game.Height = FULLSCREEN_HEIGHT;
            Game.CameraWidth = FULLSCREEN_WIDTH;
            Game.CameraHeight = FULLSCREEN_HEIGHT;
              }

              Context = new RenderWindow (new VideoMode ((uint)Game.Width, (uint)Game.Height), WindowTitleText, windowStyle, settings);

              Context.Closed += OnClose;
              Context.KeyPressed += KeyPressed;
              Context.KeyReleased += KeyReleased;
              Context.SetKeyRepeatEnabled (true);

              Rand = new Random ();
              EventMgr = new EventManager ();
              World = new GameWorld ();

              Camera = new View ();
              Camera.Center = new Vector2f (CameraWidth / 2, CameraHeight / 2);
              Camera.Size = new Vector2f (CameraWidth, CameraHeight); // Half Size
              Context.SetView (Camera);
        }
开发者ID:colincapurso,项目名称:GlobalGameJam2013,代码行数:29,代码来源:Game.cs

示例5: Game

 public Game(uint antialias, bool hq)
 {
     settings = new ContextSettings();
     settings.AntialiasingLevel = antialias;
     player = new Player();
     level = new Level();
     highQuality = hq;
 }
开发者ID:WebFreak001,项目名称:ld28-one-bullet,代码行数:8,代码来源:Game.cs

示例6: VideoSettings

        public VideoSettings()
        {
            WindowStyle    = Styles.Default; // Titlebar + Resize + Close
            WindowSettings = VideoMode.DesktopMode;

            OpenGLSettings = new ContextSettings();
            RefreshRate    = 30;
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:8,代码来源:VideoSettings.cs

示例7: Game

        public Game()
        {
            videoMode = new VideoMode(960, 540);
            title = "SFML Game Window";
            style = Styles.Close;
            context = new ContextSettings();

            ScreenManager = new ScreenManager();
        }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:9,代码来源:Game.cs

示例8: Window

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Create the window
            /// </summary>
            /// <param name="mode">Video mode to use</param>
            /// <param name="title">Title of the window</param>
            /// <param name="style">Window style (Resize | Close by default)</param>
            /// <param name="settings">Creation parameters</param>
            ////////////////////////////////////////////////////////////
            public Window(VideoMode mode, string title, Styles style, ContextSettings settings) :
                base(IntPtr.Zero)
            {
                 // Copy the title to a null-terminated UTF-32 byte array
                byte[] titleAsUtf32 = System.Text.Encoding.UTF32.GetBytes(title + '\0');

                unsafe
                {
                    fixed (byte* titlePtr = titleAsUtf32)
                    {
                        SetThis(sfWindow_createUnicode(mode, (IntPtr)titlePtr, style, ref settings));
                    }
                }
           }
开发者ID:kenygia,项目名称:SFML.Net,代码行数:23,代码来源:Window.cs

示例9: RenderWindow

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Create the window
            /// </summary>
            /// <param name="mode">Video mode to use</param>
            /// <param name="title">Title of the window</param>
            /// <param name="style">Window style (Resize | Close by default)</param>
            /// <param name="settings">Creation parameters</param>
            ////////////////////////////////////////////////////////////
            public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings) :
                base(IntPtr.Zero, 0)
            {
                 // Copy the string to a null-terminated UTF-32 byte array
                byte[] titleAsUtf32 = Encoding.UTF32.GetBytes(title + '\0');

                unsafe
                {
                    fixed (byte* titlePtr = titleAsUtf32)
                    {
                        CPointer = sfRenderWindow_createUnicode(mode, (IntPtr)titlePtr, style, ref settings);
                    }
                }
                Initialize();
           }
开发者ID:Gitii,项目名称:SFML.Net,代码行数:24,代码来源:RenderWindow.cs

示例10: WindowConfig

		public static void WindowConfig()
		{
			ContextSettings settings = new ContextSettings();
			settings.AntialiasingLevel = 4;

			myWindow = new RenderWindow(
				new VideoMode(1600, 900),
				"SFML Application (SFML.netV2.2 + Optimized Multithread)",
				Styles.Fullscreen,
				settings);

			aspectRatio = myWindow.Size.X / (double)myWindow.Size.Y;
			myWindow.SetVerticalSyncEnabled(true);
			myWindow.SetKeyRepeatEnabled(false);
			EventLinking(myWindow);
			MyShapes.SetShapes();
		}
开发者ID:RSF-Deus,项目名称:SFML.Net-V2.2-Template,代码行数:17,代码来源:SFMLConfig.cs

示例11: Main

        static void Main(string[] args)
        {
            var videoMode = new VideoMode(1000, 700);
            var contextSettings = new ContextSettings(0, 0, 4);
            RenderWindow window = new RenderWindow(videoMode, "Luda Diaria", Styles.Default, contextSettings);
            window.SetActive(true);
            window.Closed += (sender, e) => window.Close();
            Global.Window = window;

            Randomizer.Generator = new Random(42);

            var input = InputManager.Instance;
            input.Init();

            StateManager.Instance.CurrentState = new LoadingState();

            var lastTick = DateTime.Now;
            const float maxTimeStep = 0.5f;

            while (window.IsOpen())
            {
                float dt = (float)((DateTime.Now - lastTick).TotalSeconds);
                lastTick = DateTime.Now;

                window.DispatchEvents();
                window.Clear(Color.Black);

                if (input.IsKeyPressed(Keyboard.Key.Escape))
                {
                    window.Close();
                }

                while (dt > 0)
                {
                    //---UPDATE
                    var deltatTime = dt < maxTimeStep ? dt : maxTimeStep;
                    StateManager.Instance.CurrentState.Update(deltatTime);
                    dt -= maxTimeStep;
                }
                //---DRAW

                StateManager.Instance.CurrentState.Draw(window, RenderStates.Default);
                window.Display();
            }
        }
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:45,代码来源:Program.cs

示例12: Main

        private static void Main(string[] args)
        {
            var contextSettings = new ContextSettings { DepthBits = 32 };
            var window = new RenderWindow(new VideoMode(640, 480), "SFML.Net starter kit", Styles.Default, contextSettings);
            window.SetActive();

            window.Closed += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            int r=0,g=0,b=0;
            
            while (window.IsOpen())
            {
                window.DispatchEvents();                
                window.Clear(new Color((byte)r, (byte)g, (byte)b));
                window.Display();
            }
        }
开发者ID:nathanchere,项目名称:StarterKits.SFMLDotNet,代码行数:18,代码来源:Program.cs

示例13: Init

        public void Init()
        {
            ContextSettings settings = new ContextSettings();
            settings.AntialiasingLevel = 8;
            _window = new RenderWindow(new VideoMode(1600, 800), "Agar.net", Styles.Default, settings);

            _window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
            _window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnMouseButtonPressed);

            _sess = new Session(this);
            cells = new Dictionary<uint, Cell>();
            ownedCells = new List<uint>();
            _size = new Vector2f(10000, 10000);
            _viewX = _viewY = 5500;
            _viewRatio = 1;
            UpdateView();

            playing = spectating = false;
        }
开发者ID:Shiroy,项目名称:Agar.net,代码行数:19,代码来源:World.cs

示例14: Main

        public static void Main()
        {
            var resolution = new VideoMode(WIDTH, HEIGHT, 32);
            var windowSettings = new ContextSettings(32, 0, 4);
            var window = new RenderWindow(resolution, "Lockheed the Game", Styles.Close, windowSettings);

            window.Closed += Events.OnClose;
            window.KeyPressed += Events.OnKeyPressed;
            window.KeyReleased += Events.OnKeyReleased;
            window.MouseButtonPressed += Events.OnMouseButtonPressed;
            window.SetActive();

            Level.Level newLevel = Level.Level.GenerateSingleLevel();
            Character.Character glava = new Rogue("glava");

            glava.CurrentSkill = new ProjectileSkill(
                "fireball", 10, 10, 10, Tier.Beginner, 5, "weapons/projectiles/fireBall.png", 5);

            EntityManager.CurrentLevel = newLevel;
            EntityManager.Character = glava;

            DateTime lastTick = DateTime.Now;
            while (window.IsOpen())
            {
                float dt = (float)(DateTime.Now - lastTick).TotalMilliseconds;
                lastTick = DateTime.Now;
                window.DispatchEvents();

                while (dt > 0)
                {
                    EntityManager.Update();
                    dt -= MAX_TIMESTEP;
                }

                window.Clear(Color.Black);
                EntityManager.Draw(window);
                window.Display();
            }
        }
开发者ID:StanisInt,项目名称:SoftUniHomeworks,代码行数:39,代码来源:Program.cs

示例15: Main

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Request a 32-bits depth buffer when creating the window
            ContextSettings contextSettings = new ContextSettings();
            contextSettings.DepthBits = 32;

            // Create the main window
            Window window = new Window(new VideoMode(640, 480), "SFML window with OpenGL", Styles.Default, contextSettings);

            // Make it the active window for OpenGL calls
            window.SetActive();

            // Initialize OpenTK
            Toolkit.Init();
            GraphicsContext context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null);

            // Setup event handlers
            window.Closed     += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
            window.Resized    += new EventHandler<SizeEventArgs>(OnResized);

            // Set the color and depth clear values
            GL.ClearDepth(1);
            GL.ClearColor(0, 0, 0, 1);

            // Enable Z-buffer read and write
            GL.Enable(EnableCap.DepthTest);
            GL.DepthMask(true);

            // Disable lighting and texturing
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Texture2D);

            // Configure the viewport (the same size as the window)
            GL.Viewport(0, 0, (int)window.Size.X, (int)window.Size.Y);

            // Setup a perspective projection
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            float ratio = (float)(window.Size.X) / window.Size.Y;
            GL.Frustum(-ratio, ratio, -1, 1, 1, 500);

            // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
            float[] cube = new float[]
            {
                // positions    // colors (r, g, b, a)
                -50, -50, -50,  0, 0, 1, 1,
                -50,  50, -50,  0, 0, 1, 1,
                -50, -50,  50,  0, 0, 1, 1,
                -50, -50,  50,  0, 0, 1, 1,
                -50,  50, -50,  0, 0, 1, 1,
                -50,  50,  50,  0, 0, 1, 1,

                 50, -50, -50,  0, 1, 0, 1,
                 50,  50, -50,  0, 1, 0, 1,
                 50, -50,  50,  0, 1, 0, 1,
                 50, -50,  50,  0, 1, 0, 1,
                 50,  50, -50,  0, 1, 0, 1,
                 50,  50,  50,  0, 1, 0, 1,

                -50, -50, -50,  1, 0, 0, 1,
                 50, -50, -50,  1, 0, 0, 1,
                -50, -50,  50,  1, 0, 0, 1,
                -50, -50,  50,  1, 0, 0, 1,
                 50, -50, -50,  1, 0, 0, 1,
                 50, -50,  50,  1, 0, 0, 1,

                -50,  50, -50,  0, 1, 1, 1,
                 50,  50, -50,  0, 1, 1, 1,
                -50,  50,  50,  0, 1, 1, 1,
                -50,  50,  50,  0, 1, 1, 1,
                 50,  50, -50,  0, 1, 1, 1,
                 50,  50,  50,  0, 1, 1, 1,

                -50, -50, -50,  1, 0, 1, 1,
                 50, -50, -50,  1, 0, 1, 1,
                -50,  50, -50,  1, 0, 1, 1,
                -50,  50, -50,  1, 0, 1, 1,
                 50, -50, -50,  1, 0, 1, 1,
                 50,  50, -50,  1, 0, 1, 1,

                -50, -50,  50,  1, 1, 0, 1,
                 50, -50,  50,  1, 1, 0, 1,
                -50,  50,  50,  1, 1, 0, 1,
                -50,  50,  50,  1, 1, 0, 1,
                 50, -50,  50,  1, 1, 0, 1,
                 50,  50,  50,  1, 1, 0, 1,
            };

            // Enable position and color vertex components
            GL.EnableClientState(EnableCap.VertexArray);
            GL.EnableClientState(EnableCap.ColorArray);
            GL.VertexPointer(3, VertexPointerType.Float, 7 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 0));
            GL.ColorPointer(4, ColorPointerType.Float, 7 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 3));

            // Disable normal and texture coordinates vertex components
            GL.DisableClientState(EnableCap.NormalArray);
//.........这里部分代码省略.........
开发者ID:FelixKimmerle,项目名称:SFMLdotNetOpenGL,代码行数:101,代码来源:Window.cs


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