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);
            }
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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);
        }
        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();
            }
        }
Beispiel #5
0
 public Game(uint antialias, bool hq)
 {
     settings = new ContextSettings();
     settings.AntialiasingLevel = antialias;
     player = new Player();
     level = new Level();
     highQuality = hq;
 }
        public VideoSettings()
        {
            WindowStyle    = Styles.Default; // Titlebar + Resize + Close
            WindowSettings = VideoMode.DesktopMode;

            OpenGLSettings = new ContextSettings();
            RefreshRate    = 30;
        }
Beispiel #7
0
        public Game()
        {
            videoMode = new VideoMode(960, 540);
            title = "SFML Game Window";
            style = Styles.Close;
            context = new ContextSettings();

            ScreenManager = new ScreenManager();
        }
Beispiel #8
0
        ////////////////////////////////////////////////////////////
        /// <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 = Encoding.UTF32.GetBytes(title + '\0');

            unsafe
            {
                fixed(byte *titlePtr = titleAsUtf32)
                {
                    CPointer = sfWindow_createUnicode(mode, (IntPtr)titlePtr, style, ref settings);
                }
            }
        }
Beispiel #9
0
            ////////////////////////////////////////////////////////////
            /// <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));
                    }
                }
           }
Beispiel #10
0
            ////////////////////////////////////////////////////////////
            /// <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();
           }
		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();
		}
Beispiel #12
0
        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();
            }
        }
        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();
            }
        }
Beispiel #14
0
        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;
        }
Beispiel #15
0
        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();
            }
        }
Beispiel #16
0
        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.MouseMoved += MouseMoved;
            //      Context.MouseButtonPressed += MouseButtonPressed;
            //      Context.MouseButtonReleased += MouseButtonReleased;
            //      Context.MouseWheelMoved += MouseWheelMoved;
            //      Context.JoystickButtonPressed += JoystickButtonPressed;
            //      Context.JoystickButtonReleased += JoystickButtonReleased;
            //      Context.JoystickConnected += JoystickConnected;
            //      Context.JoystickDisconnected += JoystickDisconnected;
            //      Context.JoystickMoved += JoystickMoved;
              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);
              // Context.SetView(Context.DefaultView); // Resets the view to the window size. Good for drawing UI
        }
Beispiel #17
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Create the window from an existing control
 /// </summary>
 /// <param name="Handle">Platform-specific handle of the control</param>
 /// <param name="settings">Creation parameters</param>
 ////////////////////////////////////////////////////////////
 public Window(IntPtr Handle, ContextSettings settings) :
     base(sfWindow_createFromHandle(Handle, ref settings))
 {
 }
Beispiel #18
0
 static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, ref ContextSettings Params);
Beispiel #19
0
        private void Start()
        {
            //SFML неща
            ContextSettings cs = new ContextSettings();
            cs.AntialiasingLevel = 8;

            window = new RenderWindow(new VideoMode(renderFrame.width, renderFrame.height), "GRAPHical Learner", Styles.Titlebar | Styles.Close, cs);
            window.Closed += window_Closed;
            window.MouseWheelMoved += window_MouseWheelMoved;
            window.KeyPressed += window_KeyPressed;
            window.MouseButtonPressed += window_MouseButtonPressed;
            window.MouseButtonReleased += window_MouseButtonReleased;

            window.SetVerticalSyncEnabled(true);

            //Алгоритъм за подреждане
            fs = new ForceSimulatorMKIIB(1.5, 0.8);
            fs.SetGraph(activeGraph);
            fs.SimulatorStopped += fs_SimulatorStopped;

            //Изчислява се приближението на рамката
            renderFrame.CalcZoom();

            //Пуска се GUI-то
            InitializeGui();
            if (connector != null) EnablePhysics(); // ако е вързан алгоритъм, графа се подрежда автоматично
            Loop();
        }
Beispiel #20
0
 static extern IntPtr sfWindow_createFromHandle(IntPtr Handle, ref ContextSettings Params);
Beispiel #21
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Create the window from an existing control
 /// </summary>
 /// <param name="Handle">Platform-specific handle of the control</param>
 /// <param name="settings">Creation parameters</param>
 ////////////////////////////////////////////////////////////
 public Window(IntPtr Handle, ContextSettings settings) :
     base(sfWindow_createFromHandle(Handle, ref settings))
 {
 }
 public CluwneWindow(VideoMode mode, string title, Styles style, ContextSettings settings) : base(mode, title, style, settings)
 {
 }
