Exemplo n.º 1
0
        static void Main(string[] args)
        {
            UnitTest.UnitTest test = new UnitTest.UnitTest();
            string[] my_args = { System.Reflection.Assembly.GetAssembly(test.GetType()).Location};
            int returnCode = NUnit.ConsoleRunner.Runner.Main(my_args);

            if (returnCode != 0)
                Console.Beep();

            Console.WriteLine("press the anykey to exit ...");
            Console.ReadKey();
        }
        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color.MidnightBlue);

            renderer = new Gwen.Renderer.OpenTK();
            skin     = new Gwen.Skin.TexturedSkin(renderer, "DefaultSkin.png");
            //skin = new Gwen.Skin.Simple(renderer);
            //skin.DefaultFont = new Font(renderer, "Courier", 10);
            canvas = new Canvas(skin);

            input = new Gwen.Input.OpenTK(this);
            input.Initialize(canvas);

            canvas.SetSize(Width, Height);
            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor      = Color.FromArgb(255, 150, 170, 170);
            //canvas.KeyboardInputEnabled = true;

            test = new UnitTest.UnitTest(canvas);

            stopwatch.Restart();
            lastTime = 0;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color.MidnightBlue);

            renderer = new Gwen.Renderer.OpenTK();
            skin     = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png");

            skin.DefaultFont = new Font(renderer, "Arial", 10);
            canvas           = new Canvas(skin);

            input = new Input.OpenTK(this);
            input.Initialize(canvas);

            canvas.SetSize(Width, Height);
            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor      = Color.FromArgb(255, 150, 170, 170);
            ////canvas.KeyboardInputEnabled = true;

            //Control.TreeControl ctrl = new Control.TreeControl(canvas);

            //ctrl.AddNode("Node One");
            //ctrl.AddNode("Node Two").AddNode("Node Two Inside");
            //ctrl.SetBounds(20, 20, 400, 400);

            test = new UnitTest.UnitTest(canvas);

            //var button = new Button(canvas);
            //button.Font = new Font(renderer, "Times New Roman", 30);
            //button.AutoSizeToContents = false;
            //button.Text = "Hello I am a\n test button!";
            //button.SetPosition(500, 500);
            //button.SetSize(200, 30);

            stopwatch.Restart();
            lastTime = 0;
        }
        protected override void OnLoad()
        {
            GL.ClearColor(Color.MidnightBlue);

            renderer = new Gwen.Renderer.OpenTK(this);
            skin     = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png")
            {
                DefaultFont = new Font(renderer, "Arial", 10)
            };
            canvas = new Canvas(skin);

            input = new Input.OpenTK();
            input.Initialize(canvas);

            canvas.SetSize(1024, 768);
            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor      = Color.FromArgb(255, 150, 170, 170);
            //canvas.KeyboardInputEnabled = true;

            test = new UnitTest.UnitTest(canvas);

            stopwatch.Restart();
            lastTime = 0;
        }
        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color.MidnightBlue);

            renderer = new Gwen.Renderer.OpenTK();
            skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png");

            skin.DefaultFont = new Font(renderer, "Arial", 10);
            canvas = new Canvas(skin);

            input = new Input.OpenTK(this);
            input.Initialize(canvas);

            canvas.SetSize (1024, 768);
            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor = Color.FromArgb(255, 150, 170, 170);
            //canvas.KeyboardInputEnabled = true;

            test = new UnitTest.UnitTest(canvas);

            stopwatch.Restart();
            lastTime = 0;
        }
Exemplo n.º 6
0
        static void Main()
        {
            //try
            {
                const int width  = 1024;
                const int height = 768;

                // Create main window
                m_Window = new RenderWindow(new VideoMode(width, height), "GWEN.Net SFML test", Styles.Titlebar | Styles.Close | Styles.Resize, new ContextSettings(32, 0));

                // Setup event handlers
                m_Window.Closed              += OnClosed;
                m_Window.KeyPressed          += OnKeyPressed;
                m_Window.Resized             += OnResized;
                m_Window.KeyReleased         += window_KeyReleased;
                m_Window.MouseButtonPressed  += window_MouseButtonPressed;
                m_Window.MouseButtonReleased += window_MouseButtonReleased;
                m_Window.MouseWheelMoved     += window_MouseWheelMoved;
                m_Window.MouseMoved          += window_MouseMoved;
                m_Window.TextEntered         += window_TextEntered;

                //m_Window.SetFramerateLimit(60);

                const int   fps_frames = 50;
                List <long> ftime      = new List <long>(fps_frames);
                long        lastTime   = 0;

                // create GWEN renderer
                Renderer.SFML gwenRenderer = new Renderer.SFML(m_Window);

                // Create GWEN skin
                //Skin.Simple skin = new Skin.Simple(GwenRenderer);
                Skin.TexturedBase skin = new Skin.TexturedBase(gwenRenderer, "DefaultSkin.png");

                // set default font
                Font defaultFont = new Font(gwenRenderer)
                {
                    Size = 10, FaceName = "Arial Unicode MS"
                };

                // try to load, fallback if failed
                if (gwenRenderer.LoadFont(defaultFont))
                {
                    gwenRenderer.FreeFont(defaultFont);
                }
                else // try another
                {
                    defaultFont.FaceName = "Arial";
                    if (gwenRenderer.LoadFont(defaultFont))
                    {
                        gwenRenderer.FreeFont(defaultFont);
                    }
                    else // try default
                    {
                        defaultFont.FaceName = "OpenSans.ttf";
                    }
                }

                skin.SetDefaultFont(defaultFont.FaceName);
                defaultFont.Dispose(); // skin has its own

                // Create a Canvas (it's root, on which all other GWEN controls are created)
                m_Canvas = new Canvas(skin);
                m_Canvas.SetSize(width, height);
                m_Canvas.ShouldDrawBackground = true;
                m_Canvas.BackgroundColor      = System.Drawing.Color.FromArgb(255, 150, 170, 170);
                m_Canvas.KeyboardInputEnabled = true;

                // create the unit test control
                m_UnitTest = new UnitTest.UnitTest(m_Canvas);

                // Create GWEN input processor
                m_Input = new Input.SFML();
                m_Input.Initialize(m_Canvas, m_Window);

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (m_Window.IsOpen())
                {
                    m_Window.SetActive();
                    m_Window.DispatchEvents();
                    m_Window.Clear();

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

                    if (ftime.Count == fps_frames)
                    {
                        ftime.RemoveAt(0);
                    }

                    ftime.Add(stopwatch.ElapsedMilliseconds - lastTime);
                    lastTime = stopwatch.ElapsedMilliseconds;

                    if (stopwatch.ElapsedMilliseconds > 1000)
                    {
                        m_UnitTest.Fps = 1000f * ftime.Count / ftime.Sum();
                        stopwatch.Restart();
                    }

                    // render GWEN canvas
                    m_Canvas.RenderCanvas();

                    m_Window.Display();
                }

                // we only need to dispose the canvas, it will take care of disposing all its children
                m_Canvas.Dispose();

                // also dispose of these
                skin.Dispose();
                gwenRenderer.Dispose();
            }
            //catch (Exception e)
            //{
            //String msg = String.Format("Exception: {0}\n{1}", e.Message, e.StackTrace);
            //MessageBox.Show(msg);
            //}

            m_Window.Dispose();
        }
