示例#1
0
        void CreateVBO(bool origCenter)
        {
            if (Vbo != null)
            {
                Vbo.Dispose();
            }

            ushort[] ind = new ushort[] { 0, 1, 3, 1, 2, 3 };
            int      w, h, nw = 0, nh = 0;

            if (origCenter)
            {
                w  = RealWidth / 2;
                h  = RealHeight / 2;
                nw = -w;
                nh = -h;
            }
            else
            {
                w = RealWidth;
                h = RealHeight;
            }

            Vertex[] vert =
            {
                new Vertex(new Vector3(nw, nh, 0), new Vector3(0, 0, 1), new Vector2(0, 0)),
                new Vertex(new Vector3(nw, h,  0), new Vector3(0, 0, 1), new Vector2(0, 1)),
                new Vertex(new Vector3(w,  h,  0), new Vector3(0, 0, 1), new Vector2(1, 1)),
                new Vertex(new Vector3(w,  nh, 0), new Vector3(0, 0, 1), new Vector2(1, 0))
            };
            Vbo = new VBO();
            Vbo.DataToVBO(vert, ind, VBO.VertexMode.UV1);

            Vbo.Shader = GLSLShader.Load("default2d.shader");
        }
示例#2
0
        public static PostEffect Load(string shaderFileName, string flags)
        {
            PostEffect eff = new PostEffect();

            eff.effect = GLSLShader.Load(shaderFileName + (flags == "" ? "" : ":" + flags));
            return(eff);
        }
示例#3
0
        public static void Create(FBO fbo, string lightMaskFileName)
        {
            if (Settings.DisableShadowMapping)
            {
                UseShadowMapping = false;
                return;
            }

            if (FBO.IsSupported == false)
            {
                Log.WriteLine("FBOs not supported so no shadow mapping.");
                UseShadowMapping = false;
                return;
            }

            ShadowMapping.fbo = fbo;
            UseShadowMapping  = true;
            TextureLoaderParameters.WrapModeS = TextureWrapMode.ClampToEdge;
            TextureLoaderParameters.WrapModeT = TextureWrapMode.ClampToEdge;
            try
            {
                lightMask = Texture.Load(lightMaskFileName);
            }
            catch (Exception) { } // skipataan valitukset jos tiedostoa ei löydy
            TextureLoaderParameters.WrapModeS = TextureWrapMode.Repeat;
            TextureLoaderParameters.WrapModeT = TextureWrapMode.Repeat;
            depthShader          = GLSLShader.Load("depth.shader");
            depthShaderAlphaTest = GLSLShader.Load("depth.shader:ALPHATEST");
        }