Beispiel #23
0
 static extern IntPtr sfWindow_Create(VideoMode Mode, string Title, Styles Style, ref ContextSettings Params);
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Request a 24-bits depth buffer when creating the window
            ContextSettings contextSettings = new ContextSettings();
            contextSettings.DepthBits = 24;

            // Create the main window
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML graphics with OpenGL", Styles.Default, contextSettings);
            window.SetVerticalSyncEnabled(true);

            // 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);

            // Create a sprite for the background
            Sprite background = new Sprite(new Texture("resources/background.jpg"));

            // Create a text to display on top of the OpenGL object
            Text text = new Text("SFML / OpenGL demo", new Font("resources/sansation.ttf"));
            text.Position = new Vector2f(250, 450);
            text.Color = new Color(255, 255, 255, 170);

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

            // Load an OpenGL texture.
            // We could directly use a SFML.Graphics.Texture as an OpenGL texture (with its Bind() member function),
            // but here we want more control on it (generate mipmaps, ...) so we create a new one
            int texture = 0;
            using (Image image = new Image("resources/texture.jpg"))
            {
                GL.GenTextures(1, out texture);
                GL.BindTexture(TextureTarget.Texture2D, texture);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Pixels);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            }

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

            // Disable lighting
            GL.Disable(EnableCap.Lighting);

            // 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);

            // Bind the texture
            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, texture);

            // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
            float[] cube = new float[]
            {
                // positions    // texture coordinates
                -20, -20, -20,  0, 0,
                -20,  20, -20,  1, 0,
                -20, -20,  20,  0, 1,
                -20, -20,  20,  0, 1,
                -20,  20, -20,  1, 0,
                -20,  20,  20,  1, 1,

                 20, -20, -20,  0, 0,
                 20,  20, -20,  1, 0,
                 20, -20,  20,  0, 1,
                 20, -20,  20,  0, 1,
                 20,  20, -20,  1, 0,
                 20,  20,  20,  1, 1,

                -20, -20, -20,  0, 0,
                 20, -20, -20,  1, 0,
                -20, -20,  20,  0, 1,
                -20, -20,  20,  0, 1,
                 20, -20, -20,  1, 0,
                 20, -20,  20,  1, 1,

                -20,  20, -20,  0, 0,
                 20,  20, -20,  1, 0,
                -20,  20,  20,  0, 1,
                -20,  20,  20,  0, 1,
                 20,  20, -20,  1, 0,
                 20,  20,  20,  1, 1,

                -20, -20, -20,  0, 0,
                 20, -20, -20,  1, 0,
                -20,  20, -20,  0, 1,
                -20,  20, -20,  0, 1,
                 20, -20, -20,  1, 0,
                 20,  20, -20,  1, 1,

                -20, -20,  20,  0, 0,
                 20, -20,  20,  1, 0,
                -20,  20,  20,  0, 1,
                -20,  20,  20,  0, 1,
                 20, -20,  20,  1, 0,
                 20,  20,  20,  1, 1
            };

            // Enable position and texture coordinates vertex components
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.VertexPointer(3, VertexPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 0));
            GL.TexCoordPointer(2, TexCoordPointerType.Float, 5 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 3));

            // Disable normal and color vertex components
            GL.DisableClientState(ArrayCap.NormalArray);
            GL.DisableClientState(ArrayCap.ColorArray);

            Clock clock = new Clock();

            // Start game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();

                // Clear the window
                GL.Clear(ClearBufferMask.DepthBufferBit);

                // Draw background
                window.PushGLStates();
                window.Draw(background);
                window.PopGLStates();

                // Clear the depth buffer
                GL.Clear(ClearBufferMask.DepthBufferBit);

                // We get the position of the mouse cursor, so that we can move the box accordingly
                float x =  Mouse.GetPosition(window).X * 200.0F / window.Size.X - 100.0F;
                float y = -Mouse.GetPosition(window).Y * 200.0F / window.Size.Y + 100.0F;

                // Apply some transformations
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.Translate(x, y, -100.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 50, 1.0F, 0.0F, 0.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 30, 0.0F, 1.0F, 0.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 90, 0.0F, 0.0F, 1.0F);

                // Draw the cube
                GL.DrawArrays(OpenTK.Graphics.OpenGL.PrimitiveType.Triangles, 0, 36);

                // Draw some text on top of our OpenGL object
                window.PushGLStates();
                window.Draw(text);
                window.PopGLStates();

                // Finally, display the rendered frame on screen
                window.Display();
            }

            // Don't forget to destroy our texture
            GL.DeleteTextures(1, ref texture);
        }
Beispiel #25
0
 ////////////////////////////////////////////////////////////
 /// <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(sfWindow_create(mode, title, style, ref settings))
 {
 }
Beispiel #26
0
 ////////////////////////////////////////////////////////////
 /// <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(sfWindow_Create(mode, title, style, ref settings))
 {
     myInput = new Input(sfWindow_GetInput(This));
 }
