Window is a rendering window ; it can create a new window or connect to an existing one
상속: SFML.System.ObjectBase
예제 #1
0
 public static void AddWindowHandlers(Window wind)
 {
     wind.Closed += window_Closed;
     wind.KeyPressed += window_KeyPressed;
     wind.KeyReleased += window_KeyReleased;
     wind.MouseWheelMoved += window_MouseWheel;
 }
예제 #2
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// This function returns the current touch position
 /// relative to the given window
 /// </summary>
 /// <param name="Finger">Finger index</param>
 /// <param name="RelativeTo">Reference window</param>
 /// <returns>Current position of the finger</returns>
 ////////////////////////////////////////////////////////////
 public static Vector2i GetPosition(uint Finger, Window RelativeTo)
 {
     if (RelativeTo != null)
         return RelativeTo.InternalGetTouchPosition(Finger);
     else
         return sfTouch_getPosition(Finger, IntPtr.Zero);
 }
예제 #3
0
파일: Mouse.cs 프로젝트: Yozer/NanoWar
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Get the current position of the mouse
 /// </summary>
 /// This function returns the current position of the mouse
 /// cursor relative to a window.
 /// <param name="relativeTo">Reference window</param>
 /// <returns>Current position of the mouse</returns>
 ////////////////////////////////////////////////////////////
 public static Vector2i GetPosition(Window relativeTo)
 {
     if (relativeTo != null)
         return relativeTo.InternalGetMousePosition();
     else
         return sfMouse_getPosition(IntPtr.Zero);
 }
예제 #4
0
        override public SystemMessage HandleKeyInput(Window window, KeyEventArgs e)
        {
            if (e.Code == Keyboard.Key.Escape)
            {
                return new PopStateMessage(this);
            }

            return null;
        }
예제 #5
0
        private static void InitEvents(Window rw)
        {
            rw.Closed += (s, e) => ((RenderWindow)s).Close();

            rw.KeyPressed += OnKeyPressed;

            rw.KeyReleased += OnKeyReleased;

            rw.MouseMoved += OnMouseMoved;

            rw.MouseButtonPressed += OnMouseButtonPressed;

            _eventsInitialized = true;
        }
예제 #6
0
        public void Init(Window window)
        {
            window.GainedFocus += window_HasGainedFocus;
            window.LostFocus += window_HasLostFocus;

            window.MouseButtonPressed += window_MouseButtonPressed;
            window.MouseButtonReleased += window_MouseButtonReleased;
            window.MouseMoved += window_MouseMoved;

            window.KeyPressed += window_KeyPressed;
            window.KeyReleased += window_KeyReleased;

            window.Resized += window_Resized;
        }
예제 #7
0
 override public SystemMessage HandleKeyInput(Window window, KeyEventArgs e)
 {
     //check whi h key has been pressed and react accordingly
     if(e.Code == Keyboard.Key.Return)
     {
         //act differently depending on which menu object we have selected
         if (selected == 0)//easy mode
         {
             return new PushNewStateMessage(new EasyModeState());
         }
         else if (selected == 1)
         {
             return new PushNewStateMessage(new HardcoreModeState());
         }
         else if (selected == 2)
         {
             return new PushNewStateMessage(new ScoreBoardState());
         }
         else if (selected == 3)//quit the game
         {
             return new QuitMessage();
         }
     }
     else if(e.Code == Keyboard.Key.Down)
     {
         if (selected < 3)
         {
             selected++;
         }
         else
         {
             selected = 0;
         }
         pointer.Position = new Vector2f(30.0f, 100.0f * (selected + 1));
     }
     else if (e.Code == Keyboard.Key.Up)
     {
         if (selected > 0)
         {
             selected--;
         }
         else
         {
             selected = 3;
         }
         pointer.Position = new Vector2f(30.0f, 100.0f * (selected + 1));
     }
     return null;
 }
예제 #8
0
파일: GUIManager.cs 프로젝트: wtfcolt/game
        /// <summary>
        /// Initializes a new instance of the <see cref="GUIManager"/> class.
        /// </summary>
        /// <param name="window">The <see cref="Window"/> that provides the input.</param>
        /// <param name="font">Default <see cref="Font"/> to use for controls added to this <see cref="GUIManager"/>.</param>
        /// <param name="skinManager">The <see cref="ISkinManager"/> that handles the skinning for this
        /// <see cref="GUIManager"/>.</param>
        /// <param name="screenSize">The initial screen size value.</param>
        /// <exception cref="ArgumentNullException"><paramref name="skinManager"/> is null.</exception>
        public GUIManager(Window window, Font font, ISkinManager skinManager, Vector2 screenSize)
        {
            if (skinManager == null)
                throw new ArgumentNullException("skinManager");

            ScreenSize = screenSize;

            Window = window;
            _skinManager = skinManager;

            Font = font;

            // Create the tooltip
            _tooltip = CreateTooltip();
        }
