Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[TexturedCube] minor tweaks

  • Loading branch information...
commit eab3ffe504deff710212bc4a2abbff32ac1f64b7 1 parent 6e60b30
@shana shana authored
Showing with 32 additions and 9 deletions.
  1. +32 −9 TexturedCube/PaintingView.cs
View
41 TexturedCube/PaintingView.cs
@@ -69,11 +69,40 @@ protected override void CreateFrameBuffer ()
Log.Verbose ("TexturedCube", "{0}", ex);
}
- // this is a graphics setting that sets everything to the lowest mode possible so
- // the device returns a reliable graphics setting.
+ // Fallback modes
+ // If the first attempt at initializing the surface with a default graphics
+ // mode fails, then the app can try different configurations. Devices will
+ // support different modes, and what is valid for one might not be valid for
+ // another. If all options fail, you can set all values to 0, which will
+ // ask for the first available configuration the device has without any
+ // filtering.
+ // After a successful call to base.CreateFrameBuffer(), the GraphicsMode
+ // object will have its values filled with the actual values that the
+ // device returned.
+
+
+ // This is a setting that asks for any available 16-bit color mode with no
+ // other filters. It passes 0 to the buffers parameter, which is an invalid
+ // setting in the default OpenTK implementation but is valid in some
+ // Android implementations, so the AndroidGraphicsMode object allows it.
try {
Log.Verbose ("TexturedCube", "Loading with custom Android settings (low mode)");
- GraphicsMode = new AndroidGraphicsMode (0, 0, 0, 0, 0, false);
+ GraphicsMode = new AndroidGraphicsMode (16, 0, 0, 0, 0, false);
+
+ // if you don't call this, the context won't be created
+ base.CreateFrameBuffer ();
+ return;
+ } catch (Exception ex) {
+ Log.Verbose ("TexturedCube", "{0}", ex);
+ }
+
+ // this is a setting that doesn't specify any color values. Certain devices
+ // return invalid graphics modes when any color level is requested, and in
+ // those cases, the only way to get a valid mode is to not specify anything,
+ // even requesting a default value of 0 would return an invalid mode.
+ try {
+ Log.Verbose ("TexturedCube", "Loading with no Android settings");
+ GraphicsMode = new AndroidGraphicsMode (0, 4, 0, 0, 0, false);
// if you don't call this, the context won't be created
base.CreateFrameBuffer ();
@@ -86,12 +115,6 @@ protected override void CreateFrameBuffer ()
protected override void OnLoad (EventArgs e)
{
- // This is completely optional and only needed
- // if you've registered delegates for OnLoad
- base.OnLoad (e);
-
- MakeCurrent ();
-
GL.ShadeModel (All.Smooth);
GL.ClearColor (0, 0, 0, 1);
Please sign in to comment.
Something went wrong with that request. Please try again.