コード例 #1
0
 public static void Dispose()
 {
     UserInterface.UIWindow?.Dispose();
     UserInterface.UIWindow = (UIContainer)null;
     UserInterface.Elements?.Clear();
     Shaders.Dispose();
 }
コード例 #2
0
        public static void Dispose()
        {
            UIWindow.Dispose();
            UIWindow = null;

            Elements.Clear();

            Shaders.Dispose();
        }
コード例 #3
0
        public static Material InitShader(string vertexSource, string fragmentSource)
        {
            if (Shaders.Version == Shaders.ShaderVersion.GLSL120)
            {
                vertexSource   = Shaders.ConvertShader(vertexSource, true);
                fragmentSource = Shaders.ConvertShader(fragmentSource, false);
            }
            Material shaderProgram = new Material(vertexSource, fragmentSource);

            Shaders.LoadedPrograms.Add(shaderProgram);
            return(shaderProgram);
        }
コード例 #4
0
 public static void OnResize(int width, int height)
 {
     UserInterface.Width              = width;
     UserInterface.Height             = height;
     UserInterface.UIProjectionMatrix = Matrix4.CreateTranslation(new Vector3((float)(-UserInterface.Width / 2), (float)(-UserInterface.Height / 2), 0.0f)) * Matrix4.CreateOrthographic((float)UserInterface.Width, (float)UserInterface.Height, 0.0f, 1000f);
     Shaders.UpdateUIProjectionMatrix(UserInterface.UIProjectionMatrix);
     if (UserInterface.UIWindow == null)
     {
         return;
     }
     UserInterface.UIWindow.Size = new Point(UserInterface.Width, UserInterface.Height);
     UserInterface.UIWindow.OnResize();
 }
コード例 #5
0
 public static void InitUI(int width, int height)
 {
     if (!Shaders.Init(Shaders.ShaderVersion.GLSL140))
     {
         return;
     }
     UserInterface.Elements            = new Dictionary <string, UIElement>();
     UserInterface.UIWindow            = new UIContainer(new Point(0, 0), new Point(UserInterface.Width, UserInterface.Height), "TopLevel");
     UserInterface.UIWindow.RelativeTo = Corner.BottomLeft;
     UserInterface.Elements.Add("Screen", (UIElement)UserInterface.UIWindow);
     UserInterface.UIProjectionMatrix = Matrix4.CreateTranslation(new Vector3((float)(-UserInterface.Width / 2), (float)(-UserInterface.Height / 2), 0.0f)) * Matrix4.CreateOrthographic((float)UserInterface.Width, (float)UserInterface.Height, 0.0f, 1000f);
     UserInterface.Visible            = true;
     UserInterface.MainThreadID       = Thread.CurrentThread.ManagedThreadId;
     UserInterface.OnResize(width, height);
 }
コード例 #6
0
        public static void InitUI(int width, int height)
        {
            if (Shaders.Init())
            {
                Elements = new Dictionary <string, UIElement>();

                // create the top level screen container
                UIWindow            = new UIContainer(new Point(0, 0), new Point(UserInterface.Width, UserInterface.Height), "TopLevel");
                UIWindow.RelativeTo = Corner.BottomLeft;
                Elements.Add("Screen", UIWindow);

                UIProjectionMatrix = Matrix4.CreateTranslation(new Vector3(-UserInterface.Width / 2, -UserInterface.Height / 2, 0)) * Matrix4.CreateOrthographic(UserInterface.Width, UserInterface.Height, 0, 1000);

                Visible = true;

                MainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;

                OnResize(width, height);
            }
        }
コード例 #7
0
 public static bool Init(Shaders.ShaderVersion shaderVersion = Shaders.ShaderVersion.GLSL140)
 {
     if (Shaders.initialized)
     {
         return(true);
     }
     Shaders.Version = shaderVersion;
     try
     {
         Shaders.SolidUIShader    = Shaders.InitShader(Shaders.UISolidVertexSource, Shaders.UISolidFragmentSource);
         Shaders.TexturedUIShader = Shaders.InitShader(Shaders.UITexturedVertexSource, Shaders.UITexturedFragmentSource);
         Shaders.FontShader       = Shaders.InitShader(Shaders.FontVertexSource, Shaders.FontFragmentSource);
         Shaders.GradientShader   = Shaders.InitShader(Shaders.gradientVertexShaderSource, Shaders.gradientFragmentShaderSource);
         Shaders.HueShader        = Shaders.InitShader(Shaders.hueVertexShaderSource, Shaders.hueFragmentShaderSource);
         Shaders.initialized      = true;
     }
     catch (Exception ex)
     {
     }
     return(Shaders.initialized);
 }