public void Dispose() { if (texture != null) texture.Dispose(); if (vbo != null) vbo.Dispose(); texture = null; vbo = null; }
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); } }
public override void Dispose() { if (Vbo != null) { Vbo.Dispose(); Vbo = null; Log.WriteLine("Disposed: Texture2D", false); } base.Dispose(); }
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); } }
public void Dispose() { if (texture != null) { texture.Dispose(); } if (vbo != null) { vbo.Dispose(); } texture = null; vbo = null; }
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); }
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; }
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"); }