Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Mixed content in Xamarin.Forms #322

Closed
Therzok opened this issue Nov 11, 2015 · 1 comment
Closed

Mixed content in Xamarin.Forms #322

Therzok opened this issue Nov 11, 2015 · 1 comment

Comments

@Therzok
Copy link
Contributor

Therzok commented Nov 11, 2015

Testing around a bit, an app using XF and CocosSharp as simple as below, fails on iOS:

    public class App : Application
    {
        public App ()
        {
            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Start, // This line is the culprit.
                    Children = {
                        new Label {
                            XAlign = TextAlignment.Center,
                            Text = "Welcome to Xamarin Forms!"
                        },
                        new CocosSharpView {
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions = LayoutOptions.FillAndExpand,
                            DesignResolution = new Size (1024, 768),
                            ViewCreated = LoadGame,
                        },
                    }
                }
            };
        }

        static void LoadGame (object sender, EventArgs e)
        {
            var gameView = sender as CCGameView;

            if (gameView != null) {

                // Set world dimensions
                gameView.DesignResolution = new CCSizeI (1024, 768);

                gameView.ContentManager.SearchPaths = new List<string> { "Fonts", "Sounds", "Images" };

                CCScene gameScene = new CCScene (gameView);
                gameScene.AddLayer (new MainLayer ());
                gameView.RunWithScene (gameScene);
            }
        }
System.InvalidOperationException: Error with EAGLContext.RenderBufferStorage!
  at at OpenTK.Platform.iPhoneOS.iPhoneOSGameView.CreateFrameBuffer () in <filename unknown>:line 0
  at at CocosSharp.CCGameView.CreateFrameBuffer () in <filename unknown>:line 0
  at at CocosSharp.CCGameView.LayoutSubviews () in <filename unknown>:line 0
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) in /Users/builder/data/lanes/2356/9ce9e8b9/source/maccore/src/UIKit/UIApplication.cs:line 77
  at at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) in /Users/builder/data/lanes/2356/9ce9e8b9/source/maccore/src/UIKit/UIApplication.cs:line 61
  at at TestCCS.iOS.Application.Main (System.String[] args) in /Users/therzok/Personal/TestCCS/iOS/Main.cs:line 17
@rtabbara
Copy link
Member

@Therzok Can you try setting an explicit HeightRequest for the CocosSharpView to see if that helps?

As a test, I tried replacing CocosSharpView with the Xam.Forms OpenGLView using the same layout options, and while no exception was thrown, nothing was displayed either.

I think the issue is that a StackLayout implicitly has no height when setting VerticalOptions = LayoutOptions.Start --- those dimensions are dictated by its children. For a Label control, the height dimensions are driven by the native label dimensions. But for a CocosSharpView and more generally, a OpenGLView, we require the opposite situation. That is, we need the CocosSharpView dimensions to be set before we can create the native frame buffer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants