示例#1
0
文件: BitmapFont.cs 项目: bosoni/csat
 public void Dispose()
 {
     if (texture != null) texture.Dispose();
     if (vbo != null) vbo.Dispose();
     texture = null;
     vbo = null;
 }
示例#2
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);
            }
        }
示例#3
0
 public override void Dispose()
 {
     if (Vbo != null)
     {
         Vbo.Dispose();
         Vbo = null;
         Log.WriteLine("Disposed: Texture2D", false);
     }
     base.Dispose();
 }
示例#4
0
文件: OgreMesh.cs 项目: bosoni/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 Dispose()
 {
     if (texture != null)
     {
         texture.Dispose();
     }
     if (vbo != null)
     {
         vbo.Dispose();
     }
     texture = null;
     vbo     = null;
 }
示例#6
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);
        }
示例#7
0
文件: BitmapFont.cs 项目: bosoni/csat
        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;
        }
示例#8
0
文件: Texture.cs 项目: bosoni/csat
 public override void Dispose()
 {
     if (Vbo != null)
     {
         Vbo.Dispose();
         Vbo = null;
         Log.WriteLine("Disposed: Texture2D", false);
     }
     base.Dispose();
 }
示例#9
0
文件: Texture.cs 项目: bosoni/csat
        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");
        }