Exemplo n.º 1
0
        public void TestGladPositive()
        {
            var actual = new Glad().FaceMask();

            Assert.AreEqual(expected: ":-)", actual: actual);
        }
Exemplo n.º 2
0
        public void TestGladNegative()
        {
            var actual = new Glad().FaceMask();

            Assert.AreNotEqual(expected: ":-(", actual: actual);
        }
Exemplo n.º 3
0
        private void Init(WindowProps props)
        {
            m_Data.Title  = props.Title;
            m_Data.Width  = props.Width;
            m_Data.Height = props.Height;

            Debug.DLog($"Creating Window {props.Title} ({props.Width}, {props.Height})");

            if (!s_GLFWInitialized)
            {
                bool succes = Glfw.Init();

                if (!succes)
                {
                    Debug.DLogError("Could not initailize GLFW!");
                    return;
                }
                Glfw.SetErrorCallback(GLFWErrorCallback);
                s_GLFWInitialized = true;
            }


            m_Window = Glfw.CreateWindow((int)props.Width, (int)props.Height, props.Title, Monitor.None, Window.None);
            Glfw.MakeContextCurrent(m_Window);
            int status = Glad.LoadGLLoader(_GetProcAddress);

            Debug.DLog(status);
            SetVSync(true);

            #region // Set GLFW callbacks
            Glfw.SetWindowSizeCallback(m_Window, delegate(Window window, int width, int height)
            {
                WindowsWindow.m_Data.Width  = (uint)width;
                WindowsWindow.m_Data.Height = (uint)height;

                WindowsWindow.m_Data.d(new WindowResizeEvent((uint)width, (uint)height));
            });

            Glfw.SetCloseCallback(m_Window, delegate(Window window)
            {
                WindowsWindow.m_Data.d(new WindowCloseEvent());
            });

            Glfw.SetKeyCallback(m_Window, delegate(Window window, Keys key, int scanCode, InputState state, ModifierKeys mods)
            {
                switch (state)
                {
                case InputState.Release:
                    {
                        WindowsWindow.m_Data.d(new KeyReleasedEvent((int)key));
                    }
                    break;

                case InputState.Press:
                    {
                        WindowsWindow.m_Data.d(new KeyPressedEvent((int)key, 0));
                    }
                    break;

                case InputState.Repeat:
                    {
                        WindowsWindow.m_Data.d(new KeyPressedEvent((int)key, 1));
                    }
                    break;
                }
            });

            Glfw.SetMouseButtonCallback(m_Window, delegate(Window window, MouseButton button, InputState state, ModifierKeys modifiers)
            {
                switch (state)
                {
                case InputState.Release:
                    {
                        WindowsWindow.m_Data.d(new MouseButtonReleasedEvent((int)button));
                    }
                    break;

                case InputState.Press:
                    {
                        WindowsWindow.m_Data.d(new MouseButtenPressedEvent((int)button));
                    }
                    break;
                }
            });

            Glfw.SetScrollCallback(m_Window, delegate(Window window, double x, double y)
            {
                WindowsWindow.m_Data.d(new MouseScrolledEvent((float)x, (float)y));
            });

            Glfw.SetCursorPositionCallback(m_Window, delegate(Window window, double x, double y)
            {
                WindowsWindow.m_Data.d(new MouseMovedEvent((float)x, (float)y));
            });

            #endregion
        }