public void Set(int w, int h) { GL.ClearColor(System.Drawing.Color.AliceBlue); GL.Enable(EnableCap.DepthTest); AppInfo.W = w; AppInfo.H = h; AppInfo.RW = w; AppInfo.RH = h; AppInfo.Full = false; AppInfo.App = "GLApp"; VImport.RegDefaults(); for (int i = 0; i < 32; i++) { VInput.MB[i] = false; } VPen.InitDraw(); VInput.InitInput(); Vivid.Sound.VSoundSys.Init(); GL.Viewport(0, 0, w, h); GL.Scissor(0, 0, w, h); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Texture2D); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.Disable(EnableCap.StencilTest); GL.Disable(EnableCap.ScissorTest); GL.Enable(EnableCap.DepthTest); GL.DepthRange(0, 1); GL.ClearDepth(1.0f); GL.DepthFunc(DepthFunction.Less); // UI.UISys.ActiveUI.OnResize(Width, Height); VPen.SetProj(0, 0, w, h); }
public override void DrawButton(UIButton b) { VTex2D bi; bi = StateImg(b.State); int fw = SmallFont.Width(b.Name); int fh = SmallFont.Height(); Vector4 col = new Vector4(1, 1, 1, 1 * UISys.AlphaMod); switch (b.State) { case ButState.Norm: col = new Vector4(0.6f, 0.6f, 0.6f, 0.6f * UISys.AlphaMod); break; case ButState.Hover: col = new Vector4(0.8f, 0.8f, 0.8f, 0.8f * UISys.AlphaMod); break; case ButState.Press: col = Vector4.One; col.W = col.W * UISys.AlphaMod; break; } VPen.Rect((int)b.WidX, (int)b.WidY, (int)b.WidW, (int)b.WidH, bi, col); VFontRenderer.Draw(SmallFont, b.Name, (int)(b.WidX + b.WidW / 2 - (fw / 2)), (int)(b.WidY + (b.WidH) / 2 - (fh / 2)), new Vector4(1, 1, 1, UISys.AlphaMod)); if (b == UISys.Active) { VPen.Line(b.WidX, b.WidY + 4, b.WidX + b.WidW, b.WidY + 4, new Vector4(1, 1, 1, 1)); } }
protected override void OnLoad(EventArgs e) { CursorVisible = true; VPen.SetProj(0, 0, Width, Height); SetGL(); InitApp(); PushState(InitState); }
public void SetSize(int w, int h) { AppInfo.W = w; AppInfo.H = h; AppInfo.RW = w; AppInfo.RH = h; GL.Viewport(0, 0, w, h); GL.Scissor(0, 0, w, h); VPen.SetProj(0, 0, w, h); }
public override void DrawWindow(UIWindow w) { WinBackCol.W = w.Alpha * UISys.AlphaMod; // VPen.Rect(w.WidX, w.WidY, w.WidW, w.WidH, WinBord, WinBackCol); VPen.Rect(w.WidX, w.WidY, w.WidW, w.WidH, WinCon, WinBackCol); if (w.DrawTitle) { WinTitCol.W = w.Alpha * UISys.AlphaMod; VPen.Rect(w.WidX, w.WidY, w.WidW, TitleHeight, WinTitle, WinTitCol); VFontRenderer.Draw(SmallFont, w.Name, w.WidX + 5, w.WidY + 2, new Vector4(1, 1, 1, UISys.AlphaMod)); } }
public static void Draw(VFont font, string text, int x, int y, Vector4 col) { int dx = x; VPen.BlendMod = VBlend.Alpha; foreach (Char c in text) { VGlyph cg = font.Glypth[(int)c]; VPen.Rect(dx, y, cg.W, cg.H, cg.Img, col); dx += (int)((float)cg.W / 1.3f); } }
public override void DrawPanel(UIPanel p) { if (p.Flat) { VPen.Rect(p.WidX, p.WidY, p.WidW, p.WidH, new Vector4(0.7f, 0.7f, 0.7f, 0.8f)); } else { VPen.Rect(p.WidX, p.WidY, p.WidW, p.WidH, PanelBG, new Vector4(0.7f, 0.7f, 0.7f, 0.9f)); } VFontRenderer.Draw(SmallFont, p.Name, p.WidX + 5, p.WidY + 5); }
public override void Draw() { VFontRenderer.Draw(UISys.Skin().SmallFont, Name, WidX + 5, WidY + 5, new OpenTK.Vector4(1, 1, 1, 1)); if (WinOver == false) { VPen.Rect(WidX, WidY, WidW, 50, new OpenTK.Vector4(0, 0, 0.5f, 0.1f)); } else { VPen.Rect(WidX, WidY, WidW, 50, new OpenTK.Vector4(0, 0, 0.5f, 0.35f)); if (StarEngine.Input.VInput.MB[0] == false && UISys.ActiveWindow.Docked == false) { DockWin(); } } }
public StarApp(string app, int width, int height, bool full) : base(width, height, OpenTK.Graphics.GraphicsMode.Default, app, full ? GameWindowFlags.Fullscreen : GameWindowFlags.Default, DisplayDevice.Default, 4, 5, OpenTK.Graphics.GraphicsContextFlags.ForwardCompatible) { Link = this; _Title = app; AppInfo.W = width; AppInfo.H = height; AppInfo.RW = width; AppInfo.RH = height; AppInfo.Full = full; AppInfo.App = app; W = width; H = height; RW = width; RH = height; Import.Import.RegDefaults(); VPen.InitDraw(); StarEngine.Sound.StarSoundSys.Init(); }
public VApp(string app, int width, int height, bool full) : base(width, height, OpenTK.Graphics.GraphicsMode.Default, app, full ? GameWindowFlags.Fullscreen : GameWindowFlags.Default, DisplayDevice.Default, 4, 5, OpenTK.Graphics.GraphicsContextFlags.ForwardCompatible) { Link = this; _Title = app; AppInfo.W = width; AppInfo.H = height; AppInfo.RW = width; AppInfo.RH = height; AppInfo.Full = full; AppInfo.App = app; VImport.RegDefaults(); for (int i = 0; i < 32; i++) { VInput.MB[i] = false; } VPen.InitDraw(); VInput.InitInput(); Vivid.Sound.VSoundSys.Init(); }
public void DrawForm(VTex2D tex, int x = 0, int y = 0) { VPen.BlendMod = VBlend.Alpha; VPen.Rect(GX + x, GY + y, W, H, CoreTex, Col); }
public override void DrawBox(int x, int y, int w, int h) { VPen.Rect(x, y, w, h, new Vector4(0.2f, 0.2f, 0.2f, 0.8f * UISys.AlphaMod)); VPen.Rect(x + 2, y + 2, w - 4, h - 4, new Vector4(0.9f, 0.9f, 0.9f, 0.8f * UISys.AlphaMod)); }
public override void DrawLine(int x, int y, int x2, int y2, Vector4 col) { VPen.Line(x, y, x2, y2, col); }
protected override void OnLoad(EventArgs e) { CursorVisible = true; VPen.SetProj(0, 0, Width, Height); }
public override void DrawState() { bool RenderDarkLogo() { VPen.Rect(0, 0, StarApp.W, StarApp.H, LogoTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha)); return(PresentLogo); } bool RenderPresLogo() { VPen.Rect(0, 0, StarApp.W, StarApp.H, this.PresTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha)); return(GameLogo); } bool RenderGameLogo() { //Console.WriteLine("Rendering!"); VPen.Rect(0, 0, StarApp.W, StarApp.H, GameTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha)); return(ToMenu); } void DoMenu() { LogoAlpha = 0.0f; ms.Stop(); StarApp.PushState(new MainMenuState()); } bool CheckInput() { if (ToMenu) { return(true); } if (VInput.MB[0]) { return(true); } if (VInput.KeyIn(OpenTK.Input.Key.Enter) || VInput.KeyIn(OpenTK.Input.Key.Space)) { return(true); } return(false); } //Logics.Do(TestDo); Graphics.When(CheckInput, DoMenu, null); Graphics.Flow(null, RenderDarkLogo); Graphics.Flow(null, RenderPresLogo); Graphics.Flow(null, RenderGameLogo); Graphics.SmartUpdate(); return; void DarkLogo() { VPen.Rect(0, 0, StarApp.W, StarApp.H, LogoTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha)); } bool DarkLogoUntil() { return(PresentLogo); } void PresLogo() { VPen.Rect(0, 0, StarApp.W, StarApp.H, LogoTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha)); } bool PresentLogoUntil() { return(ReboundLogo); } void DoPresent() { Graphics.Do(PresLogo, PresentLogoUntil); } Graphics.Do(DarkLogo, DarkLogoUntil, DoPresent); Graphics.InternalUpdate(); }
public virtual void DrawImg(int x, int y, int w, int h, VTex2D img, Vector4 col) { VPen.Rect(x, y, w, h, img, col); }
public virtual void DrawRect(int x, int y, int w, int h, Vector4 c1, Vector4 c2) { VPen.Rect(x, y, w, h, c1, c2); }
public override void InitState() { Console.WriteLine("Loading logo tex."); LogoTex = new StarEngine.Texture.VTex2D("Data\\2D\\Logo\\DarkArtLogo.png", LoadMethod.Single); PresTex = new VTex2D("Data\\2D\\Logo\\Presents.png", LoadMethod.Single); GameTex = new VTex2D("Data\\2D\\Logo\\ArenaLogo.png", LoadMethod.Single); Console.WriteLine("Loaded."); ms = StarSoundSys.Play2DFile("Data\\Music\\Logo\\LogoTheme1.wav"); VPen.SetProj(0, 0, StarApp.W, StarApp.H); bool AlphaUp() { LogoAlpha = LogoAlpha + 0.015f; if (LogoAlpha > 1.0f) { return(true); } return(false); } int waitStart = 0; void WaitInit() { waitStart = Environment.TickCount; } bool WaitABit() { if (Environment.TickCount > waitStart + 2000) { return(true); } return(false); } bool logoDone = false; bool AlphaDown() { LogoAlpha -= 0.01f; if (LogoAlpha < 0.0f) { logoDone = true; LogoAlpha = 0.0f; return(true); } return(false); } void TestDo() { } void DoPresent() { LogoAlpha = 0.0f; PresentLogo = true; } void DoGame() { LogoAlpha = 0.0f; GameLogo = true; } void Done() { ms.Stop(); ToMenu = true; } Logics.Flow(null, AlphaUp); Logics.Flow(WaitInit, WaitABit); Logics.Flow(null, AlphaDown, DoPresent); Logics.Flow(null, AlphaUp); Logics.Flow(WaitInit, WaitABit); Logics.Flow(null, AlphaDown, DoGame); Logics.Flow(null, AlphaUp); Logics.Flow(WaitInit, WaitABit); Logics.Flow(null, AlphaDown, Done); bool StateDone() { return(logoDone); } void NextState() { ms.Stop(); PresentLogo = true; } bool UnlessMusic() { return(ms.Playing); } Logics.When(StateDone, NextState, UnlessMusic); }