Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            //load hosts (change enabled to false for debugging with any combination of hosts)
            PerformanceHost = new PerformanceHost {
                Enabled = true
            };
            SkyHost = new SkyHost {
                Enabled = true
            };
            WorldHost = new WorldHost {
                Enabled = true
            };
            InputHost = new InputHost {
                Enabled = true
            };
            BlockCursorHost = new BlockCursorHost {
                Enabled = true
            };
            UiHost = new UiHost {
                Enabled = true
            };
            _hosts = new IHost[] { PerformanceHost, SkyHost, WorldHost, InputHost, BlockCursorHost, UiHost };

            NetworkClient.AcceptPackets = true;

            //enable GL states that wont change
            GL.Enable(EnableCap.Texture2D);
            GL.ShadeModel(ShadingModel.Smooth);             //allows gradients on polygons when using different colors on the vertices (smooth is the default)
            //GL.Enable(EnableCap.PolygonSmooth); //gm: antialiasing, this is an outdated way of doing it and should be done by multisampling (for us we might be better off just not bothering)
            //GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); //gm: no noticeable difference, outdated and prob makes no difference on most modern gpus
            //GL.Hint(HintTarget.GenerateMipmapHint, HintMode.Nicest); //gm testing: no noticeable difference
            GL.CullFace(CullFaceMode.Back);          //Indicates which polygons should be discarded (culled) before they're converted to screen coordinates. The mode is either GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK to indicate front-facing, back-facing, or all polygons. To take effect, culling must be enabled using glEnable() with GL_CULL_FACE; it can be disabled with glDisable() and the same argument.
            GL.FrontFace(FrontFaceDirection.Ccw);    //Controls how front-facing polygons are determined. By default, mode is GL_CCW, which corresponds to a counterclockwise orientation of the ordered vertices of a projected polygon in window coordinates. If mode is GL_CW, faces with a clockwise orientation are considered front-facing
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.PolygonOffset(-1f, -90f);             //used by the block cursor, negatives pull polygons closer to the camera

            if (Config.Fog)
            {
                GL.Enable(EnableCap.Fog);
                Misc.SetFogParameters();
            }

            //allow these types of pointers to be used with vbos
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.ColorArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);

            //enable GL states that are on initially and hosts toggle when needed
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);

            CalculateProjectionMatrix();
            UpdateFrustum();
            WorldHost.BuildWorld();
        }
Exemple #2
0
        private static void UpdateHandler(object sender, System.Timers.ElapsedEventArgs e)
        {
            //todo: this is running slightly slower then the updates on clients, might want to investigate at some point
            Debug.Assert(Config.IsServer, "Controller update handler should only be running for servers.");

            //somehow this happens, and would cause an ArgumentOutOfRangeException from FrameEventArgs
            //gm: must be rare, i ran a server for 10 mins with 3 players and this didnt happen, maybe because we're updating more stuff now, doesnt hurt to leave it though for now
            if (UpdateStopwatch.ElapsedMilliseconds <= 0)
            {
                return;
            }

            var frameEventArgs = new FrameEventArgs(UpdateStopwatch.ElapsedMilliseconds / 1000d);

            UpdateStopwatch.Restart();

            SkyHost.UpdateSun(frameEventArgs);
            WorldData.Chunks.Update(frameEventArgs);
            GameObjects.GameItems.GameItemDynamic.UpdateAll(frameEventArgs);

            unchecked { Settings.UpdateCounter++; }
        }
Exemple #3
0
 public CloudShadowsHost(Game game, SkyHost host)
     : base(game)
 {
     this.DrawOrder = 100;
     this.Host      = host;
 }