Skip to content

Commit

Permalink
Merge pull request #168 from stackgl/166-const-let-and-precheckFrameb…
Browse files Browse the repository at this point in the history
…ufferStatus-high-cpu

FIX #166 const let and precheck framebuffer status high cpu
  • Loading branch information
dhritzkiv authored Sep 9, 2019
2 parents 60c7349 + 1648dc2 commit adbf6ab
Show file tree
Hide file tree
Showing 36 changed files with 4,893 additions and 4,779 deletions.
6 changes: 3 additions & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
'VERSION=1.0.0'
],
'sources': [
'src/bindings.cc',
'src/webgl.cc',
'src/procs.cc'
'src/native/bindings.cc',
'src/native/webgl.cc',
'src/native/procs.cc'
],
'include_dirs': [
"<!(node -e \"require('nan')\")",
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (typeof WebGLRenderingContext !== 'undefined') {
module.exports = require('./browser_index')
module.exports = require('./src/javascript/browser-index')
} else {
module.exports = require('./node_index')
module.exports = require('./src/javascript/node-index')
}
129 changes: 0 additions & 129 deletions node_index.js

This file was deleted.

18 changes: 8 additions & 10 deletions browser_index.js → src/javascript/browser-index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
'use strict'

function createContext (width, height, options) {
width = width | 0
height = height | 0
if (!(width > 0 && height > 0)) {
return null
}

var canvas = document.createElement('canvas')
const canvas = document.createElement('canvas')
if (!canvas) {
return null
}
var gl
let gl
canvas.width = width
canvas.height = height

Expand All @@ -25,24 +23,24 @@ function createContext (width, height, options) {
}
}

var _getExtension = gl.getExtension
var extDestroy = {
const _getExtension = gl.getExtension
const extDestroy = {
destroy: function () {
var loseContext = _getExtension.call(gl, 'WEBGL_lose_context')
const loseContext = _getExtension.call(gl, 'WEBGL_lose_context')
if (loseContext) {
loseContext.loseContext()
}
}
}

var extResize = {
const extResize = {
resize: function (w, h) {
canvas.width = w
canvas.height = h
}
}

var _supportedExtensions = gl.getSupportedExtensions().slice()
const _supportedExtensions = gl.getSupportedExtensions().slice()
_supportedExtensions.push(
'STACKGL_destroy_context',
'STACKGL_resize_drawingbuffer')
Expand All @@ -51,7 +49,7 @@ function createContext (width, height, options) {
}

gl.getExtension = function (extName) {
var name = extName.toLowerCase()
const name = extName.toLowerCase()
if (name === 'stackgl_resize_drawingbuffer') {
return extResize
}
Expand Down
Loading

0 comments on commit adbf6ab

Please sign in to comment.