@@ -93,8 +93,9 @@ var _flags = 0;
93
93
94
94
/**
95
95
* @returns {document.Element } the canvas dom element
96
+ * @ignore
96
97
*/
97
- var getCanvas = function ( ) {
98
+ var getCanvas = exports . _getCanvas = function ( ) {
98
99
var displayCanvas = document . getElementById ( CANVAS_ID ) ;
99
100
if ( ! displayCanvas ) {
100
101
displayCanvas = document . createElement ( "canvas" ) ;
@@ -223,8 +224,9 @@ exports._hasFocus = function() {
223
224
exports . setMode = function ( dimensions , flags ) {
224
225
SURFACE = null ;
225
226
var canvas = getCanvas ( ) ;
226
- canvas . width = dimensions [ 0 ] ;
227
- canvas . height = dimensions [ 1 ] ;
227
+ canvas . width = canvas . clientWidth = dimensions [ 0 ] ;
228
+ canvas . height = canvas . clientHeight = dimensions [ 1 ] ;
229
+
228
230
_flags = _flags || flags ;
229
231
// @ xbrowser firefox allows pointerlock only if fullscreen
230
232
if ( _flags & POINTERLOCK ) {
@@ -243,7 +245,7 @@ exports.setMode = function(dimensions, flags) {
243
245
document . addEventListener ( 'webkitfullscreenchange' , fullScreenChange , false ) ;
244
246
document . addEventListener ( 'mozfullscreenchange' , fullScreenChange , false ) ;
245
247
}
246
- return getSurface ( ) ;
248
+ return getSurface ( dimensions ) ;
247
249
} ;
248
250
249
251
/**
@@ -279,13 +281,16 @@ exports._getCanvasOffset = function() {
279
281
* Drawing on the Surface returned by `getSurface()` will draw on the screen.
280
282
* @returns {gamejs.Surface } the display Surface
281
283
*/
282
- var getSurface = exports . getSurface = function ( ) {
284
+ var getSurface = exports . getSurface = function ( dimensions ) {
283
285
if ( SURFACE === null ) {
284
286
var canvas = getCanvas ( ) ;
285
- SURFACE = new Surface ( [ canvas . clientWidth , canvas . clientHeight ] ) ;
287
+ if ( dimensions === undefined ) {
288
+ dimensions = [ canvas . clientWidth , canvas . clientHeight ] ;
289
+ }
290
+ SURFACE = new Surface ( dimensions ) ;
286
291
SURFACE . _canvas = canvas ;
287
- SURFACE . _canvas . width = canvas . clientWidth ;
288
- SURFACE . _canvas . height = canvas . clientHeight ;
292
+ SURFACE . _canvas . width = dimensions [ 0 ] ;
293
+ SURFACE . _canvas . height = dimensions [ 1 ] ;
289
294
SURFACE . _context = canvas . getContext ( '2d' ) ;
290
295
if ( ! ( _flags & DISABLE_SMOOTHING ) ) {
291
296
SURFACE . _smooth ( ) ;
0 commit comments