Beispiel #1
0
        public bool InitGameWindow(RDisplayMode displayMode, RWindowStyle windowStyle, string title = "Reactor")
        {
            try
            {
                RGame.GameWindow.Title = title;

                GameWindowRenderControl control = new GameWindowRenderControl();
                control.GameWindow            = RGame.GameWindow;
                control.GameWindow.ClientSize = new System.Drawing.Size(displayMode.Width, displayMode.Height);
                if (windowStyle == RWindowStyle.Borderless)
                {
                    control.GameWindow.WindowBorder = WindowBorder.Hidden;
                }
                control.GameWindow.X = 0;
                control.GameWindow.Y = 0;
                control.Context      = (GraphicsContext)control.GameWindow.Context;
                _renderControl       = control;

                RLog.Info(GetGLInfo());
                REngine.CheckGLError();
                RLog.Info("Game Window Renderer Initialized.");
                //PrintExtensions();
                REngine.CheckGLError();

                RShader.InitShaders();
                REngine.CheckGLError();
                Screen.Init();
                REngine.CheckGLError();
                return(true);
            } catch (Exception e) {
                RLog.Error(e);
                return(false);
            }
        }
Beispiel #2
0
        public bool ToggleFullscreen(RDisplayMode displayMode)
        {
            try
            {
                if (_renderControl.IsFullscreen)
                {
                    DisplayDevice.Default.RestoreResolution();
                    if (_renderControl.GetType() == typeof(GameWindowRenderControl))
                    {
                        (_renderControl as GameWindowRenderControl).GameWindow.WindowState = WindowState.Normal;
                    }

                    _renderControl.IsFullscreen = false;
                    RLog.Info("No longer in fullscreen mode.");
                }
                else
                {
                    if (_renderControl.GetType() == typeof(GameWindowRenderControl))
                    {
                        DisplayDevice.Default.ChangeResolution(displayMode.Width, displayMode.Height, 32, -1);
                        (_renderControl as GameWindowRenderControl).GameWindow.Size        = new System.Drawing.Size(displayMode.Width, displayMode.Height);
                        (_renderControl as GameWindowRenderControl).GameWindow.WindowState = WindowState.Fullscreen;
                        _renderControl.IsFullscreen = true;
                        RLog.Info(String.Format("Fullscreen mode activated : {0}", displayMode));
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                RLog.Error("Error attempting to go fullscreen.");
                RLog.Error(e);
                return(false);
            }
        }
Beispiel #3
0
 public void SetGameWindowIcon(System.Drawing.Icon icon)
 {
     try
     {
         RGame.GameWindow.Icon = icon;
     }
     catch (Exception e)
     {
         RLog.Error(e);
     }
 }
Beispiel #4
0
 public MemoryStream GetPackageContent(string name)
 {
     foreach (var package in packages)
     {
         if (package.ContainsEntry(name))
         {
             return(package.GetEntry(name).Result);
         }
     }
     RLog.Error(String.Format("Entry {0} not found in any loaded packages"));
     return(null);
 }
Beispiel #5
0
 public bool Init()
 {
     try
     {
         _renderControl = new DummyRenderControl();
         _renderControl.Init();
         RLog.Info(GetGLInfo());
         RLog.Info("Dummy Non-Renderer Initialized.");
         PrintExtensions();
         return(true);
     } catch (Exception e) {
         RLog.Error(e);
         return(false);
     }
 }
Beispiel #6
0
        public static void CheckGLError()
        {
            ErrorCode error = GL.GetError();

            if (error != ErrorCode.NoError)
            {
                StackTrace   trace  = new StackTrace(true);
                StackFrame[] frames = trace.GetFrames();
                RLog.Error("Stack Trace:");
                foreach (StackFrame f in frames)
                {
                    RLog.Error(f.ToString());
                }
                throw new EngineGLException("GL.GetError() returned " + error.ToString());
            }
        }
Beispiel #7
0
 public bool Dispose()
 {
     try
     {
         RLog.Info("Shutting down the engine.");
         hdrFrameBuffer.Dispose();
         _renderControl.Destroy();
         RLog.Info("Shutdown complete.\r\n\r\n\r\n\r\n");
         return(true);
     }
     catch (Exception e)
     {
         RLog.Error("Error shutting down the engine.");
         RLog.Error(e);
         return(false);
     }
 }
Beispiel #8
0
 public bool InitPictureBox(IntPtr handle)
 {
     try
     {
         PictureBoxRenderControl control = new PictureBoxRenderControl();
         control.PictureBox = (PictureBox)PictureBox.FromHandle(handle);
         control.Init();
         _renderControl = control;
         RShader.InitShaders();
         Screen.Init();
         RLog.Info(GetGLInfo());
         RLog.Info("Picture Box Renderer Initialized.");
         return(true);
     } catch (Exception e) {
         RLog.Error(e);
         return(false);
     }
 }
Beispiel #9
0
 public bool InitForm(IntPtr handle)
 {
     try
     {
         FormRenderControl control = new FormRenderControl();
         control.Form = (Form)Form.FromHandle(handle);
         control.Init();
         _renderControl = control;
         RShader.InitShaders();
         Screen.Init();
         RLog.Info(GetGLInfo());
         RLog.Info("Form Renderer Initialized.");
         PrintExtensions();
         return(true);
     }
     catch (Exception e)
     {
         RLog.Error(e);
         return(false);
     }
 }