Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        public T Create <T>(string name) where T : RSceneNode
        {
            T node = RSceneNode.Create <T>();

            RLog.Info("Created a new node named: " + name);

            return(node);
        }
Пример #4
0
        public void CenterMouse()
        {
            RGameWindow window = REngine.RGame.GameWindow;
            var         x      = window.Location.X + (window.ClientSize.Width / 2);
            var         y      = window.Location.Y + (window.ClientSize.Height / 2);

            RLog.Info(String.Format("Set MouseCenter to {0} {1}", x, y));
            Mouse.SetPosition(x, y);
        }
Пример #5
0
 public void SetGameWindowIcon(System.Drawing.Icon icon)
 {
     try
     {
         RGame.GameWindow.Icon = icon;
     }
     catch (Exception e)
     {
         RLog.Error(e);
     }
 }
Пример #6
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);
 }
Пример #7
0
        void PrintExtensions()
        {
            var extensions = GL.GetString(StringName.Extensions).Split(' ');

            foreach (var extension in extensions)
            {
                if (extension.StartsWith("GL_EXT"))
                {
                    RLog.Debug(extension);
                }
            }
        }
Пример #8
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);
     }
 }
Пример #9
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());
            }
        }
Пример #10
0
        public REngine()
        {
            RootPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            RLog.Info("Engine startup sequence activated.");


            _stopWatch = new Stopwatch();
            _fpsTimer  = new System.Timers.Timer();

            _fpsTimer.Interval = 1000;
            _fpsTimer.Elapsed += _fpsTimer_Tick;
            _fpsTimer.Start();

            _viewport     = new RViewport(0, 0, 800, 600);
            camera        = new RCamera();
            lastFrameTime = new TimeSpan();
        }
Пример #11
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);
     }
 }
Пример #12
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);
     }
 }
Пример #13
0
        public void GetMouse(out int X, out int Y, out int Wheel)
        {
            var cursor = Mouse.GetCursorState();

            if (cursor.IsConnected)
            {
                X     = cursor.X;
                Y     = cursor.Y;
                Wheel = cursor.Wheel;
            }
            else
            {
                X     = -1;
                Y     = -1;
                Wheel = -1;
            }
            RLog.Info(String.Format("Mouse Data: [X:{0},Y:{1}]", cursor.X, cursor.Y));
        }
Пример #14
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);
     }
 }
Пример #15
0
        static void Setup(TextureTarget dimension)
        {
            #region Set Texture Parameters
            GL.GenerateMipmap(GetMipmapTargetForTextureTarget(dimension));
            GL.TexParameter(dimension, TextureParameterName.TextureMinFilter, (int)TextureLoaderParameters.MinificationFilter);
            GL.TexParameter(dimension, TextureParameterName.TextureMagFilter, (int)TextureLoaderParameters.MagnificationFilter);

            GL.TexParameter(dimension, TextureParameterName.TextureWrapS, (int)TextureLoaderParameters.WrapModeS);
            GL.TexParameter(dimension, TextureParameterName.TextureWrapT, (int)TextureLoaderParameters.WrapModeT);

            float maxAniso;
            GL.GetFloat((GetPName)ExtTextureFilterAnisotropic.MaxTextureMaxAnisotropyExt, out maxAniso);
            GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, maxAniso);

            ErrorCode GLError = GL.GetError( );
            if (GLError != ErrorCode.NoError)
            {
                RLog.Info("Error setting Texture Parameters. GL Error: " + GLError);
            }
            #endregion Set Texture Parameters
        }