Comparing version 0.0.7 to 0.0.8
@@ -37,6 +37,4 @@ 'use strict'; | ||
const mode = opts.mode ? opts.mode : 'windowed'; | ||
if (opts.fullscreen) { | ||
mode = 'fullscreen'; | ||
} | ||
const mode = opts.fullscreen ? 'fullscreen' : (opts.mode ? opts.mode : 'windowed'); | ||
this._decorated = mode === 'windowed'; | ||
@@ -103,10 +101,2 @@ if (opts.decorated !== undefined) { | ||
const displays = glfw.getMonitors(); | ||
if (displays.length < 1) { | ||
throw new Error('No suitable display found for a new GLFW Window.'); | ||
} | ||
const mainScreen = displays.filter(d => d.is_primary)[0]; | ||
if (this._mode === 'windowed') { | ||
@@ -120,6 +110,3 @@ | ||
this._prevDecorated = this._decorated; | ||
this._prevWidth = this._width; | ||
this._prevHeight = this._height; | ||
this._width = mainScreen.width; | ||
this._height = mainScreen.height; | ||
this._decorated = false; | ||
@@ -132,11 +119,2 @@ glfw.windowHint(glfw.DECORATED, this._decorated ? glfw.TRUE : glfw.FALSE); | ||
const isBadId = this._display === undefined || this._display >= displays.length; | ||
const dispId = isBadId ? 0 : this._display; | ||
const currentScreen = displays[dispId]; | ||
this._prevWidth = this._width; | ||
this._prevHeight = this._height; | ||
this._width = currentScreen.width; | ||
this._height = currentScreen.height; | ||
this._window = glfw.createWindow(this._width, this._height, this._emitter, this._title, this._display); | ||
@@ -181,2 +159,47 @@ | ||
const displays = glfw.getMonitors(); | ||
if (displays.length < 1) { | ||
throw new Error('No suitable display found for a new GLFW Window.'); | ||
} | ||
const isBadId = this._display === undefined || this._display >= displays.length; | ||
const dispId = isBadId ? -1 : this._display; | ||
const currentScreen = dispId > -1 ? displays[dispId] : displays.filter(d => d.is_primary)[0]; | ||
let isResized = false; | ||
if (this._mode === 'windowed') { | ||
if ( | ||
this._prevWidth && this._width !== this._prevWidth || | ||
this._prevHeight && this._height !== this._prevHeight | ||
) { | ||
isResized = true; | ||
} | ||
this._width = this._prevWidth || this._width; | ||
this._height = this._prevHeight || this._height; | ||
this._decorated = this._prevDecorated || this._decorated; | ||
delete this._prevWidth; | ||
delete this._prevHeight; | ||
delete this._prevDecorated; | ||
} else { | ||
if ( | ||
this._width !== currentScreen.width || | ||
this._height !== currentScreen.height | ||
) { | ||
isResized = true; | ||
} | ||
this._prevWidth = this._width; | ||
this._prevHeight = this._height; | ||
this._width = currentScreen.width; | ||
this._height = currentScreen.height; | ||
} | ||
if ( ! this._modeCache[this._mode] ) { | ||
@@ -194,8 +217,8 @@ | ||
this._width = this._prevWidth || this._width; | ||
this._height = this._prevHeight || this._height; | ||
this._decorated = this._prevDecorated || this._decorated; | ||
this.makeCurrent(); | ||
if (isResized) { | ||
this.emit('resize', { width: this._width, height: this._height }) | ||
} | ||
} | ||
@@ -202,0 +225,0 @@ |
{ | ||
"author": "Luis Blanco <luisblanco1337@gmail.com>", | ||
"name": "glfw-raub", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "GLFW for Node.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
62732
381