Ejemplo n.º 1
0
        //
        // static constructor
        //

        static MediaPlayer()
        {
            volume = 1f;
            state  = new java.util.concurrent.atomic.AtomicInteger(0);
            queue  = new MediaQueue();
            var watcher = new Watcher();

            player = new android.media.MediaPlayer();
            player.setOnPreparedListener(watcher);
            player.setOnCompletionListener(watcher);
        }
Ejemplo n.º 2
0
        public Semaphore(int initialCount, int maximumCount)
        {
            if (initialCount < 0 || maximumCount < 1)
            {
                throw new System.ArgumentOutOfRangeException();
            }
            if (initialCount > maximumCount)
            {
                throw new System.ArgumentException();
            }

            current = new java.util.concurrent.atomic.AtomicInteger(initialCount);
            maximum = maximumCount;
        }
Ejemplo n.º 3
0
        //
        // constructor
        //

        private Renderer(android.app.Activity activity, Action onChanged,
                         int redSize, int greenSize, int blueSize,
                         int alphaSize, int depthSize, int stencilSize,
                         int swapInterval, bool checkErrors)
        {
            waitObject        = new android.os.ConditionVariable();
            paused            = new java.util.concurrent.atomic.AtomicInteger();
            actionOnChanged   = onChanged;
            this.swapInterval = swapInterval;
            this.checkErrors  = checkErrors;

            activity.runOnUiThread(((java.lang.Runnable.Delegate)(() =>
            {
                surface = new android.opengl.GLSurfaceView(activity);
                surface.setEGLContextClientVersion(3); // OpenGL ES 3.0
                surface.setEGLConfigChooser(redSize, greenSize, blueSize,
                                            alphaSize, depthSize, stencilSize);
                surface.setPreserveEGLContextOnPause(true);
                surface.setRenderer(this);
                surface.setRenderMode(android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY);
                activity.setContentView(surface);
            })).AsInterface());

            // wait for one onDrawFrame callback, which tells us that
            // GLSurfaceView finished initializing the GL context
            if (!waitObject.block(8000))
            {
                throw new NoSuitableGraphicsDeviceException("cannot create GLSurfaceView");
            }

            var clientBounds = GameRunner.Singleton.ClientBounds;

            if (SurfaceWidth != clientBounds.Width || SurfaceHeight != clientBounds.Height)
            {
                // while not common, it is possible for the screen to rotate,
                // between the time the Window/GameRunner is created, and the
                // time the renderer is created.  we want to identify this.
                if (actionOnChanged != null)
                {
                    actionOnChanged();
                }
            }
        }
Ejemplo n.º 4
0
        //
        // constructor
        //

        public GameRunner(Activity activity)
        {
            this.activity = activity;

            // in Bluebonnet, the following method is used to specify the
            // size that Marshal.SizeOf should return for non-primitive types.
            // this is used to enable Texture2D.GetData/SetData to accept
            // Color[] arrays.  see also SetTextureData in FNA3D_Tex
            System.Runtime.InteropServices.Marshal.SetComObjectData(
                typeof(System.Runtime.InteropServices.Marshal),
                typeof(Color), -1);

            UpdateConfiguration();

            inModal       = new java.util.concurrent.atomic.AtomicInteger();
            shouldPause   = new java.util.concurrent.atomic.AtomicInteger();
            shouldResume  = new java.util.concurrent.atomic.AtomicInteger();
            shouldExit    = new java.util.concurrent.atomic.AtomicInteger();
            shouldEvents  = new java.util.concurrent.atomic.AtomicInteger();
            waitForPause  = new android.os.ConditionVariable();
            waitForResume = new android.os.ConditionVariable();
        }