Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolalysenko committed May 7, 2016
1 parent df4a8da commit 32a2dc0
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 121 deletions.
1 change: 0 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Planned

* Improve readability of generated code
* Improve error messages for missing inputs (uniforms, attributes, count)
* Change buffer and texture APIs to separate data from rest of options
* Add in place update methods to buffers and textures
* Add support for polling buffers and animated GIFs (useful for web audio)
Expand Down
5 changes: 3 additions & 2 deletions bin/build-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ mkdirp('www/gallery', function (err) {
glob('example/*.js', {}, function (err, files) {
if (err) {
throw err
return
}
files.forEach(function (file) {
var b = browserify({
Expand All @@ -57,7 +56,6 @@ mkdirp('www/gallery', function (err) {
b.bundle(function (err, bundle) {
if (err) {
throw err
return
}
console.log('bundled', file)
minifyAndGenPage(file, bundle)
Expand Down Expand Up @@ -114,6 +112,9 @@ function writePage (file, bundle) {
</body>
</html>`,
function (err) {
if (err) {
throw err
}
console.log('wrote page', pageName(file))
})
}
1 change: 0 additions & 1 deletion bin/build-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ browserify(INPUT_FILE, { standalone: 'initREGL' })
.bundle()
.pipe(fs.createWriteStream(UNCHECKED_FILE))
.on('close', function () {

console.log('minifying script: ', UNCHECKED_FILE)

var closureCompiler = new ClosureCompiler({
Expand Down
6 changes: 3 additions & 3 deletions bin/remove-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ module.exports = function () {
node.update('')
return
}
break
break
case 'VariableDeclaration':
if (node.declarations.length === 1 &&
isCheckRequire(node.declarations[0])) {
node.update('')
return
}
break
break
}
})
this.push(result.toString())
} catch(e) {
} catch (e) {
this.push(data)
}
done()
Expand Down
3 changes: 1 addition & 2 deletions example/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const feedBackTexture = regl.texture({
copy: true,
min: 'linear',
mag: 'linear'
})
})

const drawFeedback = regl({
frag: `
Expand All @@ -35,7 +35,6 @@ const drawFeedback = regl({
gl_Position = vec4(2.0 * position - 1.0, 0, 1);
}`,


attributes: {
position: regl.buffer([-2, 0, 0, -2, 2, 2])
},
Expand Down
26 changes: 10 additions & 16 deletions example/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ const regl = require('../regl')()
const mouse = require('mouse-change')()
const MAP = require('./assets/map.json')

const setupScene = regl({
attributes: {
position: regl.buffer([ -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1 ])
},
uniforms: {
view: regl.prop('view')
},
count: 6
})

const drawBackground = regl({
frag: `
precision mediump float;
Expand Down Expand Up @@ -39,28 +29,32 @@ const drawBackground = regl({
tiles: regl.texture('assets/tiles.png'),
tileSize: [16.0, 16.0],
map: regl.texture(MAP),
mapSize: [MAP[0].length, MAP.length]
}
mapSize: [MAP[0].length, MAP.length],
view: regl.prop('view')
},

attributes: {
position: regl.buffer([ -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1 ])
},

count: 6
})

regl.frame(() => {
const {x, y} = mouse
const {width, height} = regl.stats

// Compute size of view box
const boxX = MAP[0].length * x / width
const boxY = MAP.length * y / height
const boxH = 10
const boxW = width / height * boxH

setupScene({
drawBackground({
view: [
boxX - 0.5 * boxW,
boxY - 0.5 * boxH,
boxX + 0.5 * boxW,
boxY + 0.5 * boxH
]
}, () => {
drawBackground()
})
})
1 change: 0 additions & 1 deletion lib/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ module.exports = function wrapAttributeState (
limits,
bufferState,
stringStore) {

var attributeState = {}

var NUM_ATTRIBUTES = limits.maxAttributes
Expand Down
3 changes: 0 additions & 3 deletions lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,6 @@ module.exports = function reglCompiler (
// Common state variables
// -------------------------------
var GL_POLL = link(reglPoll)
var STRING_STORE = link(stringStore)
var SHADER_STATE = link(shaderState)
var FRAMEBUFFER_STATE = link(framebufferState)
var DRAW_STATE = {
Expand Down Expand Up @@ -873,13 +872,11 @@ module.exports = function reglCompiler (
exit(STATE_STACK, '.pop();')
}

var hasShader = false
Object.keys(staticOptions).sort(optionPriority).forEach(function (param) {
var value = staticOptions[param]
switch (param) {
case 'frag':
case 'vert':
hasShader = true
var shaderId = stringStore.id(value)
shaderState.shader(
param === 'frag' ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER,
Expand Down
4 changes: 0 additions & 4 deletions lib/framebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ var GL_FLOAT = 0x1406

var GL_HALF_FLOAT_OES = 0x8D61

var GL_ALPHA = 0x1906
var GL_LUMINANCE = 0x1909
var GL_LUMINANCE_ALPHA = 0x190A
var GL_RGB = 0x1907
var GL_RGBA = 0x1908

var GL_RGBA4 = 0x8056
Expand Down
3 changes: 0 additions & 3 deletions lib/shader.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var check = require('./util/check')
var values = require('./util/values')

var DEFAULT_FRAG_SHADER = 'void main(){gl_FragColor=vec4(0,0,0,0);}'
var DEFAULT_VERT_SHADER = 'void main(){gl_Position=vec4(0,0,0,0);}'

var GL_FRAGMENT_SHADER = 35632
var GL_VERTEX_SHADER = 35633

Expand Down
2 changes: 1 addition & 1 deletion lib/strings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function createStringStore() {
module.exports = function createStringStore () {
var stringIds = {'': 0}
var stringValues = ['']
return {
Expand Down
15 changes: 11 additions & 4 deletions lib/util/check.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
// Error checking and parameter validation
/* globals btoa */
var isTypedArray = require('./is-typed-array')
var extend = require('./extend')

// only used for extracting shader names. if btoa not present, then errors
// will be slightly crappier
function decodeB64 (str) {
if (typeof btoa !== 'undefined') {
return btoa(str)
}
return 'base64:' + str
}

function raise (message) {
var error = new Error('(regl) ' + message)
Expand Down Expand Up @@ -116,7 +125,6 @@ function guessCallSite () {

function parseSource (source) {
var lines = source.split('\n')
var annotated = []
var lineNumber = 1
var fileNumber = 0
var files = {
Expand All @@ -129,7 +137,7 @@ function parseSource (source) {
var line = lines[i]
var parts = /^\s*\#\s*(\w+)\s+(.+)\s*$/.exec(line)
if (parts) {
switch(parts[1]) {
switch (parts[1]) {
case 'line':
var lineNumberInfo = /(\d+)(\s+\d+)?/.exec(parts[2])
if (lineNumberInfo) {
Expand All @@ -146,7 +154,7 @@ function parseSource (source) {
var nameInfo = /SHADER_NAME(_B64)?\s+(.*)$/.exec(parts[2])
if (nameInfo) {
files[fileNumber].name = (nameInfo[1]
? btoa(nameInfo[2])
? decodeB64(nameInfo[2])
: nameInfo[2])
}
break
Expand Down Expand Up @@ -227,7 +235,6 @@ function checkShaderError (gl, shader, source, type) {
// try to guess token
var offset = 0
line.errors.forEach(function (error) {

var message = error.message
var token = /^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(message)
if (token) {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
"url": "https://github.com/mikolalysenko/regl/issues"
},
"standard": {
"ignore": "dist/*"
"ignore": [
"dist/*",
"www/*"
]
},
"homepage": "https://mikolalysenko.github.io/regl"
}
6 changes: 0 additions & 6 deletions regl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module.exports = function wrapREGL () {
var gl = args.gl
var options = args.options

// Use string store to track string ids
var stringStore = createStringStore()

var extensionState = wrapExtensions(gl)
Expand Down Expand Up @@ -137,7 +136,6 @@ module.exports = function wrapREGL () {

var canvas = gl.canvas

// raf stuff
var rafCallbacks = []
var activeRAF = 0
function handleRAF () {
Expand Down Expand Up @@ -205,7 +203,6 @@ module.exports = function wrapREGL () {
canvas.addEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored, false)
}

// Resource destructuion
function destroy () {
stopRAF()

Expand Down Expand Up @@ -256,7 +253,6 @@ module.exports = function wrapREGL () {
return result
}

// First we separate the options into static and dynamic components
function separateDynamic (object) {
var staticItems = {}
var dynamicItems = {}
Expand Down Expand Up @@ -335,7 +331,6 @@ module.exports = function wrapREGL () {
function clear (options) {
var clearFlags = 0

// Update context state
poll()

var c = options.color
Expand All @@ -356,7 +351,6 @@ module.exports = function wrapREGL () {
gl.clear(clearFlags)
}

// Registers another requestAnimationFrame callback
function frame (cb) {
rafCallbacks.push(cb)

Expand Down
41 changes: 20 additions & 21 deletions test/blend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,31 @@ var createContext = require('./util/create-context')
var createREGL = require('../regl')

var blendFuncs = {
"0":0,
"1":1,
"zero":0,
"one":1,
"src color": 768,
"one minus src color":769,
"src alpha":770,
"one minus src alpha":771,
"dst color":774,
"one minus dst color":775,
"dst alpha":772,
"one minus dst alpha":773,
"constant color": 32769,
"one minus constant color": 32770,
"constant alpha": 32771,
"one minus constant alpha": 32772,
"src alpha saturate": 776
'0': 0,
'1': 1,
'zero': 0,
'one': 1,
'src color': 768,
'one minus src color': 769,
'src alpha': 770,
'one minus src alpha': 771,
'dst color': 774,
'one minus dst color': 775,
'dst alpha': 772,
'one minus dst alpha': 773,
'constant color': 32769,
'one minus constant color': 32770,
'constant alpha': 32771,
'one minus constant alpha': 32772,
'src alpha saturate': 776
}

var blendEquations = {
"add":32774,
"subtract":32778,
"reverse subtract":32779
'add': 32774,
'subtract': 32778,
'reverse subtract': 32779
}


tape('blend', function (t) {
var gl = createContext(16, 16)
var regl = createREGL(gl)
Expand Down
Loading

0 comments on commit 32a2dc0

Please sign in to comment.