Beispiel #1
0
        public PileUpPage()
        {
            InitializeComponent();

            var view = new OpenGLView {
                HasRenderLoop = true
            };
            var toggle = new Switch {
                IsToggled = true
            };
            var button = new Button {
                Text = "Display"
            };

            // viewの構築
            view.HeightRequest   = 300;
            view.WidthRequest    = 300;
            view.BackgroundColor = Color.Transparent;

            view.OnDisplay = (r) =>
            {
                GL.ClearColor(red, green, blue, alpha);
                GL.Clear((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                // ちょっとずつ色を変える
                red   = incrementColor(red, 0.01f);
                green = incrementColor(green, 0.02f);
                blue  = incrementColor(blue, 0.03f);
            };

            // スイッチ
            toggle.Toggled += (s, a) =>
            {
                view.HasRenderLoop = toggle.IsToggled;
            };

            // ボタン
            button.Clicked += (s, a) =>
            {
                view.Display();
            };

            var stack = new StackLayout
            {
                Padding         = new Size(20, 20),
                BackgroundColor = Color.Transparent,
                Children        =
                {
                    button, toggle, view
                }
            };

            AbsoluteLayout.SetLayoutFlags(stack, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(stack, new Rectangle(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            absoluteLayout.Children.Add(stack);
        }
Beispiel #2
0
        public void Display()
        {
            var  view      = new OpenGLView();
            bool displayed = false;

            view.DisplayRequested += (s, o) => displayed = true;

            view.Display();
            Assert.True(displayed);
        }
		public void Display ()
		{
			var view = new OpenGLView ();
			bool displayed = false;

			((IOpenGlViewController)view).DisplayRequested += (s, o) => displayed = true;

			view.Display ();
			Assert.True (displayed);
		}
        public OpenGLPage()
        {
            InitializeComponent();

            var view = new OpenGLView {
                HasRenderLoop = true
            };
            var toggle = new Switch {
                IsToggled = true
            };
            var button = new Button {
                Text = "Display"
            };

            // viewの構築
            view.HeightRequest = 300;
            view.WidthRequest  = 300;

            view.OnDisplay = (r) =>
            {
                GL.ClearColor(red, green, blue, 1.0f);
                GL.Clear((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                // ちょっとずつ色を変える
                red   = incrementColor(red, 0.01f);
                green = incrementColor(green, 0.02f);
                blue  = incrementColor(blue, 0.03f);
            };

            // スイッチ
            toggle.Toggled += (s, a) =>
            {
                view.HasRenderLoop = toggle.IsToggled;
            };

            // ボタン
            button.Clicked += (s, a) =>
            {
                view.Display();
            };

            var stack = new StackLayout
            {
                Padding  = new Size(20, 20),
                Children =
                {
                    view, toggle, button
                }
            };

            Content = stack;
        }
Beispiel #5
0
        public OpenGLPage()
        {
            Title = "OpenGL";
            var view = new OpenGLView {
                HasRenderLoop = true
            };
            var toggle = new Switch {
                IsToggled = true
            };
            var button = new Button {
                Text = "Display"
            };

            view.HeightRequest = 300;
            view.WidthRequest  = 300;

            view.OnDisplay = r => {
                GL.ClearColor(red, green, blue, 1.0f);
                GL.Clear((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                red += 0.01f;
                if (red >= 1.0f)
                {
                    red -= 1.0f;
                }
                green += 0.02f;
                if (green >= 1.0f)
                {
                    green -= 1.0f;
                }
                blue += 0.03f;
                if (blue >= 1.0f)
                {
                    blue -= 1.0f;
                }
            };

            toggle.Toggled += (s, a) => {
                view.HasRenderLoop = toggle.IsToggled;
            };
            button.Clicked += (s, a) => view.Display();

            var stack = new StackLayout
            {
                Padding  = new Size(20, 20),
                Children = { view, toggle, button }
            };

            Content = stack;
        }
Beispiel #6
0
        public OpenGLPage()
        {
            //InitializeComponent ();
            Title = "OpenGL";

            var view = new OpenGLView {
                HasRenderLoop = true,
                HeightRequest = 300,
                WidthRequest  = 300
            };
            var toggle = new Switch {
                IsToggled = true
            };
            var button = new Button {
                Text = "Display"
            };

            view.OnDisplay = (r) =>
            {
                GL.ClearColor(red, green, blue, 1f);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                red   = incr(red, 0.01f);
                green = incr(green, 0.02f);
                blue  = incr(blue, 0.03f);
            };

            toggle.Toggled += (s, a) =>
            {
                view.HasRenderLoop = toggle.IsToggled;
            };

            button.Clicked += (s, a) =>
            {
                view.Display();
            };

            var stack = new StackLayout
            {
                Padding  = new Size(20, 20),
                Children =
                {
                    view, toggle, button
                }
            };

            Content = stack;
        }
Beispiel #7
0
        public OpenGLViewDemoPage()
        {
            IOpenGLViewSharedCode sharedCode = DependencyService.Get <IOpenGLViewSharedCode>();

            Label header = new Label
            {
                Text              = "OpenGLView",
                FontSize          = 50,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            Label regretsLabel = null;

            if (sharedCode != null)
            {
                openGLView = new OpenGLView
                {
                    VerticalOptions = LayoutOptions.FillAndExpand
                };
                openGLView.OnDisplay = sharedCode.RenderLoop;
                openGLView.Display();
            }
            else
            {
                regretsLabel = new Label
                {
                    Text     = "Sorry, OpenGLView cannot be used on this device!",
                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalOptions         = LayoutOptions.CenterAndExpand,
                    Margin = new Thickness(10, 0)
                };
            }

            // Build the page.
            Title   = "OpenGLView Demo";
            Content = new StackLayout
            {
                Children =
                {
                    header,
                    sharedCode != null ? (View)openGLView : regretsLabel
                }
            };
        }
Beispiel #8
0
        public OpenGLGallery()
        {
            var view = new OpenGLView {
                HasRenderLoop = true
            };
            var toggle = new Switch {
                IsToggled = true
            };
            var button = new Button {
                Text = "Display"
            };

            view.HeightRequest = 300;
            view.WidthRequest  = 300;

            view.OnDisplay = r => {
                /*
                 * if (!inited) {
                 *      var shader = GL.CreateShader (All.VertexShader);
                 *      int length = 0;
                 *      GL.ShaderSource (shader, 1, new string [] { "void main() { gl_FragColor = vec4(0.6, 1.0, 0.0, 1.0); }"}, ref length);
                 *      GL.CompileShader (shader);
                 *      int status = 0;
                 *      GL.GetShader (shader, All.CompileStatus, ref status);
                 *      if (status == 0) {
                 *              GL.DeleteShader (shader);
                 *              throw new Exception();
                 *      }
                 *
                 *      inited = true;
                 * }
                 */
                GL.ClearColor(red, green, blue, 1.0f);
                GL.Clear((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                red += 0.01f;
                if (red >= 1.0f)
                {
                    red -= 1.0f;
                }
                green += 0.02f;
                if (green >= 1.0f)
                {
                    green -= 1.0f;
                }
                blue += 0.03f;
                if (blue >= 1.0f)
                {
                    blue -= 1.0f;
                }
            };

            toggle.Toggled   += (s, a) => { view.HasRenderLoop = toggle.IsToggled; };
            button.Activated += (s, a) => view.Display();

            var stack = new StackLayout {
                Padding = new Size(20, 20)
            };

            stack.Add(view);
            stack.Add(toggle);
            stack.Add(button);

            Content = stack;
        }