コード例 #1
0
ファイル: Game.cs プロジェクト: hexpoint/voxelgame
        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();
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: MagistrAVSH/voxelgame
        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();
        }