Example #1
0
        public override void Draw(RendererBase <ToyWorld> renderer, ToyWorld world)
        {
            if (Settings.EnabledGameObjects == RenderRequestGameObject.None)
            {
                return;
            }

            if (!Settings.Use3D)
            {
                GL.Enable(EnableCap.Blend);
                Owner.SetDefaultBlending();
            }
            else
            {
                GL.Disable(EnableCap.Blend);
            }

            GL.Enable(EnableCap.DepthTest);
            GL.DepthMask(true);

            // Bind stuff to GL
            renderer.TextureManager.Bind(TilesetTexture[0], Owner.GetTextureUnit(RenderRequestBase.TextureBindPosition.SummerTileset));
            renderer.TextureManager.Bind(TilesetTexture[1], Owner.GetTextureUnit(RenderRequestBase.TextureBindPosition.WinterTileset));
            renderer.TextureManager.Bind(TileTypesTexure, Owner.GetTextureUnit(RenderRequestBase.TextureBindPosition.TileTypes));
            renderer.EffectManager.Use(Effect);
            Effect.TextureUniform((int)RenderRequestBase.TextureBindPosition.SummerTileset);
            Effect.TextureWinterUniform((int)RenderRequestBase.TextureBindPosition.WinterTileset);
            Effect.TileTypesTextureUniform((int)RenderRequestBase.TextureBindPosition.TileTypes);
            Effect.DiffuseUniform(new Vector4(1, 1, 1, Owner.EffectPainter.GetGlobalDiffuseComponent(world)));
            Effect.TileVertexCountUniform(Settings.Use3D ? DuplicatedCubeGrid.FaceCount * 4 : 4);

            if (Settings.EnabledGameObjects.HasFlag(RenderRequestGameObject.TileLayers))
            {
                DrawTileLayers(renderer, world);
            }
            if (Settings.EnabledGameObjects.HasFlag(RenderRequestGameObject.ObjectLayers))
            {
                DrawObjectLayers(renderer, world);
            }
        }