示例#4
0
文件: OgreMesh.cs 项目: Keilerr/csat
        void LoadMesh(string name, string fileName)
        {
            Name = name;
            XmlDocument XMLDoc = null;
            XmlElement  XMLRoot;

            try
            {
                using (System.IO.StreamReader file = new System.IO.StreamReader(Settings.ModelDir + fileName))
                {
                    // tiedosto muistiin
                    string data = file.ReadToEnd();
                    XMLDoc = new XmlDocument();
                    XMLDoc.LoadXml(data);
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }

            // Validate the File
            XMLRoot = XMLDoc.DocumentElement;
            if (XMLRoot.Name != "mesh")
            {
                Log.Error("Error [" + fileName + "] Invalid .mesh.xml File. Missing <mesh>");
            }

            bool isPath = false; // jos meshi on pathi

            if (name.StartsWith("Path_"))
            {
                isPath = true;
            }

            // Process the mesh
            processMesh(XMLRoot, isPath);

            if (isPath == false)
            {
                Vbo = new VBO();
                Vbo.DataToVBO(VertexBuffer, IndexBuffer, VBO.VertexMode.UV1);

                Boundings = new BoundingSphere();
                Boundings.CreateBoundingVolume(this);

                // lataa shader
                string shader = Material.ShaderName;
                if (shader != "")
                {
                    Vbo.Shader = GLSLShader.Load(shader);
                }
            }
            else
            {
                Path path = new Path();
                path.AddPath(name, VertexBuffer);
            }
        }
示例#5
0
 public void SetSkyShader(string shaderFileName)
 {
     GetList(true);
     for (int q = 0; q < ObjList.Count; q++)
     {
         OgreMesh m = ObjList[q] as OgreMesh;
         m.Vbo.Shader = GLSLShader.Load(shaderFileName);
     }
 }
示例#6
0
文件: Billboard.cs 项目: Keilerr/csat
        public static Billboard Load(string fileName, bool softParticle)
        {
            if (Particles.SoftParticles == false)
            {
                softParticle = false;
            }

            Billboard bb = new Billboard();

            bb.billBoard            = Texture2D.Load(fileName, true);
            bb.billBoard.Vbo.Shader = GLSLShader.Load("particles.shader" + (softParticle ? ":SOFT" : ""));
            return(bb);
        }
示例#7
0
文件: VBO.cs 项目: Keilerr/csat
        public void DataToVBO(Vertex[] vertices, ushort[] indices, VertexMode mode)
        {
            if (numOfIndices > 0)
            {
                Dispose();
            }
            int size;

            vertexFlags  = mode;
            numOfIndices = indices.Length;
            Vertex.Size  = BlittableValueType.StrideOf(vertices);

            GL.GenBuffers(1, out vertexID);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexID);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * Vertex.Size), vertices, usage);
            GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
            if (vertices.Length * BlittableValueType.StrideOf(vertices) != size)
            {
                Log.Error("DataToVBO: Vertex data not uploaded correctly");
            }

            GL.GenBuffers(1, out indexID);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexID);
            GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(indices.Length * sizeof(ushort)), indices, usage);
            GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out size);
            if (indices.Length * sizeof(short) != size)
            {
                throw new ApplicationException("DataToVBO: Element data not uploaded correctly");
            }

            Shader = GLSLShader.Load();

            if (Shader != null)
            {
                if (Settings.UseGL3)
                {
                    GL.GenVertexArrays(1, out vaoID);
                    GL.BindVertexArray(vaoID);
                }
                GL.BindBuffer(BufferTarget.ArrayBuffer, vertexID);
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexID);
                Shader.SetAttributes();
                if (Settings.UseGL3)
                {
                    GL.BindVertexArray(0);
                }
            }

            GLExt.CheckGLError("DataToVBO");
        }
示例#8
0
文件: Particles.cs 项目: Keilerr/csat
        public static void EnableSoftParticles()
        {
            if (Settings.DisableSoftParticles)
            {
                softParticles = false;
                return;
            }

            if (Texture.IsFloatTextureSupported == false)
            {
                Log.WriteLine("Float textures not supported so no soft particles.");
                softParticles = false;
                return;
            }
            depthShader   = GLSLShader.Load("depth.shader:DEPTH_W");
            softParticles = true;
        }
示例#9
0
        public static BitmapFont Load(string fileName)
        {
            BitmapFont font = new BitmapFont();

            try
            {
                // lataa fonttitexture
                font.texture = Texture.Load(fileName);

                Bitmap CurrentBitmap = new Bitmap(Settings.TextureDir + fileName);

                if (CurrentBitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb || CurrentBitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                {
                    BitmapData Data = CurrentBitmap.LockBits(new Rectangle(0, 0, CurrentBitmap.Width, CurrentBitmap.Height), ImageLockMode.ReadOnly, CurrentBitmap.PixelFormat);
                    font.SearchUV(ref Data, (CurrentBitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb) ? 3 : 4);
                    CurrentBitmap.UnlockBits(Data);
                }
                else
                {
                    Log.Error("Font: wrong pixel format.");
                }
            }
            catch (Exception e)
            {
                Log.Error("Font: error loading file " + fileName + "\n" + e.ToString());
            }

            if (vbo == null)
            {
                ushort[] ind = new ushort[] { 0, 1, 3, 1, 2, 3 };
                vbo = new VBO(BufferUsageHint.StreamDraw);
                vbo.DataToVBO(letter, ind, VBO.VertexMode.UV1);

                vbo.Shader = GLSLShader.Load("default2d.shader");
            }
            return(font);
        }