Beispiel #27
0
 ////////////////////////////////////////////////////////////
 /// <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(sfWindow_Create(mode, title, style, ref settings))
 {
     myInput = new Input(sfWindow_GetInput(This));
 }
Beispiel #28
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Create the window from an existing control
 /// </summary>
 /// <param name="Handle">Platform-specific handle of the control</param>
 /// <param name="settings">Creation parameters</param>
 ////////////////////////////////////////////////////////////
 public Window(IntPtr Handle, ContextSettings settings) :
     base(sfWindow_CreateFromHandle(Handle, ref settings))
 {
     myInput = new Input(sfWindow_GetInput(This));
 }
Beispiel #29
0
 ////////////////////////////////////////////////////////////
 /// <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(sfWindow_create(mode, title, style, ref settings))
 {
 }
Beispiel #30
0
 static extern IntPtr sfWindow_createUnicode(VideoMode Mode, IntPtr Title, Styles Style, ref ContextSettings Params);
Beispiel #31
0
 static extern IntPtr sfWindow_createFromHandle(IntPtr Handle, ref ContextSettings Params);
Beispiel #32
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Create the window from an existing control
 /// </summary>
 /// <param name="Handle">Platform-specific handle of the control</param>
 /// <param name="settings">Creation parameters</param>
 ////////////////////////////////////////////////////////////
 public Window(IntPtr Handle, ContextSettings settings) :
     base(sfWindow_CreateFromHandle(Handle, ref settings))
 {
     myInput = new Input(sfWindow_GetInput(This));
 }
 public CluwneWindow(IntPtr handle, ContextSettings settings) : base(handle, settings)
 {
 }
Beispiel #34
0
 ////////////////////////////////////////////////////////////
 /// <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(sfRenderWindow_Create(mode, title, style, ref settings), 0)
 {
     Initialize();
 }
Beispiel #35
0
 static extern IntPtr sfWindow_createUnicode(VideoMode Mode, IntPtr Title, Styles Style, ref ContextSettings Params);
Beispiel #36
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Create the window from an existing control
 /// </summary>
 /// <param name="handle">Platform-specific handle of the control</param>
 /// <param name="settings">Creation parameters</param>
 ////////////////////////////////////////////////////////////
 public RenderWindow(IntPtr handle, ContextSettings settings)
     : base(sfRenderWindow_CreateFromHandle(handle, ref settings), 0)
 {
     Initialize();
 }
        /// <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);
            GL.DisableClientState(EnableCap.TextureCoordArray);

            Clock clock = new Clock();

            // Start the game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();

                // Clear color and depth buffer
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                // Apply some transformations
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.Translate(0.0F, 0.0F, -200.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 50, 1.0F, 0.0F, 0.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 30, 0.0F, 1.0F, 0.0F);
                GL.Rotate(clock.ElapsedTime.AsSeconds() * 90, 0.0F, 0.0F, 1.0F);

                // Draw the cube
                GL.DrawArrays(BeginMode.Triangles, 0, 36);

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
Beispiel #38
0
        ////////////////////////
        // Métodos
        ////////////////////////

        public void Init() 
        {
            _logger.Log(LogLevel.Info, " > Configurando aplicación.");

            // buffer 32 bits de colors
            ContextSettings contextSettings = new ContextSettings();
            contextSettings.DepthBits = 32;

            // Creamos la ventana principal
            _logger.Log(LogLevel.Info, " >> Creando ventana principal.");
            // ventana no redimensionable
            _window = new RenderWindow(new VideoMode(800, 600), "Galaga ", Styles.Close, contextSettings);

            // gestor de escenas
            _logger.Log(LogLevel.Info, " >> Creando gestor de escenas.");
            _scnManager = new SceneManager();

            // Se crea el gestor de recursos y se leen los elementos
            _logger.Log(LogLevel.Info, " >> Creando gestor de recursos.");
            _resManager = new ResourcesManager(
                this.GetType().Assembly.GetManifestResourceStream("Galaga.main.resxml"));
            _resManager.RegisterLoadFunction("texture", SFMLResourcesManager.LoadTexture);
            _resManager.RegisterLoadFunction("font", SFMLResourcesManager.LoadFont);

            // creación del contexto
            _context = new Scene.Context(_window, _resManager);

            _timePerFrame = SFML.System.Time.FromSeconds(1f / 40f);           // como mínimo 40 frames por segundo
            _isPaused = false;

            RegisterDelegates();
            RegisterScenes();

            // pongo la primera escena en la pila
            _logger.Log(LogLevel.Info, " >> Push escena principal.");
            _scnManager.Push((int)SceneID.TITLE);
        
        }