示例#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);
            }
        }
示例#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);
            }
        }
示例#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 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);
     }
 }
示例#6
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();
        }
示例#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);
     }
 }
示例#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);
     }
 }
示例#9
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));
        }
示例#10
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);
     }
 }
示例#11
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
        }