Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public Demo()
        {

            Events.MouseButtonDown += new EventHandler<SdlDotNet.Input.MouseButtonEventArgs>(Events_MouseButtonDown);
            Events.MouseButtonUp += new EventHandler<SdlDotNet.Input.MouseButtonEventArgs>(Events_MouseButtonUp);
            Events.KeyboardDown += new EventHandler<SdlDotNet.Input.KeyboardEventArgs>(Events_KeyboardDown);
            Events.KeyboardUp += new EventHandler<SdlDotNet.Input.KeyboardEventArgs>(Events_KeyboardUp);
            Events.MouseMotion += new EventHandler<SdlDotNet.Input.MouseMotionEventArgs>(Events_MouseMotion);
            objects = new List<OpenGlObject>();



            font = new Font(Path.Combine(dataDir, "FreeSans.ttf"), 40);
            font.Bold = true;
            font2 = new Font(Path.Combine(dataDir, "FreeSans.ttf"), 15);
            font2.Bold = true;
            pauseSprite = new SurfaceGl(font.Render("PAUSED", System.Drawing.Color.White, System.Drawing.Color.Black, true));
            upsSprite = new SurfaceGl(font2.Render("UPS:", System.Drawing.Color.White, System.Drawing.Color.Black, true));
            CreateNumbers();

            CreateEngine();
            timer = new PhysicsTimer(Update, .010f);

            CreateBomb();
            CreateAvatar();
            CreateClipper();
            Demo1();
        }
Esempio n. 3
0
 public  void CreateNumbers()
 {
     numberSprites = new SurfaceGl[10];
     for (int index = 0; index < numberSprites.Length; ++index)
     {
         numberSprites[index] = new SurfaceGl(font2.Render(index.ToString(), System.Drawing.Color.White, System.Drawing.Color.Black, true));
     }
 }
Esempio n. 4
0
 /// <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));
 }
Esempio n. 5
0
 /// <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;
     }
 }