Ejemplo n.º 1
0
        public static Shader CreateShader(string name, string vertexshaderpath, string fragmentshaderpath)
        {
            int vertexshaderid = GL.CreateShader(ShaderType.VertexShader);
            int fragmentshaderid = GL.CreateShader(ShaderType.FragmentShader);

            using (StreamReader r = new StreamReader(vertexshaderpath))
                GL.ShaderSource(vertexshaderid, r.ReadToEnd());
            using (StreamReader r = new StreamReader(fragmentshaderpath))
                GL.ShaderSource(fragmentshaderid, r.ReadToEnd());

            GL.CompileShader(vertexshaderid);

            string vertexshaderlog = GL.GetShaderInfoLog(vertexshaderid);
            if (!errored && !string.IsNullOrEmpty(vertexshaderlog))
            {
                errored = true;
                string renderer = GL.GetString(StringName.Renderer);
                Client.print("info", vertexshaderlog);
                //MessageBox.Show("Error occured in StoneVox. your graphics card seems to be unsupported. you are welcome to continue to use StoneVox, but likely run into visual errors. try updating your graphics card driver. Here's the name of your graphics card - " + renderer, "Error - Vertex Shader", MessageBoxButtons.OK);
            }

            GL.CompileShader(fragmentshaderid);

            string fragmentshaderlog = GL.GetShaderInfoLog(fragmentshaderid);
            if (!errored && !string.IsNullOrEmpty(fragmentshaderlog))
            {
                errored = true;
                string renderer = GL.GetString(StringName.Renderer);
                Client.print("info", fragmentshaderlog);
                //MessageBox.Show("Error occured in StoneVox. your graphics card seems to be unsupported. you are welcome to continue to use StoneVox, but likely run into visual errors. try updating your graphics card driver. Here's the name of your graphics card - " + renderer, "Error - Fragment Shader", MessageBoxButtons.OK);
            }

            int shaderid = GL.CreateProgram();
            GL.AttachShader(shaderid, vertexshaderid);
            GL.AttachShader(shaderid, fragmentshaderid);
            GL.LinkProgram(shaderid);

            string shaderlog = GL.GetProgramInfoLog(shaderid);

            if (!errored && !string.IsNullOrEmpty(shaderlog))
            {
                errored = true;
                string renderer = GL.GetString(StringName.Renderer);
                Client.print("info", shaderlog);
                //MessageBox.Show("Error occured in StoneVox. your graphics card seems to be unsupported. you are welcome to continue to use StoneVox, but likely run into visual errors. try updating your graphics card driver. Here's the name of your graphics card - " + renderer, "Error - Linking Shader", MessageBoxButtons.OK);
            }

            Shader shader = new Shader(shaderid, vertexshaderid, fragmentshaderid);
            _shaders.Add(name, shader);
            return shader;
        }
Ejemplo n.º 2
0
 public void RenderAll(Shader shader)
 {
     matrices.ForEach(t => t.RenderAll(shader));
 }
Ejemplo n.º 3
0
        public void RenderAll(Shader shader)
        {
            if (!Visible) return;

            shader.WriteUniform("highlight", new Vector3(highlight.R, highlight.G, highlight.B));

            unsafe
            {
                fixed (float* pointer = &colors[0].R)
                {
                    ShaderUtil.GetShader("qb").WriteUniformArray("colors", colorIndex, pointer);
                }
            }

            front.Render(shader);
            back.Render(shader);
            top.Render(shader);
            bottom.Render(shader);
            left.Render(shader);
            right.Render(shader);
        }
Ejemplo n.º 4
0
        public void Render(Shader shader)
        {
            if (!Visible) return;
            //foreach(var c in voxels.Values)
            //{
            ////    Debug.Print(c.front.ToString());
            ////    Debug.Print(c.back.ToString());
            ////    Debug.Print(c.left.ToString());
            ////    Debug.Print(c.right.ToString());
            //    Debug.Print(c.top.ToString());
            //    //Debug.Print(c.bottom.ToString());
            //}

            while (modifiedvoxels.Count > 0)
            {
                if (modifiedvoxels.TryPop(out modified))
                {
                    switch (modified.action)
                    {
                        case VoxleModifierAction.NONE:
                            break;
                        case VoxleModifierAction.ADD:
                            break;
                        case VoxleModifierAction.REMOVE:
                            break;
                        case VoxleModifierAction.RECOLOR:
                            break;
                    }
                }
            }

            shader.WriteUniform("highlight", new Vector3(highlight.R, highlight.G, highlight.B));

            unsafe
            {
                fixed (float* pointer = &colors[0].R)
                {
                    ShaderUtil.GetShader("qb").WriteUniformArray("colors", colorIndex, pointer);
                }
            }

            if (RayIntersectsPlane(ref front.normal, ref Singleton<Camera>.INSTANCE.direction))
            {
                front.Render(shader);
            }
            if (RayIntersectsPlane(ref back.normal, ref Singleton<Camera>.INSTANCE.direction))
            {
                back.Render(shader);
            }
            if (RayIntersectsPlane(ref top.normal, ref Singleton<Camera>.INSTANCE.direction))
            {
                top.Render(shader);
            }
            if (RayIntersectsPlane(ref bottom.normal, ref Singleton<Camera>.INSTANCE.direction))
            {
                bottom.Render(shader);
            }
            if (RayIntersectsPlane(ref left.normal, ref Singleton<Camera>.INSTANCE.direction))
            {
                left.Render(shader);
            }
            if (RayIntersectsPlane(ref right.normal, ref Singleton<Camera>.INSTANCE.direction))
            {
                right.Render(shader);
            }
        }
Ejemplo n.º 5
0
 public void Render(Shader shader)
 {
     shader.WriteUniform("light", lightscale);
     vBuffer.Render();
 }
Ejemplo n.º 6
0
 static SmoothBackground()
 {
    quadInterpolation = ShaderUtil.GetShader("quad_interpolation");
     camera = Singleton<Camera>.INSTANCE;
 }