/// <summary> /// OpenGL Start Device /// </summary> public void Start_GL() { NaviGL = new NaviFXF(); NaviGL.KeyDown += NaviGL_KeyDown; NaviGL.KeyUp += NaviGL_KeyUp; NaviGL.LostFocus += NaviGL_LostFocus; NaviGL.Disposed += NaviGL_Disposed; NaviGL.Show(); NaviGL.Location = new Point(0, 0); NaviGL.Width = Screen.PrimaryScreen.WorkingArea.Width; NaviGL.Height = Screen.PrimaryScreen.WorkingArea.Height; GLControl control = new GLControl(new GraphicsMode(32, 24, 8, 0), 3, 0, GraphicsContextFlags.Default); NaviGL.glControl1.Width = Screen.PrimaryScreen.WorkingArea.Width; NaviGL.glControl1.Height = Screen.PrimaryScreen.WorkingArea.Height; GL.ClearColor(Color.Black); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); ScreenSize.Width = Screen.PrimaryScreen.WorkingArea.Width; ScreenSize.Height = Screen.PrimaryScreen.WorkingArea.Height; GL.Viewport(0, 0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); GL.Ortho(0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height, 0, -1, 1); Load_Sprite_Sheets(); NaviForm.Hide(); Init_GL = true; }
public void Draw_Navi() { if (GLOn == false) { if (!(Host_Navi.Sprite == Host_Navi.OldSprite) || !(Host_Navi.FaceLeft == Host_Navi.OldFaceLeft)) { NaviForm.Invalidate(); Host_Navi.OldSprite = Host_Navi.Sprite; Host_Navi.OldFaceLeft = Host_Navi.FaceLeft; } } if (GLOn == true) { if (Init_GL == false) { Start_GL(); } ScreenScroll.X = Host_Navi.Location.X + Host_Navi.GetSize().X / 2 - ScreenSize.Width / 2; ScreenScroll.Y = Host_Navi.Location.Y + Host_Navi.GetSize().Y / 2 - ScreenSize.Height / 2; SizeF screenBounds = new SizeF(0 - (ScreenSize.Width - (ScreenSize.Width / ScreenZoom)) / 2, 0 - (ScreenSize.Height - (ScreenSize.Height / ScreenZoom)) / 2); SizeF stageBounds = new SizeF(0 - (stage.Bounds.Width - (stage.Bounds.Width / ScreenZoom)) / 2, 0 - (stage.Bounds.Height - (stage.Bounds.Height / ScreenZoom)) / 2); if (ScreenScroll.X + ScreenSize.Width > stage.Bounds.Width - screenBounds.Width) { ScreenScroll.X = stage.Bounds.Width - (ScreenSize.Width + screenBounds.Width); } if (ScreenScroll.X < screenBounds.Width) { ScreenScroll.X = screenBounds.Width; } if (ScreenScroll.Y < screenBounds.Height) { ScreenScroll.Y = screenBounds.Height; } if (ScreenScroll.Y + ScreenSize.Height > stage.Bounds.Height - screenBounds.Height) { ScreenScroll.Y = stage.Bounds.Height - (ScreenSize.Height + screenBounds.Height); } Draw_GL(); } }