Exemplo n.º 7
0
        static void Main()
        {
            //try
            {
                const int width = 1024;
                const int height = 768;

                // Create main window
                m_Window = new RenderWindow(new VideoMode(width, height), "GWEN.Net SFML test", Styles.Titlebar|Styles.Close|Styles.Resize, new ContextSettings(32, 0));

                // Setup event handlers
                m_Window.Closed += OnClosed;
                m_Window.KeyPressed += OnKeyPressed;
                m_Window.Resized += OnResized;
                m_Window.KeyReleased += window_KeyReleased;
                m_Window.MouseButtonPressed += window_MouseButtonPressed;
                m_Window.MouseButtonReleased += window_MouseButtonReleased;
                m_Window.MouseWheelMoved += window_MouseWheelMoved;
                m_Window.MouseMoved += window_MouseMoved;
                m_Window.TextEntered += window_TextEntered;

                //m_Window.SetFramerateLimit(60);

                const int fps_frames = 50;
                List<long> ftime = new List<long>(fps_frames);
                long lastTime = 0;

                // create GWEN renderer
                Renderer.SFML gwenRenderer = new Renderer.SFML(m_Window);

                // Create GWEN skin
                //Skin.Simple skin = new Skin.Simple(GwenRenderer);
                Skin.TexturedBase skin = new Skin.TexturedBase(gwenRenderer, "DefaultSkin.png");

                // set default font
                Font defaultFont = new Font(gwenRenderer) {Size = 10, FaceName = "Arial Unicode MS"};
                
                // try to load, fallback if failed
                if (gwenRenderer.LoadFont(defaultFont))
                {
                    gwenRenderer.FreeFont(defaultFont);
                }
                else // try another
                {
                    defaultFont.FaceName = "Arial";
                    if (gwenRenderer.LoadFont(defaultFont))
                    {
                        gwenRenderer.FreeFont(defaultFont);
                    }
                    else // try default
                    {
                        defaultFont.FaceName = "OpenSans.ttf";
                    }
                }

                skin.SetDefaultFont(defaultFont.FaceName);
                defaultFont.Dispose(); // skin has its own

                // Create a Canvas (it's root, on which all other GWEN controls are created)
                m_Canvas = new Canvas(skin);
                m_Canvas.SetSize(width, height);
                m_Canvas.ShouldDrawBackground = true;
                m_Canvas.BackgroundColor = System.Drawing.Color.FromArgb(255, 150, 170, 170);
                m_Canvas.KeyboardInputEnabled = true;

                // create the unit test control
                m_UnitTest = new UnitTest.UnitTest(m_Canvas);

                // Create GWEN input processor
                m_Input = new Input.SFML();
                m_Input.Initialize(m_Canvas, m_Window);

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (m_Window.IsOpen())
                {
                    m_Window.SetActive();
                    m_Window.DispatchEvents();
                    m_Window.Clear();

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

                    if (ftime.Count == fps_frames)
                        ftime.RemoveAt(0);

                    ftime.Add(stopwatch.ElapsedMilliseconds - lastTime);
                    lastTime = stopwatch.ElapsedMilliseconds;

                    if (stopwatch.ElapsedMilliseconds > 1000)
                    {
                        m_UnitTest.Fps = 1000f * ftime.Count / ftime.Sum();
                        stopwatch.Restart();
                    }

                    // render GWEN canvas
                    m_Canvas.RenderCanvas();

                    m_Window.Display();
                }

                // we only need to dispose the canvas, it will take care of disposing all its children
                m_Canvas.Dispose();
                
                // also dispose of these
                skin.Dispose();
                gwenRenderer.Dispose();
            }
            //catch (Exception e)
            //{
                //String msg = String.Format("Exception: {0}\n{1}", e.Message, e.StackTrace);
                //MessageBox.Show(msg);
            //}

            m_Window.Dispose();
        }