Detect software or hardware mode

Software: Away3D 4.x

Felix af Ekenstam, Newbie
Posted: 16 January 2012 05:25 PM   Total Posts: 7

Hi,

What is the best way to detect if the user is running in hardware or software mode in Away3d 4?

I want to be able to for off all effects to make software mode possible.
I tried to check view.stage3DProxy.context3D.driverInfo directly after creating my view but that gives me the classic error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

I guess the stage3DProxy is not initiates yet or something. Should i listen for some event before calling this?

   

Felix af Ekenstam, Newbie
Posted: 17 January 2012 09:11 AM   Total Posts: 7   [ # 1 ]

So eventually I found my own solution outside of Away. Just put a listener on the main stage3D object and request a new context (or wait until Away 3D does) and it will fire an event when the context is created. And that context contains info about render state etc.

var hwCheck stage.stage3Ds[0];
   
// listen to the context creation event
   
hwCheck.addEventListener(Event.CONTEXT3D_CREATEcheck);
var 
isHardware
   
function check(e=null){
hwCheck
.removeEventListener(Event.CONTEXT3D_CREATEcheck);
    var 
context3D:Context3D hwCheck.context3D;
    
// hardware of software ?
    
var isHardwarecontext3D.driverInfo.toLowerCase().indexOf("software") == -1;
    
context3D=null
   }
   
// request the 3d context
   
hwCheck.requestContext3D(Context3DRenderMode.AUTO); 
   

Felix af Ekenstam, Newbie
Posted: 17 January 2012 09:12 AM   Total Posts: 7   [ # 2 ]

So eventually I found my own solution outside of Away. Just put a listener on the main stage3D object and request a new context (or wait until Away 3D does) and it will fire an event when the context is created. And that context contains info about render state etc.

var hwCheck stage.stage3Ds[0];
   
// listen to the context creation event
   
hwCheck.addEventListener(Event.CONTEXT3D_CREATEcheck);
var 
isHardware
   
function check(e=null){
hwCheck
.removeEventListener(Event.CONTEXT3D_CREATEcheck);
    var 
context3D:Context3D hwCheck.context3D;
    
// hardware of software ?
    
var isHardwarecontext3D.driverInfo.toLowerCase().indexOf("software") == -1;
    
context3D=null
   }
   
// request the 3d context
   
hwCheck.requestContext3D(Context3DRenderMode.AUTO); 
   

Avatar
theMightyAtom, Sr. Member
Posted: 17 January 2012 10:02 AM   Total Posts: 669   [ # 3 ]

The class your looking for is “AwayStats”.
You may have seen it on demos? Gives you the framerate and memory usage as well…

   

Felix af Ekenstam, Newbie
Posted: 17 January 2012 12:17 PM   Total Posts: 7   [ # 4 ]

Yes I use that one, but it has the same problem. I still don’t know when it is ready to tell me this info. From what I understand i basically returns _views[0].renderer.stage3DProxy.context3D that would be null until the context is created.
I need to know before I start creating my scene if it is hardware or software so that I can adjust my setting accordingly. In that case my above code works well.
It would be nice if View3D did dispatch an event when the context is created though. Maybe it does?

   

Avatar
theMightyAtom, Sr. Member
Posted: 17 January 2012 01:14 PM   Total Posts: 669   [ # 5 ]

Ahh, gotcha. Sorry for the misunderstanding. Yes, an event from Away would be good if it doesn’t exist. Probably best to post under feature request

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X