예제 #9
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Update a texture from the contents of a window
 /// </summary>
 /// <param name="window">Window to copy to the texture</param>
 /// <param name="x">X offset in the texture where to copy the source pixels</param>
 /// <param name="y">Y offset in the texture where to copy the source pixels</param>
 ////////////////////////////////////////////////////////////
 public void Update(SFML.Window.Window window, uint x, uint y)
 {
     sfTexture_updateFromWindow(CPointer, window.CPointer, x, y);
 }
예제 #10
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Update a texture from the contents of a window
 /// </summary>
 /// <param name="window">Window to copy to the texture</param>
 ////////////////////////////////////////////////////////////
 public void Update(SFML.Window.Window window)
 {
     Update(window, 0, 0);
 }
예제 #11
0
파일: Window.cs 프로젝트: kenygia/SFML.Net
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Create the main window
            Window window = new Window(new VideoMode(640, 480, 32), "SFML.Net Window", Styles.Default, new ContextSettings(32, 0));
            window.SetVerticalSyncEnabled(true);

            // 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.glClearDepth(1.0F);
            Gl.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);

            // Enable Z-buffer read and write
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthMask(Gl.GL_TRUE);

            // Setup a perspective projection
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluPerspective(90.0F, 1.0F, 1.0F, 500.0F);

            int startTime = Environment.TickCount;

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

                // Activate the window before using OpenGL commands.
                // This is useless here because we have only one window which is
                // always the active one, but don't forget it if you use multiple windows
                window.SetActive();

                // Clear color and depth buffer
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

                // Apply some transformations
                float time = (Environment.TickCount - startTime) / 1000.0F;
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Gl.glTranslatef(0.0F, 0.0F, -200.0F);
                Gl.glRotatef(time * 50, 1.0F, 0.0F, 0.0F);
                Gl.glRotatef(time * 30, 0.0F, 1.0F, 0.0F);
                Gl.glRotatef(time * 90, 0.0F, 0.0F, 1.0F);

                // Draw a cube
                Gl.glBegin(Gl.GL_QUADS);

                    Gl.glColor3f(1.0F, 0.0F, 0.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F, -50.0F);

                    Gl.glColor3f(1.0F, 0.0F, 0.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, 50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F, 50.0F);
                    Gl.glVertex3f( 50.0F,  50.0F, 50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F, 50.0F);

                    Gl.glColor3f(0.0F, 1.0F, 0.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F,  50.0F);
                    Gl.glVertex3f(-50.0F, -50.0F,  50.0F);

                    Gl.glColor3f(0.0F, 1.0F, 0.0F);
                    Gl.glVertex3f(50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f(50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f(50.0F,  50.0F,  50.0F);
                    Gl.glVertex3f(50.0F, -50.0F,  50.0F);

                    Gl.glColor3f(0.0F, 0.0F, 1.0F);
                    Gl.glVertex3f(-50.0F, -50.0F,  50.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F,  50.0F);

                    Gl.glColor3f(0.0F, 0.0F, 1.0F);
                    Gl.glVertex3f(-50.0F, 50.0F,  50.0F);
                    Gl.glVertex3f(-50.0F, 50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, 50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, 50.0F,  50.0F);

                Gl.glEnd();

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
예제 #12
0
 abstract public SystemMessage HandleKeyInput(Window window, KeyEventArgs e);
예제 #13
0
파일: Window.cs 프로젝트: freemaul/SFML
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Create the main window
            Window App = new Window(new VideoMode(640, 480, 32), "SFML.Net Window");

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

            // Set the color and depth clear values
            Gl.glClearDepth(1.0F);
            Gl.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);

            // Enable Z-buffer read and write
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthMask(Gl.GL_TRUE);

            // Setup a perspective projection
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluPerspective(90.0F, 1.0F, 1.0F, 500.0F);

            float Time = 0.0F;

            // Start the game loop
            while (App.IsOpened())
            {
                // Process events
                App.DispatchEvents();

                // Set the active window before using OpenGL commands
                // It's useless here because the active window is always the same,
                // but don't forget it if you use multiple windows
                App.SetActive();

                // Clear color and depth buffer
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

                // Apply some transformations
                Time += App.GetFrameTime();
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Gl.glTranslatef(0.0F, 0.0F, -200.0F);
                Gl.glRotatef(Time * 50, 1.0F, 0.0F, 0.0F);
                Gl.glRotatef(Time * 30, 0.0F, 1.0F, 0.0F);
                Gl.glRotatef(Time * 90, 0.0F, 0.0F, 1.0F);

                // Draw a cube
                Gl.glBegin(Gl.GL_QUADS);

                    Gl.glColor3f(1.0F, 0.0F, 0.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F, -50.0F);

                    Gl.glColor3f(1.0F, 0.0F, 0.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, 50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F, 50.0F);
                    Gl.glVertex3f( 50.0F,  50.0F, 50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F, 50.0F);

                    Gl.glColor3f(0.0F, 1.0F, 0.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f(-50.0F,  50.0F,  50.0F);
                    Gl.glVertex3f(-50.0F, -50.0F,  50.0F);

                    Gl.glColor3f(0.0F, 1.0F, 0.0F);
                    Gl.glVertex3f(50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f(50.0F,  50.0F, -50.0F);
                    Gl.glVertex3f(50.0F,  50.0F,  50.0F);
                    Gl.glVertex3f(50.0F, -50.0F,  50.0F);

                    Gl.glColor3f(0.0F, 0.0F, 1.0F);
                    Gl.glVertex3f(-50.0F, -50.0F,  50.0F);
                    Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, -50.0F,  50.0F);

                    Gl.glColor3f(0.0F, 0.0F, 1.0F);
                    Gl.glVertex3f(-50.0F, 50.0F,  50.0F);
                    Gl.glVertex3f(-50.0F, 50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, 50.0F, -50.0F);
                    Gl.glVertex3f( 50.0F, 50.0F,  50.0F);

                Gl.glEnd();

                // Finally, display the rendered frame on screen
                App.Display();
            }
        }
예제 #14
0
 /// <summary>
 /// Initializes the <see cref="ILightManager"/> so it can be drawn. This must be called before any drawing
 /// can take place, but does not need to be drawn before <see cref="ILight"/> are added to or removed
 /// from the collection.
 /// </summary>
 /// <param name="window">The <see cref="Window"/>.</param>
 public void Initialize(Window window)
 {
     InitializeRenderBuffer(window);
 }
예제 #15
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Set the current position of the mouse
 /// </summary>
 /// This function sets the current position of the mouse
 /// cursor relative to a window.
 /// <param name="position">New position of the mouse</param>
 /// <param name="relativeTo">Reference window</param>
 ////////////////////////////////////////////////////////////
 public static void SetPosition(Vector2i position, Window relativeTo)
 {
     if (relativeTo != null)
         relativeTo.InternalSetMousePosition(position);
     else
         sfMouse_setPosition(position, IntPtr.Zero);
 }
예제 #16
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Get the current position of the mouse
 /// </summary>
 /// This function returns the current position of the mouse
 /// cursor relative to a window.
 /// <param name="relativeTo">Reference window</param>
 /// <returns>Current position of the mouse</returns>
 ////////////////////////////////////////////////////////////
 public static Vector2i GetPosition(Window relativeTo)
 {
     return sfMouse_getPosition(relativeTo != null ? relativeTo.CPointer : IntPtr.Zero);
 }
예제 #17
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Set the current position of the mouse
 /// </summary>
 /// This function sets the current position of the mouse
 /// cursor relative to a window.
 /// <param name="position">New position of the mouse</param>
 /// <param name="relativeTo">Reference window</param>
 ////////////////////////////////////////////////////////////
 public static void SetPosition(Vector2i position, Window relativeTo)
 {
     sfMouse_setPosition(position, relativeTo != null ? relativeTo.CPointer : IntPtr.Zero);
 }
예제 #18
0
        /// <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();

            // 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.glClearDepth(1);
            Gl.glClearColor(0, 0, 0, 1);

            // Enable Z-buffer read and write
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthMask(Gl.GL_TRUE);

            // Disable lighting and texturing
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glDisable(Gl.GL_TEXTURE_2D);

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

            // Setup a perspective projection
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            float ratio = (float)(window.Size.X) / window.Size.Y;
            Gl.glFrustum(-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.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            Gl.glEnableClientState(Gl.GL_COLOR_ARRAY);
            Gl.glVertexPointer(3, Gl.GL_FLOAT, 7 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 0));
            Gl.glColorPointer(4, Gl.GL_FLOAT, 7 * sizeof(float), Marshal.UnsafeAddrOfPinnedArrayElement(cube, 3));

            // Disable normal and texture coordinates vertex components
            Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY);
            Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);

            int startTime = Environment.TickCount;

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

                // Clear color and depth buffer
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

                // Apply some transformations
                float time = (Environment.TickCount - startTime) / 1000.0F;
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Gl.glTranslatef(0.0F, 0.0F, -200.0F);
                Gl.glRotatef(time * 50, 1.0F, 0.0F, 0.0F);
                Gl.glRotatef(time * 30, 0.0F, 1.0F, 0.0F);
                Gl.glRotatef(time * 90, 0.0F, 0.0F, 1.0F);

                // Draw the cube
                Gl.glDrawArrays(Gl.GL_TRIANGLES, 0, 36);

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
예제 #19
0
        /// <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();
            }
        }
