Created
June 15, 2012 14:57
-
-
Save alebianco/2936867 to your computer and use it in GitHub Desktop.
Check system and Stage3D info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
import flash.display.Stage3D; | |
import flash.display3D.Context3D; | |
import flash.display3D.Context3DRenderMode; | |
import flash.events.ErrorEvent; | |
import flash.events.Event; | |
import flash.system.ApplicationDomain; | |
import flash.system.Capabilities; | |
import flash.text.TextField; | |
import flash.text.TextFormat; | |
import flash.utils.Dictionary; | |
[SWF(width="640", height="480", frameRate="30")] | |
public class DriverInfo extends Sprite | |
{ | |
private var myStage3D:Stage3D; | |
private var tf:TextField; | |
public function DriverInfo() | |
{ | |
tf = addChild(new TextField()) as TextField; | |
tf.defaultTextFormat = new TextFormat("Arial, _sans", 14); | |
tf.wordWrap = true; | |
tf.multiline = true; | |
tf.selectable = true; | |
tf.x = 20; | |
tf.y = 20; | |
tf.width = 600; | |
tf.height = 440; | |
tf.htmlText += "<br/><font size='18'><b>Player</b></font><br/>"; | |
tf.htmlText += "<b>Version:</b> " + Capabilities.version + "<br/>"; | |
tf.htmlText += "<b>Debug:</b> " + (Capabilities.isDebugger ? "Yes" : "No") + "<br/>"; | |
tf.htmlText += "<b>OS version:</b> " + Capabilities.os + "<br/>"; | |
tf.htmlText += Capabilities.cpuArchitecture + "<br/>"; | |
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); | |
} | |
private function onAddedToStage(event:Event):void | |
{ | |
if( stage.stage3Ds.length > 0 ) | |
{ | |
myStage3D = stage.stage3Ds[0]; | |
// listen to the context creation event | |
myStage3D.addEventListener(Event.CONTEXT3D_CREATE, onContextCreated); | |
// listen to the error | |
myStage3D.addEventListener(ErrorEvent.ERROR, onStage3DError); | |
// request the 3d context | |
myStage3D.requestContext3D(Context3DRenderMode.AUTO); | |
} | |
} | |
// when the context is available, grab it | |
private function onContextCreated ( e:Event ):void | |
{ | |
// grab the 3D context | |
var context3D:Context3D = myStage3D.context3D; | |
var lookup:Dictionary = new Dictionary(); | |
lookup["userDisabled"] = "The Enable hardware acceleration checkbox in the Adobe Flash Player Settings UI is not selected."; | |
lookup["oldDriver"] = "There are known problems with the hardware graphics driver. Updating the graphics driver may fix this problem."; | |
lookup["unavailable"] = "Known problems with the hardware graphics driver or hardware graphics initialization failure."; | |
lookup["explicit"] = "The content explicitly requested software rendering through requestContext3D."; | |
var info:String = context3D.driverInfo; | |
tf.htmlText += "<br/><font size='18'><b>Stage3D</b></font><br/>"; | |
tf.htmlText += "<b>Rendering mode</b>: " + info + "<br/>"; | |
var check:RegExp = new RegExp("^Software Hw_disabled=([a-z]+)", "i"); | |
if (check.test(info)) { | |
var reason:String = check.exec(info)[1]; | |
if (reason in lookup) { | |
tf.htmlText += "<b>Render mode reason:</b> " + lookup[reason] + "<br/>"; | |
} | |
} | |
} | |
// display message | |
private function onStage3DError ( e:ErrorEvent ):void | |
{ | |
tf.text = "This content is not correctly embedded. Please change the wmode value to allow this content to run."; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment