Beispiel #1
0
    protected void Initialize()
    {
        m_InfoFont = new Alt.Sketch.Font("Arial", 10.01, Alt.Sketch.FontStyle.Bold);

        settings = new FarseerPhysicsGameSettings();

        FarseerPhysics_onRestart();

        m_Timer       = new Alt.GUI.Timer(10);
        m_Timer.Tick += Timer_Tick;
        m_Timer.Start();
    }
Beispiel #2
0
        protected override void Start()
        {
            base.Start();

            GwenChild = AltGUIHelper.Create_Box2DContainer(GetOrCreateGwenCanvas(), DebugDraw);

            AltGUIHelper.Box2DContainer box2DContainer = Box2DContainer;
            if (box2DContainer == null)
            {
                return;
            }

            m_InfoFont = new Alt.Sketch.Font("Arial", 10.01, Alt.Sketch.FontStyle.Bold);

            box2DContainer.Paint     += Box2DContainer_OnPaint;
            box2DContainer.MouseDown += RaiseBox2DMouseDown;
            box2DContainer.MouseUp   += RaiseBox2DMouseUp;
            box2DContainer.MouseMove += RaiseBox2DMouseMove;

            box2DContainer.Focus();
        }
Beispiel #3
0
        /*
         * Render the given  string using the given font.   Transfer the image
         * to a  surface of  power-of-2 size large  enough to fit  the string.
         * Return an OpenGL texture object.
         */
        //  Image
        public static int make_image_from_font(
            ref int w, ref int h,
            string text, Alt.Sketch.Font font)
        {
            int o = 0;

            /* Render the text. */

            if (!string.IsNullOrEmpty(text))
            {
                Alt.Sketch.SizeI size = gui.gui_measure(text, font);

                Alt.Sketch.Bitmap bitmap = new Alt.Sketch.Bitmap(size, Alt.Sketch.PixelFormat.Format32bppArgb);
                using (Alt.Sketch.Graphics graphics = Alt.Sketch.Graphics.FromImage(bitmap))
                {
                    graphics.Clear(Alt.Sketch.Color.Empty);
                    graphics.DrawString(text, font, Alt.Sketch.Brushes.White, Alt.Sketch.Point.Zero);
                }
                {
                    w = bitmap.PixelWidth;
                    h = bitmap.PixelHeight;

                    int  trw = 0;
                    bool f   = false;
                    //  left
                    for (int x = 0; x < w; x++)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            if (bitmap.GetPixel(x, y).A != 0)
                            {
                                f = true;
                                break;
                            }
                        }

                        if (f)
                        {
                            break;
                        }

                        trw++;
                    }

                    //  right
                    f = false;
                    for (int x = w - 1; x >= 0; x--)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            if (bitmap.GetPixel(x, y).A != 0)
                            {
                                f = true;
                                break;
                            }
                        }

                        if (f)
                        {
                            break;
                        }

                        trw++;
                    }

                    //  Pad the text to power-of-two

                    Alt.Sketch.BitmapData bdata = bitmap.LockBits(Alt.Sketch.ImageLockMode.ReadOnly);

                    int    w2 = 0;
                    int    h2 = 0;
                    byte[] p  = image_next2(bdata.Scan0, bdata.PixelWidth, bdata.PixelHeight, bdata.ByteDepth, trw, ref w2, ref h2);

                    bitmap.UnlockBits(bdata);


                    /* Saturate the color channels.  Modulate ONLY in alpha. */

                    Image.image_white(p, w2, h2, bitmap.ByteDepth);

                    /* Create the OpenGL texture object. */

                    o = Image.make_texture(p, w2, h2, bitmap.ByteDepth);
                }
            }
            else
            {
                /* Empty string. */

                //if (w) *
                w = 0;
                //if (h) *
                h = 0;
                //if (W) *W = 0;
                //if (H) *H = 0;
            }

            return(o);
        }