예제 #20
0
파일: Keyboard.cs 프로젝트: Rohansi/LoonyVM
        public Keyboard(byte id, Window window)
        {
            Id = id;

            _enabled = false;
            _eventQueue = new Queue<KeyEvent>(10);

            window.KeyPressed += (sender, args) =>
            {
                if (!_enabled || args.Code == SFMLKey.Unknown)
                    return;

                lock (_eventQueue)
                    _eventQueue.Enqueue(new KeyEvent(true, KeyToCode(args.Code)));
            };

            window.KeyReleased += (sender, args) =>
            {
                if (!_enabled || args.Code == SFMLKey.Unknown)
                    return;

                lock (_eventQueue)
                    _eventQueue.Enqueue(new KeyEvent(false, KeyToCode(args.Code)));
            };
        }
        /// <summary>
        /// Initializes the internal components of the buffer. This only needs to be called once.
        /// </summary>
        /// <param name="window">The <see cref="Window"/> to use.</param>
        protected void InitializeRenderBuffer(Window window)
        {
            if (_window == window)
                return;

            // Set the new Window
            _window = window;

            // Force the buffer to be rebuilt
            if (_ri != null)
            {
                // Dispose of the old buffer
                try
                {
                    if (!_ri.IsDisposed)
                        _ri.Display();
                }
                catch (Exception ex)
                {
                    const string errmsg = "Failed to dispose RenderImage `{0}`. Exception: {1}";
                    if (log.IsWarnEnabled)
                        log.WarnFormat(errmsg, _ri, ex);
                    Debug.Fail(string.Format(errmsg, _ri, ex));
                }

                // Set to null to force rebuild when needed
                _ri = null;
            }
        }
