public static void Dispose() { UserInterface.UIWindow?.Dispose(); UserInterface.UIWindow = (UIContainer)null; UserInterface.Elements?.Clear(); Shaders.Dispose(); }
public static void Dispose() { UIWindow.Dispose(); UIWindow = null; Elements.Clear(); Shaders.Dispose(); }
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); }
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(); }
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); }
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); } }
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); }