Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
automatically using 30 fps in software mode
  • Loading branch information
PrimaryFeather committed Dec 4, 2011
1 parent e8d50cc commit 9961d0c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 0 additions & 2 deletions samples/demo/src/Constants.as
Expand Up @@ -7,7 +7,5 @@ package

public static const CenterX:int = GameWidth / 2;
public static const CenterY:int = GameHeight / 2;

public static const FPS:int = 60;
}
}
13 changes: 13 additions & 0 deletions samples/demo/src/Startup.as
Expand Up @@ -3,6 +3,8 @@ package
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display3D.Context3D;
import flash.events.Event;

import starling.core.Starling;

Expand All @@ -22,6 +24,17 @@ package
mStarling.simulateMultitouch = true;
mStarling.enableErrorChecking = false;
mStarling.start();

// this event is dispatched when stage3D is set up
stage.stage3Ds[0].addEventListener(Event.CONTEXT3D_CREATE, onContextCreated);
}

private function onContextCreated(event:Event):void
{
// set framerate to 30 in software mode

if (Starling.context.driverInfo.toLowerCase().indexOf("software") != -1)
Starling.current.nativeStage.frameRate = 30;
}
}
}
10 changes: 7 additions & 3 deletions samples/demo/src/scenes/BenchmarkScene.as
Expand Up @@ -2,6 +2,7 @@ package scenes
{
import flash.system.System;

import starling.core.Starling;
import starling.display.Button;
import starling.display.Image;
import starling.display.Sprite;
Expand Down Expand Up @@ -61,8 +62,9 @@ package scenes
if (mFrameCount % mWaitFrames == 0)
{
var fps:Number = mWaitFrames / mElapsed;
var targetFps:int = Starling.current.nativeStage.frameRate;

if (Math.ceil(fps) >= Constants.FPS)
if (Math.ceil(fps) >= targetFps)
{
mFailCount = 0;
addTestObjects();
Expand Down Expand Up @@ -127,12 +129,14 @@ package scenes
mStarted = false;
mStartButton.visible = true;

var fps:int = Starling.current.nativeStage.frameRate;

trace("Benchmark complete!");
trace("FPS: " + Constants.FPS);
trace("FPS: " + fps);
trace("Number of objects: " + mContainer.numChildren);

var resultString:String = formatString("Result:\n{0} objects\nwith {1} fps",
mContainer.numChildren, Constants.FPS);
mContainer.numChildren, fps);
mResultText = new TextField(240, 200, resultString);
mResultText.fontSize = 30;
mResultText.x = Constants.CenterX - mResultText.width / 2;
Expand Down

0 comments on commit 9961d0c

Please sign in to comment.