예제 #22
0
파일: Texture.cs 프로젝트: Yozer/NanoWar
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Update a texture from the contents of a window
 /// </summary>
 /// <param name="window">Window to copy to the texture</param>
 ////////////////////////////////////////////////////////////
 public void Update(Window.Window window)
 {
     Update(window, 0, 0);
 }
예제 #23
0
파일: Texture.cs 프로젝트: Yozer/NanoWar
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Update a texture from the contents of a window
 /// </summary>
 /// <param name="window">Window to copy to the texture</param>
 /// <param name="x">X offset in the texture where to copy the source pixels</param>
 /// <param name="y">Y offset in the texture where to copy the source pixels</param>
 ////////////////////////////////////////////////////////////
 public void Update(Window.Window window, uint x, uint y)
 {
     sfTexture_updateFromWindow(CPointer, window.CPointer, x, y);
 }
예제 #24
0
        public static void Init(Window Wind)
        {
            States = new Stack<State>();
            Screen = new RenderSprite((int)Scales.XRes, (int)Scales.YRes);
            FPSLabel = new Text("FPS: Unknown", ResourceMgr.Get<Font>("Inconsolata"), Scales.GetFontSize(16));
            FPSLabel.Position = new Vector2f(0.01f * Scales.XRes, 0);

            Wind.Closed += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnClosed();
            };

            Wind.GainedFocus += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnGainedFocus();
            };

            Wind.LostFocus += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnLostFocus();
            };

            Wind.KeyPressed += (S, E) => {
                if (E.Alt && E.Code == Keyboard.Key.F4) {
                    Program.Running = false;
                    return;
                }
                if (States.Count > 0)
                    States.Peek().OnKey(E, true);
            };

            Wind.KeyReleased += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnKey(E, false);
            };

            Wind.TextEntered += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnTextEntered(E);
            };

            Wind.MouseButtonPressed += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnMouseButton(E, true);
            };

            Wind.MouseButtonReleased += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnMouseButton(E, false);
            };

            Wind.MouseEntered += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnMouseEntered(true);
            };

            Wind.MouseLeft += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnMouseEntered(false);
            };

            Wind.MouseMoved += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnMouseMoved(E);
            };

            Wind.MouseWheelMoved += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnMouseWheelMoved(E);
            };

            Wind.Resized += (S, E) => {
                if (States.Count > 0)
                    States.Peek().OnResized(E);
            };

            PushState(new MenuState());
        }