/// <summary> /// /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { if (this.font != null) { this.font.Dispose(); this.font = null; } if (this.surfaceGl1 != null) { this.surfaceGl1.Dispose(); this.surfaceGl1 = null; } if (this.surfaceGl2 != null) { this.surfaceGl2.Dispose(); this.surfaceGl2 = null; } if (this.surfaceGl3 != null) { this.surfaceGl3.Dispose(); this.surfaceGl3 = null; } } this.disposed = true; } }
/// <summary> /// Initializes the OpenGL system /// </summary> protected void InitGL() { // Reset The Current Viewport Gl.glViewport(0, 0, width, height); // Select The Projection Matrix Gl.glMatrixMode(Gl.GL_PROJECTION); // Reset The Projection Matrix Gl.glLoadIdentity(); Gl.glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); // Select The Modelview Matrix Gl.glMatrixMode(Gl.GL_MODELVIEW); // Reset The Modelview Matrix Gl.glLoadIdentity(); // Enable Smooth Shading Gl.glShadeModel(Gl.GL_SMOOTH); // Enables Depth Testing Gl.glEnable(Gl.GL_DEPTH_TEST); // The Type Of Depth Testing To Do Gl.glDepthFunc(Gl.GL_LEQUAL); // Really Nice Perspective Calculations Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST); surfaceGl1 = new SurfaceGl(font.Render(phrase1, Color.White, Color.Black)); surfaceGl2 = new SurfaceGl(font.Render(phrase2, Color.White, Color.Black)); surfaceGl3 = new SurfaceGl(font.Render(phrase3, Color.White, Color.Black)); }
public Sprite(Surface surface2) { this.surface = surface2; texture = new SurfaceGl(surface, true); texture.WrapS = WrapOption.Clamp; texture.WrapT = WrapOption.Clamp; //texture.MagFilter = MagnificationOption.GL_LINEAR; //texture.MinFilter = MinifyingOption.GL_LINEAR_MIPMAP_LINEAR; int blank = surface.TransparentColor.ToArgb(); bool[,] bitmap = new bool[surface.Width, surface.Height]; Color[,] pixels = surface.GetColors(new System.Drawing.Rectangle(0, 0, surface.Width, surface.Height)); for (int x = 0; x < bitmap.GetLength(0); ++x) { for (int y = 0; y < bitmap.GetLength(1); ++y) { bitmap[x, y] = !(pixels[x, y].A == 0 || pixels[x, y].ToArgb() == blank); } } vertexes = VertexHelper.CreateRangeFromBitmap(bitmap); Console.WriteLine("Before {0}", GetCount); vertexes = VertexHelper.ReduceRange(vertexes, 1); vertexes = VertexHelper.ReduceRange(vertexes, 2); vertexes = VertexHelper.ReduceRange(vertexes, 3); Console.WriteLine("After {0}", GetCount); vertexes = VertexHelper.SubdivideRange(vertexes, 10); Console.WriteLine("Subdivide {0}", GetCount); offset = VertexHelper.GetCentroidOfRange(vertexes); vertexes = VertexHelper.CenterVertexesRange(vertexes); }