Beispiel #1
0
        public static void OnWindowLoad()
        {
            if (WindowLoadedContextVersion != WindowContextVersion)
            {
                Window.VSync = VSyncMode.Off;
                GL.EnableClientState(ArrayCap.VertexArray);
                GL.EnableClientState(ArrayCap.ColorArray);
                GL.EnableClientState(ArrayCap.TextureCoordArray);
                GL.Enable(EnableCap.TextureRectangle);
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                WindowLoadedContextVersion = WindowContextVersion;
            }

            // set necessary uniforms
            Shader s_rgb      = Shaders.Get("rgb");
            Shader s_stencil  = Shaders.Get("stencil");
            Shader s_paletted = Shaders.Get("paletted");

            s_rgb.SetUniform("texture1", 0);
            s_stencil.SetUniform("texture1", 0);
            s_paletted.SetUniform("texture1", 0);
            s_paletted.SetUniform("texture2", 1);

            SetViewport(0, 0, Width, Height);
            SetTranslation(0f, 0f, 0f);
        }
Beispiel #2
0
            internal static void Init()
            {
                _constants = new PrecomputeConstants();
                var atmosphere = Shaders.Get("Atmosphere");

                TransmittancePass = atmosphere.GetPass("PrecomputeTransmittance");
                InscatterPass     = atmosphere.GetPass("PrecomputeInscatter");
                NeedsRecompute    = true;
                IsInitialized     = true;
            }
Beispiel #3
0
        public static void SetViewport(int x, int y, int w, int h)
        {
            GL.Viewport(x, Height - (y + h), w, h);
            Shader s_rgb      = Shaders.Get("rgb");
            Shader s_stencil  = Shaders.Get("stencil");
            Shader s_paletted = Shaders.Get("paletted");
            Shader s_notex    = Shaders.Get("notex");

            s_rgb.SetUniform("screen", (float)x, (float)y, (float)w, (float)h);
            s_stencil.SetUniform("screen", (float)x, (float)y, (float)w, (float)h);
            s_paletted.SetUniform("screen", (float)x, (float)y, (float)w, (float)h);
            s_notex.SetUniform("screen", (float)x, (float)y, (float)w, (float)h);
        }
Beispiel #4
0
 public static void SetTranslation(float x, float y, float z)
 {
     if (ShadersTranslateX != x ||
         ShadersTranslateY != y ||
         ShadersTranslateZ != z)
     {
         ShadersTranslateX = x;
         ShadersTranslateY = y;
         ShadersTranslateZ = z;
         Shader s_rgb = Shaders.Get("rgb");
         s_rgb.SetUniform("translate", ShadersTranslateX, ShadersTranslateY, ShadersTranslateZ);
         Shader s_stencil = Shaders.Get("stencil");
         s_stencil.SetUniform("translate", ShadersTranslateX, ShadersTranslateY, ShadersTranslateZ);
         Shader s_paletted = Shaders.Get("paletted");
         s_paletted.SetUniform("translate", ShadersTranslateX, ShadersTranslateY, ShadersTranslateZ);
         Shader s_notex = Shaders.Get("notex");
         s_notex.SetUniform("translate", ShadersTranslateX, ShadersTranslateY, ShadersTranslateZ);
     }
 }
Beispiel #5
0
        internal void Draw(ref DeviceContext context)
        {
            PixHelper.BeginEvent(Color.Zero, "Terrain");
            if (_terrainPass == null)
            {
                _terrainShader = Shaders.Get("Terrain");
                _terrainPass   = _terrainShader.GetPass("Main");
            }

            lock (Renderer.Context)
            {
                _terrainPass.Use(ref context);

                foreach (var chunk in _chunks)
                {
                    chunk.Value.Draw(ref context);
                }
            }
            PixHelper.EndEvent();
        }