Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added code to fall back on the default graphics mode under android #864

Merged
merged 2 commits into from

2 participants

@dellis1972
Owner

On certain devices the default AndroidGameWindow GraphicsMode does not work even though the device says it supports it see issue #654.

This takes the advice from https://bugzilla.xamarin.com/show_bug.cgi?id=6386 and adds a fallback incase the first call to base.CreateFrameBuffer fails.

@dellis1972
Owner

Opps, sorry I commited the new Content Builder project template to this PR.

@KonajuGames
Owner

Not having much luck with the PRs for this fallback code, eh?

@KonajuGames
Owner

Should the ContentBuilder changes be merged or did you want to leave them? Also, the ContentBuilder changes include the default XNA GameThumbnail.png. We should change that to something supplied by us if it is required.

@dellis1972
Owner
@KonajuGames KonajuGames merged commit 8c53ca7 into mono:develop3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2012
  1. @dellis1972

    Added code to fall back on the default graphics mode under android if…

    dellis1972 authored
    … it fails to create the framebuffer
Commits on Oct 13, 2012
  1. @dellis1972
This page is out of date. Refresh to see the latest.
View
13 MonoGame.Framework/Android/AndroidGameWindow.cs
@@ -134,13 +134,22 @@ protected override void CreateFrameBuffer()
try
{
GLContextVersion = GLContextVersion.Gles2_0;
- base.CreateFrameBuffer();
+ try
+ {
+ base.CreateFrameBuffer();
+ }
+ catch(Exception)
+ {
+ // try again using a more basic mode which hopefully the device will support
+ GraphicsMode = new AndroidGraphicsMode(0, 0, 0, 0, 0, false);
+ base.CreateFrameBuffer();
+ }
All status = GL.CheckFramebufferStatus(All.Framebuffer);
Android.Util.Log.Debug("MonoGame", "Framebuffer Status: " + status.ToString());
}
catch (Exception)
{
- throw new NotSupportedException("Could not create OpenGLES 2.0 frame buffer");
+ throw new NotSupportedException("Could not create OpenGLES 2.0 frame buffer");
}
if (_game.GraphicsDevice != null && _contextWasLost)
{
View
85 projecttemplates/visualstudio2010/ContentBuilder/ContentBuilder.csproj
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.ContentPipeline.targets" />
+ <PropertyGroup>
+ <ProjectGuid>$guid1$</ProjectGuid>
+ <ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>$safeprojectname$</RootNamespace>
+ <AssemblyName>$safeprojectname$</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
+ <XnaPlatform>Windows</XnaPlatform>
+ <XnaProfile>HiDef</XnaProfile>
+ <XnaCrossPlatformGroupID>3e373063-50e5-4165-8264-1f7139c86e71</XnaCrossPlatformGroupID>
+ <XnaOutputType>Game</XnaOutputType>
+ <MonoGamePlatform>Windows</MonoGamePlatform>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Windows' ">
+ <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+ <XnaCompressContent>true</XnaCompressContent>
+ <MonoGamePlatform>Windows</MonoGamePlatform>
+ <OutputPath>bin\Windows\Release</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Windows8' ">
+ <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+ <XnaCompressContent>true</XnaCompressContent>
+ <MonoGamePlatform>Windows8</MonoGamePlatform>
+ <OutputPath>bin\Windows8\Release</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Android' ">
+ <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+ <XnaCompressContent>true</XnaCompressContent>
+ <MonoGamePlatform>Android</MonoGamePlatform>
+ <OutputPath>bin\Android\Release</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'iOS' ">
+ <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+ <XnaCompressContent>true</XnaCompressContent>
+ <MonoGamePlatform>iOS</MonoGamePlatform>
+ <OutputPath>bin\iOS\Release</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Mac' ">
+ <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+ <XnaCompressContent>true</XnaCompressContent>
+ <MonoGamePlatform>Mac</MonoGamePlatform>
+ <OutputPath>bin\Mac\Release</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Linux' ">
+ <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+ <XnaCompressContent>true</XnaCompressContent>
+ <MonoGamePlatform>Linux</MonoGamePlatform>
+ <OutputPath>bin\Linux\Release</OutputPath>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+ <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+ <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+ <Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+ <Reference Include="mscorlib" />
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Net" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Game1.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
+ <!--
+ To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
26 projecttemplates/visualstudio2010/ContentBuilder/ContentBuilder.vstemplate
@@ -0,0 +1,26 @@
+<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
+ <TemplateData>
+ <Name>MonoGame Content Builder Project</Name>
+ <Description>A project for Compiling Content for MonoGame</Description>
+ <ProjectType>CSharp</ProjectType>
+ <ProjectSubType>
+ </ProjectSubType>
+ <SortOrder>1000</SortOrder>
+ <CreateNewFolder>true</CreateNewFolder>
+ <DefaultName>ContentBuilder</DefaultName>
+ <ProvideDefaultName>true</ProvideDefaultName>
+ <LocationField>Enabled</LocationField>
+ <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
+ <Icon>__TemplateIcon.png</Icon>
+ <PreviewImage>__PreviewImage.png</PreviewImage>
+ </TemplateData>
+ <TemplateContent>
+ <Project TargetFileName="ContentBuilder1.csproj" File="ContentBuilder.csproj" ReplaceParameters="true">
+ <ProjectItem ReplaceParameters="true" TargetFileName="Program.cs">Program.cs</ProjectItem>
+ <ProjectItem ReplaceParameters="true" TargetFileName="Game1.cs">Game1.cs</ProjectItem>
+ <Folder Name="Properties" TargetFolderName="Properties">
+ <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
+ </Folder>
+ </Project>
+ </TemplateContent>
+</VSTemplate>
View
BIN  projecttemplates/visualstudio2010/ContentBuilder/Game.ico
Binary file not shown
View
91 projecttemplates/visualstudio2010/ContentBuilder/Game1.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace $safeprojectname$
+{
+ /// <summary>
+ /// This is the main type for your game
+ /// </summary>
+ public class Game1 : Microsoft.Xna.Framework.Game
+ {
+ GraphicsDeviceManager graphics;
+ SpriteBatch spriteBatch;
+
+ public Game1()
+ {
+ graphics = new GraphicsDeviceManager(this);
+ Content.RootDirectory = "Content";
+ }
+
+ /// <summary>
+ /// Allows the game to perform any initialization it needs to before starting to run.
+ /// This is where it can query for any required services and load any non-graphic
+ /// related content. Calling base.Initialize will enumerate through any components
+ /// and initialize them as well.
+ /// </summary>
+ protected override void Initialize()
+ {
+ // TODO: Add your initialization logic here
+
+ base.Initialize();
+ }
+
+ /// <summary>
+ /// LoadContent will be called once per game and is the place to load
+ /// all of your content.
+ /// </summary>
+ protected override void LoadContent()
+ {
+ // Create a new SpriteBatch, which can be used to draw textures.
+ spriteBatch = new SpriteBatch(GraphicsDevice);
+
+ // TODO: use this.Content to load your game content here
+ }
+
+ /// <summary>
+ /// UnloadContent will be called once per game and is the place to unload
+ /// all content.
+ /// </summary>
+ protected override void UnloadContent()
+ {
+ // TODO: Unload any non ContentManager content here
+ }
+
+ /// <summary>
+ /// Allows the game to run logic such as updating the world,
+ /// checking for collisions, gathering input, and playing audio.
+ /// </summary>
+ /// <param name="gameTime">Provides a snapshot of timing values.</param>
+ protected override void Update(GameTime gameTime)
+ {
+ // Allows the game to exit
+ if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
+ this.Exit();
+
+ // TODO: Add your update logic here
+
+ base.Update(gameTime);
+ }
+
+ /// <summary>
+ /// This is called when the game should draw itself.
+ /// </summary>
+ /// <param name="gameTime">Provides a snapshot of timing values.</param>
+ protected override void Draw(GameTime gameTime)
+ {
+ GraphicsDevice.Clear(Color.CornflowerBlue);
+
+ // TODO: Add your drawing code here
+
+ base.Draw(gameTime);
+ }
+ }
+}
View
BIN  projecttemplates/visualstudio2010/ContentBuilder/GameThumbnail.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  projecttemplates/visualstudio2010/ContentBuilder/Icon.ico
Binary file not shown
View
21 projecttemplates/visualstudio2010/ContentBuilder/Program.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace $safeprojectname$
+{
+#if WINDOWS || XBOX
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ static void Main(string[] args)
+ {
+ using (Game1 game = new Game1())
+ {
+ game.Run();
+ }
+ }
+ }
+#endif
+}
+
View
35 projecttemplates/visualstudio2010/ContentBuilder/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("$projectname$")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("$registeredorganization$")]
+[assembly: AssemblyProduct("$projectname$")]
+[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type. Only Windows
+// assemblies support COM.
+[assembly: ComVisible(false)]
+
+// On Windows, the following GUID is for the ID of the typelib if this
+// project is exposed to COM. On other platforms, it unique identifies the
+// title storage container when deploying this assembly to the device.
+[assembly: Guid("$guid1$")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
View
BIN  projecttemplates/visualstudio2010/ContentBuilder/__PreviewImage.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  projecttemplates/visualstudio2010/ContentBuilder/__TemplateIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Something went wrong with that request. Please try again.