/* globals __line */

var path = require('path')
var createContext = require('../../index')
var utils = require('../common/utils.js')
var utilsLog = require('../common/utils_log.js')
var log = new utilsLog.Log(path.basename(__filename), 'DEBUG')

function main () {
  // Create context
  var width = 512
  var height = 512
  var gl = createContext(width, height)

  // Clear screen to red
  gl.clearColor(1.0, 0.0, 0.0, 1.0)
  gl.colorMask(true, true, true, true)
  gl.clear(gl.COLOR_BUFFER_BIT)

  var filename = __filename + '.ppm' // eslint-disable-line
  log.info(__line, 'rendering ' + filename)
  utils.bufferToFile(gl, width, height, filename)
  log.info(__line, 'finished rendering ' + filename)

  gl.destroy()
}

main()
